Commit 0793a8df authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.componentView: update and bug fixing

I implemented nodeReparented() (bugfix)
I use ModelNode::ComponentSource instead of childNode.type() == "QtQuick.Component"
to catch "implicit" components.

Change-Id: Ie5bd48afbb5a5b10c3544406b1229aafc5dabed5
Reviewed-on: http://codereview.qt.nokia.com/416

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent f37e589e
......@@ -127,22 +127,24 @@ void ComponentView::searchForComponentAndAddToList(const ModelNode &node)
nodeList.append(node.allSubModelNodes());
foreach (const ModelNode &childNode, nodeList) {
if (childNode.type() == "QtQuick.Component") {
if (!childNode.id().isEmpty()) {
QStandardItem *item = new QStandardItem(childNode.id());
item->setData(QVariant::fromValue(childNode), ModelNodeRole);
foreach (const ModelNode &node, nodeList) {
if (node.nodeSourceType() == ModelNode::ComponentSource) {
if (!node.id().isEmpty()) {
QStandardItem *item = new QStandardItem(node.id());
item->setData(QVariant::fromValue(node), ModelNodeRole);
item->setEditable(false);
m_standardItemModel->appendRow(item);
} else {
QString description;
if (!childNode.parentProperty().parentModelNode().id().isEmpty())
description = childNode.parentProperty().parentModelNode().id() + QLatin1Char(' ');
else
description = childNode.parentProperty().parentModelNode().simplifiedTypeName() + QLatin1Char(' ');
description += childNode.parentProperty().name();
ModelNode parentNode = node.parentProperty().parentModelNode();
if (parentNode.isValid())
if (!parentNode.id().isEmpty())
description = node.parentProperty().parentModelNode().id() + QLatin1Char(' ');
else
description = node.parentProperty().parentModelNode().simplifiedTypeName() + QLatin1Char(' ');
description += node.parentProperty().name();
QStandardItem *item = new QStandardItem(description);
item->setData(QVariant::fromValue(childNode), ModelNodeRole);
item->setData(QVariant::fromValue(node), ModelNodeRole);
item->setEditable(false);
m_standardItemModel->appendRow(item);
}
......@@ -166,7 +168,7 @@ void ComponentView::searchForComponentAndRemoveFromList(const ModelNode &node)
foreach (const ModelNode &childNode, nodeList) {
if (childNode.type() == "QtQuick.Component") {
if (childNode.nodeSourceType() == ModelNode::ComponentSource) {
if (!childNode.id().isEmpty()) {
for (int row = 0; row < m_standardItemModel->rowCount(); row++) {
if (m_standardItemModel->item(row)->text() == childNode.id())
......@@ -182,7 +184,12 @@ void ComponentView::searchForComponentAndRemoveFromList(const ModelNode &node)
}
void ComponentView::nodeAboutToBeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/) {}
void ComponentView::nodeReparented(const ModelNode &/*node*/, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/) {}
void ComponentView::nodeReparented(const ModelNode &node, const NodeAbstractProperty &/*newPropertyParent*/, const NodeAbstractProperty &/*oldPropertyParent*/, AbstractView::PropertyChangeFlags /*propertyChange*/)
{
searchForComponentAndAddToList(node);
}
void ComponentView::nodeIdChanged(const ModelNode& /*node*/, const QString& /*newId*/, const QString& /*oldId*/) {}
void ComponentView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& /*propertyList*/) {}
void ComponentView::propertiesRemoved(const QList<AbstractProperty>& /*propertyList*/) {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment