Fix Q_QDOC code for PointerToMemberFunction
In functions such as QObject::connect and similar which are using pointer to member function or functor, we have a different declaration for qdoc because we don't want to show the QEnableIf and other type traits in the doc. However, The code still needs to be valid, as we will use clang to parse the documentation. Fix it by making 'PointerToMemberFunction' and 'Functor' template parameters (which they actually are). Change-Id: Ie2648407bae21ba6d1677f6de2d6f597486b5c98 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>bb10
parent
09a1dd2fd4
commit
7d9cbc6b64
|
|
@ -168,19 +168,15 @@ public:
|
|||
|
||||
inline bool isValid() const { return mobj != Q_NULLPTR; }
|
||||
|
||||
#ifdef Q_QDOC
|
||||
static QMetaMethod fromSignal(PointerToMemberFunction signal);
|
||||
#else
|
||||
template <typename Func>
|
||||
static inline QMetaMethod fromSignal(Func signal)
|
||||
template <typename PointerToMemberFunction>
|
||||
static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
|
||||
{
|
||||
typedef QtPrivate::FunctionPointer<Func> SignalType;
|
||||
typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
|
||||
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
|
||||
"No Q_OBJECT in the class with the signal");
|
||||
return fromSignalImpl(&SignalType::Object::staticMetaObject,
|
||||
reinterpret_cast<void **>(&signal));
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if QT_DEPRECATED_SINCE(5,0)
|
||||
|
|
|
|||
|
|
@ -600,8 +600,11 @@ public:
|
|||
}
|
||||
|
||||
#ifdef Q_QDOC
|
||||
template<typename MemberFunction, int>
|
||||
static bool registerConverter(MemberFunction function);
|
||||
template<typename MemberFunctionOk, char>
|
||||
static bool registerConverter(MemberFunctionOk function);
|
||||
template<typename UnaryFunction>
|
||||
static bool registerConverter(UnaryFunction function);
|
||||
#else
|
||||
// member function as in "QString QFont::toString() const"
|
||||
|
|
|
|||
|
|
@ -210,8 +210,11 @@ public:
|
|||
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
|
||||
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
|
||||
template<typename PointerToMemberFunction, typename Functor>
|
||||
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
|
||||
template<typename PointerToMemberFunction, typename Functor>
|
||||
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
|
||||
#else
|
||||
//Connect a signal to a pointer to qobject member function
|
||||
|
|
@ -360,6 +363,7 @@ public:
|
|||
static bool disconnect(const QMetaObject::Connection &);
|
||||
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
|
||||
#else
|
||||
template <typename Func1, typename Func2>
|
||||
|
|
|
|||
|
|
@ -80,11 +80,17 @@ public:
|
|||
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
|
||||
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
static void singleShot(int msec, const QObject *receiver, PointerToMemberFunction method);
|
||||
template<typename PointerToMemberFunction>
|
||||
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method);
|
||||
template<typename Functor>
|
||||
static void singleShot(int msec, Functor functor);
|
||||
template<typename Functor>
|
||||
static void singleShot(int msec, Qt::TimerType timerType, Functor functor);
|
||||
template<typename Functor, int>
|
||||
static void singleShot(int msec, const QObject *context, Functor functor);
|
||||
template<typename Functor, int>
|
||||
static void singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor);
|
||||
#else
|
||||
// singleShot to a QObject slot
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public:
|
|||
QSignalTransition(const QObject *sender, const char *signal,
|
||||
QState *sourceState = Q_NULLPTR);
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
QSignalTransition(const QObject *object, PointerToMemberFunction signal,
|
||||
QState *sourceState = Q_NULLPTR);
|
||||
#elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS)
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ public:
|
|||
void addTransition(QAbstractTransition *transition);
|
||||
QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target);
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
QSignalTransition *addTransition(const QObject *sender, PointerToMemberFunction signal,
|
||||
QAbstractState *target);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public:
|
|||
// constructors
|
||||
QSharedPointer();
|
||||
explicit QSharedPointer(T *ptr);
|
||||
template<typename Deleter>
|
||||
QSharedPointer(T *ptr, Deleter d);
|
||||
QSharedPointer(const QSharedPointer<T> &other);
|
||||
QSharedPointer(const QWeakPointer<T> &other);
|
||||
|
|
|
|||
|
|
@ -85,11 +85,17 @@ public:
|
|||
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
|
||||
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
|
||||
template<typename PointerToMemberFunction>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
|
||||
#else
|
||||
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
|
||||
|
|
|
|||
|
|
@ -100,11 +100,17 @@ public:
|
|||
QAction *addAction(const QIcon &icon, const QString &text,
|
||||
const QObject *receiver, const char* member);
|
||||
#ifdef Q_QDOC
|
||||
template<typename PointerToMemberFunction>
|
||||
QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QString &text, Functor functor);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QString &text, const QObject *context, Functor functor);
|
||||
template<typename PointerToMemberFunction>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
|
||||
template<typename Functor>
|
||||
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor);
|
||||
#else
|
||||
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
|
||||
|
|
|
|||
Loading…
Reference in New Issue