本文整理汇总了C++中QDomDocument::importNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::importNode方法的具体用法?C++ QDomDocument::importNode怎么用?C++ QDomDocument::importNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomDocument
的用法示例。
在下文中一共展示了QDomDocument::importNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doExecute
void XBELImportCommand::doExecute(const KBookmarkGroup &/*bkGroup*/) {
// check if already open first???
KBookmarkManager *pManager = KBookmarkManager::managerForFile(m_fileName, QString());
QDomDocument doc = GlobalBookmarkManager::self()->mgr()->internalDocument();
// get the xbel
QDomNode subDoc = pManager->internalDocument().namedItem("xbel").cloneNode();
if (subDoc.isProcessingInstruction())
subDoc = subDoc.nextSibling();
if (subDoc.isDocumentType())
subDoc = subDoc.nextSibling();
if (subDoc.nodeName() != "xbel")
return;
if (!folder().isEmpty()) {
// transform into folder
subDoc.toElement().setTagName("folder");
// clear attributes
QStringList tags;
for (int i = 0; i < subDoc.attributes().count(); i++)
tags << subDoc.attributes().item(i).toAttr().name();
for (QStringList::const_iterator it = tags.constBegin(); it != tags.constEnd(); ++it)
subDoc.attributes().removeNamedItem((*it));
subDoc.toElement().setAttribute("icon", m_icon);
// give the folder a name
QDomElement textElem = doc.createElement("title");
subDoc.insertBefore(textElem, subDoc.firstChild());
textElem.appendChild(doc.createTextNode(folder()));
}
// import and add it
QDomNode node = doc.importNode(subDoc, true);
if (!folder().isEmpty()) {
GlobalBookmarkManager::self()->root().internalElement().appendChild(node);
m_group = KBookmarkGroup(node.toElement()).address();
} else {
QDomElement root = GlobalBookmarkManager::self()->root().internalElement();
QList<QDomElement> childList;
QDomNode n = subDoc.firstChild().toElement();
while (!n.isNull()) {
QDomElement e = n.toElement();
if (!e.isNull())
childList.append(e);
n = n.nextSibling();
}
QList<QDomElement>::Iterator it = childList.begin();
QList<QDomElement>::Iterator end = childList.end();
for (; it!= end ; ++it)
root.appendChild((*it));
}
}
示例2: importNode
QDomNode QDomDocumentProto::importNode(const QDomNode& importedNode, bool deep)
{
QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
if (item)
return item->importNode(importedNode, deep);
return QDomNode();
}
示例3: init
void InterpreterElementImpl::init(QRectF &contents, PortFactoryInterface const &portFactory
, QList<PortInterface *> &ports, LabelFactoryInterface &labelFactory
, QList<LabelInterface *> &labels, SdfRendererInterface *renderer, ElementRepoInterface *elementRepo)
{
Q_UNUSED(elementRepo);
if (mId.element() == "MetaEntityNode") {
mGraphics.setContent(mEditorRepoApi->stringProperty(mId, "shape"));
QDomDocument classDoc;
QDomElement sdfElement = mGraphics.firstChildElement("graphics").firstChildElement("picture");
classDoc.appendChild(classDoc.importNode(sdfElement, true));
if (!classDoc.childNodes().isEmpty()) {
mRenderer = renderer;
mRenderer->load(classDoc);
}
int width = 0;
int height = 0;
if (!sdfElement.isNull()) {
width = sdfElement.attribute("sizex").toInt();
height = sdfElement.attribute("sizey").toInt();
}
initPointPorts(portFactory, ports, width, height);
initLinePorts(portFactory, ports, width, height);
contents.setWidth(width);
contents.setHeight(height);
initLabels(width, height, labelFactory, labels);
}
}
示例4: save_types
void Signaltypes::save_types()
{
char cfg_path[MAX_PATH_LENGTH];
bool success;
QDomDocument document;
// Creating xml-document part
QDomElement root = document.createElement("Signaltypes");
root.setAttribute("version", "0.0.1");
for(unsigned i=0; i<types.size(); i++)
{
QDomNode type = document.importNode( types[i]->toQDom(), true ); // true : Import the whole tree.
root.appendChild(type);
}
// Writing-to-file part
configpath(cfg_path, "Signaltypes.xml");
QFile file(cfg_path);
success = file.open( QIODevice::WriteOnly | QIODevice::Text );
if(not success) { QMessageBox::warning(parent->mainwindow, tr("Signaltypes"), tr("Cannot write file %1:\n%2.").arg(cfg_path).arg(file.errorString())); default_types(); return; }
QTextStream stream( &file );
stream << document.toString();
file.close();
}
示例5: slotDeleteGroup
void CollapsibleGroup::slotDeleteGroup()
{
QDomDocument doc;
// delete effects from the last one to the first, otherwise each deletion would trigger an update
// in other effects's kdenlive_ix index.
for (int i = m_subWidgets.count() - 1; i >= 0; i--)
doc.appendChild(doc.importNode(m_subWidgets.at(i)->effect(), true));
emit deleteGroup(doc);
}
示例6: slotDeleteGroup
void CollapsibleGroup::slotDeleteGroup()
{
QDomDocument doc;
// delete effects from the last one to the first, otherwise each deletion would trigger an update
// in other effects's kdenlive_ix index.
for (int i = m_subWidgets.count() - 1; i >= 0; --i)
doc.appendChild(doc.importNode(m_subWidgets.at(i)->effect(), true));
doc.documentElement().setAttribute(QStringLiteral("name"), m_info.groupName);
emit deleteGroup(doc);
}
示例7: effectsData
QDomDocument CollapsibleGroup::effectsData()
{
QMutexLocker lock(&m_mutex);
QDomDocument doc;
QDomElement list = doc.createElement("effectgroup");
list.setAttribute("name", m_title->text());
doc.appendChild(list);
for (int j = 0; j < m_subWidgets.count(); j++) {
list.appendChild(doc.importNode(m_subWidgets.at(j)->effect(), true));
}
return doc;
}
示例8: elementString
QString SvgFileSplitter::elementString(const QString & elementID) {
QDomElement root = m_domDocument.documentElement();
QDomElement mainElement = TextUtils::findElementWithAttribute(root, "id", elementID);
if (mainElement.isNull()) return ___emptyString___;
QDomDocument document;
QDomNode node = document.importNode(mainElement, true);
document.appendChild(node);
return document.toString();
}
示例9: saveSettings
void ZynAddSubFxInstrument::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
m_portamentoModel.saveSettings( _doc, _this, "portamento" );
m_filterFreqModel.saveSettings( _doc, _this, "filterfreq" );
m_filterQModel.saveSettings( _doc, _this, "filterq" );
m_bandwidthModel.saveSettings( _doc, _this, "bandwidth" );
m_fmGainModel.saveSettings( _doc, _this, "fmgain" );
m_resCenterFreqModel.saveSettings( _doc, _this, "rescenterfreq" );
m_resBandwidthModel.saveSettings( _doc, _this, "resbandwidth" );
QString modifiedControllers;
for( QMap<int, bool>::ConstIterator it = m_modifiedControllers.begin();
it != m_modifiedControllers.end(); ++it )
{
if( it.value() )
{
modifiedControllers += QString( "%1," ).arg( it.key() );
}
}
_this.setAttribute( "modifiedcontrollers", modifiedControllers );
m_forwardMidiCcModel.saveSettings( _doc, _this, "forwardmidicc" );
QTemporaryFile tf;
if( tf.open() )
{
const std::string fn = QSTR_TO_STDSTR(
QDir::toNativeSeparators( tf.fileName() ) );
m_pluginMutex.lock();
if( m_remotePlugin )
{
m_remotePlugin->lock();
m_remotePlugin->sendMessage( RemotePlugin::message( IdSaveSettingsToFile ).addString( fn ) );
m_remotePlugin->waitForMessage( IdSaveSettingsToFile );
m_remotePlugin->unlock();
}
else
{
m_plugin->saveXML( fn );
}
m_pluginMutex.unlock();
QByteArray a = tf.readAll();
QDomDocument doc( "mydoc" );
if( doc.setContent( a ) )
{
QDomNode n = _doc.importNode( doc.documentElement(), true );
_this.appendChild( n );
}
}
}
示例10: toString
// Author & Date: Ehsan Azar 3 April 2012
// Purpose: Get the string equivalent of the current node or document
// Outputs:
// Returns a string of the current node (and its children) as separate XML document string
QString XmlFile::toString()
{
QDomElement node;
// If it is the first node
if (m_nodes.isEmpty())
{
return m_doc.toString();
}
// Create a document with new root
QDomDocument doc;
node = m_nodes.last().cloneNode().toElement();
if (!node.isNull())
{
doc.importNode(node, true);
doc.appendChild(node);
}
return doc.toString();
}
示例11: saveSubmitQueue
void ScrobblerSubmitter::saveSubmitQueue()
{
QFile file( m_savePath );
if( !file.open( IO_WriteOnly ) )
{
debug() << "[SCROBBLER] Couldn't write submit queue to file: " << m_savePath << endl;
return;
}
if ( m_lastSubmissionFinishTime == 0 )
m_lastSubmissionFinishTime = QDateTime::currentDateTime( Qt::UTC ).toTime_t();
QDomDocument newdoc;
QDomElement submitQueue = newdoc.createElement( "submit" );
submitQueue.setAttribute( "product", "pan" ); //registered @ last.fm Jan 2010
submitQueue.setAttribute( "version", APP_VERSION );
submitQueue.setAttribute( "lastSubmissionFinishTime", m_lastSubmissionFinishTime );
m_submitQueue.first();
for ( uint idx = 0; idx < m_submitQueue.count(); idx++ )
{
SubmitItem *item = m_submitQueue.at( idx );
QDomElement i = item->toDomElement( newdoc );
submitQueue.appendChild( i );
}
m_fakeQueue.first();
for ( uint idx = 0; idx < m_fakeQueue.count(); idx++ )
{
SubmitItem *item = m_fakeQueue.at( idx );
QDomElement i = item->toDomElement( newdoc );
submitQueue.appendChild( i );
}
QDomNode submitNode = newdoc.importNode( submitQueue, true );
newdoc.appendChild( submitNode );
QTextStream stream( &file );
stream.setEncoding( QTextStream::UnicodeUTF8 );
stream << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
stream << newdoc.toString();
file.close();
}
示例12: inFile
void F520xmlserializer::deserialize(QDomDocument xml, F520Status &f520, SysError &sysErr) {
qDebug() << "F520xmlserializer -> deserialize";
QDomNodeList attributeNodes = xml.elementsByTagName( ATTRIBUTE );
for(unsigned indey = 0; indey < attributeNodes.length(); indey++) {
QDomElement element = attributeNodes.at(indey).toElement();
qDebug() << "Element Name: " << element.attributes().namedItem(NAME).nodeValue();
if (element.attributes().namedItem(NAME).nodeValue().compare(WHERE) == 0) {
qDebug() << "Element Value: " << element.attributes().namedItem(VALUE).nodeValue();
f520.setWhere(element.attributes().namedItem(VALUE).nodeValue());
} else if (element.attributes().namedItem(NAME).nodeValue().compare(SRC) == 0) {
f520.setXmlPath(element.attributes().namedItem(VALUE).nodeValue());
} else if (element.attributes().namedItem(NAME).nodeValue().compare(MAX_ENERGY_VALUE) == 0) {
f520.setMaxNrgValue(element.attributes().namedItem(VALUE).nodeValue());
}
}
QDomNodeList carico = xml.elementsByTagName( CARICO );
if (carico.count() < 1) {
sysErr = SysError(SysError::F520_RESOUCES_NOT_FOUND, "F520 Can not find resources");
return;
}
QDomDocument document;
QDomNode tmp = document.importNode(carico.item(0), true);
document.appendChild(tmp);
qDebug() << document.toString();
QFile inFile( f520.getXmlPath() );
inFile.open( QIODevice::ReadWrite );
inFile.resize(0);
inFile.write(document.toString().toStdString().c_str());
inFile.close();
}
示例13: saveSettings
void CarlaInstrument::saveSettings(QDomDocument& doc, QDomElement& parent)
{
if (fHandle == NULL || fDescriptor->get_state == NULL)
return;
char* const state = fDescriptor->get_state(fHandle);
if (state == NULL)
return;
QDomDocument carlaDoc("carla");
if (carlaDoc.setContent(QString(state)))
{
QDomNode n = doc.importNode(carlaDoc.documentElement(), true);
parent.appendChild(n);
}
std::free(state);
}
示例14: SaveElement
QByteArray FopLeader::SaveElement( const QDomElement e )
{
QDomDocument em;
QDomElement import = em.createElement(e.tagName().toLower());
em.appendChild( import );
QDomNamedNodeMap attlist = e.attributes();
for (int i=0; i<attlist.count(); i++){
QDomNode nod = attlist.item(i);
import.setAttribute (nod.nodeName().toLower(),nod.nodeValue());
}
QDomNode child = e.firstChild();
while ( !child.isNull() ) {
if ( child.isElement() ) {
import.appendChild(em.importNode(child,true).toElement());
}
child = child.nextSibling();
}
return em.toByteArray(0);
}
示例15: getStyle
QDomDocument QgsSLDConfigParser::getStyle( const QString& styleName, const QString& layerName ) const
{
QDomElement userLayerElement = findUserLayerElement( layerName );
if ( userLayerElement.isNull() )
{
throw QgsMapServiceException( QStringLiteral( "LayerNotDefined" ), QStringLiteral( "Operation request is for a Layer not offered by the server." ) );
}
QDomElement userStyleElement = findUserStyleElement( userLayerElement, styleName );
if ( userStyleElement.isNull() )
{
throw QgsMapServiceException( QStringLiteral( "StyleNotDefined" ), QStringLiteral( "Operation request references a Style not offered by the server." ) );
}
QDomDocument styleDoc;
styleDoc.appendChild( styleDoc.importNode( userStyleElement, true ) );
return styleDoc;
}