LCOV - code coverage report
Current view: top level - home/aheinecke/dev/main/qt5/include/QtCore - qobject.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 15 19 78.9 %
Date: 2018-11-14 16:53:58 Functions: 19 42 45.2 %

          Line data    Source code
       1             : /****************************************************************************
       2             : **
       3             : ** Copyright (C) 2016 The Qt Company Ltd.
       4             : ** Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com>
       5             : ** Contact: https://www.qt.io/licensing/
       6             : **
       7             : ** This file is part of the QtCore module of the Qt Toolkit.
       8             : **
       9             : ** $QT_BEGIN_LICENSE:LGPL$
      10             : ** Commercial License Usage
      11             : ** Licensees holding valid commercial Qt licenses may use this file in
      12             : ** accordance with the commercial license agreement provided with the
      13             : ** Software or, alternatively, in accordance with the terms contained in
      14             : ** a written agreement between you and The Qt Company. For licensing terms
      15             : ** and conditions see https://www.qt.io/terms-conditions. For further
      16             : ** information use the contact form at https://www.qt.io/contact-us.
      17             : **
      18             : ** GNU Lesser General Public License Usage
      19             : ** Alternatively, this file may be used under the terms of the GNU Lesser
      20             : ** General Public License version 3 as published by the Free Software
      21             : ** Foundation and appearing in the file LICENSE.LGPL3 included in the
      22             : ** packaging of this file. Please review the following information to
      23             : ** ensure the GNU Lesser General Public License version 3 requirements
      24             : ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
      25             : **
      26             : ** GNU General Public License Usage
      27             : ** Alternatively, this file may be used under the terms of the GNU
      28             : ** General Public License version 2.0 or (at your option) the GNU General
      29             : ** Public license version 3 or any later version approved by the KDE Free
      30             : ** Qt Foundation. The licenses are as published by the Free Software
      31             : ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
      32             : ** included in the packaging of this file. Please review the following
      33             : ** information to ensure the GNU General Public License requirements will
      34             : ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
      35             : ** https://www.gnu.org/licenses/gpl-3.0.html.
      36             : **
      37             : ** $QT_END_LICENSE$
      38             : **
      39             : ****************************************************************************/
      40             : 
      41             : #ifndef QOBJECT_H
      42             : #define QOBJECT_H
      43             : 
      44             : #ifndef QT_NO_QOBJECT
      45             : 
      46             : #include <QtCore/qobjectdefs.h>
      47             : #include <QtCore/qstring.h>
      48             : #include <QtCore/qbytearray.h>
      49             : #include <QtCore/qlist.h>
      50             : #ifdef QT_INCLUDE_COMPAT
      51             : #include <QtCore/qcoreevent.h>
      52             : #endif
      53             : #include <QtCore/qscopedpointer.h>
      54             : #include <QtCore/qmetatype.h>
      55             : 
      56             : #include <QtCore/qobject_impl.h>
      57             : 
      58             : #if QT_HAS_INCLUDE(<chrono>)
      59             : #  include <chrono>
      60             : #endif
      61             : 
      62             : QT_BEGIN_NAMESPACE
      63             : 
      64             : 
      65             : class QEvent;
      66             : class QTimerEvent;
      67             : class QChildEvent;
      68             : struct QMetaObject;
      69             : class QVariant;
      70             : class QObjectPrivate;
      71             : class QObject;
      72             : class QThread;
      73             : class QWidget;
      74             : #ifndef QT_NO_REGEXP
      75             : class QRegExp;
      76             : #endif
      77             : #ifndef QT_NO_REGULAREXPRESSION
      78             : class QRegularExpression;
      79             : #endif
      80             : #ifndef QT_NO_USERDATA
      81             : class QObjectUserData;
      82             : #endif
      83             : struct QDynamicMetaObjectData;
      84             : 
      85             : typedef QList<QObject*> QObjectList;
      86             : 
      87             : Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name,
      88             :                                            const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
      89             : Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re,
      90             :                                            const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
      91             : Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re,
      92             :                                            const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
      93             : Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options);
      94             : 
      95             : class Q_CORE_EXPORT QObjectData {
      96             : public:
      97             :     virtual ~QObjectData() = 0;
      98             :     QObject *q_ptr;
      99             :     QObject *parent;
     100             :     QObjectList children;
     101             : 
     102             :     uint isWidget : 1;
     103             :     uint blockSig : 1;
     104             :     uint wasDeleted : 1;
     105             :     uint isDeletingChildren : 1;
     106             :     uint sendChildEvents : 1;
     107             :     uint receiveChildEvents : 1;
     108             :     uint isWindow : 1; //for QWindow
     109             :     uint deleteLaterCalled : 1;
     110             :     uint unused : 24;
     111             :     int postedEvents;
     112             :     QDynamicMetaObjectData *metaObject;
     113             :     QMetaObject *dynamicMetaObject() const;
     114             : };
     115             : 
     116             : 
     117             : class Q_CORE_EXPORT QObject
     118             : {
     119             :     Q_OBJECT
     120             :     Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged)
     121             :     Q_DECLARE_PRIVATE(QObject)
     122             : 
     123             : public:
     124             :     Q_INVOKABLE explicit QObject(QObject *parent=Q_NULLPTR);
     125             :     virtual ~QObject();
     126             : 
     127             :     virtual bool event(QEvent *event);
     128             :     virtual bool eventFilter(QObject *watched, QEvent *event);
     129             : 
     130             : #ifdef Q_QDOC
     131             :     static QString tr(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
     132             :     static QString trUtf8(const char *sourceText, const char *comment = Q_NULLPTR, int n = -1);
     133             :     virtual const QMetaObject *metaObject() const;
     134             :     static const QMetaObject staticMetaObject;
     135             : #endif
     136             : #ifdef QT_NO_TRANSLATION
     137             :     static QString tr(const char *sourceText, const char * = Q_NULLPTR, int = -1)
     138             :         { return QString::fromUtf8(sourceText); }
     139             : #if QT_DEPRECATED_SINCE(5, 0)
     140             :     QT_DEPRECATED static QString trUtf8(const char *sourceText, const char * = Q_NULLPTR, int = -1)
     141             :         { return QString::fromUtf8(sourceText); }
     142             : #endif
     143             : #endif //QT_NO_TRANSLATION
     144             : 
     145             :     QString objectName() const;
     146             :     void setObjectName(const QString &name);
     147             : 
     148             :     inline bool isWidgetType() const { return d_ptr->isWidget; }
     149             :     inline bool isWindowType() const { return d_ptr->isWindow; }
     150             : 
     151             :     inline bool signalsBlocked() const Q_DECL_NOTHROW { return d_ptr->blockSig; }
     152             :     bool blockSignals(bool b) Q_DECL_NOTHROW;
     153             : 
     154             :     QThread *thread() const;
     155             :     void moveToThread(QThread *thread);
     156             : 
     157             :     int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
     158             : #if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
     159             :     Q_ALWAYS_INLINE
     160             :     int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer)
     161             :     {
     162             :         return startTimer(int(time.count()), timerType);
     163             :     }
     164             : #endif
     165             :     void killTimer(int id);
     166             : 
     167             :     template<typename T>
     168             :     inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
     169             :     {
     170             :         typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     171             :         return static_cast<T>(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options));
     172             :     }
     173             : 
     174             :     template<typename T>
     175             :     inline QList<T> findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
     176             :     {
     177             :         typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     178             :         QList<T> list;
     179             :         qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject,
     180             :                                 reinterpret_cast<QList<void *> *>(&list), options);
     181             :         return list;
     182             :     }
     183             : 
     184             : #ifndef QT_NO_REGEXP
     185             :     template<typename T>
     186             :     inline QList<T> findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
     187             :     {
     188             :         typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     189             :         QList<T> list;
     190             :         qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
     191             :                                 reinterpret_cast<QList<void *> *>(&list), options);
     192             :         return list;
     193             :     }
     194             : #endif
     195             : 
     196             : #ifndef QT_NO_REGULAREXPRESSION
     197             :     template<typename T>
     198             :     inline QList<T> findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
     199             :     {
     200             :         typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     201             :         QList<T> list;
     202             :         qt_qFindChildren_helper(this, re, ObjType::staticMetaObject,
     203             :                                 reinterpret_cast<QList<void *> *>(&list), options);
     204             :         return list;
     205             :     }
     206             : #endif
     207             : 
     208             :     inline const QObjectList &children() const { return d_ptr->children; }
     209             : 
     210             :     void setParent(QObject *parent);
     211             :     void installEventFilter(QObject *filterObj);
     212             :     void removeEventFilter(QObject *obj);
     213             : 
     214             :     static QMetaObject::Connection connect(const QObject *sender, const char *signal,
     215             :                         const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
     216             : 
     217             :     static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
     218             :                         const QObject *receiver, const QMetaMethod &method,
     219             :                         Qt::ConnectionType type = Qt::AutoConnection);
     220             : 
     221             :     inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
     222             :                         const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
     223             : 
     224             : #ifdef Q_QDOC
     225             :     template<typename PointerToMemberFunction>
     226             :     static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
     227             :     template<typename PointerToMemberFunction, typename Functor>
     228             :     static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
     229             :     template<typename PointerToMemberFunction, typename Functor>
     230             :     static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
     231             : #else
     232             :     //Connect a signal to a pointer to qobject member function
     233             :     template <typename Func1, typename Func2>
     234          92 :     static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
     235             :                                      const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot,
     236             :                                      Qt::ConnectionType type = Qt::AutoConnection)
     237             :     {
     238             :         typedef QtPrivate::FunctionPointer<Func1> SignalType;
     239             :         typedef QtPrivate::FunctionPointer<Func2> SlotType;
     240             : 
     241             :         Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
     242             :                           "No Q_OBJECT in the class with the signal");
     243             : 
     244             :         //compilation error if the arguments does not match.
     245             :         Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
     246             :                           "The slot requires more arguments than the signal provides.");
     247             :         Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
     248             :                           "Signal and slot arguments are not compatible.");
     249             :         Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
     250             :                           "Return type of the slot is not compatible with the return type of the signal.");
     251             : 
     252          92 :         const int *types = Q_NULLPTR;
     253          92 :         if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
     254           0 :             types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
     255             : 
     256             :         return connectImpl(sender, reinterpret_cast<void **>(&signal),
     257             :                            receiver, reinterpret_cast<void **>(&slot),
     258          92 :                            new QtPrivate::QSlotObject<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
     259             :                                            typename SignalType::ReturnType>(slot),
     260          92 :                             type, types, &SignalType::Object::staticMetaObject);
     261             :     }
     262             : 
     263             :     //connect to a function pointer  (not a member)
     264             :     template <typename Func1, typename Func2>
     265             :     static inline typename std::enable_if<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0, QMetaObject::Connection>::type
     266             :             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
     267             :     {
     268             :         return connect(sender, signal, sender, slot, Qt::DirectConnection);
     269             :     }
     270             : 
     271             :     //connect to a function pointer  (not a member)
     272             :     template <typename Func1, typename Func2>
     273             :     static inline typename std::enable_if<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0 &&
     274             :                                           !QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction, QMetaObject::Connection>::type
     275             :             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
     276             :                     Qt::ConnectionType type = Qt::AutoConnection)
     277             :     {
     278             :         typedef QtPrivate::FunctionPointer<Func1> SignalType;
     279             :         typedef QtPrivate::FunctionPointer<Func2> SlotType;
     280             : 
     281             :         Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
     282             :                           "No Q_OBJECT in the class with the signal");
     283             : 
     284             :         //compilation error if the arguments does not match.
     285             :         Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
     286             :                           "The slot requires more arguments than the signal provides.");
     287             :         Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
     288             :                           "Signal and slot arguments are not compatible.");
     289             :         Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
     290             :                           "Return type of the slot is not compatible with the return type of the signal.");
     291             : 
     292             :         const int *types = Q_NULLPTR;
     293             :         if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
     294             :             types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
     295             : 
     296             :         return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
     297             :                            new QtPrivate::QStaticSlotObject<Func2,
     298             :                                                  typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
     299             :                                                  typename SignalType::ReturnType>(slot),
     300             :                            type, types, &SignalType::Object::staticMetaObject);
     301             :     }
     302             : 
     303             :     //connect to a functor
     304             :     template <typename Func1, typename Func2>
     305             :     static inline typename std::enable_if<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::type
     306             :             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
     307             :     {
     308             :         return connect(sender, signal, sender, std::move(slot), Qt::DirectConnection);
     309             :     }
     310             : 
     311             :     //connect to a functor, with a "context" object defining in which event loop is going to be executed
     312             :     template <typename Func1, typename Func2>
     313             :     static inline typename std::enable_if<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::type
     314           8 :             connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
     315             :                     Qt::ConnectionType type = Qt::AutoConnection)
     316             :     {
     317             :         typedef QtPrivate::FunctionPointer<Func1> SignalType;
     318           8 :         const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<Func2 , typename SignalType::Arguments>::Value;
     319             : 
     320             :         Q_STATIC_ASSERT_X((FunctorArgumentCount >= 0),
     321             :                           "Signal and slot arguments are not compatible.");
     322           8 :         const int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
     323             :         typedef typename QtPrivate::FunctorReturnType<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value>::Value SlotReturnType;
     324             : 
     325             :         Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value),
     326             :                           "Return type of the slot is not compatible with the return type of the signal.");
     327             : 
     328             :         Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
     329             :                           "No Q_OBJECT in the class with the signal");
     330             : 
     331           8 :         const int *types = Q_NULLPTR;
     332           8 :         if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
     333           0 :             types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
     334             : 
     335             :         return connectImpl(sender, reinterpret_cast<void **>(&signal), context, Q_NULLPTR,
     336           8 :                            new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount,
     337             :                                 typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value,
     338           8 :                                 typename SignalType::ReturnType>(std::move(slot)),
     339          16 :                            type, types, &SignalType::Object::staticMetaObject);
     340             :     }
     341             : #endif //Q_QDOC
     342             : 
     343             :     static bool disconnect(const QObject *sender, const char *signal,
     344             :                            const QObject *receiver, const char *member);
     345             :     static bool disconnect(const QObject *sender, const QMetaMethod &signal,
     346             :                            const QObject *receiver, const QMetaMethod &member);
     347             :     inline bool disconnect(const char *signal = Q_NULLPTR,
     348             :                            const QObject *receiver = Q_NULLPTR, const char *member = Q_NULLPTR) const
     349             :         { return disconnect(this, signal, receiver, member); }
     350             :     inline bool disconnect(const QObject *receiver, const char *member = Q_NULLPTR) const
     351             :         { return disconnect(this, Q_NULLPTR, receiver, member); }
     352             :     static bool disconnect(const QMetaObject::Connection &);
     353             : 
     354             : #ifdef Q_QDOC
     355             :     template<typename PointerToMemberFunction>
     356             :     static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
     357             : #else
     358             :     template <typename Func1, typename Func2>
     359             :     static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
     360             :                                   const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot)
     361             :     {
     362             :         typedef QtPrivate::FunctionPointer<Func1> SignalType;
     363             :         typedef QtPrivate::FunctionPointer<Func2> SlotType;
     364             : 
     365             :         Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
     366             :                           "No Q_OBJECT in the class with the signal");
     367             : 
     368             :         //compilation error if the arguments does not match.
     369             :         Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
     370             :                           "Signal and slot arguments are not compatible.");
     371             : 
     372             :         return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot),
     373             :                               &SignalType::Object::staticMetaObject);
     374             :     }
     375             :     template <typename Func1>
     376             :     static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
     377             :                                   const QObject *receiver, void **zero)
     378             :     {
     379             :         // This is the overload for when one wish to disconnect a signal from any slot. (slot=Q_NULLPTR)
     380             :         // Since the function template parameter cannot be deduced from '0', we use a
     381             :         // dummy void ** parameter that must be equal to 0
     382             :         Q_ASSERT(!zero);
     383             :         typedef QtPrivate::FunctionPointer<Func1> SignalType;
     384             :         return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
     385             :                               &SignalType::Object::staticMetaObject);
     386             :     }
     387             : #endif //Q_QDOC
     388             : 
     389             : 
     390             : #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
     391             :     void dumpObjectTree(); // ### Qt 6: remove
     392             :     void dumpObjectInfo(); // ### Qt 6: remove
     393             : #endif
     394             :     void dumpObjectTree() const;
     395             :     void dumpObjectInfo() const;
     396             : 
     397             : #ifndef QT_NO_PROPERTIES
     398             :     bool setProperty(const char *name, const QVariant &value);
     399             :     QVariant property(const char *name) const;
     400             :     QList<QByteArray> dynamicPropertyNames() const;
     401             : #endif // QT_NO_PROPERTIES
     402             : 
     403             : #ifndef QT_NO_USERDATA
     404             :     static uint registerUserData();
     405             :     void setUserData(uint id, QObjectUserData* data);
     406             :     QObjectUserData* userData(uint id) const;
     407             : #endif // QT_NO_USERDATA
     408             : 
     409             : Q_SIGNALS:
     410             :     void destroyed(QObject * = Q_NULLPTR);
     411             :     void objectNameChanged(const QString &objectName, QPrivateSignal);
     412             : 
     413             : public:
     414             :     inline QObject *parent() const { return d_ptr->parent; }
     415             : 
     416             :     inline bool inherits(const char *classname) const
     417             :         { return const_cast<QObject *>(this)->qt_metacast(classname) != Q_NULLPTR; }
     418             : 
     419             : public Q_SLOTS:
     420             :     void deleteLater();
     421             : 
     422             : protected:
     423             :     QObject *sender() const;
     424             :     int senderSignalIndex() const;
     425             :     int receivers(const char* signal) const;
     426             :     bool isSignalConnected(const QMetaMethod &signal) const;
     427             : 
     428             :     virtual void timerEvent(QTimerEvent *event);
     429             :     virtual void childEvent(QChildEvent *event);
     430             :     virtual void customEvent(QEvent *event);
     431             : 
     432             :     virtual void connectNotify(const QMetaMethod &signal);
     433             :     virtual void disconnectNotify(const QMetaMethod &signal);
     434             : 
     435             : protected:
     436             :     QObject(QObjectPrivate &dd, QObject *parent = Q_NULLPTR);
     437             : 
     438             : protected:
     439             :     QScopedPointer<QObjectData> d_ptr;
     440             : 
     441             :     static const QMetaObject staticQtMetaObject;
     442             :     friend inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT;
     443             : 
     444             :     friend struct QMetaObject;
     445             :     friend struct QMetaObjectPrivate;
     446             :     friend class QMetaCallEvent;
     447             :     friend class QApplication;
     448             :     friend class QApplicationPrivate;
     449             :     friend class QCoreApplication;
     450             :     friend class QCoreApplicationPrivate;
     451             :     friend class QWidget;
     452             :     friend class QThreadData;
     453             : 
     454             : private:
     455             :     Q_DISABLE_COPY(QObject)
     456             :     Q_PRIVATE_SLOT(d_func(), void _q_reregisterTimers(void *))
     457             : 
     458             : private:
     459             :     static QMetaObject::Connection connectImpl(const QObject *sender, void **signal,
     460             :                                                const QObject *receiver, void **slotPtr,
     461             :                                                QtPrivate::QSlotObjectBase *slot, Qt::ConnectionType type,
     462             :                                                const int *types, const QMetaObject *senderMetaObject);
     463             : 
     464             :     static bool disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot,
     465             :                                const QMetaObject *senderMetaObject);
     466             : 
     467             : };
     468             : 
     469           0 : inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal,
     470             :                                             const char *amember, Qt::ConnectionType atype) const
     471           0 : { return connect(asender, asignal, this, amember, atype); }
     472             : 
     473             : inline const QMetaObject *qt_getQtMetaObject() Q_DECL_NOEXCEPT
     474             : { return &QObject::staticQtMetaObject; }
     475             : 
     476             : #ifndef QT_NO_USERDATA
     477             : class Q_CORE_EXPORT QObjectUserData {
     478             : public:
     479             :     virtual ~QObjectUserData();
     480             : };
     481             : #endif
     482             : 
     483             : #ifdef Q_QDOC
     484             : T qFindChild(const QObject *o, const QString &name = QString());
     485             : QList<T> qFindChildren(const QObject *oobj, const QString &name = QString());
     486             : QList<T> qFindChildren(const QObject *o, const QRegExp &re);
     487             : #endif
     488             : #if QT_DEPRECATED_SINCE(5, 0)
     489             : template<typename T>
     490             : inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString())
     491             : { return o->findChild<T>(name); }
     492             : 
     493             : template<typename T>
     494             : inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QString &name = QString())
     495             : {
     496             :     return o->findChildren<T>(name);
     497             : }
     498             : 
     499             : #ifndef QT_NO_REGEXP
     500             : template<typename T>
     501             : inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
     502             : {
     503             :     return o->findChildren<T>(re);
     504             : }
     505             : #endif
     506             : 
     507             : #endif //QT_DEPRECATED
     508             : 
     509             : template <class T>
     510         162 : inline T qobject_cast(QObject *object)
     511             : {
     512             :     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     513             :     Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
     514             :                     "qobject_cast requires the type to have a Q_OBJECT macro");
     515         162 :     return static_cast<T>(ObjType::staticMetaObject.cast(object));
     516             : }
     517             : 
     518             : template <class T>
     519             : inline T qobject_cast(const QObject *object)
     520             : {
     521             :     typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType;
     522             :     Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
     523             :                       "qobject_cast requires the type to have a Q_OBJECT macro");
     524             :     return static_cast<T>(ObjType::staticMetaObject.cast(object));
     525             : }
     526             : 
     527             : 
     528             : template <class T> inline const char * qobject_interface_iid()
     529             : { return Q_NULLPTR; }
     530             : 
     531             : #ifndef Q_MOC_RUN
     532             : #  define Q_DECLARE_INTERFACE(IFace, IId) \
     533             :     template <> inline const char *qobject_interface_iid<IFace *>() \
     534             :     { return IId; } \
     535             :     template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
     536             :     { return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : Q_NULLPTR)); } \
     537             :     template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \
     538             :     { return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : Q_NULLPTR)); }
     539             : #endif // Q_MOC_RUN
     540             : 
     541             : #ifndef QT_NO_DEBUG_STREAM
     542             : Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
     543             : #endif
     544             : 
     545             : class QSignalBlocker
     546             : {
     547             : public:
     548             :     inline explicit QSignalBlocker(QObject *o) Q_DECL_NOTHROW;
     549             :     inline explicit QSignalBlocker(QObject &o) Q_DECL_NOTHROW;
     550             :     inline ~QSignalBlocker();
     551             : 
     552             : #ifdef Q_COMPILER_RVALUE_REFS
     553             :     inline QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW;
     554             :     inline QSignalBlocker &operator=(QSignalBlocker &&other) Q_DECL_NOTHROW;
     555             : #endif
     556             : 
     557             :     inline void reblock() Q_DECL_NOTHROW;
     558             :     inline void unblock() Q_DECL_NOTHROW;
     559             : private:
     560             :     Q_DISABLE_COPY(QSignalBlocker)
     561             :     QObject * m_o;
     562             :     bool m_blocked;
     563             :     bool m_inhibited;
     564             : };
     565             : 
     566             : QSignalBlocker::QSignalBlocker(QObject *o) Q_DECL_NOTHROW
     567             :     : m_o(o),
     568             :       m_blocked(o && o->blockSignals(true)),
     569             :       m_inhibited(false)
     570             : {}
     571             : 
     572             : QSignalBlocker::QSignalBlocker(QObject &o) Q_DECL_NOTHROW
     573             :     : m_o(&o),
     574             :       m_blocked(o.blockSignals(true)),
     575             :       m_inhibited(false)
     576             : {}
     577             : 
     578             : #ifdef Q_COMPILER_RVALUE_REFS
     579             : QSignalBlocker::QSignalBlocker(QSignalBlocker &&other) Q_DECL_NOTHROW
     580             :     : m_o(other.m_o),
     581             :       m_blocked(other.m_blocked),
     582             :       m_inhibited(other.m_inhibited)
     583             : {
     584             :     other.m_o = Q_NULLPTR;
     585             : }
     586             : 
     587             : QSignalBlocker &QSignalBlocker::operator=(QSignalBlocker &&other) Q_DECL_NOTHROW
     588             : {
     589             :     if (this != &other) {
     590             :         // if both *this and other block the same object's signals:
     591             :         // unblock *this iff our dtor would unblock, but other's wouldn't
     592             :         if (m_o != other.m_o || (!m_inhibited && other.m_inhibited))
     593             :             unblock();
     594             :         m_o = other.m_o;
     595             :         m_blocked = other.m_blocked;
     596             :         m_inhibited = other.m_inhibited;
     597             :         // disable other:
     598             :         other.m_o = Q_NULLPTR;
     599             :     }
     600             :     return *this;
     601             : }
     602             : #endif
     603             : 
     604             : QSignalBlocker::~QSignalBlocker()
     605             : {
     606             :     if (m_o && !m_inhibited)
     607             :         m_o->blockSignals(m_blocked);
     608             : }
     609             : 
     610             : void QSignalBlocker::reblock() Q_DECL_NOTHROW
     611             : {
     612             :     if (m_o) m_o->blockSignals(true);
     613             :     m_inhibited = false;
     614             : }
     615             : 
     616             : void QSignalBlocker::unblock() Q_DECL_NOTHROW
     617             : {
     618             :     if (m_o) m_o->blockSignals(m_blocked);
     619             :     m_inhibited = true;
     620             : }
     621             : 
     622             : namespace QtPrivate {
     623             :     inline QObject & deref_for_methodcall(QObject &o) { return  o; }
     624             :     inline QObject & deref_for_methodcall(QObject *o) { return *o; }
     625             : }
     626             : #define Q_SET_OBJECT_NAME(obj) QT_PREPEND_NAMESPACE(QtPrivate)::deref_for_methodcall(obj).setObjectName(QLatin1String(#obj))
     627             : 
     628             : QT_END_NAMESPACE
     629             : 
     630             : #endif
     631             : 
     632             : #endif // QOBJECT_H

Generated by: LCOV version 1.13