void ComponentView::searchForComponentAndAddToList(const ModelNode &node) { QList<ModelNode> nodeList; nodeList.append(node); nodeList.append(node.allSubModelNodes()); 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); removeSingleNodeFromList(node); //remove node if already present m_standardItemModel->appendRow(item); } else { QString description; 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(node), ModelNodeRole); item->setEditable(false); removeSingleNodeFromList(node); //remove node if already present m_standardItemModel->appendRow(item); } } } }
void ComponentView::searchForComponentAndAddToList(const ModelNode &node) { QList<ModelNode> nodeList; nodeList.append(node); nodeList.append(node.allSubModelNodes()); bool masterNotAdded = true; foreach (const ModelNode &node, nodeList) { if (node.nodeSourceType() == ModelNode::NodeWithComponentSource) { if (masterNotAdded) { masterNotAdded = true; addMasterDocument(); } if (!hasEntryForNode(node)) { QString description = descriptionForNode(node); QStandardItem *item = new QStandardItem(description); item->setData(QVariant::fromValue(node.internalId()), ModelNodeRole); item->setEditable(false); removeSingleNodeFromList(node); //remove node if already present m_standardItemModel->appendRow(item); } } } }
static ModelNode createNodeFromNode(const ModelNode &modelNode,const QHash<QString, QString> &idRenamingHash, AbstractView *view) { QList<QPair<QString, QVariant> > propertyList; QList<QPair<QString, QVariant> > variantPropertyList; foreach (const VariantProperty &variantProperty, modelNode.variantProperties()) { propertyList.append(QPair<QString, QVariant>(variantProperty.name(), variantProperty.value())); } ModelNode newNode(view->createModelNode(modelNode.type(),modelNode.majorVersion(),modelNode.minorVersion(), propertyList, variantPropertyList, modelNode.nodeSource(), modelNode.nodeSourceType())); syncBindingProperties(newNode, modelNode, idRenamingHash); syncId(newNode, modelNode, idRenamingHash); syncNodeProperties(newNode, modelNode, idRenamingHash, view); syncNodeListProperties(newNode, modelNode, idRenamingHash, view); return newNode; }
static void handleComponent(const ModelNode &modelNode) { if (modelNode.nodeSourceType() == ModelNode::NodeWithComponentSource) designDocument()->changeToSubComponent(modelNode); }