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


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

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


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

示例1: ParsePackage

	PackageInfo ParsePackage (const QByteArray& data,
			const QUrl& baseUrl,
			const QString& packageName,
			const QStringList& packageVersions)
	{
		QDomDocument doc;
		QString msg;
		int line = 0;
		int column = 0;
		if (!doc.setContent (data, &msg, &line, &column))
		{
			qWarning () << Q_FUNC_INFO
					<< "erroneous document with msg"
					<< msg
					<< line
					<< column
					<< data;
			throw std::runtime_error ("Unagle to parse package description.");
		}

		PackageInfo packageInfo;

		QDomElement package = doc.documentElement ();

		QString type = package.attribute ("type");
		if (type == "iconset")
			packageInfo.Type_ = PackageInfo::TIconset;
		else if (type == "translation")
			packageInfo.Type_ = PackageInfo::TTranslation;
		else if (type == "plugin")
			packageInfo.Type_ = PackageInfo::TPlugin;
		else if (type == "theme")
			packageInfo.Type_ = PackageInfo::TTheme;
		else
			packageInfo.Type_ = PackageInfo::TData;

		packageInfo.Language_ = package.attribute ("language");
		packageInfo.Name_ = packageName;
		packageInfo.Versions_ = packageVersions;
		packageInfo.Description_ = package.firstChildElement ("description").text ();
		packageInfo.LongDescription_ = package.firstChildElement ("long").text ();

		QDomElement images = package.firstChildElement ("images");
		QDomElement imageNode = images.firstChildElement ("thumbnail");
		while (!imageNode.isNull ())
		{
			Image image =
			{
				Image::TThumbnail,
				MakeProperURL (imageNode.attribute ("url"), baseUrl)
			};
			packageInfo.Images_ << image;
			imageNode = imageNode.nextSiblingElement ("thumbnail");
		}
		imageNode = images.firstChildElement ("screenshot");
		while (!imageNode.isNull ())
		{
			Image image =
			{
				Image::TScreenshot,
				MakeProperURL (imageNode.attribute ("url"), baseUrl)
			};
			packageInfo.Images_ << image;
			imageNode = imageNode.nextSiblingElement ("screenshot");
		}
		packageInfo.IconURL_ = images.firstChildElement ("icon").attribute ("url");

		QDomElement tags = package.firstChildElement ("tags");
		QDomElement tagNode = tags.firstChildElement ("tag");
		while (!tagNode.isNull ())
		{
			packageInfo.Tags_ << tagNode.text ();
			tagNode = tagNode.nextSiblingElement ("tag");
		}

		QDomElement verNode = package.firstChildElement ("versions")
				.firstChildElement ("version");
		while (!verNode.isNull ())
		{
			if (verNode.hasAttribute ("size"))
			{
				bool ok = false;
				qint64 size = verNode.attribute ("size").toLong (&ok);
				if (ok)
					packageInfo.PackageSizes_ [verNode.text ()] = size;
			}

			packageInfo.VersionArchivers_ [verNode.text ()] =
					verNode.attribute ("archiver", "gz");

			verNode = verNode.nextSiblingElement ("version");
		}

		QDomElement maintNode = package.firstChildElement ("maintainer");
		packageInfo.MaintName_ = maintNode.firstChildElement ("name").text ();
		packageInfo.MaintEmail_ = maintNode.firstChildElement ("email").text ();

		QDomElement depends = package.firstChildElement ("depends");
		QDomElement dependNode = depends.firstChildElement ("depend");
		while (!dependNode.isNull ())
//.........这里部分代码省略.........
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:101,代码来源:xmlparsers.cpp

示例2: capabilitiesReplyFinished

void QgsWFSConnection::capabilitiesReplyFinished()
{
  // handle network errors
  if ( mCapabilitiesReply->error() != QNetworkReply::NoError )
  {
    mErrorCode = QgsWFSConnection::NetworkError;
    mErrorMessage = mCapabilitiesReply->errorString();
    emit gotCapabilities();
    return;
  }

  // handle HTTP redirects
  QVariant redirect = mCapabilitiesReply->attribute( QNetworkRequest::RedirectionTargetAttribute );
  if ( !redirect.isNull() )
  {
    QgsDebugMsg( "redirecting to " + redirect.toUrl().toString() );
    QNetworkRequest request( redirect.toUrl() );
    request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork );
    request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );

    mCapabilitiesReply->deleteLater();
    mCapabilitiesReply = QgsNetworkAccessManager::instance()->get( request );

    connect( mCapabilitiesReply, SIGNAL( finished() ), this, SLOT( capabilitiesReplyFinished() ) );
    return;
  }

  QByteArray buffer = mCapabilitiesReply->readAll();

  QgsDebugMsg( "parsing capabilities: " + buffer );

  // parse XML
  QString capabilitiesDocError;
  QDomDocument capabilitiesDocument;
  if ( !capabilitiesDocument.setContent( buffer, true, &capabilitiesDocError ) )
  {
    mErrorCode = QgsWFSConnection::XmlError;
    mErrorMessage = capabilitiesDocError;
    emit gotCapabilities();
    return;
  }

  QDomElement doc = capabilitiesDocument.documentElement();

  // hangle exceptions
  if ( doc.tagName() == "ExceptionReport" )
  {
    QDomNode ex = doc.firstChild();
    QString exc = ex.toElement().attribute( "exceptionCode", "Exception" );
    QDomElement ext = ex.firstChild().toElement();
    mErrorCode = QgsWFSConnection::ServerExceptionError;
    mErrorMessage = exc + ": " + ext.firstChild().nodeValue();
    emit gotCapabilities();
    return;
  }

  mCaps.clear();

  // get the <FeatureType> elements
  QDomNodeList featureTypeList = capabilitiesDocument.elementsByTagNameNS( WFS_NAMESPACE, "FeatureType" );
  for ( unsigned int i = 0; i < featureTypeList.length(); ++i )
  {
    FeatureType featureType;
    QDomElement featureTypeElem = featureTypeList.at( i ).toElement();

    //Name
    QDomNodeList nameList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "Name" );
    if ( nameList.length() > 0 )
    {
      featureType.name = nameList.at( 0 ).toElement().text();
    }
    //Title
    QDomNodeList titleList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "Title" );
    if ( titleList.length() > 0 )
    {
      featureType.title = titleList.at( 0 ).toElement().text();
    }
    //Abstract
    QDomNodeList abstractList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "Abstract" );
    if ( abstractList.length() > 0 )
    {
      featureType.abstract = abstractList.at( 0 ).toElement().text();
    }

    //DefaultSRS is always the first entry in the feature srs list
    QDomNodeList defaultCRSList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "DefaultSRS" );
    if ( defaultCRSList.length() > 0 )
    {
      featureType.crslist.append( defaultCRSList.at( 0 ).toElement().text() );
    }

    //OtherSRS
    QDomNodeList otherCRSList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "OtherSRS" );
    for ( unsigned int i = 0; i < otherCRSList.length(); ++i )
    {
      featureType.crslist.append( otherCRSList.at( i ).toElement().text() );
    }

    //Support <SRS> for compatibility with older versions
    QDomNodeList srsList = featureTypeElem.elementsByTagNameNS( WFS_NAMESPACE, "SRS" );
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: dropMimeData

