26 mDocument.appendChild(mDocument.createElement(
"root"));
28 for (std::map<QString, DataPtr>::const_iterator iter = source.begin(); iter != source.end(); ++iter)
30 this->insertFrame(iter->second);
44 void FrameForest::insertFrame(
DataPtr data)
46 QString parentFrame = data->getParentSpace();
47 QString currentFrame = data->getSpace();
52 QDomNode parentNode = this->getNodeAnyway(parentFrame);
53 QDomNode currentNode = this->getNodeAnyway(currentFrame);
55 if (parentNode.isNull())
59 currentNode = currentNode.parentNode().removeChild(currentNode);
60 parentNode.appendChild(currentNode);
68 QDomNodeList list = mDocument.elementsByTagName(frame);
76 QDomNode FrameForest::getNodeAnyway(QString frame)
78 QDomNode retval = this->
getNode(frame);
81 retval = mDocument.createElement(frame);
82 mDocument.documentElement().appendChild(retval);
89 bool FrameForest::isAncestorOf(QDomNode node, QDomNode ancestor)
93 while (!this->isRootNode(node))
100 node = node.parentNode();
106 bool FrameForest::isRootNode(QDomNode node)
108 return node == mDocument.documentElement();
115 if (this->isRootNode(node))
117 while (!this->isRootNode(node.parentNode()))
118 node = node.parentNode();
127 if (this->isAncestorOf(ref, node))
130 while (!this->isRootNode(node.parentNode()))
133 if (this->isAncestorOf(ref, node.parentNode()))
135 node = node.parentNode();
146 std::vector<QDomNode> retval;
147 retval.push_back(node);
149 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling())
152 std::copy(subnodes.begin(), subnodes.end(), back_inserter(retval));
163 std::vector<DataPtr> retval;
165 for (
unsigned i = 0; i < nodes.size(); ++i)
167 DataPtr data = mSource[nodes[i].toElement().tagName()];
170 retval.push_back(data);