本文整理汇总了C++中ModelNode::parentProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::parentProperty方法的具体用法?C++ ModelNode::parentProperty怎么用?C++ ModelNode::parentProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::parentProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchForComponentAndAddToList
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);
}
}
}
}
示例2: nodeSlidAround
void ModelToTextMerger::nodeSlidAround(const ModelNode &movingNode, const ModelNode &inFrontOfNode)
{
if (!inFrontOfNode.isValid() || movingNode.parentProperty() == inFrontOfNode.parentProperty())
schedule(new MoveNodeRewriteAction(movingNode, inFrontOfNode));
else
Q_ASSERT(!"Nodes do not belong to the same containing property");
}
示例3: componentIdForModelNode
static inline QString componentIdForModelNode(const ModelNode &modelNode)
{
if (modelNode.id().isEmpty()) {
if (modelNode.hasParentProperty()
&& modelNode.parentProperty().name() != "data"
&& modelNode.parentProperty().name() != "children") {
return modelNode.parentProperty().name();
} else {
return modelNode.simplifiedTypeName();
}
} else {
return modelNode.id();
}
}
示例4: findTabViewModelNode
static ModelNode findTabViewModelNode(const ModelNode ¤tModelNode)
{
if (currentModelNode.metaInfo().isSubclassOf("QtQuick.Controls.TabView", -1, -1))
return currentModelNode;
else
return findTabViewModelNode(currentModelNode.parentProperty().parentModelNode());
}
示例5: resolveBinding
static ModelNode resolveBinding(const QString &binding, ModelNode currentNode, AbstractView* view)
{
int i = 0;
QString element = binding.split(QLatin1Char('.')).at(0);
while (!element.isEmpty())
{
if (element == "parent") {
if (currentNode.hasParentProperty())
currentNode = currentNode.parentProperty().toNodeAbstractProperty().parentModelNode();
else
return ModelNode(); //binding not valid
} else if (currentNode.hasProperty(element)) {
if (currentNode.property(element).isNodeProperty()) {
currentNode = currentNode.nodeProperty(element).modelNode();
} else {
currentNode = view->modelNodeForId(element); //id
if (!currentNode.isValid())
return ModelNode(); //binding not valid
}
} else {
currentNode = view->modelNodeForId(element); //id
}
i++;
if (i < binding.split(QLatin1Char('.')).count())
element = binding.split(QLatin1Char('.')).at(i);
else
element.clear();
}
return currentNode;
}
示例6: reparentHere
void NodeAbstractProperty::reparentHere(const ModelNode &modelNode, bool isNodeList)
{
if (modelNode.parentProperty() == *this)
return;
Internal::WriteLocker locker(model());
if (!isValid())
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
if (isNodeProperty()) {
NodeProperty nodeProperty(toNodeProperty());
if (nodeProperty.modelNode().isValid())
throw InvalidReparentingException(__LINE__, __FUNCTION__, __FILE__);
}
if (modelNode.isAncestorOf(parentModelNode()))
throw InvalidReparentingException(__LINE__, __FUNCTION__, __FILE__);
if (internalNode()->hasProperty(name()) && !internalNode()->property(name())->isNodeAbstractProperty())
model()->d->removeProperty(internalNode()->property(name()));
if (modelNode.hasParentProperty()) {
Internal::InternalNodeAbstractProperty::Pointer oldParentProperty = modelNode.internalNode()->parentProperty();
model()->d->reparentNode(internalNode(), name(), modelNode.internalNode(), isNodeList);
Q_ASSERT(!oldParentProperty.isNull());
} else {
model()->d->reparentNode(internalNode(), name(), modelNode.internalNode(), isNodeList);
}
}
示例7: createSubNode
void TestPropertyEditor::createSubNode()
{
std::auto_ptr<QWidget> widget(new QWidget());
QScopedPointer<Model> model(Model::create("import Qt 4.6\n Item {}"));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
QVERIFY(view.data());
model->attachView(view.data());
setupPropertyEditor(widget.get(), model.data());
QVERIFY(view->rootModelNode().isValid());
selectThrough(view->rootModelNode());
ModelNode childNode = view->createModelNode("Qt/Rectangle", 4, 6);
view->rootModelNode().nodeListProperty("data").reparentHere(childNode);
QVERIFY(childNode.isValid());
QVERIFY(view->rootModelNode().allDirectSubModelNodes().contains(childNode));
QVERIFY(childNode.parentProperty().parentModelNode() == view->rootModelNode());
QCOMPARE(childNode.type(), QString("Qt/Rectangle"));
selectThrough(childNode);
QVERIFY(childNode.id().isEmpty());
childNode.setId("Blah");
QCOMPARE(childNode.id(), QString("Blah"));
QCOMPARE(childNode.id(), QString("Blah"));
}
示例8: updateItemRowOrder
/**
Updates the sibling position of the item, depending on the position in the model.
*/
void NavigatorTreeModel::updateItemRowOrder(const ModelNode &node)
{
if (!containsNode(node))
return;
ItemRow itemRow = itemRowForNode(node);
int currentRow = itemRow.idItem->row();
int newRow = currentRow;
if (node.parentProperty().parentModelNode().isValid())
newRow = modelNodeChildren(node.parentProperty().parentModelNode()).indexOf(node);
Q_ASSERT(newRow >= 0);
if (currentRow != newRow) {
QStandardItem *parentIdItem = itemRow.idItem->parent();
QList<QStandardItem*> items = parentIdItem->takeRow(currentRow);
parentIdItem->insertRow(newRow, items);
}
}
示例9: nodeAboutToBeRemoved
void StatesEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
if (removedNode.hasParentProperty()) {
const NodeAbstractProperty propertyParent = removedNode.parentProperty();
if (propertyParent.parentModelNode().isRootNode() && propertyParent.name() == "states")
m_lastIndex = propertyParent.indexOf(removedNode);
}
if (currentState().isValid() && removedNode == currentState())
setCurrentState(baseState());
}
示例10: descriptionForNode
QString ComponentView::descriptionForNode(const ModelNode &node) const
{
QString description;
if (!node.id().isEmpty()) {
description = node.id();
} else if (node.hasParentProperty()) {
ModelNode parentNode = node.parentProperty().parentModelNode();
if (parentNode.id().isEmpty())
description = parentNode.simplifiedTypeName() + QLatin1Char(' ');
else
description = parentNode.id() + QLatin1Char(' ');
description += node.parentProperty().name();
}
return description;
}
示例11: variantPropertyInEditedPath
bool variantPropertyInEditedPath(const VariantProperty &variantProperty, const ModelNode &editingPathViewModelNode)
{
ModelNode pathElementModelNode = variantProperty.parentModelNode();
if (pathElementModelNode.hasParentProperty()) {
if (isInEditedPath(pathElementModelNode.parentProperty(), editingPathViewModelNode))
return true;
}
return false;
}
示例12: removeNode
void TestPropertyEditor::removeNode()
{
std::auto_ptr<QWidget> widget(new QWidget());
QScopedPointer<Model> model(Model::create("import Qt 4.6\n Item {}"));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
QVERIFY(view.data());
model->attachView(view.data());
setupPropertyEditor(widget.get(), model.data());
QCOMPARE(view->rootModelNode().allDirectSubModelNodes().count(), 0);
selectThrough(view->rootModelNode());
ModelNode childNode = view->createModelNode("Qt/Rectangle", 4, 6);
view->rootModelNode().nodeListProperty("data").reparentHere(childNode);
QVERIFY(childNode.isValid());
QCOMPARE(view->rootModelNode().allDirectSubModelNodes().count(), 1);
QVERIFY(view->rootModelNode().allDirectSubModelNodes().contains(childNode));
QVERIFY(childNode.parentProperty().parentModelNode() == view->rootModelNode());
selectThrough(childNode);
ModelNode subChildNode = view->createModelNode("Qt/Rectangle", 4, 6);
childNode.nodeListProperty("data").reparentHere(subChildNode);
QVERIFY(subChildNode.isValid());
QCOMPARE(childNode.allDirectSubModelNodes().count(), 1);
QVERIFY(childNode.allDirectSubModelNodes().contains(subChildNode));
QVERIFY(subChildNode.parentProperty().parentModelNode() == childNode);
selectThrough(subChildNode);
childNode.destroy();
QCOMPARE(view->rootModelNode().allDirectSubModelNodes().count(), 0);
QVERIFY(!view->rootModelNode().allDirectSubModelNodes().contains(childNode));
QVERIFY(!childNode.isValid());
QVERIFY(!subChildNode.isValid());
}
示例13: createRect
void TestPropertyEditor::createRect()
{
try {
std::auto_ptr<QWidget> widget(new QWidget());
QScopedPointer<Model> model(Model::create("import Qt 4.6\n Item {}"));
QVERIFY(model.data());
QScopedPointer<TestView> view(new TestView);
QVERIFY(view.data());
model->attachView(view.data());
setupPropertyEditor(widget.get(), model.data());
QVERIFY(view->rootModelNode().isValid());
//selectThrough(view->rootModelNode());
ModelNode childNode = view->createModelNode("Qt/Rectangle", 4, 6);
view->rootModelNode().nodeListProperty("data").reparentHere(childNode);
QVERIFY(childNode.isValid());
QVERIFY(view->rootModelNode().allDirectSubModelNodes().contains(childNode));
QVERIFY(childNode.parentProperty().parentModelNode() == view->rootModelNode());
QCOMPARE(childNode.type(), QString("Qt/Rectangle"));
QVERIFY(childNode.id().isEmpty());
childNode.setId("Rect01");
QCOMPARE(childNode.id(), QString("Rect01"));
childNode.variantProperty("x") = 100;
QCOMPARE(QmlObjectNode(childNode).instanceValue("x").toInt(), 100);
childNode.variantProperty("y") = 100;
QCOMPARE(QmlObjectNode(childNode).instanceValue("y").toInt(), 100);
childNode.variantProperty("width") = 100;
QCOMPARE(QmlObjectNode(childNode).instanceValue("width").toInt(), 100);
childNode.variantProperty("height") = 100;
QCOMPARE(QmlObjectNode(childNode).instanceValue("height").toInt(), 100);
selectThrough(childNode);
QCOMPARE(childNode.propertyNames().count(), 4);
QCOMPARE(childNode.variantProperty("scale").value(), QVariant());
} catch (Exception &) {
QFAIL("Exception thrown");
}
}
示例14: nodeOrParentInSet
static bool nodeOrParentInSet(const ModelNode &modelNode, const QSet<ModelNode> &nodeSet)
{
ModelNode currentModelnode = modelNode;
while (currentModelnode.isValid()) {
if (nodeSet.contains(currentModelnode))
return true;
if (!currentModelnode.hasParentProperty())
return false;
currentModelnode = currentModelnode.parentProperty().parentModelNode();
}
return false;
}
示例15: nodeOrParentInSet
static bool nodeOrParentInSet(const ModelNode &node, const QSet<ModelNode> &nodeSet)
{
ModelNode n = node;
while (n.isValid()) {
if (nodeSet.contains(n))
return true;
if (!n.hasParentProperty())
return false;
n = n.parentProperty().parentModelNode();
}
return false;
}