Use QQmlAbstractBoundSignal where appropriate.
authorMichael Brasser <michael.brasser@nokia.com>
Wed, 21 Mar 2012 06:28:32 +0000 (16:28 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 26 Mar 2012 05:24:29 +0000 (07:24 +0200)
Prepare for the addition of another subclass.

Change-Id: I340f735503e661d9d735f3316a065f807294921b
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
src/qml/debugger/qqmlenginedebugservice.cpp
src/qml/qml/qqmlboundsignal.cpp
src/qml/qml/qqmlboundsignal_p.h
src/qml/qml/qqmlcontext.h
src/qml/qml/qqmlproperty.cpp
tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp

index 40af773..4bd8753 100644 (file)
@@ -223,7 +223,7 @@ void QQmlEngineDebugService::buildObjectDump(QDataStream &message,
     
     int childrenCount = children.count();
     for (int ii = 0; ii < children.count(); ++ii) {
-        if (qobject_cast<QQmlContext*>(children[ii]) || QQmlBoundSignal::cast(children[ii]))
+        if (qobject_cast<QQmlContext*>(children[ii]) || qobject_cast<QQmlAbstractBoundSignal*>(children[ii]))
             --childrenCount;
     }
 
@@ -235,7 +235,7 @@ void QQmlEngineDebugService::buildObjectDump(QDataStream &message,
         QObject *child = children.at(ii);
         if (qobject_cast<QQmlContext*>(child))
             continue;
-        QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+        QQmlAbstractBoundSignal *signal = qobject_cast<QQmlAbstractBoundSignal*>(child);
         if (signal) {
             if (!dumpProperties)
                 continue;
index 543b69a..f8015a5 100644 (file)
@@ -161,12 +161,6 @@ QQmlExpression *QQmlBoundSignal::setExpression(QQmlExpression *e)
     return rv;
 }
 
-QQmlBoundSignal *QQmlBoundSignal::cast(QObject *o)
-{
-    QQmlAbstractBoundSignal *s = qobject_cast<QQmlAbstractBoundSignal*>(o);
-    return static_cast<QQmlBoundSignal *>(s);
-}
-
 int QQmlBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a)
 {
     if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) {
index 1138615..ab14de0 100644 (file)
@@ -67,6 +67,10 @@ class Q_QML_EXPORT QQmlAbstractBoundSignal : public QObject
 public:
     QQmlAbstractBoundSignal(QObject *parent = 0);
     virtual ~QQmlAbstractBoundSignal() = 0;
+
+    virtual int index() const = 0;
+    virtual QQmlExpression *expression() const = 0;
+    virtual QQmlExpression *setExpression(QQmlExpression *) = 0;
 };
 
 class QQmlBoundSignalParameters;
@@ -85,8 +89,6 @@ public:
 
     bool isEvaluating() const { return m_isEvaluating; }
 
-    static QQmlBoundSignal *cast(QObject *);
-
 protected:
     virtual int qt_metacall(QMetaObject::Call c, int id, void **a);
 
index f6d8aa1..4b11095 100644 (file)
@@ -98,7 +98,6 @@ private:
     friend class QQmlComponent;
     friend class QQmlComponentPrivate;
     friend class QQmlScriptPrivate;
-    friend class QQmlBoundSignalProxy;
     friend class QQmlContextData;
     QQmlContext(QQmlContextData *);
     QQmlContext(QQmlEngine *, bool);
index 14778ce..ebcf903 100644 (file)
@@ -928,7 +928,7 @@ QQmlPropertyPrivate::signalExpression(const QQmlProperty &that)
     for (int ii = 0; ii < children.count(); ++ii) {
         QObject *child = children.at(ii);
 
-        QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+        QQmlAbstractBoundSignal *signal = qobject_cast<QQmlAbstractBoundSignal*>(child);
         if (signal && signal->index() == that.index()) 
             return signal->expression();
     }
@@ -957,7 +957,7 @@ QQmlPropertyPrivate::setSignalExpression(const QQmlProperty &that,
     for (int ii = 0; ii < children.count(); ++ii) {
         QObject *child = children.at(ii);
 
-        QQmlBoundSignal *signal = QQmlBoundSignal::cast(child);
+        QQmlAbstractBoundSignal *signal = qobject_cast<QQmlAbstractBoundSignal*>(child);
         if (signal && signal->index() == that.index()) 
             return signal->setExpression(expr);
     }
index e84e662..d082593 100644 (file)
@@ -202,10 +202,10 @@ void tst_QQmlEngineDebugService::recursiveObjectTest(
     foreach (const QmlDebugPropertyReference &p, oref.properties) {
         QCOMPARE(p.objectDebugId, QQmlDebugService::idForObject(o));
 
-        // signal properties are fake - they are generated from QQmlBoundSignal children
+        // signal properties are fake - they are generated from QQmlAbstractBoundSignal children
         if (p.name.startsWith("on") && p.name.length() > 2 && p.name[2].isUpper()) {
-            QList<QQmlBoundSignal*> signalHandlers =
-                    o->findChildren<QQmlBoundSignal*>();
+            QList<QQmlAbstractBoundSignal*> signalHandlers =
+                    o->findChildren<QQmlAbstractBoundSignal*>();
             QString signal = p.value.toString();
             bool found = false;
             for (int i = 0; i < signalHandlers.count(); ++i)