void ComponentView::searchForComponentAndAddToList(const ModelNode &node) { bool masterNotAdded = true; foreach (const ModelNode &node, node.allSubModelNodesAndThisNode()) { 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 void setupIdRenamingHash(const ModelNode &modelNode, QHash<QString, QString> &idRenamingHash, AbstractView *view) { foreach (const ModelNode &node, modelNode.allSubModelNodesAndThisNode()) { if (!node.id().isEmpty()) { QString newId = node.id(); QString baseId; int number = 1; splitIdInBaseNameAndNumber(newId, &baseId, &number); while (view->hasId(newId) || idRenamingHash.values().contains(newId)) { newId = baseId + QString::number(number); number++; } idRenamingHash.insert(node.id(), newId); } } }