Пример #1
0
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
0
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
0
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
0
static void removeAllToolBars(QDomDocument& doc)
{
    QDomElement parent = doc.documentElement();
    const QList<QDomElement> toolBars = extractToolBars(doc);
    foreach(const QDomElement& e, toolBars) {
        parent.removeChild(e);
    }
Пример #5
0
/*******************************************
 * 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
0
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
0
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
0
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);
}
/* 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
0
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
0
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();
   }
}
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
0
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
0
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
0
void KXMLGUIClient::storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties )
{
  QDomElement actionPropElement = doc.documentElement().namedItem( "ActionProperties" ).toElement();

  if ( actionPropElement.isNull() )
  {
    actionPropElement = doc.createElement( "ActionProperties" );
    doc.documentElement().appendChild( actionPropElement );
  }

  while ( !actionPropElement.firstChild().isNull() )
    actionPropElement.removeChild( actionPropElement.firstChild() );

  ActionPropertiesMap::ConstIterator it = properties.begin();
  ActionPropertiesMap::ConstIterator end = properties.end();
  for (; it != end; ++it )
  {
    QDomElement action = doc.createElement( "Action" );
    action.setAttribute( "name", it.key() );
    actionPropElement.appendChild( action );

    QMap<QString, QString> attributes = (*it);
    QMap<QString, QString>::ConstIterator attrIt = attributes.begin();
    QMap<QString, QString>::ConstIterator attrEnd = attributes.end();
    for (; attrIt != attrEnd; ++attrIt )
      action.setAttribute( attrIt.key(), attrIt.data() );
  }
}
Пример #16
0
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();
	}
}
Пример #17
0
void Archive::importBasketIcon(QDomElement properties, const QString &extractionFolder)
{
	QString iconName = XMLWork::getElementText(properties, "icon");
	if (!iconName.isEmpty() && iconName != "basket") {
		QPixmap icon = KIconLoader::global()->loadIcon(
            iconName, KIconLoader::NoGroup, 16, KIconLoader::DefaultState,
            QStringList(), 0L, /*canReturnNull=*/true
            );
		// The icon does not exists on that computer, import it:
		if (icon.isNull()) {
			QDir dir;
			dir.mkdir(Global::savesFolder() + "basket-icons/");
			FormatImporter copier; // Only used to copy files synchronously
			// Of the icon path was eg. "/home/seb/icon.png", it was exported as "basket-icons/_home_seb_icon.png".
			// So we need to copy that image to "~/.kde/share/apps/basket/basket-icons/icon.png":
			int slashIndex = iconName.lastIndexOf('/');
			QString iconFileName = (slashIndex < 0 ? iconName : iconName.right(slashIndex - 2));
			QString source       = extractionFolder + "basket-icons/" + iconName.replace('/', '_');
			QString destination = Global::savesFolder() + "basket-icons/" + iconFileName;
			if (!dir.exists(destination))
				copier.copyFolder(source, destination);
			// Replace the emblem path in the tags.xml copy:
			QDomElement iconElement = XMLWork::getElement(properties, "icon");
			properties.removeChild(iconElement);
			QDomDocument document = properties.ownerDocument();
			XMLWork::addElement(document, properties, "icon", destination);
		}
	}
}
Пример #18
0
bool Database::removeProject(const SProject * project)
{
    QDomDocument doc = loadDataBase();
    QDomElement docElem = doc.documentElement();
    QDomNode n = docElem.firstChild();

    while (!n.isNull()) {
        QDomElement e = n.toElement(); 
        if (!e.isNull()) {
            if (e.attribute("name") == project->projectName())
                docElem.removeChild(n);
        }
        n = n.nextSibling();
    }

    QFile file(m_dbfile);
    
    if (file.open(QIODevice::WriteOnly| QIODevice::Text)) {
        QTextStream ts(&file);
        ts << doc.toString();
        file.close();
    } else {
        return false;
    }

    return true;
}
Пример #19
0
/**
 * \brief Supprime une note
 * \param id id de la note à supprimer
 */
