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


C++ QDomElement::toElement方法代码示例

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


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

示例1: runtime_error

  /*!
  * \author Anders Fernstrom
  * \date 2005-11-30
  *
  * \brief Parse the xml file using OLD readmode
  *
  * \param domdoc The QDomDocument that should be parsed.
  */
  Cell *XMLParser::parseOld( QDomDocument &domdoc )
  {
    // Create a root element
    QDomElement root = domdoc.documentElement();

    // Check if correct root, otherwise throw exception
    if( root.toElement().tagName() != "Notebook" )
    {
      string msg = "Wrong root node (" + root.toElement().tagName().toStdString() +
        ") in file " + filename_.toStdString() + " (Old File)";
      throw runtime_error( msg.c_str() );
    }

    // Remove first cellgroup.
    QDomNode node = root.firstChild();
    if( !node.isNull() )
    {
      QDomElement element = node.toElement();
      if( !element.isNull() )
        if( element.tagName() == "CellGroupData" )
          node = element.firstChild();
    }

    // Create the grouppcell that will be the root parent.
    Cell *rootcell = factory_->createCell( "cellgroup", 0 );
    xmltraverse( rootcell, node );
    return rootcell;
  }
开发者ID:cbhust,项目名称:OMNotebook,代码行数:36,代码来源:xmlparser.cpp

示例2: QStringLiteral

QDomElement QgsCurvePolygon::asGml2( QDomDocument &doc, int precision, const QString &ns, const AxisOrder axisOrder ) const
{
  // GML2 does not support curves
  QDomElement elemPolygon = doc.createElementNS( ns, QStringLiteral( "Polygon" ) );

  if ( isEmpty() )
    return elemPolygon;

  QDomElement elemOuterBoundaryIs = doc.createElementNS( ns, QStringLiteral( "outerBoundaryIs" ) );
  std::unique_ptr< QgsLineString > exteriorLineString( exteriorRing()->curveToLine() );
  QDomElement outerRing = exteriorLineString->asGml2( doc, precision, ns, axisOrder );
  outerRing.toElement().setTagName( QStringLiteral( "LinearRing" ) );
  elemOuterBoundaryIs.appendChild( outerRing );
  elemPolygon.appendChild( elemOuterBoundaryIs );
  std::unique_ptr< QgsLineString > interiorLineString;
  for ( int i = 0, n = numInteriorRings(); i < n; ++i )
  {
    QDomElement elemInnerBoundaryIs = doc.createElementNS( ns, QStringLiteral( "innerBoundaryIs" ) );
    interiorLineString.reset( interiorRing( i )->curveToLine() );
    QDomElement innerRing = interiorLineString->asGml2( doc, precision, ns, axisOrder );
    innerRing.toElement().setTagName( QStringLiteral( "LinearRing" ) );
    elemInnerBoundaryIs.appendChild( innerRing );
    elemPolygon.appendChild( elemInnerBoundaryIs );
  }
  return elemPolygon;
}
开发者ID:SrNetoChan,项目名称:Quantum-GIS,代码行数:26,代码来源:qgscurvepolygon.cpp

示例3: File

QList<NewsItemData> NewslineWidget::loadRSSFile(const QString& FilePath)
{
  QList<NewsItemData> News;

  QFile File(FilePath);

  if (File.open(QIODevice::ReadOnly))
  {
    QDomDocument Doc;
    QDomElement Root;

    bool Parsed = Doc.setContent(&File);
    File.close();

    if (Parsed)
    {
      Root = Doc.documentElement();

      if (!Root.isNull())
      {

        if (Root.tagName() == QString("rss"))
        {
          QDomElement ChannelNode = Root.firstChildElement("channel");

          if (!ChannelNode.isNull())
          {
            for(QDomElement CurrNode = ChannelNode.firstChildElement();
                !CurrNode.isNull();
                CurrNode = CurrNode.nextSiblingElement())
            {
              QDomElement CurrElement = CurrNode.toElement();
              if (!CurrElement.isNull() && CurrElement.tagName() == "item")
              {
                // TODO
                NewsItemData Item;
                Item.Title = CurrNode.firstChildElement("title").toElement().text();
                Item.Text = CurrNode.firstChildElement("description").toElement().text();
                Item.ISODate = CurrNode.firstChildElement("pubDate").toElement().text();

                for(QDomElement CurrTagNode = CurrNode.firstChildElement("category");
                    !CurrTagNode.isNull();
                    CurrTagNode = CurrTagNode.nextSiblingElement())
                {
                  Item.Tags.push_back(CurrTagNode.toElement().text());
                }

                if (Item.Tags.isEmpty()) Item.Tags.push_back(tr("misc"));

                News.push_back(Item);
              }
            }
          }
        }
      }
    }
  }
  return News;
}
开发者ID:jylfc0307,项目名称:openfluid-1,代码行数:59,代码来源:NewslineWidget.cpp

