void rebuildLayerList(KisNodeSP layer = 0) { bool refreshingFromRoot = false; if (!image) { layers.clear(); return; } if (layer == 0) { refreshingFromRoot = true; layers.clear(); layer = image->rootLayer(); } // implementation node: The root node is not a visible node, and so // is never added to the list of layers QList<KisNodeSP> children = layer->childNodes(layerClassNames(), KoProperties()); if (children.count() == 0) return; for(quint32 i = children.count(); i > 0; --i) { layers << children.at(i-1); rebuildLayerList(children.at(i-1)); } if (refreshingFromRoot) refreshLayerMovementAbilities(); }
void KisKraSaveXmlVisitorTest::testCreateDomDocument() { KisDocument* doc = createCompleteDocument(); quint32 count = 0; QDomDocument dom; QDomElement image = dom.createElement("IMAGE"); // Legacy! KisSaveXmlVisitor visitor(dom, image, count, "", true); Q_ASSERT(doc->image()); QStringList list; doc->image()->lock(); KisCountVisitor cv(list, KoProperties()); doc->image()->rootLayer()->accept(cv); doc->image()->rootLayer()->accept(visitor); QCOMPARE((int)visitor.m_count, (int)cv.count()); //delete doc; }
int deepChildCount(KisNodeSP layer) { quint32 childCount = layer->childCount(); QList<KisNodeSP> children = layer->childNodes(layerClassNames(), KoProperties()); for(quint32 i = 0; i < childCount; ++i) childCount += deepChildCount(children.at(i)); return childCount; }
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 }