コード例 #1
0
ファイル: Pattern.cpp プロジェクト: nachocarballeda/lmms
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
0
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
0
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
0
ファイル: menumanager.cpp プロジェクト: ghl800/touch16
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
0
ファイル: main.cpp プロジェクト: Karry/monavsailfish
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
0
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
0
ファイル: quantaprojectpart.cpp プロジェクト: KDE/quanta
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
0
ファイル: bookmarkWidget.cpp プロジェクト: WeiqiJust/CHER-Ob
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
0
ファイル: pstoplugin.cpp プロジェクト: sharkman/plugins
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
0
ファイル: xdgmenureader.cpp プロジェクト: libqtxdg/libqtxdg
/*
 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
0
ファイル: elementwrapper.cpp プロジェクト: pvuorela/kcalcore
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
0
ファイル: filewriter.cpp プロジェクト: ChALkeR/vacuum-im
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
0
ファイル: xdgmenureader.cpp プロジェクト: Wubbbi/razor-qt
/************************************************
 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
0
QDomNode RemoveScriptDomVisitor::endVisit(QDomElement elementNode) const
{
	auto nextsibling = elementNode.nextSibling();
	if (elementNode.tagName().toLower() == "script")
		elementNode.parentNode().removeChild(elementNode);
	return nextsibling;
}
コード例 #15
0
bool KoStyleStack::isUserStyle( const QDomElement& e, const QString& family ) const
{
    if ( e.attributeNS( m_styleNSURI, "family", QString::null ) != family )
        return false;
    const QDomElement parent = e.parentNode().toElement();
    //kdDebug(30003) << k_funcinfo << "tagName=" << e.tagName() << " parent-tagName=" << parent.tagName() << endl;
    return parent.localName() == "styles" /*&& parent.namespaceURI() == KoXmlNS::office*/;
}
コード例 #16
0
ファイル: bb_track.cpp プロジェクト: Cubiicle/lmms
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] );
	}
}
コード例 #17
0
ファイル: ChatModel.cpp プロジェクト: hmartinet/D-LAN
/**
  * 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;
}
コード例 #18
0
ファイル: xdgmenureader.cpp プロジェクト: libqtxdg/libqtxdg
void XdgMenuReader::addDirTag(QDomElement& previousElement, const QString& tagName, const QString& dir)
{
    QFileInfo dirInfo(mDirName, dir);
    if (dirInfo.isDir())
    {
//        qDebug() << "\tAdding " + dirInfo.canonicalFilePath();
        QDomElement element = mXml.createElement(tagName);
        element.appendChild(mXml.createTextNode(dirInfo.canonicalFilePath()));
        previousElement.parentNode().insertBefore(element, previousElement);
    }
}
コード例 #19
0
ファイル: widget.cpp プロジェクト: vikkiorrikki/Colorist
void Widget::parseXML(const QDomNode node)
{
    QString theme, complex;
    QDomNode domNode = node.firstChild();
    while(!domNode.isNull()) {
        if(domNode.isElement()) {
           QDomElement domElement = domNode.toElement();
           if(!domElement.isNull()) {
               if( domElement.tagName() == "theme")
               {
                   theme = domElement.attribute("title");
                   ui->listWidget->addItem(theme);
               }
               if( domElement.tagName() == "complexity")
               {
                   complex = domElement.attribute("id");

                   QMap<QString, QList<QString>* > *map;
                   if(levels->value(domElement.parentNode().toElement().attribute("title")) == NULL)
                   {
                       map = new QMap<QString, QList<QString>* >() ;
                   }
                   else
                   {
                       map = levels->value(domElement.parentNode().toElement().attribute("title"));
                   }
                   map->insert(complex, new QList<QString>() );
                   levels->insert(domElement.parentNode().toElement().attribute("title"), map);
               }
               if(domElement.tagName() == "level")
               {
                   levels->value(domElement.parentNode().toElement().parentNode().toElement().attribute("title"))->value(domElement.parentNode().toElement().attribute("id"))->push_back(domElement.attribute("file"));
               }
           }
        }
        parseXML(domNode);
        domNode = domNode.nextSibling();
     }
}
コード例 #20
0
ファイル: uic.cpp プロジェクト: Miguel-J/eneboo-core
/*! Extracts an layout name from \a e. It's stored in the 'name'
 property of the preceeding sibling (the first child of a QLayoutWidget).
 */
QString Uic::getLayoutName( const QDomElement& e ) {
  QDomElement p = e.parentNode().toElement();
  QString name;

  if ( getClassName( p ) != "QLayoutWidget" )
    name = "Layout";

  QDomElement n = getObjectProperty( p, "name" );
  if ( n.firstChild().toElement().tagName() == "cstring" ) {
    name.prepend( n.firstChild().toElement().firstChild().toText().data() );
    return QStringList::split( "::", name ).last();
  }
  return e.tagName();
}
コード例 #21
0
/*! Extracts an layout name from \a e. It's stored in the 'name'
 property of the preceding sibling (the first child of a QLayoutWidget).
 */