bool QgsLegendModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
{
  Q_UNUSED( action );
  Q_UNUSED( column );

  if ( !data->hasFormat( "text/xml" ) )
  {
    return false;
  }

  QStandardItem* dropIntoItem = 0;
  if ( parent.isValid() )
  {
    dropIntoItem = itemFromIndex( parent );
  }
  else
  {
    dropIntoItem = invisibleRootItem();
  }

  //get XML doc
  QByteArray encodedData = data->data( "text/xml" );
  QDomDocument xmlDoc;
  xmlDoc.setContent( encodedData );

  QDomElement dragDataElem = xmlDoc.documentElement();
  if ( dragDataElem.tagName() != "LegendModelDragData" )
  {
    return false;
  }

  QDomNodeList nodeList = dragDataElem.childNodes();
  int nChildNodes = nodeList.size();
  QDomElement currentElem;
  QString currentTagName;
  QgsComposerLegendItem* currentItem = 0;

  for ( int i = 0; i < nChildNodes; ++i )
  {
    currentElem = nodeList.at( i ).toElement();
    if ( currentElem.isNull() )
    {
      continue;
    }
    currentTagName = currentElem.tagName();
    if ( currentTagName == "LayerItem" )
    {
      currentItem = new QgsComposerLayerItem();
    }
    else if ( currentTagName == "GroupItem" )
    {
      currentItem = new QgsComposerGroupItem();
    }
    else
    {
      continue;
    }
    currentItem->readXML( currentElem );
    if ( row < 0 )
    {
      dropIntoItem->insertRow( dropIntoItem->rowCount(), currentItem );
    }
    else
    {
      dropIntoItem->insertRow( row + i, currentItem );
    }
  }
  emit layersChanged();
  return true;
}
开发者ID:lordi,项目名称:Quantum-GIS,代码行数:70,代码来源:qgslegendmodel.cpp

示例4: parseTracks

