Esempio n. 1
0
// Author & Date: Ehsan Azar       5 April 2012
// Purpose: Get document fragment one level deep
//           this fragment can be imported in other documents
// Outputs:
//   Returns a document fragment
QDomDocumentFragment XmlFile::getFragment()
{
    QDomElement node;
    if (m_nodes.isEmpty())
        node = m_doc.firstChildElement();
    else
        node = m_nodes.last();
    QDomDocumentFragment frag = m_doc.createDocumentFragment();
    QDomNodeList list = node.childNodes();
    for (uint i = 0; i < list.length(); ++i)
    {
        QDomNode node = list.item(i).cloneNode();
        frag.appendChild(node);
    }
    return frag;
}
Esempio n. 2
0
void Fidelity::GUI::ComponentLinkItem::compileXmlFragment(QDomDocumentFragment& fragment) const
{
	// Construct new link element
	QDomElement link = fragment.ownerDocument().createElement("link");

	// Construct first component element
	QDomElement startComponent = fragment.ownerDocument().createElement("component");
	startComponent.setAttribute("nodeName",m_StartNodeItem->Node()->Name());
	startComponent.setAttribute("uuid",m_StartComponentID);

	// Construct second component element
	QDomElement endComponent = fragment.ownerDocument().createElement("component");
	endComponent.setAttribute("nodeName",m_EndNodeItem->Node()->Name());
	endComponent.setAttribute("uuid",m_EndComponentID);
	
	// Handle nodeType attributenode where the link starts
	if(m_LinkType == BeamLink) {
		link.setAttribute("nodeType","beam");
	}
	else {
		link.setAttribute("nodeType","control");
	}

	// Handle directionality attribute
	if(m_Directionality == Unidirectional) {
		link.setAttribute("directionality","unidirectional");
		startComponent.setAttribute("role","source");
		endComponent.setAttribute("role","destination");
	}
	else {
		link.setAttribute("directionality","bidirectional");
	}

	// Put it all together
	link.appendChild(startComponent);
	link.appendChild(endComponent);
	fragment.appendChild(link);
}