QString Ui3Reader::getLayoutName(const QDomElement& e)
{
    QDomElement p = e.parentNode().toElement();
    QString name;

    if (getClassName(p) != QLatin1String("QLayoutWidget"))
        name = QLatin1String("Layout");

    QDomElement n = getObjectProperty(p, QLatin1String("name"));
    if (n.firstChild().toElement().tagName() == QLatin1String("cstring")) {
        name.prepend(n.firstChild().toElement().firstChild().toText().data());
        return name.split(QLatin1String("::")).last();
    }
    return e.tagName();
}
コード例 #22
0
ファイル: bb_track.cpp プロジェクト: Cubiicle/lmms
void bbTCO::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
	_this.setAttribute( "name", name() );
	if( _this.parentNode().nodeName() == "clipboard" )
	{
		_this.setAttribute( "pos", -1 );
	}
	else
	{
		_this.setAttribute( "pos", startPosition() );
	}
	_this.setAttribute( "len", length() );
	_this.setAttribute( "muted", isMuted() );
	_this.setAttribute( "color", m_color );
}
コード例 #23
0
bool LayerAttributes::getSvgElementID(QDomDocument * doc, ViewIdentifierClass::ViewIdentifier viewIdentifier, ViewLayer::ViewLayerID viewLayerID) {
	int layerCount;
	QDomElement layer = getSvgElementLayer(doc, viewIdentifier, viewLayerID, layerCount);
	m_multiLayer = (layerCount > 1);

	if (layer.isNull()) return false;
	if (layerCount == 0) return false;

	m_filename = layer.parentNode().toElement().attribute("image");
	if (m_filename.isNull()) return false;
	if (m_filename.isEmpty()) return false;

	m_canFlipVertical = layer.parentNode().parentNode().toElement().attribute("flipvertical").compare("true") == 0;
	m_canFlipHorizontal = layer.parentNode().parentNode().toElement().attribute("fliphorizontal").compare("true") == 0;

	m_layerName = layer.attribute("layerId");
	if (m_layerName.isNull()) return false;
	if (m_layerName.isEmpty()) return false;

	QString stickyVal = layer.attribute("sticky");
	m_sticky = stickyVal.compare("true", Qt::CaseInsensitive) == 0;

	return true;
}
コード例 #24
0
ファイル: XMLConfigLoader.cpp プロジェクト: nerd-toolkit/nerd
/**
 * Returns the path to the given XML Element in the document,
 * Example:
 *  <elem1>
 *    <elem2 />
 *  </elem1>
 *  
 *  Input: elem2
 *  Output: "elem1/elem2"
 * 
 * @return QString with the path to to the QDomElement.
 */