void Rss::parseTracks(QNetworkReply *reply) {
    if (!reply) {
        std::cout << qPrintable(QString("{\"error\": \"%1\"}").arg(tr("Network error")));
        QCoreApplication::exit(1);
        return;
    }
    
    if (reply->error() != QNetworkReply::NoError) {
        reply->deleteLater();
        std::cout << qPrintable(QString("{\"error\": \"%1: %2\"}").arg(tr("Network error")).arg(reply->errorString()));
        QCoreApplication::exit(1);
        return;
    }
    
    QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
    
    if (!redirect.isNull()) {
        reply->deleteLater();
        
        if (m_redirects < MAX_REDIRECTS) {
            followRedirect(redirect.toString());
        }
        else {
            std::cout << qPrintable(QString("{\"error\": \"%1: %2\"}").arg(tr("Network error"))
                                                                .arg(tr("Maximum redirects reached")));
            QCoreApplication::exit(1);
        }
        
        return;
    }
    
    QDomDocument doc;    
    
    if (!doc.setContent(reply->readAll(), true)) {
        reply->deleteLater();
        std::cout << qPrintable(QString("{\"error\": \"%1\"}").arg(tr("Unable to parse XML")));
        QCoreApplication::exit(1);
        return;
    }
    
    QDomElement docElem = doc.documentElement();
    QDomNodeList items = docElem.elementsByTagName("item");
    QDomNode channelElem = docElem.firstChildElement("channel");
    QString thumbnailUrl = channelElem.firstChildElement("image").attribute("href");
    QString genre = channelElem.firstChildElement("category").attribute("text");
    
    for (int i = 0; i < items.size(); i++) {
        QDomElement item = items.at(i).toElement();
        QDateTime dt = QDateTime::fromString(item.firstChildElement("pubDate").text().section(' ', 0, -2),
                                               "ddd, dd MMM yyyy hh:mm:ss");
        QString streamUrl = item.firstChildElement("enclosure").attribute("url");
        
        QVariantMap result;
        result["_dt"] = dt;
        result["artist"] = item.firstChildElement("author").text();
        result["date"] = dt.toString("dd MMM yyyy");
        result["description"] = item.firstChildElement("description").text();
        result["duration"] = item.firstChildElement("duration").text();
        result["format"] = streamUrl.mid(streamUrl.lastIndexOf('.') + 1).toUpper();
        result["genre"] = genre;
        result["id"] = reply->url();
        result["largeThumbnailUrl"] = thumbnailUrl;
        result["streamUrl"] = streamUrl;
        result["thumbnailUrl"] = thumbnailUrl;
        result["title"] = item.firstChildElement("title").text();
        result["url"] = item.firstChildElement("link").text();
        m_results << result;
    }
    
    reply->deleteLater();
    
    if (m_urls.isEmpty()) {
        printResult();
    }
    else {
        listTracks(m_urls.takeFirst());
    }
}
开发者ID:vakkov,项目名称:musikloud2,代码行数:78,代码来源:rss.cpp

示例5: on_UpdateListBtn_clicked

///
/// Download and update the drumkit list
///
void SoundLibraryImportDialog::on_UpdateListBtn_clicked()
{
	QApplication::setOverrideCursor(Qt::WaitCursor);
	DownloadWidget drumkitList( this, trUtf8( "Updating SoundLibrary list..." ), repositoryCombo->currentText() );
	drumkitList.exec();

	m_soundLibraryList.clear();

	QString sDrumkitXML = drumkitList.get_xml_content();

	QDomDocument dom;
	dom.setContent( sDrumkitXML );
	QDomNode drumkitNode = dom.documentElement().firstChild();
	while ( !drumkitNode.isNull() ) {
		if( !drumkitNode.toElement().isNull() ) {

			if ( drumkitNode.toElement().tagName() == "drumkit" || drumkitNode.toElement().tagName() == "song" || drumkitNode.toElement().tagName() == "pattern" ) {

				SoundLibraryInfo soundLibInfo;
			
				if ( drumkitNode.toElement().tagName() =="song" ) {
					soundLibInfo.setType( "song" );
				}

				if ( drumkitNode.toElement().tagName() =="drumkit" ) {
					soundLibInfo.setType( "drumkit" );
				}

				if ( drumkitNode.toElement().tagName() =="pattern" ) {
					soundLibInfo.setType( "pattern" );
				}

				QDomElement nameNode = drumkitNode.firstChildElement( "name" );
				if ( !nameNode.isNull() ) {
					soundLibInfo.setName( nameNode.text() );
				}

				QDomElement urlNode = drumkitNode.firstChildElement( "url" );
				if ( !urlNode.isNull() ) {
					soundLibInfo.setUrl( urlNode.text() );
				}

				QDomElement infoNode = drumkitNode.firstChildElement( "info" );
				if ( !infoNode.isNull() ) {
					soundLibInfo.setInfo( infoNode.text() );
				}

				QDomElement authorNode = drumkitNode.firstChildElement( "author" );
				if ( !authorNode.isNull() ) {
					soundLibInfo.setAuthor( authorNode.text() );
				}

				QDomElement licenseNode = drumkitNode.firstChildElement( "license" );
				if ( !licenseNode.isNull() ) {
					soundLibInfo.setLicense( licenseNode.text() );
				}

				m_soundLibraryList.push_back( soundLibInfo );
			}
		}
		drumkitNode = drumkitNode.nextSibling();
	}

	updateSoundLibraryList();
	QApplication::restoreOverrideCursor();
}
开发者ID:GregoryBonik,项目名称:hydrogen,代码行数:69,代码来源:SoundLibraryImportDialog.cpp