void Workspace::deleteNote(const QString &id){
    // delete in notes
    QDomElement dom_el = dom->documentElement();
    QDomNodeList node_list = dom_el.elementsByTagName("notes");
    QDomElement node = node_list.at(0).toElement();
    QDomNodeList sub_node_list = node.elementsByTagName("note");
    QDomElement sub_node;
    for (int i = 0; i < sub_node_list.count(); i++){
        sub_node = sub_node_list.at(i).toElement();
        if (sub_node.text() == id){
            sub_node = node.removeChild(sub_node).toElement();
            notes.remove(id);
        }
    }

    // delete in trash_notes
    node_list = dom_el.elementsByTagName("trash_notes");
    node = node_list.at(0).toElement();
    sub_node_list = node.elementsByTagName("note");
    for (int i = 0; i < sub_node_list.count(); i++){
        sub_node = sub_node_list.at(i).toElement();
        if (sub_node.text() == id){
            sub_node = node.removeChild(sub_node).toElement();
            trash_notes.remove(id);
        }
    }

    // delete in tags_associations
    node_list = dom_el.elementsByTagName("tags");
    node = node_list.at(0).toElement();
    sub_node_list = node.elementsByTagName("tag");
    for (int i = 0; i < sub_node_list.count(); i++){
        sub_node = sub_node_list.at(i).toElement(); // element tag
        QDomNodeList sub_sub_node_list = sub_node.elementsByTagName("name");
        QDomElement sub_sub_node_name = node_list.at(0).toElement();
        sub_sub_node_list = sub_node.elementsByTagName("note_id");
        for (int j = 0; j < sub_sub_node_list.count(); j++){
            QDomElement sub_sub_node_note_id = sub_sub_node_list.at(j).toElement();
            if (sub_sub_node_note_id.text() == id){
                sub_node.removeChild(sub_sub_node_note_id);
                tags_associations.remove(sub_node.text(), sub_sub_node_note_id.text());
            }
        }
    }

    saveFile();
}
Пример #20
0
bool XmlDataLayer::kontrahenciDeleteData(QString name) {
	QDomDocument doc(sett().getCustomersDocName());
	QDomElement root;
	QDomElement urzad;
	QDomElement firma;

	QFile file(sett().getCustomersXml());
	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();
			urzad = root.firstChild().toElement();
			firma = root.lastChild().toElement();
		}
		QString text;

		for (QDomNode n = firma.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("name"). compare(name) == 0) {
				firma.removeChild(n);
				break;
			}
		}

		for (QDomNode n = urzad.firstChild(); !n.isNull(); n = n.nextSibling()) {
			if (n.toElement().attribute("name"). compare(name) == 0) {
				urzad.removeChild(n);
				break;
			}
		}

		QString xml = doc.toString();
		file.close();
		file.open(QIODevice::WriteOnly);
		QTextStream ts(&file);
		ts << xml;

		file.close();
	}
	return true;
}
void ContactSetConfigurationHelper::saveToConfiguration(
    ConfigurationApi *configurationStorage, QDomElement contactSetNode, const ContactSet &contactSet)
{
    while (!contactSetNode.childNodes().isEmpty())
        contactSetNode.removeChild(contactSetNode.childNodes().at(0));

    for (auto const &c : contactSet)
        configurationStorage->appendTextNode(contactSetNode, "Contact", c.uuid().toString());
}
Пример #22
0
void removeNodes(QDomElement& root, const XDomNodeList& nl)
{
	for (int i = 0; i < nl.count(); ++i) {
		QDomElement e = nl.item(i).toElement();
		if (e.isNull())
			continue;
		root.removeChild(e);
	}
}
Пример #23
0
QDomDocument QgsMapLayer::asLayerDefinition()
{
  QDomDocument doc( "qgis-layer-definition" );
  QDomElement maplayer = doc.createElement( "maplayer" );
  this->writeLayerXML( maplayer, doc );
  maplayer.removeChild( maplayer.firstChildElement( "id" ) );
  doc.appendChild( maplayer );
  return doc;
}
Пример #24
0
void XmlConfManager::changeCommand(QString server, QString code) {
	QDomElement serverElement = findServer(server);
	QDomElement changeCommand = serverElement.firstChildElement("command");
	serverElement.removeChild(changeCommand);
	changeCommand = confDesc.createElement("command");

	QDomText command = confDesc.createTextNode(code);
	changeCommand.appendChild(command);
	serverElement.appendChild(changeCommand);
}
Пример #25
0
bool removeElements(QDomElement &parent, const QString &tag) {
    QDomNodeList list = parent.elementsByTagName(tag);
    KIS_SAFE_ASSERT_RECOVER_NOOP(list.size() <= 1);

    for (int i = 0; i < list.size(); i++) {
        parent.removeChild(list.at(i));
    }

    return list.size() > 0;
}
Пример #26
0
void QERecipe::buttonDeleteClicked()
{

    QDomElement rootElement;
    QDomElement recipeElement;
    QDomNode rootNode;
    QString currentName;
    QString name;
    int count;


    currentName = qComboBoxRecipeList->currentText();

    if (QMessageBox::question(this, "Info", "Do you want to delete recipe '" + currentName + "'?", QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
    {
        count = 0;
        rootElement = document.documentElement();
        if (rootElement.tagName() == "epicsqt")
        {
            rootNode = rootElement.firstChild();
            while (rootNode.isNull() == false)
            {
                recipeElement = rootNode.toElement();
                if (recipeElement.tagName() == "recipe")
                {
                    if (recipeElement.attribute("name").isEmpty())
                    {
                        name = "Recipe #" + QString::number(count);
                        count++;
                    }
                    else
                    {
                        name = recipeElement.attribute("name");
                    }
                    if (currentName.compare(name) == 0)
                    {
                        rootElement.removeChild(rootNode);
                        break;
                    }
                }
                rootNode = rootNode.nextSibling();
            }
        }
        if (saveRecipeList())
        {
            QMessageBox::information(this, "Info", "The recipe '" + currentName + "' was successfully delete!");
        }
        else
        {
            // TODO: restore original document if there is an error
            QMessageBox::critical(this, "Error", "Unable to delete recipe '" + currentName + "' in file '" + filename + "'!");
        }
    }

}
Пример #27
0
void MainWindow::on_actionDelete_activated()
{

  QDomElement picture = album.toElement();
  for(QDomNode photoElements = picture.firstChild(); !photoElements.isNull(); photoElements = photoElements.nextSibling())
  {
      QDomElement photoElement = photoElements.toElement();
          photoElement.removeChild(photoElement.firstChild());
  }

}
Пример #28
0
QDomDocument QgsMapLayer::asLayerDefinition( QList<QgsMapLayer *> layers, QString relativeBasePath )
{
  QDomDocument doc( "qgis-layer-definition" );
  QDomElement layerselm = doc.createElement( "maplayers" );
  foreach ( QgsMapLayer* layer, layers )
  {
    QDomElement layerelm = doc.createElement( "maplayer" );
    layer->writeLayerXML( layerelm, doc, relativeBasePath  );
    layerelm.removeChild( layerelm.firstChildElement( "id" ) );
    layerselm.appendChild( layerelm );
  }
Пример #29
0
QDomElement KWDWriter::setLayout(QDomElement paragraph, QDomElement layout) {
	QDomElement theLayout;
	if (layout.isNull())
		theLayout=_doc->createElement("LAYOUT");
	else
		theLayout=layout.cloneNode().toElement();
	QDomElement oldLayout=currentLayout(paragraph);
	paragraph.removeChild(oldLayout);
	paragraph.appendChild(theLayout);
	return theLayout;
}
Пример #30
0
void MyXML::removeElement(QString fileName)
{
    if (fileName.isEmpty())
        return;
    QDomElement filelist = doc.documentElement().firstChildElement("FileList");
    QDomElement elt = filelist.firstChildElement("File");
    for (; !elt.isNull(); elt = elt.nextSiblingElement("File")) {
        if (elt.attribute("Name") == fileName) {
            filelist.removeChild(elt);
        }
    }
}