本文整理汇总了C++中ModelNode::isRootNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::isRootNode方法的具体用法?C++ ModelNode::isRootNode怎么用?C++ ModelNode::isRootNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::isRootNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitCurrentComponentChanged
void ComponentAction::emitCurrentComponentChanged(int index)
{
if (dontEmitCurrentComponentChanged)
return;
ModelNode componentModelNode = m_componentView->modelNode(index);
if (componentModelNode.isRootNode())
emit changedToMaster();
else
emit currentComponentChanged(componentModelNode);
}
示例2: loadInFileComponent
bool DesignDocument::loadInFileComponent(const ModelNode &componentNode)
{
QString componentText = rewriterView()->extractText(QList<ModelNode>() << componentNode).value(componentNode);
if (componentText.isEmpty())
return false;
if (!componentNode.isRootNode()) {
//change to subcomponent model
changeToInFileComponentModel(createComponentTextModifier(m_documentTextModifier.data(), rewriterView(), componentText, componentNode));
}
return true;
}
示例3: changeCurrentModelTo
void DesignDocumentController::changeCurrentModelTo(const ModelNode &node)
{
if (d->componentNode == node)
return;
if (Internal::DesignModeWidget::instance()->currentDesignDocumentController() != this)
return;
DesignDocumentControllerPrivate::clearCrumblePath = false;
while (d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isValid() &&
!d->formEditorView->crumblePath()->dataForLastIndex().value<CrumbleBarInfo>().modelNode.isRootNode())
d->formEditorView->crumblePath()->popElement();
if (node.isRootNode() && d->formEditorView->crumblePath()->dataForLastIndex().isValid())
d->formEditorView->crumblePath()->popElement();
changeToSubComponent(node);
DesignDocumentControllerPrivate::clearCrumblePath = true;
}
示例4: createItemRow
NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
{
Q_ASSERT(node.isValid());
uint hash = node.internalId();
const bool dropEnabled = node.metaInfo().isValid();
QStandardItem *idItem = new QStandardItem;
idItem->setDragEnabled(true);
idItem->setDropEnabled(dropEnabled);
idItem->setEditable(true);
idItem->setData(hash, NavigatorRole);
if (node.metaInfo().isValid())
idItem->setToolTip(node.type());
else
idItem->setToolTip(msgUnknownItem(node.type()));
# ifdef _LOCK_ITEMS_
QStandardItem *lockItem = new QStandardItem;
lockItem->setDragEnabled(true);
lockItem->setDropEnabled(dropEnabled);
lockItem->setEditable(false);
lockItem->setCheckable(true);
lockItem->setData(hash, NavigatorRole);
# endif
QStandardItem *visibilityItem = new QStandardItem;
visibilityItem->setDropEnabled(dropEnabled);
visibilityItem->setCheckable(true);
visibilityItem->setEditable(false);
visibilityItem->setData(hash, NavigatorRole);
if (node.isRootNode())
visibilityItem->setCheckable(false);
QMap<QString, QStandardItem *> propertyItems;
foreach (const QString &propertyName, visibleProperties(node)) {
QStandardItem *propertyItem = new QStandardItem;
propertyItem->setSelectable(false);
propertyItem->setDragEnabled(false);
propertyItem->setDropEnabled(dropEnabled);
propertyItem->setEditable(false);
propertyItem->setData(propertyName, Qt::DisplayRole);
propertyItems.insert(propertyName, propertyItem);
idItem->appendRow(propertyItem);
}
示例5: createItemRow
NavigatorTreeModel::ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
{
Q_ASSERT(node.isValid());
uint hash = qHash(node);
const bool dropEnabled = node.metaInfo().isValid();
QStandardItem *idItem = new QStandardItem;
idItem->setDragEnabled(true);
idItem->setDropEnabled(dropEnabled);
idItem->setEditable(true);
idItem->setData(hash, Qt::UserRole);
#ifdef _LOCK_ITEMS_
QStandardItem *lockItem = new QStandardItem;
lockItem->setDragEnabled(true);
lockItem->setDropEnabled(dropEnabled);
lockItem->setEditable(false);
lockItem->setCheckable(true);
lockItem->setData(hash, Qt::UserRole);
#endif
QStandardItem *visibilityItem = new QStandardItem;
visibilityItem->setDropEnabled(dropEnabled);
visibilityItem->setCheckable(true);
visibilityItem->setEditable(false);
visibilityItem->setData(hash, Qt::UserRole);
if (node.isRootNode()) {
visibilityItem->setCheckable(false);
}
#ifdef _LOCK_ITEMS_
return ItemRow(idItem, lockItem, visibilityItem);
#else
return ItemRow(idItem, visibilityItem);
#endif
}
示例6: auxiliaryDataChanged
void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data)
{
if ((node.isRootNode() && (name == "width" || name == "height")) || name.endsWith(PropertyName("@NodeInstance"))) {
if (hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node);
QVariant value = data;
if (value.isValid()) {
PropertyValueContainer container(instance.instanceId(), name, value, TypeName());
ChangeAuxiliaryCommand changeAuxiliaryCommand(QVector<PropertyValueContainer>() << container);
nodeInstanceServer()->changeAuxiliaryValues(changeAuxiliaryCommand);
} else {
if (node.hasVariantProperty(name)) {
PropertyValueContainer container(instance.instanceId(), name, node.variantProperty(name).value(), TypeName());
ChangeValuesCommand changeValueCommand(QVector<PropertyValueContainer>() << container);
nodeInstanceServer()->changePropertyValues(changeValueCommand);
} else if (node.hasBindingProperty(name)) {
PropertyBindingContainer container(instance.instanceId(), name, node.bindingProperty(name).expression(), TypeName());
ChangeBindingsCommand changeValueCommand(QVector<PropertyBindingContainer>() << container);
nodeInstanceServer()->changePropertyBindings(changeValueCommand);
}
}
}
}
}
示例7: changeTypeName
void PropertyEditorContextObject::changeTypeName(const QString &typeName)
{
if (!m_model || !m_model->rewriterView())
return;
/* Ideally we should not missuse the rewriterView
* If we add more code here we have to forward the property editor view */
RewriterView *rewriterView = m_model->rewriterView();
if (rewriterView->selectedModelNodes().isEmpty())
return;
ModelNode selectedNode = rewriterView->selectedModelNodes().constFirst();
try {
RewriterTransaction transaction =
rewriterView->beginRewriterTransaction(QByteArrayLiteral("PropertyEditorContextObject:changeTypeName"));
NodeMetaInfo metaInfo = m_model->metaInfo(typeName.toLatin1());
if (!metaInfo.isValid()) {
Core::AsynchronousMessageBox::warning(tr("Invalid Type"), tr("%1 is an invalid type.").arg(typeName));
return;
}
if (selectedNode.isRootNode())
rewriterView->changeRootNodeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
else
selectedNode.changeType(metaInfo.typeName(), metaInfo.majorVersion(), metaInfo.minorVersion());
transaction.commit();
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
}
示例8: changeToSubComponent
void DesignDocumentController::changeToSubComponent(const ModelNode &componentNode)
{
Q_ASSERT(d->masterModel);
QWeakPointer<Model> oldModel = d->model;
Q_ASSERT(oldModel.data());
if (d->model == d->subComponentModel) {
changeToMasterModel();
}
QString componentText = d->rewriterView->extractText(QList<ModelNode>() << componentNode).value(componentNode);
if (componentText.isEmpty())
return;
bool explicitComponent = false;
if (componentText.contains("Component")) { //explicit component
explicitComponent = true;
}
d->componentNode = componentNode;
if (!componentNode.isRootNode()) {
Q_ASSERT(d->model == d->masterModel);
Q_ASSERT(componentNode.isValid());
//change to subcomponent model
ModelNode rootModelNode = componentNode.view()->rootModelNode();
Q_ASSERT(rootModelNode.isValid());
if (d->componentTextModifier)
delete d->componentTextModifier;
int componentStartOffset;
int componentEndOffset;
int rootStartOffset = d->rewriterView->nodeOffset(rootModelNode);
if (explicitComponent) { //the component is explciit we have to find the first definition inside
componentStartOffset = d->rewriterView->firstDefinitionInsideOffset(componentNode);
componentEndOffset = componentStartOffset + d->rewriterView->firstDefinitionInsideLength(componentNode);
} else { //the component is implicit
componentStartOffset = d->rewriterView->nodeOffset(componentNode);
componentEndOffset = componentStartOffset + d->rewriterView->nodeLength(componentNode);
}
d->componentTextModifier = new ComponentTextModifier (d->textModifier, componentStartOffset, componentEndOffset, rootStartOffset);
d->model->detachView(d->rewriterView.data());
d->rewriterView->setTextModifier(d->componentTextModifier);
d->subComponentModel->attachView(d->rewriterView.data());
Q_ASSERT(d->rewriterView->rootModelNode().isValid());
d->model = d->subComponentModel;
}
Q_ASSERT(d->masterModel);
Q_ASSERT(d->model);
loadCurrentModel();
d->componentView->setComponentNode(componentNode);
}