示例6: registerType

//!
//! Loads the XML description of a widget type from the file with the given
//! name.
//!
//! \param filename The name of an XML file describing a widget type.
//!
bool WidgetFactory::registerType ( const QString &filename )
{
	QFile file (filename);
    if (!file.exists()) {
        Log::error(QString("widget plugin file not found: \"%1\"").arg(filename), "WidgetFactory::registerType");
        return false;
    }
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        Log::error(QString("Error loading widget plugin file \"%1\".").arg(filename), "WidgetFactory::registerType");
        return false;
    }

    // read the content of the file using a simple XML reader
    QDomDocument description;
    QXmlInputSource source (&file);
    QXmlSimpleReader xmlReader;
    QString errorMessage;
    int errorLine = 0;
    int errorColumn = 0;
    if (!description.setContent(&source, &xmlReader, &errorMessage, &errorLine, &errorColumn)) {
        Log::error(QString("Error parsing \"%1\": %2, line %3, char %4").arg(filename).arg(errorMessage).arg(errorLine).arg(errorColumn), "WidgetFactory::registerType");
        return false;
    }

    // obtain node type information from attributes
    QDomElement rootElement = description.documentElement();
    QString PluginName = rootElement.attribute("name");
    QString PluginDLL = rootElement.attribute("plugin");
	QString PluginCall = rootElement.attribute("call");


	//// decode the full filename into its path and base file name
    QString filePath = file.fileName().mid(0, file.fileName().lastIndexOf('/') + 1);
    QString baseFilename = file.fileName().mid(file.fileName().lastIndexOf('/') + 1);
    Log::debug(QString("Parsing \"%1\"...").arg(baseFilename), "WidgetFactory::registerType");

    // load plugin if a plugin filename is given
    if (filename != "") {
        QString pluginFilename =  filePath  + PluginDLL;

#ifdef _DEBUG
        // adjust the plugin filename to load the debug version of the DLL
        pluginFilename = pluginFilename.replace(".dll", "_d.dll");
#endif
        if (QFile::exists(pluginFilename)) {
            Log::debug(QString("Loading plugin \"%1\"...").arg(pluginFilename), "WidgetFactory::registerType");
            QPluginLoader loader (pluginFilename);
            WidgetTypeInterface *widgetTypeInterface = qobject_cast<WidgetTypeInterface *>(loader.instance());
            if (!widgetTypeInterface) {
                Log::error(QString("Plugin \"%1\" could not be loaded: %2").arg(pluginFilename).arg(loader.errorString()), "WidgetFactory::registerType");
                return false;
            }
			if(!m_widgetTypeMap.contains(PluginCall)){
				m_widgetTypeMap[PluginCall] = widgetTypeInterface;
			}
        } else {
            Log::error(QString("Plugin file \"%1\" could not be found.").arg(pluginFilename), "WidgetFactory::registerType");
            return false;
        }
    }

    return true;
}
开发者ID:banduladh,项目名称:levelfour,代码行数:69,代码来源:WidgetFactory.cpp

示例7: layerBoundingBoxInProjectCRS

QgsRectangle QgsServerProjectParser::layerBoundingBoxInProjectCRS( const QDomElement& layerElem, const QDomDocument &doc ) const
{
  QgsRectangle BBox;
  if ( layerElem.isNull() )
  {
    return BBox;
  }

  //read box coordinates and layer auth. id
  QDomElement boundingBoxElem = layerElem.firstChildElement( "BoundingBox" );
  if ( boundingBoxElem.isNull() )
  {
    return BBox;
  }

  double minx, miny, maxx, maxy;
  bool conversionOk;
  minx = boundingBoxElem.attribute( "minx" ).toDouble( &conversionOk );
  if ( !conversionOk )
  {
    return BBox;
  }
  miny = boundingBoxElem.attribute( "miny" ).toDouble( &conversionOk );
  if ( !conversionOk )
  {
    return BBox;
  }
  maxx = boundingBoxElem.attribute( "maxx" ).toDouble( &conversionOk );
  if ( !conversionOk )
  {
    return BBox;
  }
  maxy = boundingBoxElem.attribute( "maxy" ).toDouble( &conversionOk );
  if ( !conversionOk )
  {
    return BBox;
  }


  QString version = doc.documentElement().attribute( "version" );

  //create layer crs
  const QgsCoordinateReferenceSystem& layerCrs = QgsCRSCache::instance()->crsByAuthId( boundingBoxElem.attribute( version == "1.1.1" ? "SRS" : "CRS" ) );
  if ( !layerCrs.isValid() )
  {
    return BBox;
  }

  BBox.setXMinimum( minx );
  BBox.setXMaximum( maxx );
  BBox.setYMinimum( miny );
  BBox.setYMaximum( maxy );

  if ( version != "1.1.1" && layerCrs.axisInverted() )
  {
    BBox.invert();
  }

  //get project crs
  const QgsCoordinateReferenceSystem& projectCrs = projectCRS();
  QgsCoordinateTransform t( layerCrs, projectCrs );

  //transform
  BBox = t.transformBoundingBox( BBox );
  return BBox;
}
开发者ID:Naisha634,项目名称:QGIS,代码行数:66,代码来源:qgsserverprojectparser.cpp

