本文整理汇总了C++中QDomElement::cloneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::cloneNode方法的具体用法?C++ QDomElement::cloneNode怎么用?C++ QDomElement::cloneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::cloneNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveData
QString PrivateStorage::saveData(const Jid &AStreamJid, const QDomElement &AElement)
{
if (FStanzaProcessor && isOpen(AStreamJid) && !AElement.tagName().isEmpty() && !AElement.namespaceURI().isEmpty())
{
Stanza request(STANZA_KIND_IQ);
request.setType(STANZA_TYPE_SET).setUniqueId();
QDomElement elem = request.addElement("query",NS_JABBER_PRIVATE);
elem.appendChild(AElement.cloneNode(true));
if (FStanzaProcessor->sendStanzaRequest(this,AStreamJid,request,PRIVATE_STORAGE_TIMEOUT))
{
LOG_STRM_INFO(AStreamJid,QString("Private data save request sent, ns=%1, id=%2").arg(AElement.namespaceURI(),request.id()));
if (FPreClosedStreams.contains(AStreamJid))
notifyDataChanged(AStreamJid,AElement.tagName(),AElement.namespaceURI());
FSaveRequests.insert(request.id(),insertElement(AStreamJid,AElement));
return request.id();
}
else
{
LOG_STRM_WARNING(AStreamJid,QString("Failed to send private data save request, ns=%1").arg(AElement.namespaceURI()));
}
}
else if (!isOpen(AStreamJid))
{
REPORT_ERROR("Failed to save private data: Storage is not opened");
}
else if (AElement.tagName().isEmpty() || AElement.namespaceURI().isEmpty())
{
REPORT_ERROR("Failed to save private data: Invalid data");
}
return QString::null;
}
示例2: apply
void QgsMapStylingWidget::apply()
{
if ( mStackedWidget->currentIndex() == mVectorPage )
{
QString undoName = "Style Change";
int currentPage = mMapStyleTabs->currentIndex();
if ( currentPage == mLabelTabIndex )
{
mLabelingWidget->apply();
emit styleChanged( mCurrentLayer );
undoName = "Label Change";
}
else if ( currentPage == mStyleTabIndex )
{
mVectorStyleWidget->apply();
QgsProject::instance()->setDirty( true );
mMapCanvas->clearCache();
mMapCanvas->refresh();
emit styleChanged( mCurrentLayer );
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( mCurrentLayer );
QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( layer->rendererV2()->type() );
undoName = QString( "Style Change - %1" ).arg( m->visibleName() );
}
QString errorMsg;
QDomDocument doc( "style" );
QDomElement rootNode = doc.createElement( "qgis" );
doc.appendChild( rootNode );
mCurrentLayer->writeStyle( rootNode, doc, errorMsg );
mCurrentLayer->undoStackStyles()->beginMacro( undoName );
mCurrentLayer->undoStackStyles()->push( new QgsMapLayerStyleCommand( mCurrentLayer, rootNode, mLastStyleXml ) );
mCurrentLayer->undoStackStyles()->endMacro();
// Override the last style on the stack
mLastStyleXml = rootNode.cloneNode();
}
}
示例3: addParameter
void KeyframeEdit::addParameter(const QDomElement &e, int activeKeyframe)
{
keyframe_list->blockSignals(true);
m_params.append(e.cloneNode().toElement());
QDomElement na = e.firstChildElement(QStringLiteral("name"));
QString paramName = i18n(na.text().toUtf8().data());
QDomElement commentElem = e.firstChildElement(QStringLiteral("comment"));
QString comment;
if (!commentElem.isNull())
comment = i18n(commentElem.text().toUtf8().data());
int columnId = keyframe_list->columnCount();
keyframe_list->insertColumn(columnId);
keyframe_list->setHorizontalHeaderItem(columnId, new QTableWidgetItem(paramName));
DoubleParameterWidget *doubleparam = new DoubleParameterWidget(paramName, 0,
m_params.at(columnId).attribute(QStringLiteral("min")).toDouble(), m_params.at(columnId).attribute(QStringLiteral("max")).toDouble(),
m_params.at(columnId).attribute(QStringLiteral("default")).toDouble(), comment, columnId, m_params.at(columnId).attribute(QStringLiteral("suffix")), m_params.at(columnId).attribute(QStringLiteral("decimals")).toInt(), this);
connect(doubleparam, SIGNAL(valueChanged(double)), this, SLOT(slotAdjustKeyframeValue(double)));
connect(this, SIGNAL(showComments(bool)), doubleparam, SLOT(slotShowComment(bool)));
connect(doubleparam, SIGNAL(setInTimeline(int)), this, SLOT(slotUpdateVisibleParameter(int)));
m_slidersLayout->addWidget(doubleparam, columnId, 0);
if (e.attribute(QStringLiteral("intimeline")) == QLatin1String("1")) {
doubleparam->setInTimelineProperty(true);
}
QStringList frames = e.attribute(QStringLiteral("keyframes")).split(';', QString::SkipEmptyParts);
for (int i = 0; i < frames.count(); ++i) {
int frame = frames.at(i).section('=', 0, 0).toInt();
bool found = false;
int j;
for (j = 0; j < keyframe_list->rowCount(); ++j) {
int currentPos = getPos(j);
if (frame == currentPos) {
keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1)));
found = true;
break;
} else if (currentPos > frame) {
break;
}
}
if (!found) {
keyframe_list->insertRow(j);
keyframe_list->setVerticalHeaderItem(j, new QTableWidgetItem(getPosString(frame)));
keyframe_list->setItem(j, columnId, new QTableWidgetItem(frames.at(i).section('=', 1, 1)));
keyframe_list->resizeRowToContents(j);
}
if ((activeKeyframe > -1) && (activeKeyframe == frame)) {
keyframe_list->setCurrentCell(i, columnId);
keyframe_list->selectRow(i);
}
}
keyframe_list->resizeColumnsToContents();
keyframe_list->blockSignals(false);
keyframe_list->horizontalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
keyframe_list->verticalHeader()->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
slotAdjustKeyframeInfo(false);
button_delete->setEnabled(keyframe_list->rowCount() > 1);
}
示例4: createRootXmlTags
// createRootXmlTags
//
// This function creates three QStrings, one being an <?xml .. ?> processing
// instruction, and the others being the opening and closing tags of an
// element, <foo> and </foo>. This basically allows us to get the raw XML
// text needed to open/close an XML stream, without resorting to generating
// the XML ourselves. This function uses QDom to do the generation, which
// ensures proper encoding and entity output.
static void createRootXmlTags(const QDomElement &root, QString *xmlHeader, QString *tagOpen, QString *tagClose)
{
QDomElement e = root.cloneNode(false).toElement();
// insert a dummy element to ensure open and closing tags are generated
QDomElement dummy = e.ownerDocument().createElement("dummy");
e.appendChild(dummy);
// convert to xml->text
QString str;
{
QTextStream ts(&str, QIODevice::WriteOnly);
e.save(ts, 0);
}
// parse the tags out
int n = str.indexOf('<');
int n2 = str.indexOf('>', n);
++n2;
*tagOpen = str.mid(n, n2-n);
n2 = str.lastIndexOf('>');
n = str.lastIndexOf('<');
++n2;
*tagClose = str.mid(n, n2-n);
// generate a nice xml processing header
*xmlHeader = "<?xml version=\"1.0\"?>";
}
示例5: pushUndoItem
void QgsLayerStylingWidget::pushUndoItem( const QString &name )
{
QString errorMsg;
QDomDocument doc( QStringLiteral( "style" ) );
QDomElement rootNode = doc.createElement( QStringLiteral( "qgis" ) );
doc.appendChild( rootNode );
mCurrentLayer->writeStyle( rootNode, doc, errorMsg, QgsReadWriteContext() );
mCurrentLayer->undoStackStyles()->push( new QgsMapLayerStyleCommand( mCurrentLayer, name, rootNode, mLastStyleXml ) );
// Override the last style on the stack
mLastStyleXml = rootNode.cloneNode();
}
示例6: saveChanges
bool plotsDialog::saveChanges()
{
#ifdef Q_OS_WIN32
QFile ofile(globalpara.caseName),file("plotTemp.xml");
#endif
#ifdef Q_OS_MAC
QDir dir = qApp->applicationDirPath();
/*dir.cdUp();*/
/*dir.cdUp();*/
/*dir.cdUp();*/
QString bundleDir(dir.absolutePath());
QFile ofile(globalpara.caseName),file(bundleDir+"/plotTemp.xml");
#endif
QDomDocument odoc,doc;
QDomElement oroot;
QTextStream stream;
stream.setDevice(&ofile);
if(!ofile.open(QIODevice::ReadWrite|QIODevice::Text))
{
globalpara.reportError("Fail to open case file to update plot data.",this);
return false;
}
else if(!odoc.setContent(&ofile))
{
globalpara.reportError("Fail to load xml document from case file to update plot data.",this);
return false;
}
if(!file.open(QIODevice::ReadOnly|QIODevice::Text))
{
globalpara.reportError("Fail to open plot temp file to update plot data.",this);
return false;
}
else if(!doc.setContent(&file))
{
globalpara.reportError("Fail to load xml document from plot temp file to update plot data..",this);
return false;
}
else
{
QDomElement plotData = doc.elementsByTagName("plotData").at(0).toElement();
QDomNode copiedPlot = plotData.cloneNode(true);
oroot = odoc.elementsByTagName("root").at(0).toElement();
oroot.replaceChild(copiedPlot,odoc.elementsByTagName("plotData").at(0));
ofile.resize(0);
odoc.save(stream,4);
file.close();
ofile.close();
stream.flush();
return true;
}
}
示例7: davParsePropstats
QWebdavUrlInfo::QWebdavUrlInfo(const QDomElement & dom)
{
QDomElement href = dom.namedItem( "href" ).toElement();
node_ = dom.cloneNode();
if ( !href.isNull() )
{
QString urlStr = QUrl::fromPercentEncoding(href.text().toUtf8());
QDomNodeList propstats = dom.elementsByTagName( "propstat" );
davParsePropstats( urlStr, propstats );
}
}
示例8: parseFeature
bool parseFeature(QDomElement& e, Layer* aLayer)
{
bool ret= false;
QDomElement c = e.cloneNode().toElement();
while(!c.isNull()) {
if (c.tagName() == "Placemark")
ret = parsePlacemark(c, aLayer);
else
ret = parseContainer(c, aLayer);
c = c.nextSiblingElement();
}
return ret;
}
示例9: QUndoCommand
EditTransitionCommand::EditTransitionCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, bool doIt, QUndoCommand * parent) :
QUndoCommand(parent),
m_view(view),
m_track(track),
m_oldeffect(oldeffect),
m_pos(pos),
m_doIt(doIt)
{
m_effect = effect.cloneNode().toElement();
QString effectName;
QDomElement namenode = effect.firstChildElement("name");
if (!namenode.isNull()) effectName = i18n(namenode.text().toUtf8().data());
else effectName = i18n("effect");
setText(i18n("Edit transition %1", effectName));
}
示例10: processSxe
bool SxeSession::processSxe(const QDomElement &sxe, const QString &id) {
// Don't accept duplicates
if(!id.isEmpty() && usedSxeIds_.contains(id)) {
qDebug() << QString("Tried to process a duplicate %1 (received: %2).").arg(sxe.attribute("id")).arg(usedSxeIds_.size()).toLatin1();
return false;
}
if(!id.isEmpty())
usedSxeIds_ += id;
// store incoming edits when queueing
if(queueing_) {
// Make sure the element is not already in the queue.
foreach(IncomingEdit i, queuedIncomingEdits_)
if(i.xml == sxe) return false;
IncomingEdit incoming;
incoming.id = id;
incoming.xml = sxe.cloneNode(true).toElement();
queuedIncomingEdits_.append(incoming);
return false;
}
// create an SxeEdit for each child of the <sxe/>
QList<SxeEdit*> edits;
for(QDomNode n = sxe.firstChild(); !n.isNull(); n = n.nextSibling()) {
if(n.nodeName() == "new")
edits.append(new SxeNewEdit(n.toElement()));
else if(n.nodeName() == "set")
edits.append(new SxeRecordEdit(n.toElement()));
else if(n.nodeName() == "remove")
edits.append(new SxeRemoveEdit(n.toElement()));
}
if (edits.size() == 0) return false;
// process all the edits
foreach(SxeEdit* e, edits) {
SxeRecord* meta;
if(e->type() == SxeEdit::New)
meta = createRecord(e->rid());
else
meta = record(e->rid());
if(meta)
meta->apply(doc_, e);
}
示例11: QUndoCommand
EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt) :
QUndoCommand(),
m_view(view),
m_track(track),
m_oldeffect(oldeffect),
m_pos(pos),
m_stackPos(stackPos),
m_doIt(doIt)
{
m_effect = effect.cloneNode().toElement();
QString effectName;
QDomNode namenode = effect.elementsByTagName("name").item(0);
if (!namenode.isNull()) effectName = i18n(namenode.toElement().text().toUtf8().data());
else effectName = i18n("effect");
setText(i18n("Edit effect %1", effectName));
}
示例12: QObject
//---------------------------------------------------------------------------------------------------------------------
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
: QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), doc(doc), toolId(id),
cursor(doc->getCursor())
{
setText(tr("Delete tool"));
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
xml = domElement.cloneNode().toElement();
parentNode = domElement.parentNode();
}
else
{
qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
return;
}
}
示例13: SaveOption
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::SaveOption(QSharedPointer<VGObject> &obj)
{
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
if (oldDomElement.isElement())
{
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
SaveOptions(newDomElement, obj);
SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id);
connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree);
qApp->getUndoStack()->push(saveOptions);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
示例14: updateItemFromDocument
void updateItemFromDocument( ProjectBaseItem *item, const QString &name )
{
QDomElement child = findElementInDocument( item, name );
KUrl folder;
if (item->folder())
folder = item->folder()->url();
if (item->file())
folder = item->file()->url();
QString relativeFileName =
KUrl::relativePath( projectFile.directory(), folder.directory() );
relativeFileName.append(folder.fileName());
QDomElement newNode = child.cloneNode().toElement();
newNode.setAttribute("name",folder.fileName());
newNode.setAttribute("url",relativeFileName);
child.parentNode().replaceChild( newNode, child );
}
示例15: xmlToString
// xmlToString
//
// This function converts a QDomElement into a QString, using stripExtraNS
// to make it pretty.
static QString xmlToString(const QDomElement &e, const QString &fakeNS, const QString &fakeQName, bool clip)
{
QDomElement i = e.cloneNode().toElement();
// It seems QDom can only have one namespace attribute at a time (see docElement 'HACK').
// Fortunately we only need one kind depending on the input, so it is specified here.
QDomElement fake = e.ownerDocument().createElementNS(fakeNS, fakeQName);
fake.appendChild(i);
fake = stripExtraNS(fake);
QString out;
{
QTextStream ts(&out, QIODevice::WriteOnly);
fake.firstChild().save(ts, 0);
}
// 'clip' means to remove any unwanted (and unneeded) characters, such as a trailing newline
if(clip) {
int n = out.lastIndexOf('>');
out.truncate(n+1);
}
return out;
}