本文整理汇总了C++中KisNodeSP::add方法的典型用法代码示例。如果您正苦于以下问题:C++ KisNodeSP::add方法的具体用法?C++ KisNodeSP::add怎么用?C++ KisNodeSP::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisNodeSP
的用法示例。
在下文中一共展示了KisNodeSP::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addNode
bool KisNodeFacade::addNode(KisNodeSP node, KisNodeSP parent, quint32 index)
{
if (!node) return false;
if (!parent) return false;
if (index == parent->childCount())
return parent->add(node, parent->lastChild());
else if (index != 0)
return parent->add(node, parent->at(index));
else
return parent->add(node, 0);
}
示例2: testChildNodes
void KisNodeTest::testChildNodes()
{
KisNodeSP root = new TestNodeA();
KisNodeSP a = new TestNodeA();
root->add(a, 0);
a->setVisible(true);
a->setUserLocked(true);
KisNodeSP b = new TestNodeB();
root->add(b, 0);
b->setVisible(false);
b->setUserLocked(true);
KisNodeSP c = new TestNodeC();
root->add(c, 0);
c->setVisible(false);
c->setVisible(false);
QList<KisNodeSP> allNodes = root->childNodes(QStringList(), KoProperties());
QCOMPARE((int) allNodes.count(), 3); // a, b, c
QStringList nodeTypes;
nodeTypes << "TestNodeA" << "TestNodeB";
QList<KisNodeSP> subSetOfNodeTypes = root->childNodes(nodeTypes, KoProperties());
QVERIFY(subSetOfNodeTypes.count() == 2); // a, b
nodeTypes.clear();
nodeTypes << "TestNodeB" << "TestNodeC";
KoProperties props;
props.setProperty("visibile", false);
props.setProperty("locked", true);
QList<KisNodeSP> subsetOfTypesAndProps = root->childNodes(nodeTypes, props);
QVERIFY(subsetOfTypesAndProps.count() == 1); // b
KoProperties props2;
props.setProperty("visibile", false);
QList<KisNodeSP> subSetOfProps = root->childNodes(QStringList(), props);
QVERIFY(subSetOfProps.count() == 2); // b, c
}
示例3: toBottom
bool KisNodeFacade::toBottom(KisNodeSP node)
{
if (!node) return false;
if (!node->parent()) return false;
KisNodeSP parent = node->parent();
if (node == parent->firstChild()) return true;
// Sets the parent of this node to 0
if (!parent->remove(node)) return false;
return parent->add(node, 0);
}
示例4: testOrdering
void KisNodeTest::testOrdering()
{
TestUtil::TestGraphListener graphListener;
KisNodeSP root = new TestNodeA();
root->setGraphListener(&graphListener);
KisNodeSP node1 = new TestNodeA();
KisNodeSP node2 = new TestNodeA();
KisNodeSP node3 = new TestNodeA();
KisNodeSP node4 = new TestNodeA();
/*
+---------+
| node 4 |
| node 2 |
| node 3 |
| node 1 |
|root |
+---------+
*/
graphListener.resetBools();
QVERIFY(root->lastChild() == 0);
root->add(node1, root->lastChild());
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node1);
graphListener.resetBools();
QVERIFY(root->lastChild() == node1);
root->add(node2, root->lastChild());
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node2);
graphListener.resetBools();
QVERIFY(root->lastChild() == node2);
root->add(node3, node1);
QVERIFY(root->lastChild() == node2);
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node2);
graphListener.resetBools();
root->add(node4, root->lastChild());
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node4);
graphListener.resetBools();
QVERIFY(root->childCount() == 4);
QVERIFY(node1->parent() == root);
QVERIFY(node2->parent() == root);
QVERIFY(node3->parent() == root);
QVERIFY(node4->parent() == root);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node4);
QVERIFY(root->at(0) == node1);
QVERIFY(root->at(1) == node3);
QVERIFY(root->at(2) == node2);
QVERIFY(root->at(3) == node4);
QVERIFY(root->index(node1) == 0);
QVERIFY(root->index(node3) == 1);
QVERIFY(root->index(node2) == 2);
QVERIFY(root->index(node4) == 3);
QVERIFY(node4->prevSibling() == node2);
QVERIFY(node3->prevSibling() == node1);
QVERIFY(node2->prevSibling() == node3);
QVERIFY(node1->prevSibling() == 0);
QVERIFY(node4->nextSibling() == 0);
QVERIFY(node3->nextSibling() == node2);
QVERIFY(node2->nextSibling() == node4);
QVERIFY(node1->nextSibling() == node3);
/*
+---------+
| node 3 |
| node 4 |
| node 2 |
| node 1 |
|root |
+---------+
//.........这里部分代码省略.........
示例5: testSetDirty
void KisNodeTest::testSetDirty()
{
// Create a node graph with two branches
/*
node2
node4
node6
node5
node5
node3
node1
root
*/
KisNodeSP root = new TestNode();
root->setName("root");
KisNodeSP node1 = new TestNode();
node1->setName("node1");
QVERIFY(root->add(node1, 0));
KisNodeSP node2 = new TestNode();
node2->setName("node2");
QVERIFY(root->add(node2, node1));
KisNodeSP node3 = new TestNode();
node3->setName("node3");
QVERIFY(node1->add(node3, 0));
KisNodeSP node4 = new TestNode();
node4->setName("node4");
QVERIFY(node1->add(node4, node3));
KisNodeSP node5 = new TestNode();
node5->setName("node5");
QVERIFY(node3->add(node5, 0));
KisNodeSP node6 = new TestNode();
node6->setName("node6");
QVERIFY(node5->add(node6, 0));
KisNodeSP node7 = new TestNode();
node7->setName("node7");
QVERIFY(node6->add(node7, 0));
#if 0 // XXX: rewrite tests after redesign to update strategies
node1->setDirty();
QVERIFY(node1->isDirty());
QVERIFY(!node2->isDirty());
QVERIFY(root->isDirty());
root->setClean();
QVERIFY(!root->isDirty());
node1->setClean();
QVERIFY(!node1->isDirty());
node7->setDirty(QRect(10, 10, 100, 100));
QVERIFY(node7->isDirty());
QVERIFY(node7->isDirty(QRect(5, 5, 15, 15)));
QVERIFY(root->isDirty(QRect(5, 5, 15, 15)));
QVERIFY(!root->isDirty(QRect(-10, -10, 20, 20)));
QVERIFY(!node2->isDirty());
node7->setClean(QRect(10, 10, 10, 10));
QVERIFY(!node7->isDirty(QRect(10, 10, 10, 10)));
QVERIFY(node7->isDirty());
QVERIFY(node7->isDirty(QRect(0, 0, 50, 50)));
#endif
}