示例8: setProjectSettingsXML

bool OpenCLTraceOptions::setProjectSettingsXML(const gtString& projectAsXMLString)
{
    QString qtStr = acGTStringToQString(projectAsXMLString);

    QDomDocument doc;
    doc.setContent(qtStr.toUtf8());

    QDomElement rootElement = doc.documentElement();
    QDomNode rootNode = rootElement.firstChild();
    QDomNode childNode = rootNode.firstChild();

    QString nodeVal;
    bool val;

    while (!childNode.isNull())
    {
        val = false;
        nodeVal = childNode.firstChild().nodeValue();

        if (nodeVal == "T")
        {
            val = true;
        }

        if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsGenerateOccupancy))
        {
            m_currentSettings.m_generateKernelOccupancy = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsShowErrorCode))
        {
            m_currentSettings.m_alwaysShowAPIErrorCode = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsCollapseClGetEventInfo))
        {
            m_currentSettings.m_collapseClGetEventInfo = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsEnableNavigation))
        {
            m_currentSettings.m_generateSymInfo = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsGenerateSummaryPage))
        {
            m_currentSettings.m_generateSummaryPage = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIsToFilter))
        {
            m_currentSettings.m_filterAPIsToTrace = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsMaxAPIs))
        {
            m_currentSettings.m_maxAPICalls = nodeVal.toInt();
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsWriteDataTimeOut))
        {
            m_currentSettings.m_writeDataTimeOut = val;
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsTimeOutInterval))
        {
            m_currentSettings.m_timeoutInterval = nodeVal.toInt();
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIType))
        {
            if (nodeVal == acGTStringToQString(GPU_STR_ProjectSettingsAPITypeOpenCL))
            {
                m_currentSettings.m_apiToTrace = APIToTrace_OPENCL;
            }
            else if (nodeVal == acGTStringToQString(GPU_STR_ProjectSettingsAPITypeHSA))
            {
                m_currentSettings.m_apiToTrace = APIToTrace_HSA;
            }
            else
            {
                m_currentSettings.m_apiToTrace = APIToTrace_OPENCL;
                GT_ASSERT_EX(false, L"Invalid project settings option");
            }
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsRulesTree))
        {
            if (childNode.hasChildNodes())
            {
                UpdateTreeWidgetFromXML(childNode, m_pAPIRulesTW, false);
            }
            else
            {
                if (m_pAPIRulesTW != nullptr)
                {
                    Util::SetCheckState(m_pAPIRulesTW, true);
                }
            }

            UpdateRuleList();
        }
        else if (childNode.nodeName() == acGTStringToQString(GPU_STR_ProjectSettingsAPIsFilterTree))
        {
            if (childNode.hasChildNodes())
            {
                UpdateTreeWidgetFromXML(childNode, m_pAPIsToTraceTW, true);
            }
            else
            {
//.........这里部分代码省略.........
开发者ID:PlusChie,项目名称:CodeXL,代码行数:101,代码来源:OpenCLTraceSettingPage.cpp

示例9: on_pbtnLoadPredefinedQueries_clicked

/**
* Slot called when pbtnLoadPredefinedQueries button is pressed. The method will open a file dialog and then
* try to parse through an XML file of predefined queries.
*/
void eVisDatabaseConnectionGui::on_pbtnLoadPredefinedQueries_clicked()
{
  //There probably needs to be some more error checking, but works for now.

  //Select the XML file to parse
  QString myFilename = QFileDialog::getOpenFileName( this, tr( "Open File" ), ".", "XML ( *.xml )" );
  if ( myFilename != "" )
  {
    //Display the name of the file being parsed
    lblPredefinedQueryFilename->setText( myFilename );

    //If the file exists load it into a QDomDocument
    QFile myInputFile( myFilename );
    if ( myInputFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
    {
      QString errorString;
      int errorLine;
      int errorColumn;
      QDomDocument myXmlDoc;
      if ( myXmlDoc.setContent( &myInputFile, &errorString, &errorLine, &errorColumn ) )
      {
        //clear any existing query descrptions
        cboxPredefinedQueryList->clear();
        if ( !mQueryDefinitionMap->empty() )
        {
          delete( mQueryDefinitionMap );
          mQueryDefinitionMap = new QMap<int, eVisQueryDefinition>;
        }

        //Loop through each child looking for a query tag
        int myQueryCount = 0;
        QDomNode myNode = myXmlDoc.documentElement().firstChild();
        while ( !myNode.isNull() )
        {
          if ( myNode.toElement().tagName() == "query" )
          {
            bool insert = false;
            eVisQueryDefinition myQueryDefinition;
            QDomNode myChildNodes = myNode.toElement().firstChild();
            while ( !myChildNodes.isNull() )
            {
              QDomNode myDataNode = myChildNodes.toElement().firstChild();
              QString myDataNodeContent = "";
              if ( !myDataNode.isNull() )
              {
                myDataNodeContent = myDataNode.toText().data();
              }

              if ( myChildNodes.toElement().tagName() == "shortdescription" )
              {
                if ( myDataNodeContent != "" )
                {
                  myQueryDefinition.setShortDescription( myDataNodeContent );
                  myQueryCount++;
                  insert = true;
                }
              }
              else if ( myChildNodes.toElement().tagName() == "description" )
              {
                myQueryDefinition.setDescription( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "databasetype" )
              {
                myQueryDefinition.setDatabaseType( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "databasehost" )
              {
                myQueryDefinition.setDatabaseHost( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "databaseport" )
              {
                myQueryDefinition.setDatabasePort( myDataNodeContent.toInt() );
              }
              else if ( myChildNodes.toElement().tagName() == "databasename" )
              {
                myQueryDefinition.setDatabaseName( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "databaseusername" )
              {
                myQueryDefinition.setDatabaseUsername( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "databasepassword" )
              {
                myQueryDefinition.setDatabasePassword( myDataNodeContent );
              }
              else if ( myChildNodes.toElement().tagName() == "sqlstatement" )
              {
                myQueryDefinition.setSqlStatement( myDataNodeContent );
              }

              myChildNodes = myChildNodes.nextSibling();
            } //end  while( !myChildNodes.isNull() )

            if ( insert )
            {
              mQueryDefinitionMap->insert( myQueryCount - 1, myQueryDefinition );
//.........这里部分代码省略.........
开发者ID:ACorradini,项目名称:QGIS,代码行数:101,代码来源:evisdatabaseconnectiongui.cpp

示例10: metadataElement

 QDomElement metadataElement( const QDomDocument& document )
 {
     QDomElement root = document.documentElement();
     return root.firstChildElement( "metadata" );
 }
开发者ID:sebastian-su,项目名称:Charm,代码行数:5,代码来源:XmlSerialization.cpp

示例11: QgsDebugMsg

bool QgsStyleV2::load( QString filename )
{
  mErrorString.clear();

  // Open the sqlite database
  if ( !openDB( filename ) )
  {
    mErrorString = "Unable to open database file specified";
    QgsDebugMsg( mErrorString );
    return false;
  }

  // Make sure there are no Null fields in parenting symbols ang groups
  char *query = sqlite3_mprintf( "UPDATE symbol SET groupid=0 WHERE groupid IS NULL;"
                                 "UPDATE colorramp SET groupid=0 WHERE groupid IS NULL;"
                                 "UPDATE symgroup SET parent=0 WHERE parent IS NULL;" );
  runEmptyQuery( query );

  // First create all the main symbols
  query = sqlite3_mprintf( "SELECT * FROM symbol" );

  sqlite3_stmt *ppStmt;
  int nError = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
  while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
  {
    QDomDocument doc;
    QString symbol_name = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymbolName ) );
    QString xmlstring = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymbolXML ) );
    if ( !doc.setContent( xmlstring ) )
    {
      QgsDebugMsg( "Cannot open symbol " + symbol_name );
      continue;
    }

    QDomElement symElement = doc.documentElement();
    QgsSymbolV2 *symbol = QgsSymbolLayerV2Utils::loadSymbol( symElement );
    if ( symbol != NULL )
      mSymbols.insert( symbol_name, symbol );
  }

  sqlite3_finalize( ppStmt );

  query = sqlite3_mprintf( "SELECT * FROM colorramp" );
  nError = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, NULL );
  while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
  {
    QDomDocument doc;
    QString ramp_name = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, ColorrampName ) );
    QString xmlstring = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, ColorrampXML ) );
    if ( !doc.setContent( xmlstring ) )
    {
      QgsDebugMsg( "Cannot open symbol " + ramp_name );
      continue;
    }
    QDomElement rampElement = doc.documentElement();
    QgsVectorColorRampV2 *ramp = QgsSymbolLayerV2Utils::loadColorRamp( rampElement );
    if ( ramp )
      mColorRamps.insert( ramp_name, ramp );
  }

  mFileName = filename;
  return true;
}
开发者ID:paulfab,项目名称:QGIS,代码行数:63,代码来源:qgsstylev2.cpp

示例12: reportElement

    QDomElement reportElement( const QDomDocument& document )
    {
        QDomElement root = document.documentElement();
        return root.firstChildElement( "report" );

    }
开发者ID:sebastian-su,项目名称:Charm,代码行数:6,代码来源:XmlSerialization.cpp

示例13: GetOSDisplayString

QString EventDispatcher::GetOSDisplayString()
{
        QStringList key;
    QStringList string;
    QFile xmlFile("/System/Library/CoreServices/SystemVersion.plist");
    if(xmlFile.open(QIODevice::ReadOnly))
    {
        QString content=xmlFile.readAll();
        xmlFile.close();
        QString errorStr;
        int errorLine;
        int errorColumn;
        QDomDocument domDocument;
        if (!domDocument.setContent(content, false, &errorStr,&errorLine,&errorColumn))
            return "Mac OS X";
        else
        {
            QDomElement root = domDocument.documentElement();
            if(root.tagName()!="plist")
                return "Mac OS X";
            else
            {
                if(root.isElement())
                {
                    QDomElement SubChild=root.firstChildElement("dict");
                    while(!SubChild.isNull())
                    {
                        if(SubChild.isElement())
                        {
                            QDomElement SubChild2=SubChild.firstChildElement("key");
                            while(!SubChild2.isNull())
                            {
                                if(SubChild2.isElement())
                                    key << SubChild2.text();
                                else
                                    return "Mac OS X";
                                SubChild2 = SubChild2.nextSiblingElement("key");
                            }
                            SubChild2=SubChild.firstChildElement("string");
                            while(!SubChild2.isNull())
                            {
                                if(SubChild2.isElement())
                                    string << SubChild2.text();
                                else
                                    return "Mac OS X";
                                SubChild2 = SubChild2.nextSiblingElement("string");
                            }
                        }
                        else
                            return "Mac OS X";
                        SubChild = SubChild.nextSiblingElement("property");
                    }
                }
                else
                    return "Mac OS X";
            }
        }
    }
    if(key.size()!=string.size())
        return "Mac OS X";
    int index=0;
    while(index<key.size())
    {
        if(key.at(index)=="ProductVersion")
            return "Mac OS X "+string.at(index);
        index++;
    }
    return "Mac OS X";
}
开发者ID:blizzard4591,项目名称:Ultracopier,代码行数:69,代码来源:EventDispatcher.cpp

示例14: drawObject

void GLBox::drawObject(const QDomDocument &doc)
{
	QDomElement root = doc.documentElement().toElement();

	QDomElement texture1 = root.elementsByTagName("textures").item(0).toElement();

	for (QDomNode i = texture1.firstChild(); !i.isNull(); i = i.nextSibling())
	{
		QDomElement e = i.toElement();

		QString name = e.attribute("name");
		QString file = e.attribute("file");
		QString color = e.attribute("color", "0xFFFFFF");
		QString xscale = e.attribute("xscale", "1.0");
		QString yscale = e.attribute("yscale", "1.0");

		qDebug()<<"Adding Texture:"<<name<<color<<file<<xscale<<yscale;
		textures[name] = Texture(color.toUInt(0, 16), file, xscale.toFloat(), yscale.toFloat());
	}

	QDomElement item = root.elementsByTagName("items").item(0).toElement();

	for (QDomNode i = item.firstChild(); !i.isNull(); i = i.nextSibling())
	{
		QDomElement e = i.toElement();

		QString x = e.attribute("x");
		QString y = e.attribute("y");
		QString z = e.attribute("z");
		QString rotation = e.attribute("rotation", "0.0");
		QString type = e.attribute("type");

		if (type == "wall")
		{
			QString length = e.attribute("length");
			QString innerTexture = e.attribute("innerTexture");
			QString outerTexture = e.attribute("outerTexture");
			QString height = e.attribute("height", "10.0");
			QString thickness = e.attribute("thickness", "0.5");

			qDebug()<<"Adding Wall:"<<x<<y<<z<<rotation<<length<<innerTexture<<outerTexture<<height<<thickness;

			Wall *wall = new Wall(x.toFloat(), y.toFloat(), z.toFloat(), rotation.toFloat(), length.toFloat(), textures[innerTexture], textures[outerTexture], height.toFloat(), thickness.toFloat());

			// now we start parsing the windows
			for (QDomNode w = e.firstChild(); !w.isNull(); w = w.nextSibling()) {
				QDomElement tmp = w.toElement();

				if (tmp.tagName() == "window") {
					QString position = tmp.attribute("position");
					QString length = tmp.attribute("length");
					QString texture = tmp.attribute("texture");
					QString lowerHeight = tmp.attribute("lowerHeight", "3.0");
					QString upperHeight = tmp.attribute("upperHeight", "7.0");
					wall->addWindow(position.toFloat(), length.toFloat(), textures[texture], lowerHeight.toFloat(), upperHeight.toFloat());
					qDebug()<<"Added Window:"<<position<<length<<texture<<lowerHeight<<upperHeight;
				}
				else if (tmp.tagName() == "door") {
					QString position = tmp.attribute("position");
					QString length = tmp.attribute("length");
					QString texture = tmp.attribute("texture");
					QString height = tmp.attribute("height", "7.0");
					wall->addDoor(position.toFloat(), length.toFloat(), textures[texture], height.toFloat());
					qDebug()<<"Added Door:"<<position<<length<<texture<<height;
				}
			}

			addObject(wall);
		} else if (type == "floor") {
			QString texture = e.attribute("texture");
			qDebug()<<"Adding Floor:"<<x<<y<<z<<rotation;
			Floor *floor = new Floor(x.toFloat(), y.toFloat(), z.toFloat(), rotation.toFloat(), textures[texture]);

			// now we start parsing the windows
			for (QDomNode w = e.firstChild(); !w.isNull(); w = w.nextSibling()) {
				QDomElement tmp = w.toElement();

				if (tmp.tagName() == "point") {
					QString x = tmp.attribute("x");
					QString y = tmp.attribute("y");
					floor->addPoint(x.toFloat(), y.toFloat());

					qDebug()<<"Added Point:"<<x<<y;
				}
			}

			addObject(floor);
		}
	}
}
开发者ID:sourav87,项目名称:lblock,代码行数:90,代码来源:drawobject.cpp

示例15: convert

QTextDocument* Converter::convert(const QString &fileName)
{
    firstTime = true;
    Document oooDocument(fileName);
    if (!oooDocument.open())
    {
        return 0;
    }
    m_TextDocument = new QTextDocument;
    m_Cursor = new QTextCursor(m_TextDocument);

    /**
     * Create the dom of the content
     */
    QXmlSimpleReader reader;

    QXmlInputSource source;
    source.setData(oooDocument.content());
    QString errorMsg;
    QDomDocument document;
    if (!document.setContent(&source, &reader, &errorMsg))
    {
        setError(QString("Invalid XML document: %1").arg(errorMsg), -1);
        delete m_Cursor;
        return m_TextDocument;
    }

    /**
     * Read the style properties, so the are available when
     * parsing the content.
     */

    m_StyleInformation = new StyleInformation();

    if (oooDocument.content().size() == 0)
    {
        setError("Empty document", -1);
    }

    StyleParser styleParser(&oooDocument, document, m_StyleInformation);
    if (!styleParser.parse())
    {
        setError("Unable to read style information", -1);
        delete m_Cursor;
        return 0;
    }

    /**
    * Add all images of the document to resource framework
    */

    QMap<QString, QByteArray> imageLIST = oooDocument.images();
    QMapIterator<QString, QByteArray> it(imageLIST);
    while (it.hasNext())
    {
        it.next();
        m_TextDocument->addResource(QTextDocument::ImageResource, QUrl(it.key()), QImage::fromData(it.value()));
    }

    /**
     * Set the correct page size
     */

    const QString masterLayout = m_StyleInformation->masterPageName();

    if (m_StyleInformation->pagePropertyExists(masterLayout))
    {
        const int DPX = 231; /// im.logicalDpiX(); // 231
        const int DPY = 231; // im.logicalDpiY(); // 231
        const int A4Width = MM_TO_POINT(210); /// A4 210 x297 mm
        const int A4Height = MM_TO_POINT(297);

        const PageFormatProperty property = m_StyleInformation->pageProperty(masterLayout);
        int pageWidth = qRound(property.width() / 72.0 * DPX);
        if (pageWidth < 1) {
            pageWidth = A4Width;
        }
        int pageHeight = qRound(property.height() / 72.0 * DPY);
        if (pageHeight < 1) {
            pageHeight = A4Height;
        }
        m_TextDocument->setPageSize(QSize(pageWidth, pageHeight));

        QTextFrameFormat frameFormat;
        frameFormat.setMargin(qRound(property.margin()));

        QTextFrame *rootFrame = m_TextDocument->rootFrame();
        rootFrame->setFrameFormat(frameFormat);
    }

    /**
     * Parse the content of the document
     */
    const QDomElement documentElement = document.documentElement();

    QDomElement element = documentElement.firstChildElement();
    while (!element.isNull())
    {
        if (element.tagName() == QLatin1String("body"))
        {
//.........这里部分代码省略.........
开发者ID:madnight,项目名称:chessx,代码行数:101,代码来源:converter.cpp


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