本文整理汇总了C++中QDomNode::cloneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNode::cloneNode方法的具体用法?C++ QDomNode::cloneNode怎么用?C++ QDomNode::cloneNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNode
的用法示例。
在下文中一共展示了QDomNode::cloneNode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareLKPTables
void compareLKPTables(QDomNode table,QDomDocument &docB)
{
QDomNode node;
node = table;
while (!node.isNull())
{
QDomNode tableFound = findTable(docB,node.toElement().attribute("name",""));
if (!tableFound.isNull())
{
QDomNode field = node.firstChild();
while (!field.isNull())
{
QDomNode fieldFound = findValue(tableFound,field.toElement().attribute("code",""));
if (!fieldFound.isNull())
{
if (field.toElement().attribute("description","") != fieldFound.toElement().attribute("description",""))
fatal("VNS:Value " + field.toElement().attribute("code","") + " of lookup table " + node.toElement().attribute("name","") + " from A not the same in B");
}
else
{
log("VNF:Value " + field.toElement().attribute("code","") + " of lookup table " + node.toElement().attribute("name","") + " from A not found in B");
tableFound.appendChild(field.cloneNode(true));
}
field = field.nextSibling();
}
}
else
{
log("TNF:Lookup table " + node.toElement().attribute("name","") + " from A not found in B");
//Now adds the lookup table
docB.documentElement().appendChild(node.cloneNode(true));
}
node = node.nextSibling();
}
}
示例2: setReportTemplate
bool MReportEngine::setReportTemplate(QDomNode &d)
{
clearFormatting();
*rt = d.cloneNode(true).toDocument();
initTemplate();
return true;
}
示例3: getRowIndex
/**
* \en
* insert new row in table and replace tag to value
* \_en
* \ru
* Вставляет новую строку в таблицу, заменяет теги на значения, удаляет тег секции из строки таблицы.
* Выполняет рекурсивный поиск узла, содержащего строку таблицы. У этого узла есть
* специальное имя(w:r), которое распознается функцией. После того, как узел найден, строка строка дублируется,
* а из текущей строки удаляются все теги секции, чтобы избежать мнократного размножения строк таблицы.
* \_ru
* \param node - \en context for inserting \_en \ru узел, в который происходит вставка \_ru
* \see searchTags()
*/
void
aMSOTemplate::insertRowValues(QDomNode node)
{
QDomNode n = node;
while(!n.parentNode().isNull())
{
n = n.parentNode();
QDomElement e = n.toElement();
if( n.nodeName()=="Row" )
{
QDomAttr a = n.toElement().attributeNode( "ss:Index" );
n.parentNode().insertAfter(n.cloneNode(true),n);
clearTags(n,true);
QMap<QString,QString>::Iterator it;
for ( it = values.begin(); it != values.end(); ++it )
{
searchTags(n,it.key());
}
int rowIndex = a.value().toInt();
if (rowIndex == 0)
{
rowIndex = getRowIndex(n);
n.toElement().setAttribute("ss:Index",rowIndex);
}
n.nextSibling().toElement().setAttribute("ss:Index",rowIndex+1);
}
}
}
示例4: QDomNode
QDomNode QDomNodeProto:: cloneNode(bool deep) const
{
QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
if (item)
return item->cloneNode(deep);
return QDomNode();
}
示例5:
WaveformWidgetHolder::WaveformWidgetHolder(WaveformWidgetAbstract* waveformWidget,
WWaveformViewer* waveformViewer,
const QDomNode& node,
const SkinContext& skinContext)
: m_waveformWidget(waveformWidget),
m_waveformViewer(waveformViewer),
m_skinNodeCache(node.cloneNode()),
m_skinContextCache(skinContext) {
}
示例6: addCorrectNS
QDomElement addCorrectNS(const QDomElement &e)
{
int x;
// grab child nodes
/*QDomDocumentFragment frag = e.ownerDocument().createDocumentFragment();
QDomNodeList nl = e.childNodes();
for(x = 0; x < nl.count(); ++x)
frag.appendChild(nl.item(x).cloneNode());*/
// find closest xmlns
QDomNode n = e;
while(!n.isNull() && !n.toElement().hasAttribute("xmlns") && n.toElement().namespaceURI() == "" )
n = n.parentNode();
QString ns;
if(n.isNull() || !n.toElement().hasAttribute("xmlns")){
if (n.toElement().namespaceURI () == ""){
ns = "jabber:client";
} else {
ns = n.toElement().namespaceURI();
}
} else {
ns = n.toElement().attribute("xmlns");
}
// make a new node
QDomElement i = e.ownerDocument().createElementNS(ns, e.tagName());
// copy attributes
QDomNamedNodeMap al = e.attributes();
for(x = 0; x < al.count(); ++x) {
QDomAttr a = al.item(x).toAttr();
if(a.name() != "xmlns")
i.setAttributeNodeNS(a.cloneNode().toAttr());
}
// copy children
QDomNodeList nl = e.childNodes();
for(x = 0; x < nl.count(); ++x) {
QDomNode n = nl.item(x);
if(n.isElement())
i.appendChild(addCorrectNS(n.toElement()));
else
i.appendChild(n.cloneNode());
}
//i.appendChild(frag);
return i;
}
示例7: stripExtraNS
// stripExtraNS
//
// This function removes namespace information from various nodes for
// display purposes only (the element is pretty much useless for processing
// after this). We do this because QXml is a bit overzealous about outputting
// redundant namespaces.
static QDomElement stripExtraNS(const QDomElement &e)
{
// find closest parent with a namespace
QDomNode par = e.parentNode();
while(!par.isNull() && par.namespaceURI().isNull())
par = par.parentNode();
bool noShowNS = false;
if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
noShowNS = true;
// build qName (prefix:localName)
QString qName;
if(!e.prefix().isEmpty())
qName = e.prefix() + ':' + e.localName();
else
qName = e.tagName();
QDomElement i;
int x;
if(noShowNS)
i = e.ownerDocument().createElement(qName);
else
i = e.ownerDocument().createElementNS(e.namespaceURI(), qName);
// copy attributes
QDomNamedNodeMap al = e.attributes();
for(x = 0; x < al.count(); ++x) {
QDomAttr a = al.item(x).cloneNode().toAttr();
// don't show xml namespace
if(a.namespaceURI() == NS_XML)
i.setAttribute(QString("xml:") + a.name(), a.value());
else
i.setAttributeNodeNS(a);
}
// copy children
QDomNodeList nl = e.childNodes();
for(x = 0; x < nl.count(); ++x) {
QDomNode n = nl.item(x);
if(n.isElement())
i.appendChild(stripExtraNS(n.toElement()));
else
i.appendChild(n.cloneNode());
}
return i;
}
示例8: oldStyleNS
static QDomElement oldStyleNS(const QDomElement &e)
{
// find closest parent with a namespace
QDomNode par = e.parentNode();
while(!par.isNull() && par.namespaceURI().isNull())
par = par.parentNode();
bool noShowNS = false;
if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
noShowNS = true;
QDomElement i;
uint x;
//if(noShowNS)
i = e.ownerDocument().createElement(e.tagName());
//else
// i = e.ownerDocument().createElementNS(e.namespaceURI(), e.tagName());
// copy attributes
QDomNamedNodeMap al = e.attributes();
for(x = 0; x < al.count(); ++x)
i.setAttributeNode(al.item(x).cloneNode().toAttr());
if(!noShowNS)
i.setAttribute("xmlns", e.namespaceURI());
// copy children
QDomNodeList nl = e.childNodes();
for(x = 0; x < nl.count(); ++x) {
QDomNode n = nl.item(x);
if(n.isElement())
i.appendChild(oldStyleNS(n.toElement()));
else
i.appendChild(n.cloneNode());
}
return i;
}
示例9: setReportData
bool MReportEngine::setReportData(QDomNode &d)
{
*rd = d.cloneNode(true).toDocument();
initData();
return true;
}
示例10: QString
void
DeferredParameterEdit::setXML()
{
QDomNode tmpNode = tmpParentNode_.firstChild();
// no edit -> nothing to be done
if (!modified_)
return;
// delete entry if edit field is empty
if (tmpNode.isNull() ||
tmpNode.firstChild().isNull()) {
if (!node_.isNull()) {
parentNode_.removeChild(node_);
delete item_;
}
else {
modified_ = false;
}
return;
}
// crete a node if necessary
if (node_.isNull()) {
MIRO_ASSERT(!parentNode_.ownerDocument().isNull());
QDomElement e = parentNode_.ownerDocument().createElement(XML_TAG_PARAMETER);
e.setAttribute(XML_ATTRIBUTE_KEY, name());
node_ = parentNode_.appendChild(e);
MIRO_ASSERT(!node_.isNull());
}
//--------------------------------------
// replace node by new content
// remember the predecessor
QListViewItem * pre = NULL;
if (item_) {
QListViewItem * parent = item_->listViewItem()->parent();
if (parent != NULL) {
pre = parent->firstChild();
while (pre != NULL) {
if (pre->nextSibling() == item_->listViewItem())
break;
pre = pre->nextSibling();
}
}
// delete the current content
delete item_;
}
// replace the xml subtree
QDomNode node = tmpNode.cloneNode();
node_.parentNode().replaceChild(node, node_);
node_ = node;
// reconstruct the listview if available
if (parentItem_) {
item_ = NULL;
QString typeName = parameter_.type_;
if (type_ == NESTED_PARAMETER) {
Miro::CFG::Type const * const parameterType =
ConfigFile::instance()->description().getType(typeName);
if (parameterType == NULL) {
throw QString("Parameter description for " + typeName +
" not found.\nCheck whether the relevant description file is loaded.");
}
item_ = new CompoundParameter(*parameterType,
node,
parentItem_->listViewItem(), pre,
parentItem_, name());
}
else if (type_ == VECTOR ||
type_ == SET) {
item_ = new ParameterList(parameter_,
node,
parentItem_->listViewItem(), pre,
parentItem_, name());
}
if (item_ != NULL)
dynamic_cast<ParameterXML *>(item_)->init();
}
}