From 88e215b6d56b406d994f97a0adbd2a6afff655be Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 23 Apr 2013 09:25:29 +0200 Subject: [PATCH] Adding emitComponentCompleteSignalForAttachedProperty() 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 --- src/qml/qml/qqmlcomponentattached_p.h | 3 ++- src/quick/designer/designersupport.cpp | 13 +++++++++++++ src/quick/designer/designersupport.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h index 3c27e79..ae416dc 100644 --- a/src/qml/qml/qqmlcomponentattached_p.h +++ b/src/qml/qml/qqmlcomponentattached_p.h @@ -43,12 +43,13 @@ #define QQMLCOMPONENTATTACHED_P_H #include +#include #include QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QQmlComponentAttached : public QObject +class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject { Q_OBJECT public: diff --git a/src/quick/designer/designersupport.cpp b/src/quick/designer/designersupport.cpp index 063fa6e..2dd041b 100644 --- a/src/quick/designer/designersupport.cpp +++ b/src/quick/designer/designersupport.cpp @@ -51,6 +51,8 @@ #include #include #include +#include +#include #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 DesignerSupport::statesForItem(QQuickItem *item) { QList objectList; diff --git a/src/quick/designer/designersupport.h b/src/quick/designer/designersupport.h index 4567e5c..5139a65 100644 --- a/src/quick/designer/designersupport.h +++ b/src/quick/designer/designersupport.h @@ -125,6 +125,7 @@ public: static QQuickItem *anchorCenterInTargetItem(QQuickItem *item); static QPair anchorLineTarget(QQuickItem *item, const QString &name, QQmlContext *context); static void resetAnchor(QQuickItem *item, const QString &name); + static void emitComponentCompleteSignalForAttachedProperty(QQuickItem *item); static QList statesForItem(QQuickItem *item); -- 2.7.4