示例4: loadKeyframe

KisKeyframeSP KisScalarKeyframeChannel::loadKeyframe(const QDomElement &keyframeNode)
{
    int time = keyframeNode.toElement().attribute("time").toUInt();
    QVariant value = keyframeNode.toElement().attribute("value");

    KUndo2Command tempParentCommand;
    KisKeyframeSP keyframe = createKeyframe(time, KisKeyframeSP(), &tempParentCommand);
    setScalarValue(keyframe, value.toReal());

    return keyframe;
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:11,代码来源:kis_scalar_keyframe_channel.cpp

示例5: if

bool K3b::MixedDoc::loadDocumentData( QDomElement* rootElem )
{
    QDomNodeList nodes = rootElem->childNodes();

    if( nodes.length() < 4 )
        return false;

    if( nodes.item(0).nodeName() != "general" )
        return false;
    if( !readGeneralDocumentData( nodes.item(0).toElement() ) )
        return false;

    if( nodes.item(1).nodeName() != "audio" )
        return false;
    QDomElement audioElem = nodes.item(1).toElement();
    if( !m_audioDoc->loadDocumentData( &audioElem ) )
        return false;

    if( nodes.item(2).nodeName() != "data" )
        return false;
    QDomElement dataElem = nodes.item(2).toElement();
    if( !m_dataDoc->loadDocumentData( &dataElem ) )
        return false;

    if( nodes.item(3).nodeName() != "mixed" )
        return false;

    QDomNodeList optionList = nodes.item(3).childNodes();
    for( int i = 0; i < optionList.count(); i++ ) {

        QDomElement e = optionList.item(i).toElement();
        if( e.isNull() )
            return false;

        if( e.nodeName() == "remove_buffer_files" )
            setRemoveImages( e.toElement().text() == "yes" );
        else if( e.nodeName() == "image_path" )
            setTempDir( e.toElement().text() );
        else if( e.nodeName() == "mixed_type" ) {
            QString mt = e.toElement().text();
            if( mt == "last_track" )
                setMixedType( DATA_LAST_TRACK );
            else if( mt == "second_session" )
                setMixedType( DATA_SECOND_SESSION );
            else
                setMixedType( DATA_FIRST_TRACK );
        }
    }

    return true;
}
开发者ID:KDE,项目名称:k3b,代码行数:51,代码来源:k3bmixeddoc.cpp

示例6:

static QList<QString> fetchVariableNames
    (const QDomDocument *serviceDesc, bool eventableOnly)
{
    QList<QString> names;

    QDomNodeList variables = serviceDesc->elementsByTagName("stateVariable");
    QDomElement var = variables.at(0).toElement();
    for (; var.isNull() == false ; var = var.nextSiblingElement()) {
        QDomElement variable = var.toElement();
        if (variable.isNull())
            continue;

        QString sendEvents = variable.attribute("sendEvents");
        bool envetable =    sendEvents.compare("yes", Qt::CaseInsensitive) == 0
                         || sendEvents.compare("true", Qt::CaseInsensitive) == 0;

        if (envetable == false && eventableOnly)
            continue;

        /* TODO: each of the chained calls is failable */
        QString name
            = variable.elementsByTagName("name").at(0).toElement().text();
        names.append(name);
    }

    return names;
}
开发者ID:SylvanHuang,项目名称:uca-devices,代码行数:27,代码来源:sensorservices.cpp

示例7: updDomChangedVar

int XmlFlochaTransfer::updDomChangedVar(unsigned int *indx, QString &varname, const ArrayDimensInfo &info)
{
    int rtn = -1;
    auto it = indexVarNameNodeMap.find(*indx);


    if(it != indexVarNameNodeMap.end())
    {
        it->second.first = varname;
        it->second.second.toElement().setTagName(varname);
        setEleNodeText(it->second.second.toElement(), QString("%1,%2,%3,%4").arg(info.dimension)
                       .arg(info.dimensionSize[0]).arg(info.dimensionSize[1]).arg(info.dimensionSize[2]));
        commandManager->editVarMap(indx, varname, info);
    }
    else
    {
        QDomElement newnode;
        newnode = domDocument.createElement(varname);
        varPoolParentNode.appendChild(newnode);
        setEleNodeText(newnode.toElement(), QString("%1,%2,%3,%4").arg(info.dimension)
                       .arg(info.dimensionSize[0]).arg(info.dimensionSize[1]).arg(info.dimensionSize[2]));

        commandManager->editVarMap(indx, varname, info);
        indexVarNameNodeMap.insert(std::make_pair(*indx,std::make_pair(varname,newnode)));
        //*indx = VariableIndex;
        //++VariableIndex;

    }


    return rtn;
}
开发者ID:xjoof,项目名称:flowchart,代码行数:32,代码来源:xmlflochatransfer.cpp

示例8: Process

void HuggleFeedProviderWiki::Process(QString data)
{
    //QStringList lines = data.split("\n");
    QDomDocument d;
    d.setContent(data);
    QDomNodeList l = d.elementsByTagName("rc");
    int CurrentNode = l.count();
    if (l.count() == 0)
    {
        Huggle::Syslog::HuggleLogs->Log("Error, wiki provider returned: " + data);
        return;
    }
    // recursively scan all RC changes
    QDateTime t = this->LatestTime;
    bool Changed = false;
    while (CurrentNode > 0)
    {
        CurrentNode--;
        // get a time of rc change
        QDomElement item = l.at(CurrentNode).toElement();
        if (!item.attributes().contains("timestamp"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-timestamp-missing", item.toElement().nodeName()));
            continue;
        }
        QDateTime time = MediaWiki::FromMWTimestamp(item.attribute("timestamp"));
        if (time < t)
        {
            // this record is older than latest parsed record, so we don't want to parse it
            continue;
        } else
        {
            Changed = true;
            t = time;
        }
        if (!item.attributes().contains("type"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-type-missing", item.text()));
            continue;
        }
        if (!item.attributes().contains("title"))
        {
            Huggle::Syslog::HuggleLogs->Log(_l("rc-title-missing", item.text()));
            continue;
        }
        QString type = item.attribute("type");
        if (type == "edit" || type == "new")
        {
            ProcessEdit(item);
        }
        else if (type == "log")
        {
            ProcessLog(item);
        }
    }
    if (Changed)
    {
        this->LatestTime = t.addSecs(1);
    }
}
开发者ID:Krenair,项目名称:huggle3-qt-lx,代码行数:60,代码来源:hugglefeedproviderwiki.cpp

示例9: load

// Load the DB from a DomElement
bool MemDbLoader::load(const QDomElement & elemSource, QSqlDatabase db)
{
    _lastError = "";
    
    // Login to the SQLITE memory DB

	if(db.isOpen()) {
		db.close();
		db.open();
	}

	if(db.databaseName() != memDbName) {
		_lastError = createMemoryDB();
		if(!_lastError.isEmpty()) {
			return false;
		}
		db = QSqlDatabase::database();
		if(!db.open()) {
			_lastError = "Error opening QSQLITE memory database";
			return false;
		}  
	}
	_db = db;

    QDomNodeList nlist = elemSource.childNodes();
    for(int i = 0; i < nlist.count(); i++ ) {
        QDomElement it = nlist.item(i).toElement();
        if(it.tagName()=="table") {
            parseTable(it.toElement());
        }
    }
    return _lastError.isEmpty();
}
开发者ID:0TheFox0,项目名称:MayaOpenRPT,代码行数:34,代码来源:memdbloader.cpp

示例10: load

// Load the DB from a DomElement
bool MemDbLoader::load(const QDomElement & elemSource)
{
    _lastError = "";
    
    // Login to the SQLITE memory DB

    if(!QSqlDatabase::isDriverAvailable("QSQLITE")) {
        _lastError = "SQLITE plugin not available - data can't be loaded";
        return false;
    }
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");

    if(!db.open()) {
        _lastError = "Error opening QSQLITE memory database";
        return false;
    }    

    QDomNodeList nlist = elemSource.childNodes();
    for(int i = 0; i < nlist.count(); i++ ) {
        QDomElement it = nlist.item(i).toElement();
        if(it.tagName()=="table") {
            parseTable(it.toElement());
        }
    }
    return _lastError.isEmpty();
}
开发者ID:Wushaowei001,项目名称:xtuple,代码行数:28,代码来源:memdbloader.cpp

示例11: loadData

DataPtr DataManagerImpl::loadData(QDomElement node, QString rootPath)
{
	QString uid = node.toElement().attribute("uid");
	QString name = node.toElement().attribute("name");
	QString type = node.toElement().attribute("type");

	QDir relativePath = this->findRelativePath(node, rootPath);
	QString absolutePath = this->findAbsolutePath(relativePath, rootPath);

	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	DataPtr data = mDataFactory->create(type, uid, name);
	if (!data)
	{
		reportWarning(QString("Unknown type: %1 for file %2").arg(type).arg(absolutePath));
		return DataPtr();
	}
	bool loaded = data->load(absolutePath);

	if (!loaded)
	{
		reportWarning("Unknown file: " + absolutePath);
		return DataPtr();
	}

	if (!name.isEmpty())
		data->setName(name);
	data->setFilename(relativePath.path());

	this->loadData(data);

	// conversion for change in format 2013-10-29
	QString newPath = rootPath+"/"+data->getFilename();
	if (QDir::cleanPath(absolutePath) != QDir::cleanPath(newPath))
	{
		reportWarning(QString("Detected old data format, converting from %1 to %2").arg(absolutePath).arg(newPath));
		data->save(rootPath);
	}

	return data;
}
开发者ID:c0ns0le,项目名称:CustusX,代码行数:42,代码来源:cxDataManagerImpl.cpp

示例12: loadSingleProperty

static QDomElement loadSingleProperty( QDomElement e, const QString& name )
{
    QDomElement n;
    for ( n = e.firstChild().toElement();
	  !n.isNull();
	  n = n.nextSibling().toElement() ) {
	if ( n.tagName() == "property" && n.toElement().attribute("name") == name )
	    return n;
    }
    return n;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:11,代码来源:project.cpp

示例13: getObjectProperty

/*! Extracts a named object property from \a e.
 */
QDomElement Uic::getObjectProperty( const QDomElement& e, const QString& name )
{
    QDomElement n;
    for ( n = e.firstChild().toElement();
	  !n.isNull();
	  n = n.nextSibling().toElement() ) {
	if ( n.tagName() == "property"  && n.toElement().attribute("name") == name )
	    return n;
    }
    return n;
}
开发者ID:AliYousuf,项目名称:univ-aca-mips,代码行数:13,代码来源:object.cpp

示例14: if

bool
NetworkObject::fromDomElement(QDomElement de)
{
  clear();

  bool ok = false;

  QString name;
  QDomNodeList dlist = de.childNodes();
  for(int i=0; i<dlist.count(); i++)
    {
      QDomElement dnode = dlist.at(i).toElement();
      QString str = dnode.toElement().text();
      if (dnode.tagName() == "name")
	ok = load(str);
      else if (dnode.tagName() == "vopacity")
	m_Vopacity = str.toFloat();
      else if (dnode.tagName() == "vstops")
	{
	  QStringList xyz = str.split(" ");
	  for(int s=0; s<xyz.count()/5; s++)
	    {
	      float pos;
	      int r,g,b,a;
	      pos = xyz[5*s+0].toFloat();
	      r = xyz[5*s+1].toInt();
	      g = xyz[5*s+2].toInt();
	      b = xyz[5*s+3].toInt();
	      a = xyz[5*s+4].toInt();
	      m_Vstops << QGradientStop(pos, QColor(r,g,b,a));
	    }
	}
      else if (dnode.tagName() == "eopacity")
	m_Eopacity = str.toFloat();
      else if (dnode.tagName() == "estops")
	{
	  QStringList xyz = str.split(" ");
	  for(int s=0; s<xyz.count()/5; s++)
	    {
	      float pos;
	      int r,g,b,a;
	      pos = xyz[5*s+0].toFloat();
	      r = xyz[5*s+1].toInt();
	      g = xyz[5*s+2].toInt();
	      b = xyz[5*s+3].toInt();
	      a = xyz[5*s+4].toInt();
	      m_Vstops << QGradientStop(pos, QColor(r,g,b,a));
	    }
	}
    }

  return ok;
}
开发者ID:Elavina6,项目名称:drishti,代码行数:53,代码来源:networkobject.cpp

示例15: buildFromXMLParam

/**
  * @brief: Build UI element for required parameter
  * @returns: True if success, false otherwise
  */
bool PolRunTool::buildFromXMLParam(QDomElement param)
{
    QString name = param.toElement().text();
    //Create line edit box
    QLabel* label = new QLabel(name,this);
    QLineEdit* edit = new QLineEdit(this);
    QHBoxLayout* hLayout = new QHBoxLayout(this);
    QSpacerItem* s = new QSpacerItem(20,10,QSizePolicy::Minimum, QSizePolicy::Expanding);
    hLayout->addWidget(label);
    hLayout->addWidget(edit);
    hLayout->addItem(s);
    ui->layout_Parameters->addLayout(hLayout);
    return true;
}
开发者ID:CosteaPaul,项目名称:PolToolBox,代码行数:18,代码来源:polruntool.cpp


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