forked from qt-creator/qt-creator
QmlDesigner: Better componentComplete
Change-Id: I2bfdbeabd4d08474d50434d7e13c32b780e783ca Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
30d3e7e51d
commit
89db22a1c8
@@ -482,20 +482,6 @@ QPair<PropertyName, ServerNodeInstance> GraphicalNodeInstance::anchor(const Prop
|
||||
|
||||
}
|
||||
|
||||
static void doComponentCompleteRecursive(QQuickItem *item)
|
||||
{
|
||||
if (item) {
|
||||
if (DesignerSupport::isComponentComplete(item))
|
||||
return;
|
||||
|
||||
foreach (QQuickItem *childItem, item->childItems())
|
||||
doComponentCompleteRecursive(childItem);
|
||||
|
||||
static_cast<QQmlParserStatus*>(item)->componentComplete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void disableTextCursor(QQuickItem *item)
|
||||
{
|
||||
foreach (QQuickItem *childItem, item->childItems())
|
||||
@@ -512,7 +498,7 @@ static void disableTextCursor(QQuickItem *item)
|
||||
|
||||
void GraphicalNodeInstance::doComponentComplete()
|
||||
{
|
||||
doComponentCompleteRecursive(quickItem());
|
||||
doComponentCompleteRecursive(quickItem(), nodeInstanceServer());
|
||||
|
||||
disableTextCursor(quickItem());
|
||||
|
||||
|
||||
@@ -475,8 +475,13 @@ QList<ServerNodeInstance> NodeInstanceServer::setupInstances(const CreateSceneC
|
||||
setInstanceAuxiliaryData(container);
|
||||
}
|
||||
|
||||
foreach (ServerNodeInstance instance, instanceList)
|
||||
|
||||
QListIterator<ServerNodeInstance> instanceListIterator(instanceList);
|
||||
instanceListIterator.toBack();
|
||||
while (instanceListIterator.hasPrevious()) {
|
||||
ServerNodeInstance instance = instanceListIterator.previous();
|
||||
instance.doComponentComplete();
|
||||
}
|
||||
|
||||
return instanceList;
|
||||
}
|
||||
|
||||
@@ -1179,6 +1179,38 @@ QObject *ObjectNodeInstance::parentObject(QObject *object)
|
||||
return object->parent();
|
||||
}
|
||||
|
||||
void ObjectNodeInstance::doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer)
|
||||
{
|
||||
if (object) {
|
||||
QQuickItem *item = qobject_cast<QQuickItem*>(object);
|
||||
|
||||
if (item && DesignerSupport::isComponentComplete(item))
|
||||
return;
|
||||
|
||||
QList<QObject*> childList = object->children();
|
||||
|
||||
if (item) {
|
||||
foreach (QQuickItem *childItem, item->childItems()) {
|
||||
if (!childList.contains(childItem))
|
||||
childList.append(childItem);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QObject *child, childList) {
|
||||
if (!nodeInstanceServer->hasInstanceForObject(child))
|
||||
doComponentCompleteRecursive(child, nodeInstanceServer);
|
||||
}
|
||||
|
||||
if (item) {
|
||||
static_cast<QQmlParserStatus*>(item)->componentComplete();
|
||||
} else {
|
||||
QQmlParserStatus *qmlParserStatus = dynamic_cast< QQmlParserStatus*>(object);
|
||||
if (qmlParserStatus)
|
||||
qmlParserStatus->componentComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ObjectNodeInstance::Pointer ObjectNodeInstance::parentInstance() const
|
||||
{
|
||||
QObject *parentHolder = parent();
|
||||
@@ -1247,9 +1279,7 @@ bool ObjectNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &/
|
||||
|
||||
void ObjectNodeInstance::doComponentComplete()
|
||||
{
|
||||
QQmlParserStatus *qmlParserStatus = dynamic_cast< QQmlParserStatus*>(object());
|
||||
if (qmlParserStatus)
|
||||
qmlParserStatus->componentComplete();
|
||||
doComponentCompleteRecursive(object(), nodeInstanceServer());
|
||||
}
|
||||
|
||||
bool ObjectNodeInstance::isRootNodeInstance() const
|
||||
|
||||
@@ -196,6 +196,7 @@ protected:
|
||||
void deleteObjectsInList(const QQmlProperty &metaProperty);
|
||||
QVariant convertSpecialCharacter(const QVariant& value) const;
|
||||
static QObject *parentObject(QObject *object);
|
||||
static void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer);
|
||||
|
||||
private:
|
||||
QHash<PropertyName, QVariant> m_resetValueHash;
|
||||
|
||||
Reference in New Issue
Block a user