当前位置: 首页>>代码示例>>C++>>正文


C++ QDomDocument::elementsByTagName方法代码示例

本文整理汇总了C++中QDomDocument::elementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomDocument::elementsByTagName方法的具体用法?C++ QDomDocument::elementsByTagName怎么用?C++ QDomDocument::elementsByTagName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDomDocument的用法示例。


在下文中一共展示了QDomDocument::elementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setDownloadingThreadNodeValue

void XMLOperations::setDownloadingThreadNodeValue(QDomDocument &domDoc, QString URL, QList<SDownloadThread> nodeValue)
{
    QDomNodeList tmpList = domDoc.elementsByTagName("File");
    for (int i = 0; i < tmpList.count(); i ++)
    {
        //contentNode:子节点File下面包含的内容节点列表
        QDomNodeList contentNode = tmpList.item(i).toElement().childNodes();
        QDomNode tmpURLNode;
        QDomNode tmpTargeNode;
        for (int j = 0; j < contentNode.count(); j ++)
        {
            QString tmpTagName = contentNode.item(j).nodeName();
            if (tmpTagName == "URL")
                tmpURLNode = contentNode.item(j);
            else if (tmpTagName == "Threads")
                tmpTargeNode = contentNode.item(j);
            else
                continue;
        }
        if (tmpURLNode.toElement().text() == URL)
        {
            //Thread list
            QDomNodeList threadNodeList = tmpTargeNode.toElement().childNodes();
            if (threadNodeList.count() != nodeValue.count())
                return;
            for (int x = 0; x < threadNodeList.count(); x ++)
            {
                QDomNodeList targetNodeList = threadNodeList.item(x).toElement().childNodes();
                for (int y = 0; y < targetNodeList.count(); y ++)
                {
                    if (targetNodeList.item(y).toElement().nodeName() == "CompleteBlockCount"
                            && nodeValue.at(x).completedBlockCount != "")
                        targetNodeList.item(y).toElement().firstChild().setNodeValue(nodeValue.at(x).completedBlockCount);
                }
            }
            break;
        }
    }
}
开发者ID:Augus-Wang,项目名称:PointDownload,代码行数:39,代码来源:xmloperations.cpp

示例2: removeFromProjectFile

/*
  Remove a file from the project file.
  Don't delete the file.
*/
bool ProjectManager::removeFromProjectFile(const QString & projectPath, const QString & filePath)
{
  bool retval = false;
  QDomDocument doc;
  QDir dir(projectPath);
  QFile projectFile(dir.filePath(dir.dirName() + ".xml"));
  if (doc.setContent(&projectFile)) {
    projectFile.close();
    QDomNodeList files = doc.elementsByTagName("files").at(0).childNodes();
    for (int i = 0; i < files.count(); i++) {
      if (files.at(i).toElement().text() == dir.relativeFilePath(filePath)) {
        QDomNode parent = files.at(i).parentNode();
        parent.removeChild(files.at(i));
        if (projectFile.open(QIODevice::WriteOnly|QFile::Text)) {
          projectFile.write(doc.toByteArray(2));
          retval = true;
        }
      }
    }
  }
  return retval;
}
开发者ID:sanjog47,项目名称:makecontroller,代码行数:26,代码来源:ProjectManager.cpp

示例3: onRemoveFileRequest

/*
  Remove the file in the current project's project file.
  The file has already been removed from the filebrowser UI.
*/
void ProjectInfo::onRemoveFileRequest(QString filename)
{
  QFile projectFile(projectFilePath( ));
  QDomDocument doc;
  if(doc.setContent(&projectFile))
  {
    projectFile.close();
    QDomNodeList files = doc.elementsByTagName("files").at(0).childNodes();
    for(int i = 0; i < files.count(); i++)
    {
      if(files.at(i).toElement().text() == filename)
      {
        QDomNode parent = files.at(i).parentNode();
        parent.removeChild(files.at(i));
        if(projectFile.open(QIODevice::WriteOnly|QFile::Text))
          projectFile.write(doc.toByteArray());
        mainWindow->removeFileFromProject(filename);
        return;
      }
    }
  }
}
开发者ID:YTakami,项目名称:makecontroller,代码行数:26,代码来源:ProjectInfo.cpp