QString XMLConfigLoader::getFullPath(const QDomElement &element)
{
  QString path = element.tagName();
  
  QDomNode parent = element.parentNode();
  while(!parent.isNull())
  {
    if(parent.isElement() && !parent.parentNode().isDocument())
    {
      path = path.prepend(parent.toElement().tagName() + "/");
    }
    parent = parent.parentNode();
  }
  
  return path;
}
コード例 #25
0
bool XMLWriter::remove(TrollingObject* p_object)
{
    if(!loadDocument())
        return false;

    QDomElement trollingObject;
    int id = p_object->getId();

    if(!getTrollingObjectElement(trollingObject, id))
        return false;

    clearNodeContents(trollingObject);
    trollingObject.parentNode().removeChild(trollingObject);

    return saveDocument();
}
コード例 #26
0
ファイル: parserxml.cpp プロジェクト: jloaiza/NewDiglet
void parserxml::eraseNode(std::string pNodeDirection)
{
    if(isRoot(pNodeDirection))
    {
        _document.removeChild(_document.firstChild());
    }
    else
    {
        int index = getPositionChild(pNodeDirection);
        QDomElement child = tourXML(pNodeDirection);
        QDomElement childfather = child.parentNode().toElement();
        childfather.removeChild(childfather.elementsByTagName(QString::fromStdString(childNameExtract(pNodeDirection))).at(index));
    }
    qDebug() << "Nodo borrado con exito.";
    updateDocument();
}
コード例 #27
0
ファイル: xdgmenu.cpp プロジェクト: Alexandr-Galko/razor-qt
void XdgMenuPrivate::simplify(QDomElement& element)
{
    MutableDomElementIterator it(element);
    //it.toFront();
    while(it.hasNext())
    {
        QDomElement n = it.next();

        if (n.tagName() == "Name")
        {
            // The <Name> field must not contain the slash character ("/");
            // implementations should discard any name containing a slash.
            element.setAttribute("name", n.text().remove('/'));
            n.parentNode().removeChild(n);
        }

        // ......................................
        else if(n.tagName() == "Deleted")
        {
            element.setAttribute("deleted", true);
            n.parentNode().removeChild(n);
        }
        else if(n.tagName() == "NotDeleted")
        {
            element.setAttribute("deleted", false);
            n.parentNode().removeChild(n);
        }

        // ......................................
        else if(n.tagName() == "OnlyUnallocated")
        {
            element.setAttribute("onlyUnallocated", true);
            n.parentNode().removeChild(n);
        }
        else if(n.tagName() == "NotOnlyUnallocated")
        {
            element.setAttribute("onlyUnallocated", false);
            n.parentNode().removeChild(n);
        }

        // ......................................
        else if(n.tagName() == "FileInfo")
        {
            n.parentNode().removeChild(n);
        }

        // ......................................
        else if(n.tagName() == "Menu")
        {
            simplify(n);
        }

    }

}
コード例 #28
0
// stripExtraNS
//
// This function removes namespace information from various nodes for
// display purposes only (the element is pretty much useless for processing
// after this).  We do this because QXml is a bit overzealous about outputting
// redundant namespaces.
static QDomElement stripExtraNS(const QDomElement &e)
{
	// find closest parent with a namespace
	QDomNode par = e.parentNode();
	while(!par.isNull() && par.namespaceURI().isNull())
		par = par.parentNode();
	bool noShowNS = false;
	if(!par.isNull() && par.namespaceURI() == e.namespaceURI())
		noShowNS = true;

	// build qName (prefix:localName)
	QString qName;
	if(!e.prefix().isEmpty())
		qName = e.prefix() + ':' + e.localName();
	else
		qName = e.tagName();

	QDomElement i;
	int x;
	if(noShowNS)
		i = e.ownerDocument().createElement(qName);
	else
		i = e.ownerDocument().createElementNS(e.namespaceURI(), qName);

	// copy attributes
	QDomNamedNodeMap al = e.attributes();
	for(x = 0; x < al.count(); ++x) {
		QDomAttr a = al.item(x).cloneNode().toAttr();

		// don't show xml namespace
		if(a.namespaceURI() == NS_XML)
			i.setAttribute(QString("xml:") + a.name(), a.value());
		else
			i.setAttributeNodeNS(a);
	}

	// copy children
	QDomNodeList nl = e.childNodes();
	for(x = 0; x < nl.count(); ++x) {
		QDomNode n = nl.item(x);
		if(n.isElement())
			i.appendChild(stripExtraNS(n.toElement()));
		else
			i.appendChild(n.cloneNode());
	}
	return i;
}
コード例 #29
0
ファイル: deltool.cpp プロジェクト: jessikbarret/Valentina
//---------------------------------------------------------------------------------------------------------------------
DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent)
    : QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), doc(doc), toolId(id),
      cursor(doc->getCursor())
{
    setText(tr("Delete tool"));
    QDomElement domElement = doc->elementById(QString().setNum(id));
    if (domElement.isElement())
    {
        xml = domElement.cloneNode().toElement();
        parentNode = domElement.parentNode();
    }
    else
    {
        qDebug()<<"Can't get tool by id = "<<toolId<<Q_FUNC_INFO;
        return;
    }
}
コード例 #30
0
// emits the given QDomDocument for eventual plugins, checks after that
// if there are any relevance elements. If there are none, random search is
// implied and performed.
// finally, the search is actually started
void MrmlPart::performQuery( QDomDocument& doc )
{
    QDomElement mrml = doc.documentElement();

    emit aboutToStartQuery( doc ); // let plugins play with it :)

    // no items available? All "neutral"? -> random search

    QDomElement queryStep = KMrml::firstChildElement( mrml, "query-step" );
    bool randomSearch = false;

    if ( !queryStep.isNull() )
    {
        QDomElement relevanceList =
            KMrml::firstChildElement(queryStep, "user-relevance-element-list");
        QValueList<QDomElement> relevanceElements =
            KMrml::directChildElements( relevanceList,
                                        "user-relevance-element" );

        randomSearch = relevanceElements.isEmpty();

        if ( randomSearch )
        {
            m_random->setChecked( true );
            m_random->setEnabled( false );
            queryStep.setAttribute("query-type", "at-random");

            // remove user-relevance-element-list element for random search
            relevanceList.parentNode().removeChild( relevanceList );
        }
    }
    else
    {
        KMessageBox::error( m_view, i18n("Error formulating the query. The "
                                         "\"query-step\" element is missing."),
                            i18n("Query Error") );
    }

    m_job = transferJob( url() );
    slotSetStatusBar( randomSearch ? i18n("Random search...") :
                                     i18n("Searching...") );
    m_job->addMetaData( MrmlShared::kio_task(), MrmlShared::kio_startQuery() );
    qDebug("\n\nSending XML:\n%s", doc.toString().latin1());
    m_job->addMetaData( MrmlShared::mrml_data(), doc.toString() );
}