summaryrefslogtreecommitdiff
path: root/src/imports/webchannel/qmlwebchannel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/webchannel/qmlwebchannel.h')
-rw-r--r--src/imports/webchannel/qmlwebchannel.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/imports/webchannel/qmlwebchannel.h b/src/imports/webchannel/qmlwebchannel.h
index bcbb9cf..c45796f 100644
--- a/src/imports/webchannel/qmlwebchannel.h
+++ b/src/imports/webchannel/qmlwebchannel.h
@@ -45,6 +45,7 @@
#include <qwebchannel.h>
#include "qmlwebchannelattached.h"
+#include "qwebchanneltransportinterface.h"
#include <QVector>
@@ -53,13 +54,13 @@
QT_BEGIN_NAMESPACE
-class QmlWebChannelAttached;
-
class QmlWebChannel : public QWebChannel
{
Q_OBJECT
+ Q_PROPERTY( QQmlListProperty<QWebChannelTransportInterface> connections READ transports );
Q_PROPERTY( QQmlListProperty<QObject> registeredObjects READ registeredObjects )
+
public:
QmlWebChannel(QObject *parent = 0);
virtual ~QmlWebChannel();
@@ -67,13 +68,19 @@ public:
Q_INVOKABLE void registerObjects(const QVariantMap& objects);
QQmlListProperty<QObject> registeredObjects();
+ QQmlListProperty<QWebChannelTransportInterface> transports();
+
// TODO: remove this by replacing QML with C++ tests
Q_INVOKABLE bool test_clientIsIdle() const;
static QmlWebChannelAttached* qmlAttachedProperties(QObject *obj);
+ Q_INVOKABLE void connectTo(QObject *transport);
+ Q_INVOKABLE void disconnectFrom(QObject *transport);
+
private slots:
void objectIdChanged(const QString &newId);
+ void transportDestroyed(QObject *transport);
private:
static void registeredObjects_append(QQmlListProperty<QObject> *prop, QObject* item);
@@ -81,7 +88,14 @@ private:
static QObject *registeredObjects_at(QQmlListProperty<QObject> *prop, int index);
static void registeredObjects_clear(QQmlListProperty<QObject> *prop);
+ static void transports_append(QQmlListProperty<QWebChannelTransportInterface> *prop, QWebChannelTransportInterface* item);
+ static int transports_count(QQmlListProperty<QWebChannelTransportInterface> *prop);
+ static QWebChannelTransportInterface *transports_at(QQmlListProperty<QWebChannelTransportInterface> *prop, int index);
+ static void transports_clear(QQmlListProperty<QWebChannelTransportInterface> *prop);
+
QVector<QObject*> m_registeredObjects;
+ // required as when the object is destroyed, we must still find the address of the base class somehow
+ QHash<QObject*, QWebChannelTransportInterface*> m_connectedObjects;
};
QML_DECLARE_TYPE( QmlWebChannel )