本文整理汇总了C++中ModelNode::allDirectSubModelNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ ModelNode::allDirectSubModelNodes方法的具体用法?C++ ModelNode::allDirectSubModelNodes怎么用?C++ ModelNode::allDirectSubModelNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelNode
的用法示例。
在下文中一共展示了ModelNode::allDirectSubModelNodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareTree
// TODO: this need to e updated for states
static bool compareTree(const ModelNode &node1, const ModelNode &node2)
{
if (!node1.isValid() || !node2.isValid()) {
return false;
}
if (node1.type() != node2.type()) {
return false;
}
// Compare properties
{
const QList<AbstractProperty> propList1 = node1.properties();
const QList<AbstractProperty> propList2 = node2.properties();
QList<AbstractProperty>::const_iterator iter1 = propList1.constBegin();
QList<AbstractProperty>::const_iterator iter2 = propList2.constBegin();
for (;
iter1 != propList1.constEnd() && iter2 != propList2.constEnd();
iter1++, iter2++) {
if (!compareProperty(*iter1, *iter2))
return false;
}
if (iter1 != propList1.constEnd() || iter2 != propList2.constEnd())
return false;
}
// Compare list of children
{
const QList<ModelNode> childList1 = node1.allDirectSubModelNodes();
const QList<ModelNode> childList2 = node2.allDirectSubModelNodes();
QList<ModelNode>::const_iterator iter1;
QList<ModelNode>::const_iterator iter2;
for (iter1 = childList1.constBegin(), iter2 = childList2.constBegin();
iter1 != childList1.constEnd() && iter2 != childList2.constEnd();
iter1++, iter2++) {
if (!compareTree((*iter1), (*iter2)))
return false;
}
if (iter1 != childList1.constEnd() || iter2 != childList2.constEnd())
return false;
}
return true;
}
示例2: propagateInvisible
void NavigatorTreeModel::propagateInvisible(const ModelNode &node, const bool &invisible)
{
QList <ModelNode> children = node.allDirectSubModelNodes();
foreach (ModelNode child, children) {
child.setAuxiliaryData("childOfInvisible",invisible);
if (!child.auxiliaryData("invisible").toBool())
propagateInvisible(child,invisible);
}
示例3: 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());
}
示例4: selectThrough
static void selectThrough(ModelNode node, QWidget* propWidget = 0)
{
QVERIFY(node.isValid());
int numberOfProperties = node.propertyNames().count();
QList<AbstractProperty> properties = node.properties();
node.view()->clearSelectedModelNodes();
node.view()->selectModelNode(node);
QString name = node.id();
qApp->processEvents();
QTest::qSleep(100);
qApp->processEvents();
QTest::qSleep(100);
qApp->processEvents();
inspectPropertyEditor(node, propWidget);
//selecting should not effect any properties at all!
QCOMPARE(node.propertyNames().count(), numberOfProperties);
foreach (const AbstractProperty &property, properties)
if (property.isVariantProperty()) {
QCOMPARE(property.toVariantProperty().value(), node.variantProperty(property.name()).value());
}
QList<ModelNode> childNodes = node.allDirectSubModelNodes();
foreach (const ModelNode &childNode, childNodes)
selectThrough(childNode, propWidget);
}