示例4: sentXMLDone

void ServerInterface::sentXMLDone()
{
    disconnect(m_reply, SIGNAL(finished()), this, SLOT(sentXMLDone()));
    m_reply->deleteLater();
    if(checkError())
    {
        QString doctype = m_getDoc.first();
        m_getDoc.removeFirst();
        m_getData.removeFirst();
        QByteArray response = m_reply->readAll();


        QDomDocument doc;

        if(doc.setContent(response))
        {
            QDomNodeList list = doc.elementsByTagName("TransactionTicket");
            if(list.count() == 1 &&
               list.at(0).isElement() &&
               list.at(0).hasChildNodes())
            {
                QDomElement element = list.at(0).toElement();
                QString text = element.childNodes().at(0).toText().nodeValue();
                emit commitFile(doctype, text.toInt());
            }
        }

        if(m_getDoc.isEmpty())
        {
            m_reply = NULL;
            emit commitDone();
        }
        else
        {
            sendXML();
        }
    }

}
开发者ID:capeisti,项目名称:uistelupaivakirja-desktop,代码行数:39,代码来源:serverinterface.cpp

示例5: parse

ChatStylePlistFileReader::Status ChatStylePlistFileReader::parse(const QDomDocument& document)
{
    QString key, value;
    QDomNodeList keyElements = document.elementsByTagName(QLatin1String("key"));

    for (int i = 0; i < keyElements.size(); i++) {
        if (keyElements.at(i).nextSibling().toElement().tagName() != QLatin1String("key")) {
            key = keyElements.at(i).toElement().text();
            QDomElement nextElement= keyElements.at(i).nextSibling().toElement();
            if (!nextElement.tagName().compare(QLatin1String("true"), Qt::CaseInsensitive)) {
                value = QLatin1String("1");
            } else if(!nextElement.tagName().compare(QLatin1String("false"), Qt::CaseInsensitive)) {
                value = QLatin1String("0");
            } else {
                value = nextElement.text();
            }
            d->data.insert(key, value);
        }
    }

    return Ok;
}
开发者ID:KDE,项目名称:ktp-text-ui,代码行数:22,代码来源:chat-style-plist-file-reader.cpp

示例6: getChildByTag

QDomElement BaseXMLVisitor::getChildByTag(const char *name)
{

    //qDebug("BaseXMLVisitor::getChildByTag(%s): called", name );
    QDomNode mainNode = mNodePath.back();
    if (mainNode.isNull()) {
        qDebug("  BaseXMLVisitor::getChildByTag(): path is null");
        return QDomElement();
    }

    if (mainNode.isElement())
    {
//        qDebug("  BaseXMLVisitor::getChildByTag(): path ends with element");

        QDomElement mainElement = mainNode.toElement();
        QDomNodeList nodesWithTag = mainElement.elementsByTagName(name);
        if (nodesWithTag.length() != 0)
        {
//            qDebug("  BaseXMLVisitor::getChildByTag(): found sub element");
            return nodesWithTag.at(0).toElement();
        }
        return QDomElement();
    }

    if (mainNode.isDocument())
    {
//        qDebug("  BaseXMLVisitor::getChildByTag(): path ends with document");
        QDomDocument mainDocument = mainNode.toDocument();
        QDomNodeList nodesWithTag = mainDocument.elementsByTagName(name);
        if (nodesWithTag.length() != 0)
        {
//            qDebug("  BaseXMLVisitor::getChildByTag(): found sub element");
            return nodesWithTag.at(0).toElement();
        }
        return QDomElement();
    }

    return QDomElement();
}
开发者ID:Aldrog,项目名称:corecvs,代码行数:39,代码来源:baseXMLVisitor.cpp

示例7: replyFinished

