本文整理汇总了C++中KisNodeSP::index方法的典型用法代码示例。如果您正苦于以下问题:C++ KisNodeSP::index方法的具体用法?C++ KisNodeSP::index怎么用?C++ KisNodeSP::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisNodeSP
的用法示例。
在下文中一共展示了KisNodeSP::index方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCreation
void KisNodeFacadeTest::testCreation()
{
TestGraphListener graphListener;
KisNodeSP node = new TestNodeA();
QVERIFY(node->graphListener() == 0);
KisNodeFacade facade(node);
QVERIFY(facade.root() == node);
node->setGraphListener(&graphListener);
QVERIFY(node->graphListener() != 0);
// Test contract for initial state
QVERIFY(node->parent() == 0);
QVERIFY(node->firstChild() == 0);
QVERIFY(node->lastChild() == 0);
QVERIFY(node->prevSibling() == 0);
QVERIFY(node->nextSibling() == 0);
QVERIFY(node->childCount() == 0);
QVERIFY(node->at(0) == 0);
QVERIFY(node->at(UINT_MAX) == 0);
QVERIFY(node->index(0) == -1);
}
示例2: moveNode
bool KisNodeFacade::moveNode(KisNodeSP node, KisNodeSP parent, KisNodeSP aboveThis)
{
dbgImage << "moveNode " << node << " " << parent << " " << aboveThis;
if (!node) {
dbgImage << "cannot move null node"; return false;
}
if (!parent) {
dbgImage << "cannot move to null parent"; return false;
}
if (node == parent) {
dbgImage << "cannot move self inside self"; return false;
}
if (node == aboveThis) {
dbgImage << "cannot move self above self"; return false;
}
if (parent == aboveThis) {
dbgImage << "cannot move above parent"; return false;
}
if (!node->parent()) {
dbgImage << "node does not have a parent"; return false;
}
if (aboveThis && aboveThis->parent() != parent) {
dbgImage << "above this parent is not the parent"; return false;
}
int newIndex = aboveThis ? parent->index(aboveThis) + 1 : 0;
return moveNode(node, parent, newIndex);
}
示例3: lowerNode
bool KisNodeFacade::lowerNode(KisNodeSP node)
{
if (!node) return false;
if (!node->parent()) return false;
KisNodeSP parent = node->parent();
KisNodeSP prevSibling = node->prevSibling();
if (node->prevSibling()) {
int prevIndex = parent->index(prevSibling);
return moveNode(node, parent, prevIndex);
} else {
return true; // We're already at bottom, but there's no sense
// in complaining
}
}
示例4: testOrdering
void KisNodeFacadeTest::testOrdering()
{
TestGraphListener graphListener;
KisNodeSP root = new TestNodeA();
root->setGraphListener(&graphListener);
KisNodeFacade facade(root);
KisNodeSP node1 = new TestNodeA();
KisNodeSP node2 = new TestNodeA();
KisNodeSP node3 = new TestNodeA();
KisNodeSP node4 = new TestNodeA();
KisNodeSP node5 = new TestNodeA();
/*
+---------+
| node 4 |
| node 2 |
| node 3|
| node 1 |
|root |
+---------+
*/
graphListener.resetBools();
QVERIFY(facade.addNode(node1, root, root->childCount()) == true);
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node1);
QVERIFY(root->childCount() == 1);
graphListener.resetBools();
QVERIFY(facade.addNode(node2, root, root->childCount()) == true);
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node2);
QVERIFY(root->childCount() == 2);
graphListener.resetBools();
QVERIFY(facade.addNode(node3, node1) == true);
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node2);
QVERIFY(root->childCount() == 2);
QVERIFY(node1->childCount() == 1);
graphListener.resetBools();
QVERIFY(facade.addNode(node4, root, root->lastChild()) == true);
QVERIFY(graphListener.beforeInsertRow == true);
QVERIFY(graphListener.afterInsertRow == true);
QVERIFY(graphListener.beforeRemoveRow == false);
QVERIFY(graphListener.afterRemoveRow == false);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node4);
QVERIFY(root->childCount() == 3);
graphListener.resetBools();
QVERIFY(node1->parent() == root);
QVERIFY(node2->parent() == root);
QVERIFY(node3->parent() == node1);
QVERIFY(node4->parent() == root);
QVERIFY(root->firstChild() == node1);
QVERIFY(root->lastChild() == node4);
QVERIFY(root->at(0) == node1);
QVERIFY(root->at(1) == node2);
QVERIFY(root->at(2) == node4);
QVERIFY(node1->at(0) == node3);
QVERIFY(root->index(node1) == 0);
QVERIFY(root->index(node2) == 1);
QVERIFY(root->index(node4) == 2);
QVERIFY(node1->index(node3) == 0);
QVERIFY(node4->prevSibling() == node2);
QVERIFY(node2->prevSibling() == node1);
QVERIFY(node1->prevSibling() == 0);
QVERIFY(node3->prevSibling() == 0);
QVERIFY(node4->nextSibling() == 0);
QVERIFY(node2->nextSibling() == node4);
QVERIFY(node1->nextSibling() == node2);
QVERIFY(node3->nextSibling() == 0);
/*
node 4
node 2
node 3
node 1
//.........这里部分代码省略.........
示例5: dumpNodeStack
void dumpNodeStack(KisNodeSP node, QString prefix = QString("\t"))
{
for (uint i = 0; i < node->childCount(); ++i) {
if (node->at(i)->parent())
dbgImage << prefix << "\t" << node->at(i) << "node at" << i << " has index from parent:" << node->index(node->at(i));
if (node->at(i)->childCount() > 0) {
dumpNodeStack(node->at(i), prefix + "\t");
}
}
}
示例6: 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 |
+---------+
//.........这里部分代码省略.........