47 mDocument.appendChild(mDocument.createElement(
"root"));
49 for (std::map<QString, DataPtr>::const_iterator iter = source.begin(); iter != source.end(); ++iter)
51 this->insertFrame(iter->second);
65 void FrameForest::insertFrame(
DataPtr data)
67 QString parentFrame = data->getParentSpace();
68 QString currentFrame = data->getSpace();
73 QDomNode parentNode = this->getNodeAnyway(parentFrame);
74 QDomNode currentNode = this->getNodeAnyway(currentFrame);
76 if (parentNode.isNull())
80 currentNode = currentNode.parentNode().removeChild(currentNode);
81 parentNode.appendChild(currentNode);
89 QDomNodeList list = mDocument.elementsByTagName(frame);
97 QDomNode FrameForest::getNodeAnyway(QString frame)
99 QDomNode retval = this->
getNode(frame);
102 retval = mDocument.createElement(frame);
103 mDocument.documentElement().appendChild(retval);
110 bool FrameForest::isAncestorOf(QDomNode node, QDomNode ancestor)
114 while (!this->isRootNode(node))
116 if (node == ancestor)
121 node = node.parentNode();
127 bool FrameForest::isRootNode(QDomNode node)
129 return node == mDocument.documentElement();
136 if (this->isRootNode(node))
138 while (!this->isRootNode(node.parentNode()))
139 node = node.parentNode();
148 if (this->isAncestorOf(ref, node))
151 while (!this->isRootNode(node.parentNode()))
154 if (this->isAncestorOf(ref, node.parentNode()))
156 node = node.parentNode();
167 std::vector<QDomNode> retval;
168 retval.push_back(node);
170 for (QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling())
173 std::copy(subnodes.begin(), subnodes.end(), back_inserter(retval));
184 std::vector<DataPtr> retval;
186 for (
unsigned i = 0; i < nodes.size(); ++i)
188 DataPtr data = mSource[nodes[i].toElement().tagName()];
191 retval.push_back(data);
QDomNode getOldestAncestor(QDomNode node)
std::vector< DataPtr > getDataFromDescendantsAndSelf(QDomNode node)
boost::shared_ptr< class Data > DataPtr
std::vector< QDomNode > getDescendantsAndSelf(QDomNode node)
QDomNode getNode(QString frame)
FrameForest(const std::map< QString, DataPtr > &source)
QDomDocument getDocument()
QDomNode getOldestAncestorNotCommonToRef(QDomNode child, QDomNode ref)
Namespace for all CustusX production code.