本文整理汇总了C++中QDomElement::removeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::removeChild方法的具体用法?C++ QDomElement::removeChild怎么用?C++ QDomElement::removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::removeChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: productsDeleteData
bool XmlDataLayer::productsDeleteData(QString name) {
QDomDocument doc(sett().getProdutcsDocName());
QDomElement root;
QDomElement products;
QDomElement services;
QFile file(sett().getProductsXml());
if (!file.open(QIODevice::ReadOnly)) {
qDebug() << "File" << file.fileName() << "doesn't exists";
return false;
} else {
QTextStream stream(&file);
if (!doc.setContent(stream.readAll())) {
qDebug("can not set content ");
file.close();
return false;
} else {
root = doc.documentElement();
products = root.firstChild().toElement();
services = root.lastChild().toElement();
}
QString text;
for (QDomNode n = services.firstChild(); !n.isNull(); n
= n.nextSibling()) {
if (n.toElement().attribute("idx"). compare(name) == 0) {
services.removeChild(n);
break;
}
}
for (QDomNode n = products.firstChild(); !n.isNull(); n
= n.nextSibling()) {
if (n.toElement().attribute("idx"). compare(name) == 0) {
products.removeChild(n);
break;
}
}
QString xml = doc.toString();
file.close();
file.open(QIODevice::WriteOnly);
QTextStream ts(&file);
ts << xml;
file.close();
}
return true;
}
示例2: 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;
}
示例3: removeImage
void ParserAlbum::removeImage(Image *image)
{
m_pFile->close();
if(!m_pFile->open(QIODevice::WriteOnly))
{
return;
}
QDomElement element = m_pDoc->documentElement();
QDomElement node = element.firstChild().toElement();
QDomElement images = node;
node = node.firstChildElement();
while(!node.isNull())
{
qDebug() << node.tagName() << " : " << node.text();
if(node.text() == image->sourceImage())
{
images.removeChild(node);
qDebug() << "removed : " << node.text();
node = node.nextSibling().toElement();
}
else
{
node = node.nextSibling().toElement();
}
}
if(m_pFile->isOpen())
{
QTextStream(m_pFile) << m_pDoc->toString();
m_pFile->close();
}
}
示例4: removeAllToolBars
static void removeAllToolBars(QDomDocument& doc)
{
QDomElement parent = doc.documentElement();
const QList<QDomElement> toolBars = extractToolBars(doc);
foreach(const QDomElement& e, toolBars) {
parent.removeChild(e);
}
示例5: modifyDeviceInfoXml
/*******************************************
* void DeviceInfo::modifyDeviceInfoXml
******************************************/
void DeviceInfo::modifyDeviceInfoXml( QString devPropName, QString value )
{
QDomDocument document;
QDomElement element;
QFile file(getDeviceInfoXmlPath());
if( file.open( QIODevice::ReadOnly) )
{
document.setContent(&file);
file.close();
QDomNodeList elementList = document.elementsByTagName("DevPropValue");
for( int i = 0 ; i < elementList.count(); i++ )
{
element = elementList.item( i ).toElement();
if( devPropName == element.attribute( "id" ) )
{
// Assuming first child is the text node containing the friendly name
element.removeChild( element.firstChild() );
QDomText text = document.createTextNode( value );
element.appendChild( text );
if( file.open( QIODevice::WriteOnly | QIODevice::Truncate ) )
{
QTextStream ts( &file );
ts << document.toString();
}
break;
}
}
}
}
示例6: SetAttribute
void ProjectFile::SetAttribute(QString parentTag, QString childTag, QString attribute, QString value)
{
QDomElement parentTagElement = documentElement().namedItem(parentTag).toElement();
if (parentTagElement.isNull())
{
parentTagElement = createElement(parentTag);
documentElement().appendChild(parentTagElement);
}
QDomElement childTagElement = parentTagElement.namedItem(childTag).toElement();
if (childTagElement.isNull())
{
childTagElement = createElement(childTag);
parentTagElement.appendChild(childTagElement);
}
QDomNode attributeNode = childTagElement.namedItem(value);
if (!attributeNode.isNull())
{
childTagElement.removeChild(attributeNode);
}
QDomElement attributeElement = createElement(attribute);
attributeElement.appendChild(createTextNode(value));
childTagElement.appendChild(attributeElement);
SaveProject();
}
示例7: redefinePlaylist
void PlaylistHandler::redefinePlaylist(std::string playlistName, std::vector<Song*> songs) {
checkInit();
QDomElement playlist = getPlaylistFromName(playlistName);
QDomNode node = playlist.firstChild();
std::vector<QDomElement> removeVector;
while (!node.isNull()) {
QDomElement element = node.toElement();
if (!element.isNull() && element.tagName() == "Song") {
removeVector.push_back(element);
}
node = node.nextSibling();
}
for (unsigned int i = 0; i < removeVector.size(); i++) {
playlist.removeChild(removeVector.at(i));
}
for (unsigned int i = 0; i < songs.size(); i++) {
Song* song = songs.at(i);
QDomElement songElement = doc.createElement("Song");
songElement.setAttribute("SongName", QString::fromStdString(song->getSongName()));
songElement.setAttribute("ArtistName", QString::fromStdString(song->getArtistName()));
songElement.setAttribute("AlbumName", QString::fromStdString(song->getAlbumName()));
songElement.setAttribute("SongId", song->getSongId());
songElement.setAttribute("ArtistId", song->getArtistId());
songElement.setAttribute("AlbumId", song->getAlbumId());
songElement.setAttribute("CoverArtFilename", QString::fromStdString(song->getCoverArtFilename()));
playlist.appendChild(songElement);
}
save();
emit songsChanged(playlistName, getSongs(playlistName));
}
示例8: stripAnswers
QString XmlUtil::stripAnswers(const QString &input) {
QDomDocument doc;
doc.setContent(input);
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while ( !n.isNull() ) {
QDomElement e = n.toElement();
if ( !e.isNull() && (e.namespaceURI().isEmpty() || e.namespaceURI() == XML_NS) ) {
if ( e.nodeName() == "choose" ) {
QDomElement c = e.firstChildElement("choice");
while ( !c.isNull() ) {
c.removeAttribute("answer");
c = c.nextSiblingElement("choice");
}
} else if ( e.nodeName() == "identification" ) {
QDomElement a = e.firstChildElement("a");
while ( !a.isNull() ) {
e.removeChild(a);
a = e.firstChildElement("a");
}
}
}
n = n.nextSibling();
}
return doc.toString(2);
}
示例9: addNewDevice
/* public slots */
void Boot_Devices::addNewDevice(QDomElement &_el)
{
QString _devName = _el.tagName();
//qDebug()<<_devName;
QString _devType = _el.attribute("type");
_devName.append(" ");
_devName.append(_devType);
int _order = devices->count()+1;
bool _used = !_el.firstChildElement("boot").isNull();
if (_used)
_order = _el
.firstChildElement("boot")
.attribute("order").toInt()-1;
QDomDocument doc;
doc.setContent(QString());
doc.appendChild(_el);
QString _data = doc.toDocument().toString();
if ( !_el.firstChildElement("boot").isNull() ) {
_el.removeChild(_el.firstChildElement("boot"));
};
//qDebug()<<doc.toDocument().toString();
QListWidgetItem *_item = new QListWidgetItem();
_item->setText(_devName);
_item->setCheckState( (_used)? Qt::Checked:Qt::Unchecked );
_item->setIcon(QIcon::fromTheme("computer"));
_item->setData(Qt::UserRole, _data);
devices->insertItem(_order, _item);
}
示例10: on_descriptionPlainTextEdit_textChanged
void MainWindow::on_descriptionPlainTextEdit_textChanged()
{
if(loadingTheInformations)
return;
QList<QListWidgetItem *> itemsUI=ui->itemList->selectedItems();
if(itemsUI.size()!=1)
return;
quint32 selectedItem=itemsUI.first()->data(99).toUInt();
QDomElement description = items[selectedItem].firstChildElement("description");
while(!description.isNull())
{
if((!description.hasAttribute("lang") && ui->descriptionEditLanguageList->currentText()=="en")
||
(description.hasAttribute("lang") && ui->descriptionEditLanguageList->currentText()==description.attribute("lang"))
)
{
QDomText newTextElement=description.ownerDocument().createTextNode(ui->descriptionPlainTextEdit->toPlainText());
QDomNodeList nodeList=description.childNodes();
int sub_index=0;
while(sub_index<nodeList.size())
{
description.removeChild(nodeList.at(sub_index));
sub_index++;
}
description.appendChild(newTextElement);
return;
}
description = description.nextSiblingElement("description");
}
QMessageBox::warning(this,tr("Warning"),tr("Text not found"));
}
示例11: purgeIncludesExcludes
static void purgeIncludesExcludes(QDomElement elem, const QString &appId, QDomElement &excludeNode, QDomElement &includeNode)
{
// Remove any previous includes/excludes of appId
QDomNode n = elem.firstChild();
while( !n.isNull() )
{
QDomElement e = n.toElement(); // try to convert the node to an element.
bool bIncludeNode = (e.tagName() == MF_INCLUDE);
bool bExcludeNode = (e.tagName() == MF_EXCLUDE);
if (bIncludeNode)
includeNode = e;
if (bExcludeNode)
excludeNode = e;
if (bIncludeNode || bExcludeNode)
{
QDomNode n2 = e.firstChild();
while ( !n2.isNull() )
{
QDomNode next = n2.nextSibling();
QDomElement e2 = n2.toElement();
if (!e2.isNull() && e2.tagName() == MF_FILENAME)
{
if (e2.text() == appId)
{
e.removeChild(e2);
break;
}
}
n2 = next;
}
}
n = n.nextSibling();
}
}
示例12: copyMetaData
void QInstallerTools::copyMetaData(const QString &_targetDir, const QString &metaDataDir,
const PackageInfoVector &packages, const QString &appName, const QString &appVersion)
{
const QString targetDir = makePathAbsolute(_targetDir);
if (!QFile::exists(targetDir))
QInstaller::mkpath(targetDir);
QDomDocument doc;
QDomElement root;
QFile existingUpdatesXml(QFileInfo(metaDataDir, QLatin1String("Updates.xml")).absoluteFilePath());
if (existingUpdatesXml.open(QIODevice::ReadOnly) && doc.setContent(&existingUpdatesXml)) {
root = doc.documentElement();
// remove entry for this component from existing Updates.xml, if found
foreach (const PackageInfo &info, packages) {
const QDomNodeList packageNodes = root.childNodes();
for (int i = packageNodes.count() - 1; i >= 0; --i) {
const QDomNode node = packageNodes.at(i);
if (node.nodeName() != QLatin1String("PackageUpdate"))
continue;
if (node.firstChildElement(QLatin1String("Name")).text() != info.name)
continue;
root.removeChild(node);
}
}
existingUpdatesXml.close();
} else {
示例13: todoToDom
bool LocalXmlBackend::todoToDom(const OpenTodoList::ITodo *todo, QDomDocument &doc)
{
QDomElement root = doc.documentElement();
if ( !root.isElement() ) {
root = doc.createElement( "todo" );
doc.appendChild( root );
}
root.setAttribute( "id", todo->uuid().toString() );
root.setAttribute( "title", todo->title() );
root.setAttribute( "done", todo->done() ? "true" : "false" );
root.setAttribute( "priority", todo->priority() );
root.setAttribute( "weight", todo->weight() );
if ( todo->dueDate().isValid() ) {
root.setAttribute( "dueDate", todo->dueDate().toString() );
} else {
root.removeAttribute( "dueDate" );
}
QDomElement descriptionElement = root.firstChildElement( "description" );
if ( !descriptionElement.isElement() ) {
descriptionElement = doc.createElement( "description" );
root.appendChild( descriptionElement );
}
while ( !descriptionElement.firstChild().isNull() ) {
descriptionElement.removeChild( descriptionElement.firstChild() );
}
QDomText descriptionText = doc.createTextNode( todo->description() );
descriptionElement.appendChild( descriptionText );
return true;
}
示例14: changeUser
void XmlConfManager::changeUser(QString server, User user) {
QDomElement serverElement = findServer(server);
QDomElement userElement = serverElement.firstChildElement("user");
serverElement.removeChild(userElement);
/* Recréation de l'utilisateur */
userElement = confDesc.createElement("user");
QDomElement nickname = confDesc.createElement("nickname");
QDomElement ghost = confDesc.createElement("ghost");
QDomElement username = confDesc.createElement("username");
QDomElement realname = confDesc.createElement("realname");
QDomText nickText = confDesc.createTextNode(user.nickname);
QDomText ghostText = confDesc.createTextNode(user.ghost);
QDomText usernameText = confDesc.createTextNode(user.username);
QDomText realnameText = confDesc.createTextNode(user.realname);
nickname.appendChild(nickText);
ghost.appendChild(ghostText);
username.appendChild(usernameText);
realname.appendChild(realnameText);
userElement.appendChild(nickname);
userElement.appendChild(ghost);
userElement.appendChild(username);
userElement.appendChild(realname);
serverElement.appendChild(userElement);
}
示例15: renameMergedStates
void Archive::renameMergedStates(QDomNode notes, QMap<QString, QString> &mergedStates)
{
QDomNode n = notes.firstChild();
while ( ! n.isNull() ) {
QDomElement element = n.toElement();
if (!element.isNull()) {
if (element.tagName() == "group" ) {
renameMergedStates(n, mergedStates);
} else if (element.tagName() == "note") {
QString tags = XMLWork::getElementText(element, "tags");
if (!tags.isEmpty()) {
QStringList tagNames = tags.split(";");
for (QStringList::Iterator it = tagNames.begin(); it != tagNames.end(); ++it) {
QString &tag = *it;
if (mergedStates.contains(tag)) {
tag = mergedStates[tag];
}
}
QString newTags = tagNames.join(";");
QDomElement tagsElement = XMLWork::getElement(element, "tags");
element.removeChild(tagsElement);
QDomDocument document = element.ownerDocument();
XMLWork::addElement(document, element, "tags", newTags);
}
}
}
n = n.nextSibling();
}
}