summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobjectdefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qobjectdefs.h')
-rw-r--r--src/corelib/kernel/qobjectdefs.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 31f3067829..1ad24387e0 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -291,6 +291,7 @@ public:
struct Q_CORE_EXPORT QMetaObject
{
+ class Connection;
const char *className() const;
const QMetaObject *superClass() const;
@@ -336,7 +337,7 @@ struct Q_CORE_EXPORT QMetaObject
static QByteArray normalizedType(const char *type);
// internal index-based connect
- static bool connect(const QObject *sender, int signal_index,
+ static Connection connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index,
int type = 0, int *types = 0);
// internal index-based disconnect
@@ -458,6 +459,30 @@ struct Q_CORE_EXPORT QMetaObject
} d;
};
+class Q_CORE_EXPORT QMetaObject::Connection {
+ void *d_ptr; //QObjectPrivate::Connection*
+ explicit Connection(void *data) : d_ptr(data) { }
+ friend class QObject;
+ friend struct QMetaObject;
+public:
+ ~Connection();
+ Connection();
+ Connection(const Connection &other);
+ Connection &operator=(const Connection &other);
+#ifdef qdoc
+ operator bool() const;
+#else
+ typedef void *Connection::*RestrictedBool;
+ operator RestrictedBool() const { return d_ptr ? &Connection::d_ptr : 0; }
+#endif
+
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline Connection(Connection &&o) : d_ptr(o.d_ptr) { o.d_ptr = 0; }
+ inline Connection &operator=(Connection &&other)
+ { qSwap(d_ptr, other.d_ptr); return *this; }
+#endif
+};
+
typedef const QMetaObject& (*QMetaObjectAccessor)();
struct QMetaObjectExtraData