void MainWindow::on_actionPage_backward_activated() { QDomElement root = document->documentElement(); QDomElement picture = album.toElement(); root.insertBefore(picture, picture.previousSiblingElement("photo")); if(album.previousSibling().isNull()) { ui->actionMove_backward->setEnabled(false); ui->actionPage_backward->setEnabled(false); } if(!album.nextSibling().isNull()) { ui->actionMove_forward->setEnabled(true); ui->actionPage_forward->setEnabled(true); } ui->statusBar->showMessage("Moved photo back one in album"); }
void writeJob::resetModuleName(const QString name) { qDebug()<<"writeJob::resetModuleName"; QDomElement root = doc.documentElement(); QDomElement modEle = root.firstChildElement("Module"); while (!modEle.isNull()) { if(modEle.attribute("name")==name && modEle.attribute("id")==moduleID) { /// 采用的替换法,多替换几次???难道仅仅是这个函数多执行几次??? QDomElement prevModEle=modEle.previousSiblingElement("Module"); root.insertBefore(modEle,prevModEle); break; } modEle = modEle.nextSiblingElement("Module"); } if(!write()) qDebug()<<"writeJob::reset job failed"; }
/************************************************ Duplicate <MergeXXX> elements (that specify the same file) are handled as with duplicate <AppDir> elements (the last duplicate is used). ************************************************/ void XdgMenuReader::processMergeTags(QDomElement& element) { QDomElement n = element.lastChildElement(); QStringList mergedFiles; while (!n.isNull()) { QDomElement next = n.previousSiblingElement(); // MergeFile .................. if (n.tagName() == "MergeFile") { processMergeFileTag(n, &mergedFiles); n.parentNode().removeChild(n); } // MergeDir ................... else if(n.tagName() == "MergeDir") { processMergeDirTag(n, &mergedFiles); n.parentNode().removeChild(n); } // DefaultMergeDirs ........... else if (n.tagName() == "DefaultMergeDirs") { processDefaultMergeDirsTag(n, &mergedFiles); n.parentNode().removeChild(n); } // AppDir ................... else if(n.tagName() == "AppDir") { processAppDirTag(n); n.parentNode().removeChild(n); } // DefaultAppDirs ............. else if(n.tagName() == "DefaultAppDirs") { processDefaultAppDirsTag(n); n.parentNode().removeChild(n); } // DirectoryDir ................... else if(n.tagName() == "DirectoryDir") { processDirectoryDirTag(n); n.parentNode().removeChild(n); } // DefaultDirectoryDirs ........... else if(n.tagName() == "DefaultDirectoryDirs") { processDefaultDirectoryDirsTag(n); n.parentNode().removeChild(n); } // Menu ....................... else if(n.tagName() == "Menu") { processMergeTags(n); } n = next; } }