Adding emitComponentCompleteSignalForAttachedProperty()
authorThomas Hartmann <Thomas.Hartmann@digia.com>
Tue, 23 Apr 2013 07:25:29 +0000 (09:25 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 23 Apr 2013 10:53:48 +0000 (12:53 +0200)
Each item that is created by a component gets the
attached property "Component".
This property has the signal onCompleted.

This function allows the designer to manually emit this
signal once the item is setup.

I had to export QQmlComponentAttached for this.

Change-Id: I45b4e72af4f12cdcda29f165cc9bc4d9dee8faf7
Reviewed-by: Marco Bubke <marco.bubke@digia.com>

src/qml/qml/qqmlcomponentattached_p.h
src/quick/designer/designersupport.cpp
src/quick/designer/designersupport.h

index 3c27e79..ae416dc 100644 (file)
 #define QQMLCOMPONENTATTACHED_P_H
 
 #include <QtQml/qqml.h>
+#include <private/qtqmlglobal_p.h>
 #include <QtCore/QObject>
 
 QT_BEGIN_NAMESPACE
 
 
-class Q_AUTOTEST_EXPORT QQmlComponentAttached : public QObject
+class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject
 {
     Q_OBJECT
 public:
index 063fa6e..2dd041b 100644 (file)
@@ -51,6 +51,8 @@
 #include <QtQuick/private/qquickstategroup_p.h>
 #include <QtGui/QImage>
 #include <private/qqmlvme_p.h>
+#include <private/qqmlcomponentattached_p.h>
+#include <private/qqmldata_p.h>
 
 #include "designerwindowmanager_p.h"
 
@@ -375,6 +377,17 @@ void DesignerSupport::resetAnchor(QQuickItem *item, const QString &name)
     }
 }
 
+void DesignerSupport::emitComponentCompleteSignalForAttachedProperty(QQuickItem *item)
+{
+    QQmlData *data = QQmlData::get(item);
+    if (data && data->context) {
+        QQmlComponentAttached *componentAttached = data->context->componentAttached;
+        if (componentAttached) {
+            emit componentAttached->completed();
+        }
+    }
+}
+
 QList<QObject*> DesignerSupport::statesForItem(QQuickItem *item)
 {
     QList<QObject*> objectList;
index 4567e5c..5139a65 100644 (file)
@@ -125,6 +125,7 @@ public:
     static QQuickItem *anchorCenterInTargetItem(QQuickItem *item);
     static QPair<QString, QObject*> anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context);
     static void resetAnchor(QQuickItem *item, const QString &name);
+    static void emitComponentCompleteSignalForAttachedProperty(QQuickItem *item);
 
 
     static QList<QObject*> statesForItem(QQuickItem *item);