本文整理汇总了C++中QDomDocument::cloneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::cloneNode方法的具体用法?C++ QDomDocument::cloneNode怎么用?C++ QDomDocument::cloneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::cloneNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cloneNode
QDomNode QDomDocumentProto::cloneNode(bool deep) const
{
QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
if (item)
return item->cloneNode(deep);
return QDomNode();
}
示例2: writeGetCapabilities
void writeGetCapabilities( QgsServerInterface* serverIface, const QString& version,
const QgsServerRequest& request, QgsServerResponse& response,
bool projectSettings )
{
QgsServerRequest::Parameters params = request.parameters();
QString configFilePath = serverIface->configFilePath();
QgsServerSettings* serverSettings = serverIface->serverSettings();
QgsAccessControl* accessControl = serverIface->accessControls();
QgsCapabilitiesCache* capabilitiesCache = serverIface->capabilitiesCache();
QStringList cacheKeyList;
cacheKeyList << ( projectSettings ? QStringLiteral( "projectSettings" ) : version );
cacheKeyList << getenv( "SERVER_NAME" );
bool cache = true;
if ( accessControl )
cache = accessControl->fillCacheKey( cacheKeyList );
QString cacheKey = cacheKeyList.join( QStringLiteral( "-" ) );
const QDomDocument* capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey );
if ( !capabilitiesDocument ) //capabilities xml not in cache. Create a new one
{
QgsMessageLog::logMessage( QStringLiteral( "Capabilities document not found in cache" ) );
QDomDocument doc;
QgsWmsServer server( configFilePath,
*serverSettings,
params,
getConfigParser( serverIface ),
accessControl );
doc = server.getCapabilities( version, projectSettings );
if ( cache )
{
capabilitiesCache->insertCapabilitiesDocument( configFilePath, cacheKey, &doc );
capabilitiesDocument = capabilitiesCache->searchCapabilitiesDocument( configFilePath, cacheKey );
}
else
{
doc = doc.cloneNode().toDocument();
capabilitiesDocument = &doc;
}
}
else
{
QgsMessageLog::logMessage( QStringLiteral( "Found capabilities document in cache" ) );
}
response.setHeader( QStringLiteral( "Content-Type" ), QStringLiteral( "text/xml; charset=utf-8" ) );
response.write( capabilitiesDocument->toByteArray() );
}
示例3: qDomDocumentToString
QString qDomDocumentToString(const QDomDocument &pDomDocument)
{
// Serialise the given DOM document
// Note: normally, we would simply be using QDomDocument::save(), but we
// want elements' attributes to be sorted when serialised (so that it
// is easier to compare two different XML documents). Unfortunately,
// QDomDocument::save() doesn't provide such a functionality (since
// the order of attributes doesn't matter in XML). So, we make a call
// to QDomDocument::save(), but only after having removed all the
// elements' attributes, which we serialise manually afterwards...
QString res = QString();
// Make a deep copy of the given DOM document and remove all the elements'
// attributes (but keep track of them, so that we can later on serialise
// them manually)
QDomDocument domDocument = pDomDocument.cloneNode().toDocument();
QMap<QString, QString> elementsAttributes = QMap<QString, QString>();
for (QDomElement childElement = domDocument.firstChildElement();
!childElement.isNull(); childElement = childElement.nextSiblingElement()) {
cleanDomElement(childElement, elementsAttributes);
}
// Serialise our 'reduced' DOM document
QTextStream textStream(&res, QIODevice::WriteOnly);
domDocument.save(textStream, 4);
// Manually serialise the elements' attributes
foreach (const QString &elementAttribute, elementsAttributes.keys())
res.replace(elementAttribute+"=\"\"", elementsAttributes.value(elementAttribute));
return res;
}
示例4:
/**
* Constructs stanza from a DOM document. Constructor makes a deep copy of QDomDocument.
*
* @param document DOM document
*/
Stanza::Stanza(const QDomDocument& document)
{
m_doc = document.cloneNode(true).toDocument();
}
示例5: openFile
// if no file is open
void MainWindow::openFile(QString &xmlFileName, QFile &xmlFile, QDomDocument &xmlDomDocument, QDomDocument &xmlDomDocumentOrg, bool createFile)
{
QString filename;
// open file diaglog
if(createFile == OPEN_EXISTING_FILE){
// Open diaglog to -- open existing file
filename = QFileDialog::getOpenFileName(this, tr("Open File"),
"",
tr("Files (*.xml)"));
}
else{
// Open diaglog to -- create new file
filename = QFileDialog::getSaveFileName(this, tr("Save File"),
"",
tr("Files (*.xml)"));
}
// Check if cancel button is pressed in the QFileDialog
if(filename != "")
{
//copy file name to globalobject
xmlFileName = filename;
// create new xml file & text stream
//xmlOpenFile();
// Add a delay
xmlLibObject.xmlOpenFile( xmlFileName, xmlFile, xmlStream);
if(createFile == OPEN_EXISTING_FILE){
//Load the XML file
//xmlLoadFile();
xmlLibObject.xmlLoadFile(xmlDomDocument, xmlFile);
//close file
//xmlCloseFile();
//xmlLibObject.xmlCloseFile(xmlStream, xmlDomDocument, xmlFile);
//Now again open & truncate the file
//xmlOpenFileTruncate();
//xmlLibObject.xmlOpenFileTruncate( xmlFileName, xmlFile, xmlStream);
//Get the root element
//xmlGetRoot();
xmlLibObject.xmlGetRoot(xmlRoot, xmlDomDocument);
// copy data to the tree view
// copy data to the text view
loadXmltoTreeAndTextView();
//Its not new file
b_newFileCreationSignal = FALSE;
//create backup for original xml.
xmlDomDocumentOrg.clear();
xmlDomDocumentOrg = xmlDomDocument.cloneNode(true).toDocument();
}
else{
//Add root node
//xmlAddRoot();
xmlLibObject.xmlAddRoot(xmlRoot, xmlDomDocument);
// File contains new node
b_fileDoesNotContainsNode = TRUE;
//New file creation signal
b_newFileCreationSignal = TRUE;
//New file created
xmlDomDocumentOrg.clear();
}
// xml file is already open
b_xmlFileAlreadyOpen = TRUE;
}
else {
// Do nothing cancel presses
}
}