本文整理汇总了C++中QDomElement::parentNode方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::parentNode方法的具体用法?C++ QDomElement::parentNode怎么用?C++ QDomElement::parentNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::parentNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSettings
void Pattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setAttribute( "type", m_patternType );
_this.setAttribute( "name", name() );
// as the target of copied/dragged pattern is always an existing
// pattern, we must not store actual position, instead we store -1
// which tells loadSettings() not to mess around with position
if( _this.parentNode().nodeName() == "clipboard" ||
_this.parentNode().nodeName() == "dnddata" )
{
_this.setAttribute( "pos", -1 );
}
else
{
_this.setAttribute( "pos", startPosition() );
}
_this.setAttribute( "len", length() );
_this.setAttribute( "muted", isMuted() );
_this.setAttribute( "steps", m_steps );
// now save settings of all notes
for( NoteVector::Iterator it = m_notes.begin();
it != m_notes.end(); ++it )
{
if( ( *it )->length() )
{
( *it )->saveState( _doc, _this );
}
}
}
示例2: checkLayerGroupAttribute
bool QgsServerProjectParser::checkLayerGroupAttribute( const QString& attributeName, const QString& layerId ) const
{
//search layer (if it is a layer), test if attribute is true. If not, return false.
QString lName;
QHash< QString, QDomElement >::const_iterator layerIt = mProjectLayerElementsById.find( layerId );
if ( layerIt != mProjectLayerElementsById.constEnd() )
{
if ( !layerIt.value().attribute( attributeName, "1" ).toInt() )
{
return false;
}
lName = layerName( layerIt.value() );
}
QDomElement currentElement;
if ( lName.isEmpty() )
{
currentElement = legendGroupByName( layerId );
}
else
{
//get <legendlayer> element from legend section
QDomElement legendElement = legendElem();
QDomNodeList layerNodeList = legendElement.elementsByTagName( "legendlayer" );
for ( int i = 0; i < layerNodeList.size(); ++i )
{
QDomElement currentLayerElement = layerNodeList.at( i ).toElement();
if ( currentLayerElement.attribute( "name" ) == lName )
{
currentElement = currentLayerElement;
if ( !currentElement.attribute( attributeName, "1" ).toInt() )
{
return false;
}
break;
}
}
}
if ( currentElement.isNull() )
{
return false;
}
while ( !currentElement.parentNode().isNull() )
{
if ( currentElement.attribute( attributeName, "1" ).toInt() != 1 )
{
return false;
}
if ( currentElement.parentNode().nodeName() != "legendgroup" )
{
break;
}
currentElement = currentElement.parentNode().toElement();
}
return true;
}
示例3: save
bool UserProfile::save() const
{
QDomDocument domDoc;
QDomElement rootElement = createElement(this, source(), parentElement(), domDoc);
if (!rootElement.isNull()) {
//Пересоздадим основной элемент
QDomElement oldRootElement = rootElement;
rootElement = domDoc.createElement(rootElement.tagName());
oldRootElement.parentNode().appendChild(rootElement);
oldRootElement.parentNode().removeChild(oldRootElement);
QDomElement idElement = domDoc.createElement("id");
rootElement.appendChild(idElement);
QDomText idText = domDoc.createTextNode(QString::number(id()));
idElement.appendChild(idText);
QDomElement nameElement = domDoc.createElement("name");
rootElement.appendChild(nameElement);
QDomText nameText = domDoc.createTextNode(name());
nameElement.appendChild(nameText);
QDomElement photoElement = domDoc.createElement("photo");
rootElement.appendChild(photoElement);
QByteArray ba;
QBuffer buffer(&ba);
if (!photo().isNull()) {
buffer.open(QIODevice::WriteOnly);
//Смаштабируем фото
if (photo().width() > m_preferredSize.width() || photo().height() > m_preferredSize.height()) {
QImage scaledPhoto = photo().scaled(m_preferredSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
scaledPhoto.save(&buffer, "PNG");
} else {
photo().save(&buffer, "PNG");
}
}
QDomText photoText = domDoc.createTextNode(ba.toBase64());
photoElement.appendChild(photoText);
QDomElement statusesElement = domDoc.createElement("statuses");
rootElement.appendChild(statusesElement);
m_stateModel->appendItemsToDomElement(statusesElement, domDoc);
QFile file (source().toLocalFile());
if(file.open(QFile::WriteOnly)) {
QTextStream ts(&file);
ts.setCodec("UTF-8");
ts << domDoc.toString();
file.close();
return true;
}
}
return false;
}
示例4: readInfoAboutExample
void MenuManager::readInfoAboutExample(const QDomElement &example)
{
QString name = example.attribute("name");
if (this->info.contains(name))
qWarning() << "__WARNING: MenuManager::readInfoAboutExample: Demo/example with name"
<< name << "appears twize in the xml-file!__";
this->info[name]["filename"] = example.attribute("filename");
this->info[name]["category"] = example.parentNode().toElement().tagName();
this->info[name]["dirname"] = example.parentNode().toElement().attribute("dirname");
this->info[name]["changedirectory"] = example.attribute("changedirectory");
this->info[name]["image"] = example.attribute("image");
}
示例5: deletePackage
bool deletePackage( QDomDocument *list, QString path )
{
QString map = findMapInDir( path );
if( path.endsWith( "MoNav.ini" ) )
{
QDomElement mapElement = findPackageElement( *list, "map", map );
if( mapElement.isNull() )
{
printf( "map not in list\n" );
return false;
}
list->documentElement().removeChild( mapElement );
printf( "deleted map entry\n" );
}
else if( path.endsWith( ".mmm" ) )
{
QString name = path.split("_")[1];
QDomElement moduleElement = findPackageElement( *list, "module", name, map );
if( moduleElement.isNull() )
{
printf("module not in list\n");
return 1;
}
QDomElement parentElement = moduleElement.parentNode().toElement();
parentElement.removeChild( moduleElement );
while( !parentElement.hasChildNodes() )
{
moduleElement = parentElement;
parentElement = parentElement.parentNode().toElement();
parentElement.removeChild( moduleElement );
}
printf( "deleted module entry\n" );
}
else
{
printf( "unrecognized package format\n" );
return false;
}
return true;
}
示例6: handleXmlElement
QList<QTreeWidgetItem*> BtBookmarkLoader::loadTree(QString fileName)
{
qDebug() << "BtBookmarkLoader::loadTree";
QList<QTreeWidgetItem*> itemList;
QDomDocument doc;
doc.setContent(loadXmlFromFile(fileName));
//bookmarkfolder::loadBookmarksFromXML()
QDomElement document = doc.documentElement();
if( document.tagName() != "SwordBookmarks" ) {
qWarning("Not a BibleTime Bookmark XML file");
return QList<QTreeWidgetItem*>();
}
QDomElement child = document.firstChild().toElement();
while ( !child.isNull() && child.parentNode() == document) {
qDebug() << "BtBookmarkLoader::loadTree while start";
QTreeWidgetItem* i = handleXmlElement(child, 0);
itemList.append(i);
if (!child.nextSibling().isNull()) {
child = child.nextSibling().toElement();
} else {
child = QDomElement(); //null
}
}
return itemList;
}
示例7: removeItems
QStringList QuantaProjectPart::removeItems(const QStringList &items)
{
QStringList removedItems;
QString fileName;
QStringList::ConstIterator itemsEnd = items.constEnd();
for (QStringList::ConstIterator itemIt = items.constBegin(); itemIt != itemsEnd; ++itemIt)
{
QMap<QString, QDomElement>::Iterator end = m_files.end();
QMap<QString, QDomElement>::Iterator deleteIt = end;
QMap<QString, QDomElement>::Iterator it = m_files.begin();
while (it != end)
{
fileName = it.key();
if (fileName == *itemIt || fileName.startsWith(*itemIt + '/'))
{
kDebug(24000) << "File removed from project: " << fileName;
QDomElement el = it.value();
el.parentNode().removeChild(el);
deleteIt = it;
removedItems += fileName;
}
++it;
if (deleteIt != end)
{
m_files.erase(deleteIt);
deleteIt = end;
}
}
}
return removedItems;
}
示例8: deleteItemPermanently
void BookmarkWidget::deleteItemPermanently(const QString xmlPath, QTreeWidgetItem* item)
{
if(!item) {
QList<QTreeWidgetItem*> list = bTreeWidget->selectedItems();
if(list.isEmpty()) return;
item = list.at(0);
if(!item) return;
}
// DT: don't move this!
QString uuid = item->text(UUID_COLUMN);
QDomDocument doc;
QDomElement elt = findElementbyUUID(doc, uuid, BOOKMARK, xmlPath);
QList<QTreeWidgetItem *> items = bTreeWidget->findItems(uuid, Qt::MatchExactly, UUID_COLUMN);
item = items.at(0);
delete item;
if(elt.isNull()) return;
QDomNode parent = elt.parentNode();
parent.removeChild(elt);
saveDOMToFile(doc, xmlPath);
//refreshBookmarkList();
}
示例9: processEvent
bool PstoPlugin::processEvent(int account, QDomElement &e) {
Q_UNUSED(account);
Q_UNUSED(e);
if (!enabled) {
return false;
}
QDomDocument doc = e.ownerDocument();
QString jid = e.childNodes().at(3).firstChild().nodeValue().split("/").at(0); // always here
if (psto_jids.contains(jid)) {
QString full_jid = e.childNodes().at(5).attributes()
.namedItem("from").nodeValue();
QDomElement body = e.childNodes().at(5).firstChildElement(); // the same
QDomText body_text = body.firstChild().toText();
QDomElement html = doc.createElement("html");
html.setAttribute("xmlns", "http://jabber.org/protocol/xhtml-im");
body.parentNode().appendChild(html);
QDomElement html_body = doc.createElement("body");
html_body.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
html.appendChild(html_body);
QStringList message_strings = body_text.nodeValue().split("\n");
int line_number = 0;
foreach (QString line, message_strings) {
processMessageString(line_number, line, full_jid, html_body);
line_number++;
}
示例10: mergeFile
/*
If fileName is not an absolute path then the file to be merged should be located
relative to the location of this menu file.
************************************************/
void XdgMenuReader::mergeFile(const QString& fileName, QDomElement& element, QStringList* mergedFiles)
{
XdgMenuReader reader(mMenu, this);
QFileInfo fileInfo(QDir(mDirName), fileName);
if (!fileInfo.exists())
return;
if (mergedFiles->contains(fileInfo.canonicalFilePath()))
{
//qDebug() << "\tSkip: allredy merged";
return;
}
//qDebug() << "Merge file: " << fileName;
mergedFiles->append(fileInfo.canonicalFilePath());
if (reader.load(fileName, mDirName))
{
//qDebug() << "\tOK";
QDomElement n = reader.xml().firstChildElement().firstChildElement();
while (!n.isNull())
{
// As a special exception, remove the <Name> element from the root
// element of each file being merged.
if (n.tagName() != QLatin1String("Name"))
{
QDomNode imp = mXml.importNode(n, true);
element.parentNode().insertBefore(imp, element);
}
n = n.nextSiblingElement();
}
}
}
示例11: xmlBase
QString ElementWrapper::xmlBase() const
{
if (!d->xmlBaseParsed) // xmlBase not computed yet
{
QDomElement current = d->element;
while (!current.isNull())
{
if (current.hasAttributeNS(xmlNamespace(), QLatin1String("base")))
{
d->xmlBase = current.attributeNS(xmlNamespace(), QLatin1String("base"));
return d->xmlBase;
}
QDomNode parent = current.parentNode();
if (!parent.isNull() && parent.isElement())
current = parent.toElement();
else
current = QDomElement();
}
d->xmlBaseParsed = true;
}
return d->xmlBase;
}
示例12: writeElementChilds
void FileWriter::writeElementChilds(const QDomElement &AParent)
{
QDomNode node = AParent.firstChild();
while (!node.isNull())
{
if (node.isElement())
{
QDomElement elem = node.toElement();
if (elem.tagName() != "thread")
{
FXmlWriter->writeStartElement(elem.tagName());
QString elemNs = elem.namespaceURI();
if (!elemNs.isEmpty() && elem.parentNode().namespaceURI()!=elemNs)
FXmlWriter->writeAttribute("xmlns",elem.namespaceURI());
QDomNamedNodeMap attrMap = elem.attributes();
for (uint i=0; i<attrMap.length(); i++)
{
QDomNode attrNode = attrMap.item(i);
FXmlWriter->writeAttribute(attrNode.nodeName(), attrNode.nodeValue());
}
writeElementChilds(elem);
FXmlWriter->writeEndElement();
}
}
else if (node.isCharacterData())
{
FXmlWriter->writeCharacters(node.toCharacterData().data());
}
node = node.nextSibling();
}
}
示例13: processMergeDirTag
/************************************************
A <MergeDir> contains the name of a directory. Each file in the given directory
which ends in the ".menu" extension should be merged in the same way that a
<MergeFile> would be. If the filename given as a <MergeDir> is not an absolute
path, it should be located relative to the location of the menu file being parsed.
The files inside the merged directory are not merged in any specified order.
Duplicate <MergeDir> elements (that specify the same directory) are handled as with
duplicate <AppDir> elements (the last duplicate is used).
KDE additional scans ~/.config/menus.
************************************************/
void XdgMenuReader::processMergeDirTag(QDomElement& element, QStringList* mergedFiles)
{
//qDebug() << "Process " << element;// << "in" << mFileName;
mergeDir(element.text(), element, mergedFiles);
element.parentNode().removeChild(element);
}
示例14: saveTrackSpecificSettings
void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _this )
{
// _this.setAttribute( "icon", m_trackLabel->pixmapFile() );
/* _this.setAttribute( "current", s_infoMap[this] ==
engine::getBBEditor()->currentBB() );*/
if( s_infoMap[this] == 0 &&
_this.parentNode().parentNode().nodeName() != "clone" &&
_this.parentNode().nodeName() != "journaldata" )
{
( (JournallingObject *)( engine::getBBTrackContainer() ) )->
saveState( _doc, _this );
}
if( _this.parentNode().parentNode().nodeName() == "clone" )
{
_this.setAttribute( "clonebbt", s_infoMap[this] );
}
}
示例15: getLineStr
/**
* Return a string with all the field: "[<date>] <nick>: <message>".
*/
QString ChatModel::getLineStr(int row, bool withHTML) const
{
QString result = this->formatMessage(this->messages[row]);
if (!withHTML)
{
QDomDocument doc;
doc.setContent(result);
QDomElement HTMLElement = doc.firstChildElement("html");
QDomElement BodyElement = HTMLElement.firstChildElement("body");
QDomElement currentElement = BodyElement.firstChildElement();
while (!currentElement.isNull())
{
QDomElement nextElement = currentElement.nextSiblingElement();
if (currentElement.tagName() == "img")
{
QStringList srcEmoticon = currentElement.attribute("src").split('/', QString::SkipEmptyParts);
if (srcEmoticon.count() == 3)
{
QStringList emoticonSymbols = this->emoticons.getSmileSymbols(srcEmoticon[1], srcEmoticon[2]);
if (!emoticonSymbols.isEmpty())
currentElement.parentNode().replaceChild(doc.createTextNode(emoticonSymbols.first()), currentElement);
}
}
else if (currentElement.tagName() == "span")
{
QDomElement innerSpanElement = currentElement.firstChildElement();
while (!innerSpanElement.isNull())
{
QDomElement nextInnerSpanElement = innerSpanElement.nextSiblingElement();
if (innerSpanElement.tagName() == "br")
innerSpanElement.parentNode().replaceChild(doc.createTextNode("\n"), innerSpanElement);
innerSpanElement = nextInnerSpanElement;
}
}
currentElement = nextElement;
}
return BodyElement.text();
}
return result;
}