// --- Slots --------------------------------------------------------------- //
void PubChemQueryThread::replyFinished(QNetworkReply *reply)
{
    QByteArray replyData = reply->readAll();

    // check to see if the reply contains a request id. If it does
    // the PUG must be polled again.
    QDomDocument document;
    document.setContent(replyData, false);

    QDomNodeList nodes = document.elementsByTagName("PCT-Waiting_reqid");
    if(!nodes.isEmpty()){
        QDomNode node = nodes.at(0);
        QDomElement element = node.toElement();

        QString waitingId = element.text();
        poll(waitingId);
    }
    else{
        m_response = replyData;
        exit(0);
    }
}
开发者ID:NabilNoaman,项目名称:chemkit,代码行数:23,代码来源:pubchemquerythread.cpp

示例8: checkMissingCodecs

void Wizard::checkMissingCodecs()
{
    const QStringList acodecsList = KdenliveSettings::audiocodecs();
    const QStringList vcodecsList = KdenliveSettings::videocodecs();
    bool replaceVorbisCodec = false;
    if (acodecsList.contains("libvorbis")) replaceVorbisCodec = true;
    bool replaceLibfaacCodec = false;
    if (!acodecsList.contains("aac") && acodecsList.contains("libfaac")) replaceLibfaacCodec = true;
    
    QString exportFolder = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/export/";
    QDir directory = QDir(exportFolder);
    QStringList filter;
    filter << "*.xml";
    QStringList fileList = directory.entryList(filter, QDir::Files);
    // We should parse customprofiles.xml in last position, so that user profiles
    // can also override profiles installed by KNewStuff
    QStringList requiredACodecs;
    QStringList requiredVCodecs;
    foreach(const QString &filename, fileList) {
        QDomDocument doc;
        QFile file(exportFolder + filename);
        doc.setContent(&file, false);
        file.close();
        QString std;
        QString format;
        QDomNodeList profiles = doc.elementsByTagName("profile");
        for (int i = 0; i < profiles.count(); ++i) {
            std = profiles.at(i).toElement().attribute("args");
            format.clear();
            if (std.startsWith(QLatin1String("acodec="))) format = std.section("acodec=", 1, 1);
            else if (std.contains(" acodec=")) format = std.section(" acodec=", 1, 1);
            if (!format.isEmpty()) requiredACodecs << format.section(' ', 0, 0).toLower();
            format.clear();
            if (std.startsWith(QLatin1String("vcodec="))) format = std.section("vcodec=", 1, 1);
            else if (std.contains(" vcodec=")) format = std.section(" vcodec=", 1, 1);
            if (!format.isEmpty()) requiredVCodecs << format.section(' ', 0, 0).toLower();
        }
    }
开发者ID:rugubara,项目名称:kdenlive-15.08.1,代码行数:38,代码来源:wizard.cpp

示例9: mystream

QMap<QString,QString>  GraphicsWorkflow::extractSvgElements(const QString& xmltext) {
    QDomDocument doc;
    QMap<QString,QString>  result;

    bool isopen = doc.setContent(xmltext);
    if ( !isopen) {
        SafetYAWL::streamlog
                << SafetLog::Error
                << tr("Se presentó un error al tratar de extraer los elementos del archivo de flujo "
                      "de trabajo tipo SVG");
        return result;
    }

    QDomNodeList list = doc.elementsByTagName("g");

    for(int i = 0; i < list.count();i++) {
        QString nodeid, nodetext;
        QTextStream mystream(&nodetext);

        QDomNode node = list.at(i);
        QDomNamedNodeMap attrs = node.attributes();
        nodeid =  attrs.namedItem("id").nodeValue().trimmed();
        if ( nodeid != "graph0") {
            node.save(mystream,0);
            mystream.flush();
//            SafetYAWL::streamlog
//                    << SafetLog::Debug
//                    << tr("Grafico SVG nodetext numero \"%2\": \"%1\"")
//                    .arg(nodetext)
//                    .arg(i);
            QString newdoc = Safet::templateSVGString1.arg(nodetext);
            //result[nodeid] = localeNormalize(newdoc);
            result[nodeid] = newdoc;

        }
    }
    return result;
}
开发者ID:Cenditel,项目名称:pysafet,代码行数:38,代码来源:graphicsworkflow.cpp

示例10: MergeXml

void XmlSettingsDialog::MergeXml (const QByteArray& newXml)
{
	QDomDocument newDoc;
	newDoc.setContent (newXml);

	QList<QByteArray> props = WorkingObject_->dynamicPropertyNames ();

	QDomNodeList nodes = newDoc.elementsByTagName ("item");
	for (int i = 0; i < nodes.size (); ++i)
	{
		QDomElement elem = nodes.at (i).toElement ();
		if (elem.isNull ())
			continue;

		QString propName = elem.attribute ("property");
		if (!props.contains (propName.toLatin1 ()))
			continue;

		QVariant value = GetValue (elem);
		if (value.isNull ())
			continue;

		WorkingObject_->setProperty (propName.toLatin1 ().constData (), value);

		QWidget *object = findChild<QWidget*> (propName);
		if (!object)
		{
			qWarning () << Q_FUNC_INFO
				<< "could not find object for property"
				<< propName;
			continue;
		}
		HandlersManager_->SetValue (object, value);
	}

	UpdateXml ();
	HandlersManager_->ClearNewValues ();
}
开发者ID:,项目名称:,代码行数:38,代码来源:

示例11: doCredit

int YourPayProcessor::doCredit(const int pccardid, const int pcvv, const double pamount, const double ptax, const bool ptaxexempt, const double pfreight, const double pduty, const int pcurrid, QString &pneworder, QString &preforder, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("YP:doCredit(%d, %d, %f, %f, %d, %f, %f, %d, %s, %s, %d)",
	   pccardid, pcvv, pamount, ptax, ptaxexempt, pfreight, pduty, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

  int returnValue = 0;
  double amount = currToCurr(pcurrid, _ypcurrid, pamount, &returnValue);
  if (returnValue < 0)
    return returnValue;

  QDomDocument request;

  returnValue = buildCommon(pccardid, pcvv, amount, request, "CREDIT");
  if (returnValue !=  0)
    return returnValue;

  QDomElement elem = request.createElement("transactiondetails");
  request.documentElement().appendChild(elem);
  CREATECHILDTEXTNODE(elem, "oid",              preforder);
  CREATECHILDTEXTNODE(elem, "reference_number", pneworder);
  CREATECHILDTEXTNODE(elem, "terminaltype",     "UNSPECIFIED");
  CREATECHILDTEXTNODE(elem, "taxexempt",        ptaxexempt ? "Y" : "N");

  CREATECHILDTEXTNODE(request.elementsByTagName("payment").at(0),
		      "tax", QString::number(ptax));

  QString response;
  returnValue = sendViaHTTP(request.toString(), response);
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "R", pamount, pcurrid,
			       pneworder, preforder, pccpayid, pparams);

  return returnValue;
}
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:38,代码来源:yourpayprocessor.cpp

示例12: addToProjectFile

/*
  Add a filepath to this project's file list.
  It's path should be relative to the project directory.
*/
bool ProjectManager::addToProjectFile(const QString & projectPath, const QString & newFilePath)
{
  bool retval = false;
  QDomDocument newProjectDoc;
  QDir projectDir(projectPath);
  QFile projectFile(projectDir.filePath(projectDir.dirName() + ".xml"));
  // read in the existing file, and add a node to the "files" section
  if (newProjectDoc.setContent(&projectFile)) {
    projectFile.close();
    QDomElement newFileElement = newProjectDoc.createElement("file");
    QDomText newFilePathElement = newProjectDoc.createTextNode(projectDir.relativeFilePath(newFilePath));
    newFileElement.appendChild(newFilePathElement);
    newProjectDoc.elementsByTagName("files").at(0).toElement().appendChild(newFileElement);

    // write our newly manipulated file
    if (projectFile.open(QIODevice::WriteOnly | QFile::Text)) { // reopen as WriteOnly
      projectFile.write(newProjectDoc.toByteArray(2));
      projectFile.close();
      retval = true;
    }
  }
  return retval;
}
开发者ID:sanjog47,项目名称:makecontroller,代码行数:27,代码来源:ProjectManager.cpp

示例13: readProject

void QgsMapCanvas::readProject( const QDomDocument & doc )
{
  QDomNodeList nodes = doc.elementsByTagName( "mapcanvas" );
  if ( nodes.count() )
  {
    QDomNode node = nodes.item( 0 );

    QgsMapSettings tmpSettings;
    tmpSettings.readXML( node );
    setMapUnits( tmpSettings.mapUnits() );
    setCrsTransformEnabled( tmpSettings.hasCrsTransformEnabled() );
    setDestinationCrs( tmpSettings.destinationCrs() );
    setExtent( tmpSettings.extent() );
    setRotation( tmpSettings.rotation() );
    mSettings.datumTransformStore() = tmpSettings.datumTransformStore();

    clearExtentHistory(); // clear the extent history on project load
  }
  else
  {
    QgsDebugMsg( "Couldn't read mapcanvas information from project" );
  }
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:23,代码来源:qgsmapcanvas.cpp

示例14: on_mImportColorsButton_clicked

void QgsRasterTerrainAnalysisDialog::on_mImportColorsButton_clicked()
{
  QString file = QFileDialog::getOpenFileName( 0, tr( "Import Colors and elevations from xml" ), QDir::homePath() );
  if ( file.isEmpty() )
  {
    return;
  }

  QFile inputFile( file );
  if ( !inputFile.open( QIODevice::ReadOnly ) )
  {
    QMessageBox::critical( 0, tr( "Error opening file" ), tr( "The relief color file could not be opened" ) );
    return;
  }

  QDomDocument doc;
  if ( !doc.setContent( &inputFile, false ) )
  {
    QMessageBox::critical( 0, tr( "Error parsing xml" ), tr( "The xml file could not be loaded" ) );
    return;
  }

  mReliefClassTreeWidget->clear();

  QDomNodeList reliefColorList = doc.elementsByTagName( "ReliefColor" );
  for ( int i = 0; i < reliefColorList.size(); ++i )
  {
    QDomElement reliefColorElem = reliefColorList.at( i ).toElement();
    QTreeWidgetItem* newItem = new QTreeWidgetItem();
    newItem->setText( 0, reliefColorElem.attribute( "MinElevation" ) );
    newItem->setText( 1, reliefColorElem.attribute( "MaxElevation" ) );
    newItem->setBackground( 2, QBrush( QColor( reliefColorElem.attribute( "red" ).toInt(), reliefColorElem.attribute( "green" ).toInt(),
                                       reliefColorElem.attribute( "blue" ).toInt() ) ) );
    mReliefClassTreeWidget->addTopLevelItem( newItem );
  }
}
开发者ID:stevenmizuno,项目名称:QGIS,代码行数:36,代码来源:qgsrasterterrainanalysisdialog.cpp

示例15: loadEnums

void ConfigLoader::loadEnums(QDomDocument const &config)
{
    Reflection *result = new ReflectionGen();
    result->name = ReflectionNaming("enums", NULL, NULL);

    QDomNodeList enums = config.elementsByTagName("enum");
    for (unsigned i = 0; i < enums.length(); i++)
    {
        QDomElement enumElement = enums.at(i).toElement();
        EnumReflection *enumReflection = new EnumReflection();
        enumReflection->name = getNamingFromXML(enumElement);

        QDomNodeList items = enumElement.elementsByTagName("item");
        for (unsigned j = 0; j < items.length(); j++)
        {
            QDomElement itemElement = items.at(j).toElement();
            int id = itemElement.attribute("id").toInt();
            enumReflection->options.push_back(new EnumOption(id, getNamingFromXML(itemElement)));
        }

        // TODO: add support for comment and description
        mEnums.insert(QString(enumReflection->name.name), enumReflection);
    }
}
开发者ID:Pechckin,项目名称:test,代码行数:24,代码来源:configLoader.cpp


注:本文中的QDomDocument::elementsByTagName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。