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


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

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


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

示例1: createEmbeddedLayer

bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& projectFilePath, QList<QDomNode>& brokenNodes,
                                      QList< QPair< QgsVectorLayer*, QDomElement > >& vectorLayerList, bool saveFlag )
{
  QFile projectFile( projectFilePath );
  if ( !projectFile.open( QIODevice::ReadOnly ) )
  {
    return false;
  }

  QDomDocument projectDocument;
  if ( !projectDocument.setContent( &projectFile ) )
  {
    return false;
  }

  //does project store pathes absolute or relative?
  bool useAbsolutePathes = true;
  QDomElement propertiesElem = projectDocument.documentElement().firstChildElement( "properties" );
  if ( !propertiesElem.isNull() )
  {
    QDomElement absElem = propertiesElem.firstChildElement( "Paths" ).firstChildElement( "Absolute" );
    if ( !absElem.isNull() )
    {
      useAbsolutePathes = absElem.text().compare( "true", Qt::CaseInsensitive ) == 0;
    }
  }

  QDomElement projectLayersElem = projectDocument.documentElement().firstChildElement( "projectlayers" );
  if ( projectLayersElem.isNull() )
  {
    return false;
  }

  QDomNodeList mapLayerNodes = projectLayersElem.elementsByTagName( "maplayer" );
  for ( int i = 0; i < mapLayerNodes.size(); ++i )
  {
    //get layer id
    QDomElement mapLayerElem = mapLayerNodes.at( i ).toElement();
    QString id = mapLayerElem.firstChildElement( "id" ).text();
    if ( id == layerId )
    {
      //layer can be embedded only once
      if ( mapLayerElem.attribute( "embedded" ) == "1" )
      {
        return false;
      }

      mEmbeddedLayers.insert( layerId, qMakePair( projectFilePath, saveFlag ) );

      //change datasource path from relative to absolute if necessary
      if ( !useAbsolutePathes )
      {
        QDomElement provider = mapLayerElem.firstChildElement( "provider" );
        if ( provider.text() == "spatialite" )
        {
          QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );

          QgsDataSourceURI uri( dsElem.text() );

          QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + uri.database() );
          if ( absoluteDs.exists() )
          {
            uri.setDatabase( absoluteDs.absoluteFilePath() );
            dsElem.removeChild( dsElem.childNodes().at( 0 ) );
            dsElem.appendChild( projectDocument.createTextNode( uri.uri() ) );
          }
        }
        else
        {
          QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );
          QString debug( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
          QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
          if ( absoluteDs.exists() )
          {
            dsElem.removeChild( dsElem.childNodes().at( 0 ) );
            dsElem.appendChild( projectDocument.createTextNode( absoluteDs.absoluteFilePath() ) );
          }
        }
      }

      if ( addLayer( mapLayerElem, brokenNodes, vectorLayerList ) )
      {
        return true;
      }
      else
      {
        mEmbeddedLayers.remove( layerId );
        return false;
      }
    }
  }

  return false;
}
开发者ID:Arctictern265,项目名称:Quantum-GIS,代码行数:94,代码来源:qgsproject.cpp

示例2: loadSld

QgsFeatureRenderer* QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage )
{
  QDomElement element = node.toElement();
  if ( element.isNull() )
    return nullptr;

  // get the UserStyle element
  QDomElement userStyleElem = element.firstChildElement( "UserStyle" );
  if ( userStyleElem.isNull() )
  {
    // UserStyle element not found, nothing will be rendered
    errorMessage = "Info: UserStyle element not found.";
    return nullptr;
  }

  // get the FeatureTypeStyle element
  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( "FeatureTypeStyle" );
  if ( featTypeStyleElem.isNull() )
  {
    errorMessage = "Info: FeatureTypeStyle element not found.";
    return nullptr;
  }

  // use the RuleRenderer when more rules are present or the rule
  // has filters or min/max scale denominators set,
  // otherwise use the SingleSymbol renderer
  bool needRuleRenderer = false;
  int ruleCount = 0;

  QDomElement ruleElem = featTypeStyleElem.firstChildElement( "Rule" );
  while ( !ruleElem.isNull() )
  {
    ruleCount++;

    // more rules present, use the RuleRenderer
    if ( ruleCount > 1 )
    {
      QgsDebugMsg( "more Rule elements found: need a RuleRenderer" );
      needRuleRenderer = true;
      break;
    }

    QDomElement ruleChildElem = ruleElem.firstChildElement();
    while ( !ruleChildElem.isNull() )
    {
      // rule has filter or min/max scale denominator, use the RuleRenderer
      if ( ruleChildElem.localName() == "Filter" ||
           ruleChildElem.localName() == "MinScaleDenominator" ||
           ruleChildElem.localName() == "MaxScaleDenominator" )
      {
        QgsDebugMsg( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" );
        needRuleRenderer = true;
        break;
      }

      ruleChildElem = ruleChildElem.nextSiblingElement();
    }

    if ( needRuleRenderer )
    {
      break;
    }

    ruleElem = ruleElem.nextSiblingElement( "Rule" );
  }

  QString rendererType;
  if ( needRuleRenderer )
  {
    rendererType = "RuleRenderer";
  }
  else
  {
    rendererType = "singleSymbol";
  }
  QgsDebugMsg( QString( "Instantiating a '%1' renderer..." ).arg( rendererType ) );

  // create the renderer and return it
  QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( rendererType );
  if ( !m )
  {
    errorMessage = QString( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
    return nullptr;
  }

  QgsFeatureRenderer* r = m->createRendererFromSld( featTypeStyleElem, geomType );
  return r;
}
开发者ID:fritsvanveen,项目名称:QGIS,代码行数:88,代码来源:qgsrenderer.cpp

示例3: convertRasterProperties

void QgsProjectFileTransform::convertRasterProperties( QDomDocument& doc, QDomNode& parentNode,
    QDomElement& rasterPropertiesElem, QgsRasterLayer* rlayer )
{
  //no data
  //TODO: We would need to set no data on all bands, but we don't know number of bands here
  QDomNode noDataNode = rasterPropertiesElem.namedItem( "mNoDataValue" );
  QDomElement noDataElement = noDataNode.toElement();
  if ( !noDataElement.text().isEmpty() )
  {
    QgsDebugMsg( "mNoDataValue = " + noDataElement.text() );
    QDomElement noDataElem = doc.createElement( "noData" );

    QDomElement noDataRangeList = doc.createElement( "noDataRangeList" );
    noDataRangeList.setAttribute( "bandNo", 1 );

    QDomElement noDataRange =  doc.createElement( "noDataRange" );
    noDataRange.setAttribute( "min", noDataElement.text() );
    noDataRange.setAttribute( "max", noDataElement.text() );
    noDataRangeList.appendChild( noDataRange );

    noDataElem.appendChild( noDataRangeList );

    parentNode.appendChild( noDataElem );
  }

  QDomElement rasterRendererElem = doc.createElement( "rasterrenderer" );
  //convert general properties

  //invert color
  rasterRendererElem.setAttribute( "invertColor", "0" );
  QDomElement  invertColorElem = rasterPropertiesElem.firstChildElement( "mInvertColor" );
  if ( !invertColorElem.isNull() )
  {
    if ( invertColorElem.text() == "true" )
    {
      rasterRendererElem.setAttribute( "invertColor", "1" );
    }
  }

  //opacity
  rasterRendererElem.setAttribute( "opacity", "1" );
  QDomElement transparencyElem = parentNode.firstChildElement( "transparencyLevelInt" );
  if ( !transparencyElem.isNull() )
  {
    double transparency = transparencyElem.text().toInt();
    rasterRendererElem.setAttribute( "opacity", QString::number( transparency / 255.0 ) );
  }

  //alphaBand was not saved until now (bug)
  rasterRendererElem.setAttribute( "alphaBand", -1 );

  //gray band is used for several renderers
  int grayBand = rasterBandNumber( rasterPropertiesElem, "mGrayBandName", rlayer );

  //convert renderer specific properties
  QString drawingStyle = rasterPropertiesElem.firstChildElement( "mDrawingStyle" ).text();

  // While PalettedColor should normaly contain only integer values, usually
  // color palette 0-255, it may happen (Tim, issue #7023) that it contains
  // colormap classification with double values and text labels
  // (which should normaly only appear in SingleBandPseudoColor drawingStyle)
  // => we have to check first the values and change drawingStyle if necessary
  if ( drawingStyle == "PalettedColor" )
  {
    QDomElement customColorRampElem = rasterPropertiesElem.firstChildElement( "customColorRamp" );
    QDomNodeList colorRampEntryList = customColorRampElem.elementsByTagName( "colorRampEntry" );

    for ( int i = 0; i < colorRampEntryList.size(); ++i )
    {
      QDomElement colorRampEntryElem = colorRampEntryList.at( i ).toElement();
      QString strValue = colorRampEntryElem.attribute( "value" );
      double value = strValue.toDouble();
      if ( value < 0 || value > 10000 || value != ( int )value )
      {
        QgsDebugMsg( QString( "forcing SingleBandPseudoColor value = %1" ).arg( value ) );
        drawingStyle = "SingleBandPseudoColor";
        break;
      }
    }
  }

  if ( drawingStyle == "SingleBandGray" )
  {
    rasterRendererElem.setAttribute( "type", "singlebandgray" );
    rasterRendererElem.setAttribute( "grayBand", grayBand );
    transformContrastEnhancement( doc, rasterPropertiesElem, rasterRendererElem );
  }
  else if ( drawingStyle == "SingleBandPseudoColor" )
  {
    rasterRendererElem.setAttribute( "type", "singlebandpseudocolor" );
    rasterRendererElem.setAttribute( "band", grayBand );
    QDomElement newRasterShaderElem = doc.createElement( "rastershader" );
    QDomElement newColorRampShaderElem = doc.createElement( "colorrampshader" );
    newRasterShaderElem.appendChild( newColorRampShaderElem );
    rasterRendererElem.appendChild( newRasterShaderElem );

    //switch depending on mColorShadingAlgorithm
    QString colorShadingAlgorithm = rasterPropertiesElem.firstChildElement( "mColorShadingAlgorithm" ).text();
    if ( colorShadingAlgorithm == "PseudoColorShader" || colorShadingAlgorithm == "FreakOutShader" )
    {
//.........这里部分代码省略.........
开发者ID:ColeCummins,项目名称:QGIS,代码行数:101,代码来源:qgsprojectfiletransform.cpp

示例4: f

Font::Font(QString image_path, QString xml_path)
{
    QFile f(xml_path);
    QString errorStr("");
    int errorLine(0);
    int errorColumn(0);
    QDomDocument doc;
    QDomElement root;
    
    if (!f.open(QFile::ReadOnly | QFile::Text)) {
        qCritical("ERROR: Failed to open config file \"%s\": %s",
                  xml_path.toUtf8().constData(),
                  f.errorString().toUtf8().constData()
                  );
        return;
    }
    
    if (!doc.setContent(&f, false, &errorStr, &errorLine, &errorColumn)) {
        qCritical("ERROR: Failed to parse config file \"%s\" at line %d, column %d:\n%s",
                  xml_path.toUtf8().constData(),
                  errorLine,
                  errorColumn,
                  errorStr.toUtf8().constData()
                  );
        return;
    }
    
    root = doc.documentElement();
    if (root.tagName() != "Font") {
        qCritical("ERROR: Unexpected root element \"%s\" at line %d, column %d",
                  root.tagName().toUtf8().constData(),
                  root.lineNumber(),
                  root.columnNumber());
        return;
    }
    
    this->size = root.attribute("size").toInt();
    this->family = root.attribute("family");
    this->height = root.attribute("height").toInt();
    this->style = root.attribute("style");
    
//    qDebug("Font: %d, %s, %d, %s", this->size, this->family.toUtf8().constData(), this->height, this->style.toUtf8().constData());
    
    _minChar = 127;
    _maxChar = 0;
    QDomElement childElement = root.firstChildElement();
    while (!childElement.isNull()) {
        QString tagName = childElement.tagName();
        if (tagName == "Char") {
            Char *c = new Char(childElement);
            this->_chars[c->code] = c;
            if (c->code > _maxChar)
                _maxChar = c->code;
            if (c->code < _minChar)
                _minChar = c->code;
        }
        childElement = childElement.nextSiblingElement();
    }
    
    QImageReader image_reader(image_path);
    this->_image = image_reader.read();
}
开发者ID:jnwatts,项目名称:FontImageToHeaders,代码行数:62,代码来源:font.cpp

示例5: createFromSld

QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &element )
{
  QgsDebugMsg( "Entered." );

  QString name;
  QColor fillColor, lineColor;
  double size, lineWidth;

  QDomElement fillElem = element.firstChildElement( "Fill" );
  if ( fillElem.isNull() )
    return NULL;

  QDomElement graphicFillElem = fillElem.firstChildElement( "GraphicFill" );
  if ( graphicFillElem.isNull() )
    return NULL;

  QDomElement graphicElem = graphicFillElem.firstChildElement( "Graphic" );
  if ( graphicElem.isNull() )
    return NULL;

  if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, lineColor, lineWidth, size ) )
    return NULL;

  if ( name != "horline" )
    return NULL;

  double angle = 0.0;
  QString angleFunc;
  if ( QgsSymbolLayerV2Utils::rotationFromSldElement( graphicElem, angleFunc ) )
  {
    bool ok;
    double d = angleFunc.toDouble( &ok );
    if ( ok )
      angle = d;
  }

  double offset = 0.0;
  QPointF vectOffset;
  if ( QgsSymbolLayerV2Utils::displacementFromSldElement( graphicElem, vectOffset ) )
  {
    offset = sqrt( pow( vectOffset.x(), 2 ) + pow( vectOffset.y(), 2 ) );
  }

  QgsLinePatternFillSymbolLayer* sl = new QgsLinePatternFillSymbolLayer();
  sl->setColor( lineColor );
  sl->setLineWidth( lineWidth );
  sl->setLineAngle( angle );
  sl->setOffset( offset );
  sl->setDistance( size );

  // try to get the outline
  QDomElement strokeElem = element.firstChildElement( "Stroke" );
  if ( !strokeElem.isNull() )
  {
    QgsSymbolLayerV2 *l = QgsSymbolLayerV2Utils::createLineLayerFromSld( strokeElem );
    if ( l )
    {
      QgsSymbolLayerV2List layers;
      layers.append( l );
      sl->setSubSymbol( new QgsLineSymbolV2( layers ) );
    }
  }

  return sl;
}
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:65,代码来源:qgsfillsymbollayerv2.cpp

示例6: on_actionRunQryFromFile_triggered

void ReportViewWidget::on_actionRunQryFromFile_triggered()
{
	QString path = m_dirModel->data(ui.dirView->currentIndex(), QDirModel::FilePathRole).toString();
	if (!QFileInfo(path).isFile() || !QFile(path).exists())
		return;

    QString errorStr;
    int errorLine;
    int errorColumn;

    QFile file(path);
    if (!file.open(QFile::ReadOnly | QFile::Text)) {
        QMessageBox::warning(this, "CuteFarm",
                             tr("Can not read file  %1\nError: %2")
                             .arg(QFile(path).fileName())
                             .arg(file.errorString()));
        return;
    }

    if (!m_domDocument.setContent(&file, true, &errorStr, &errorLine,
                                &errorColumn)) {
        QMessageBox::information(this, "CuteFarm",
                                 tr("Error in line %1, column %2\nError: %3")
                                 .arg(errorLine)
                                 .arg(errorColumn)
                                 .arg(errorStr));
        return;
    }

    QDomElement root = m_domDocument.documentElement();
    if (root.tagName() != "qry") {
        QMessageBox::information(this, "CuteFarm",
                                 tr("This file is not a query file."));
        return;
    } else if (root.hasAttribute("version")
               && root.attribute("version") != "1.0") {
        QMessageBox::information(this, "CuteFarm",
                                 tr("The file is not an query version 1.0 "
                                    "file."));
        return;
    }

    QString sql = root.firstChildElement("sql").text();
    file.close();

	if (sql.contains("INSERT", Qt::CaseInsensitive) ||
			sql.contains("UPDATE", Qt::CaseInsensitive) ||
			sql.contains("CREATE", Qt::CaseInsensitive) ||
			sql.contains("DELETE", Qt::CaseInsensitive))
		return;

	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
	m_qryModel->setQuery(sql);
	ui.resultView->resizeColumnsToContents();
	ui.resultView->horizontalHeader()->setStretchLastSection(true);
	QApplication::restoreOverrideCursor();

	if (m_qryModel->lastError().type() != QSqlError::NoError)
		emit statusMsg(tr("Error"), 2500);
	else
		emit statusMsg("Ok", 2500);

	ui.textEditError->setText(m_qryModel->lastError().text());
}
开发者ID:jewie,项目名称:cutefarm,代码行数:64,代码来源:reportviewwidget.cpp

示例7: read

void LineSegment::read(const QDomElement& e)
      {
      for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement())
            readProperties(ee);
      }
开发者ID:briff,项目名称:MuseScore,代码行数:5,代码来源:line.cpp

示例8: charger

void Dossier::charger(const FormationManager& forman, const PeriodeManager& periodeman, const UVManager& uvman, const NoteManager& notman)
{
    QDomDocument doc = this->chargerXml(chemin_fichier + "/" + fichier);
    QDomElement racine = doc.documentElement();

    std::vector<const Formation*> tempformations;
    std::vector<Inscription> tempinscriptions;
    Factory<UV> tempuvs;
    std::map<QString,Note> tempnotes;
    QString tempForma = "NULL", tempInscri = "NULL";

    if(racine.tagName() == "dossier")
    {
        QString tempNom, tempPrenom, tempFormation, tempUv, tempNote, code;
        QDomElement unElement = racine.firstChildElement();

        while(!unElement.isNull())
        {
            if(unElement.tagName() == "nom")
            {
                tempNom = unElement.text();
            }
            else if(unElement.tagName() == "prenom")
            {
                tempPrenom = unElement.text();
            }
            else if(unElement.tagName() == "formations")
            {
                tempForma = unElement.text();
                tempformations.push_back(&forman.getFormation(tempForma));
            }
            else if(unElement.tagName() == "inscription")
            {
                QDomElement filsElement = unElement.firstChildElement();
                while(!filsElement.isNull())
                {
                    if(filsElement.tagName()=="code"){
                        code = filsElement.text();
                    }
                    else if(filsElement.tagName()=="semestre"){
                        tempInscri = filsElement.text();
                    }
                    else if(filsElement.tagName() =="formation"){
                        tempFormation = filsElement.text();
                    }
                    else if(filsElement.tagName() == "uv")
                    {
                        QDomElement filsUV = filsElement.firstChildElement();
                        while(!filsUV.isNull())
                        {
                            if(filsUV.tagName() == "codeUV"){
                                tempUv = filsUV.text();
                                tempuvs.ajouter(tempUv,uvman.getUV(tempUv));
                            }
                            if(filsUV.tagName() == "note"){
                                tempNote = filsUV.text();
                                tempnotes[tempUv] = notman.getNote(tempNote);
                            }
                            filsUV = filsUV.nextSiblingElement();
                        }

                    }
                filsElement = filsElement.nextSiblingElement();
                }
                Inscription temp(code,periodeman.getPeriode(tempInscri),forman.getFormation(tempFormation));
                for (map<QString,UV>::iterator it = tempuvs.begin(); it != tempuvs.end(); it++)
                {
                    temp.ajouterUV(it->second);
                    temp.modifierNote(it->second.getCode(),tempnotes.find(it->second.getCode())->second.getNote());
                }
                tempuvs.vider();
                tempinscriptions.push_back(temp);
            }
            unElement = unElement.nextSiblingElement();
        }
        this->setLogin();
        this->setNom(tempNom);
        this->setPrenom(tempPrenom);
        this->setLogin();
        if (tempForma != "NULL")
        {
            for (unsigned int i = 0; i < tempformations.size(); i++)
            {
               ajouterFormation(*tempformations[i]);
            }
            tempformations.clear();
            tempForma = "NULL";
        }
        if (tempInscri!="NULL")
        {
            for(unsigned int i=0; i < tempinscriptions.size(); i++)
            {
                ajouterInscription(tempinscriptions[i].getCode(),tempinscriptions[i].getPeriode(),tempinscriptions[i].getFormation());
                tempuvs=tempinscriptions[i].getUVs();
                for (map<QString,UV>::iterator it = tempuvs.begin(); it != tempuvs.end(); it++)
                {
                    getInscription(tempinscriptions[i].getCode()).ajouterUV(uvman.getUV(it->second.getCode()));
                    getInscription(tempinscriptions[i].getCode()).
                            modifierNote(it->second.getCode(),tempnotes.find(it->second.getCode())->second.getNote());
                }
//.........这里部分代码省略.........
开发者ID:szewenicolas,项目名称:Projet_L021,代码行数:101,代码来源:Dossier.cpp

示例9: load

Script* Script::load(std::string name)
{
    std::string filename = "scripts/";
    filename.append(name);
    filename.append(".xml");

    QFile file(filename.c_str());
    if(!file.open(QIODevice::ReadOnly))
    {
        pi_warn("Could not open file");
        return NULL;
    }

    QDomDocument document;
    document.setContent(&file);

    QDomElement docElem = document.documentElement();

    // check if this is a valid script file
    if(docElem.tagName().toLower().compare("script") != 0)
    {
        pi_warn("Invalid configuration file: tag \"script\" is missing");
        return NULL;
    }

    Script* script = new Script();

    script->m_name = name;

    QDomElement elem = docElem.firstChildElement();

    while(!elem.isNull())
    {
        if(elem.tagName().toLower().compare("rule") == 0)
        {
            Rule* rule = Rule::load(&elem);
            if(rule != NULL)
            {
                script->addRule(rule);
            }
        }
        else if(elem.tagName().toLower().compare("variable") == 0)
        {
            Variable* variable = Variable::load(&elem);
            if(variable != NULL)
            {
                script->addVariable(variable);
            }
        }
        else if(elem.tagName().toLower().compare("description") == 0)
        {
            script->m_desc = elem.text().toStdString();
        }

        elem = elem.nextSiblingElement();
    }

    file.close();

    return script;
}
开发者ID:appl,项目名称:RASP,代码行数:61,代码来源:Script.cpp

示例10: read

void Box::read(const QDomElement& de)
      {
      _leftMargin = _rightMargin = _topMargin = _bottomMargin = 0.0;
      bool keepMargins = false;        // whether original margins have to be kept when reading old file

      for (QDomElement e = de.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
            const QString& tag(e.tagName());
            const QString& text(e.text());
            if (tag == "height")
                  _boxHeight = Spatium(text.toDouble());
            else if (tag == "width")
                  _boxWidth = Spatium(text.toDouble());
            else if (tag == "topGap")
                  _topGap = text.toDouble();
            else if (tag == "bottomGap")
                  _bottomGap = text.toDouble();
            else if (tag == "leftMargin")
                  _leftMargin = text.toDouble();
            else if (tag == "rightMargin")
                  _rightMargin = text.toDouble();
            else if (tag == "topMargin")
                  _topMargin = text.toDouble();
            else if (tag == "bottomMargin")
                  _bottomMargin = text.toDouble();
            else if (tag == "Text") {
                  Text* t;
                  if (type() == TBOX) {
                        t = static_cast<TBox*>(this)->getText();
                        t->read(e);
                        }
                  else {
                        t = new Text(score());
                        t->read(e);
                        add(t);
                        if (score()->mscVersion() <= 114)
                              t->setLayoutToParentWidth(true);
                        }
                  }
            else if (tag == "Symbol") {
                  Symbol* s = new Symbol(score());
                  s->read(e);
                  add(s);
                  }
            else if (tag == "Image") {
                  // look ahead for image type
                  QString path;
                  QDomElement ee = e.firstChildElement("path");
                  if (!ee.isNull())
                        path = ee.text();
                  Image* image = 0;
                  QString s(path.toLower());
                  if (s.endsWith(".svg"))
                        image = new SvgImage(score());
                  else
                        if (s.endsWith(".jpg")
                     || s.endsWith(".png")
                     || s.endsWith(".gif")
                     || s.endsWith(".xpm")
                        ) {
                        image = new RasterImage(score());
                        }
                  else {
                        qDebug("unknown image format <%s>\n", path.toLatin1().data());
                        }
                  if (image) {
                        image->setTrack(score()->curTrack);
                        image->read(e);
                        add(image);
                        }
                  }
            else if (tag == "FretDiagram") {
                  FretDiagram* f = new FretDiagram(score());
                  f->read(e);
                  add(f);
                  }
            else if (tag == "LayoutBreak") {
                  LayoutBreak* lb = new LayoutBreak(score());
                  lb->read(e);
                  add(lb);
                  }
            else if (tag == "HBox") {
                  HBox* hb = new HBox(score());
                  hb->read(e);
                  add(hb);
                  keepMargins = true;     // in old file, box nesting used outer box margins
                  }
            else if (tag == "VBox") {
                  VBox* vb = new VBox(score());
                  vb->read(e);
                  add(vb);
                  keepMargins = true;     // in old file, box nesting used outer box margins
                  }
            else
                  domError(e);
            }

      // with .msc versions prior to 1.17, box margins were only used when nesting another box inside this box:
      // for backward compatibility set them to 0 in all other cases

      if (score()->mscVersion() < 117 && (type() == HBOX || type() == VBOX) && !keepMargins)  {
//.........这里部分代码省略.........
开发者ID:alexkonradi,项目名称:MuseScore,代码行数:101,代码来源:box.cpp

示例11: load

bool Scene::load(const QString& fn) {
    QFile file(fn);
    if (!file.open(QIODevice::ReadOnly)) {
        return false;
    }

    QByteArray data = file.readAll();
    QDomDocument doc;
    if (!doc.setContent(data)) {
        return false;
    }

    clearSelection();
    beginResetModel();
    m_history->clear();
    if (m_static_body)
        delete m_static_body;
    m_static_body = 0;
    foreach( Body* b, m_bodys ) {
        delete b;
    }
    m_bodys.clear();

    QDomElement root = doc.documentElement();
    m_worldSize.setWidth(root.attribute("width").toInt());
    m_worldSize.setHeight(root.attribute("height").toInt());
    QDomElement node = root.firstChildElement("body");
    while (node.isElement()) {
        QString type = node.attribute("type");
        Body* b = 0;
        if (type=="StaticBody") {
            b = new StaticBody(this,"body",this);
            ReadAttributes(b,node);
            if (!m_static_body)
                m_static_body = b;
            else {
                m_bodys.push_back( b );
            }
        } else if (type=="DynamicBody") {
            b = new DynamicBody(this,"body",this);
            ReadAttributes(b,node);
            m_bodys.push_back( b );
        }
        if (b) {
            QDomElement primNode = node.firstChildElement("primitive");
            while (primNode.isElement()) {
                Primitive* p = 0;
                QString type = primNode.attribute("type");
                p = Primitive::create(type,b,this);
                if (p) {
                    ReadAttributes(p,primNode);
                    b->addPrimitive(p);
                }
                primNode = primNode.nextSiblingElement("primitive");
            }
            connect( b,SIGNAL(changed()),this,SLOT(bodyChanged()));
        }
        node = node.nextSiblingElement("body");
    }
    endResetModel();
    m_filename = fn;
    emit changed();
    return true;
}
开发者ID:andryblack,项目名称:Chipmunk-Sandbox,代码行数:64,代码来源:scene.cpp

示例12: QGraphicsItem

ProcessViewItem::ProcessViewItem(QDomElement _graph, const QColor &_color, QGraphicsItem *parent)
        : QGraphicsItem(parent)
        , graph(_graph)
        , color(_color)
        , box_topleft(-140, -140)
        , box_bottomright(140, 140)
        , old_box_topleft(box_topleft)
        , old_box_bottomright(box_bottomright)
        , min_box(120, 80){
    setPos(GetGraphToplevelPosition(graph));
    resizer_topleft     = new ResizeViewItem(this);
    resizer_bottomright = new ResizeViewItem(this);
    resizer_topleft->setPos(box_topleft);
    resizer_bottomright->setPos(box_bottomright);
    connect(resizer_topleft, SIGNAL(positionChanged(ResizeViewItem*)),
            this, SLOT(sizeChanged(ResizeViewItem*)));
    connect(resizer_bottomright, SIGNAL(positionChanged(ResizeViewItem*)),
            this, SLOT(sizeChanged(ResizeViewItem*)));
    connect(resizer_topleft, SIGNAL(mouseRelease(ResizeViewItem*)),
            this, SLOT(mouseRelease(ResizeViewItem*)));
    connect(resizer_bottomright, SIGNAL(mouseRelease(ResizeViewItem*)),
            this, SLOT(mouseRelease(ResizeViewItem*)));
    setFlag(ItemIsMovable, true);
    QDomElement nodes = graph.firstChildElement("nodes");
    for (QDomElement n=nodes.firstChildElement(); !n.isNull(); n=n.nextSiblingElement()){
        NodeViewItem *item;
        QString nodename = n.attribute("name");
        if (nodename.startsWith("input_proxy_")){
            item = new InputProxyViewItem(n, this);
        } else if (nodename.startsWith("output_proxy_")){
            item = new OutputProxyViewItem(n, this);
        } else {
            item = new NodeViewItem(n, this);
        }
        item->setPos(-item->width/2, -item->height/2);
        nodeviewitemlist.push_back(item);
        connect(item, SIGNAL(positionChanged(const NodeViewItem*)),
                this, SLOT(positionChanged(const NodeViewItem*)));
    }
    QDomElement edges = graph.firstChildElement("connections");
    for (QDomElement edge=edges.firstChildElement(); !edge.isNull(); edge=edge.nextSiblingElement()){
        const NodeViewItem *from = 0, *to = 0;
        for (list<NodeViewItem*>::const_iterator j=nodeviewitemlist.begin(); j!=nodeviewitemlist.end(); ++j){
            if ((*j)->node.attribute("name") == edge.attribute("from")){
                from = *j;
            }
            if ((*j)->node.attribute("name") == edge.attribute("to")){
                to = *j;
            }
        }
        if ((from != 0) && (to != 0)){
            int from_index = GetOutportIndex(from->node, edge.attribute("from-port"));
            int to_index   = GetInportIndex(to->node, edge.attribute("to-port"));
            //cout << ", index: " << from_index << ", " << to_index << ", elem: " << hex << (void*)node->elem2 << ", " << (void*)node->elem3 << dec << endl;
            EdgeViewItem *item = new EdgeViewItem(from, to, from_index, to_index, this);
            for (list<NodeViewItem*>::const_iterator nvi=nodeviewitemlist.begin(); nvi!=nodeviewitemlist.end(); ++nvi){
                if (   ((*nvi)->node.attribute("name") == edge.attribute("from"))
                    || ((*nvi)->node.attribute("name") == edge.attribute("to"))){
                    connect((*nvi), SIGNAL(positionChanged(const NodeViewItem*)),
                            item, SLOT(redrawEdge(const NodeViewItem*)));
                }
            }
        }
开发者ID:axel-freesp,项目名称:edit-sp,代码行数:63,代码来源:processviewitem.cpp

示例13: channel

	channels_container_t RSS10Parser::Parse (const QDomDocument& doc,
			const IDType_t& feedId) const
	{
		channels_container_t result;
	
		QMap<QString, Channel_ptr> item2Channel;
		QDomElement root = doc.documentElement ();
		QDomElement channelDescr = root.firstChildElement ("channel");
		while (!channelDescr.isNull ())
		{
			Channel_ptr channel (new Channel (feedId));
			channel->Title_ = channelDescr.firstChildElement ("title").text ().trimmed ();
			channel->Link_ = channelDescr.firstChildElement ("link").text ();
			channel->Description_ =
				channelDescr.firstChildElement ("description").text ();
			channel->PixmapURL_ =
				channelDescr.firstChildElement ("image")
				.firstChildElement ("url").text ();
			channel->LastBuild_ = GetDCDateTime (channelDescr);
	
			QDomElement itemsRoot = channelDescr.firstChildElement ("items");
			QDomNodeList seqs = itemsRoot.elementsByTagNameNS (RDF_, "Seq");
	
			channelDescr = channelDescr.nextSiblingElement ("channel");
	
			if (!seqs.size ())
				continue;
	
			QDomElement seqElem = seqs.at (0).toElement ();
			QDomNodeList lis = seqElem.elementsByTagNameNS (RDF_, "li");
			for (int i = 0; i < lis.size (); ++i)
				item2Channel [lis.at (i).toElement ().attribute ("resource")] = channel;
	
			result.push_back (channel);
		}
	
		QDomElement itemDescr = root.firstChildElement ("item");
		while (!itemDescr.isNull ())
		{
			QString about = itemDescr.attributeNS (RDF_, "about");
			if (item2Channel.contains (about))
			{
				Item_ptr item (new Item (item2Channel [about]->ChannelID_));
				item->Title_ = itemDescr.firstChildElement ("title").text ();
				item->Link_ = itemDescr.firstChildElement ("link").text ();
				item->Description_ = itemDescr.firstChildElement ("description").text ();
				GetDescription (itemDescr, item->Description_);
	
				item->Categories_ = GetAllCategories (itemDescr);
				item->Author_ = GetAuthor (itemDescr);
				item->PubDate_ = GetDCDateTime (itemDescr);
				item->Unread_ = true;
				item->NumComments_ = GetNumComments (itemDescr);
				item->CommentsLink_ = GetCommentsRSS (itemDescr);
				item->CommentsPageLink_ = GetCommentsLink (itemDescr);
				item->Enclosures_ = GetEncEnclosures (itemDescr, item->ItemID_);
				QPair<double, double> point = GetGeoPoint (itemDescr);
				item->Latitude_ = point.first;
				item->Longitude_ = point.second;
				if (item->Guid_.isEmpty ())
					item->Guid_ = "empty";
	
				item2Channel [about]->Items_.push_back (item);
			}
			itemDescr = itemDescr.nextSiblingElement ("item");
		}
	
		return result;
	}
开发者ID:Zereal,项目名称:leechcraft,代码行数:69,代码来源:rss10parser.cpp

示例14: cargaConf

/**
\return
**/
void BfCompany::cargaConf()
{
    BL_FUNC_DEBUG
    QFile file ( g_confpr->value( CONF_DIR_USER ) + "bulmafact_" + dbName() + ".cfn" );
    QDomDocument doc ( "mydocument" );
    if ( !file.open ( QIODevice::ReadOnly ) )
        return;
    if ( !doc.setContent ( &file ) ) {
        file.close();
        return;
    }
    file.close();

    // print out the element names of all elements that are direct children
    // of the outermost element.
    QDomElement docElem = doc.documentElement();
    QDomElement principal = docElem.firstChildElement ( "PRINCIPAL" );
    /// Cogemos la coordenada X
    QString nx = principal.firstChildElement ( "X" ).toElement().text();

    /// Cogemos la coordenada Y
    QString ny = principal.firstChildElement ( "Y" ).toElement().text();

    /// Cogemos el ancho
    QString nwidth = principal.firstChildElement ( "WIDTH" ).toElement().text();

    /// Cogemos el alto
    QString nheight = principal.firstChildElement ( "HEIGHT" ).toElement().text();

    /// Si est&aacute; maximizada, ignoramos las otras dimensiones
    if (principal.firstChildElement ( "MAXIMIZED" ).toElement().text() == "true")
	 m_bulmafact->setWindowState(Qt::WindowMaximized);
    else /// Establecemos la geometria de la ventana principal.
	 m_bulmafact->setGeometry ( nx.toInt(), ny.toInt(), nwidth.toInt(), nheight.toInt() );

    /// Cogemos el indexador
    QString indexador = principal.firstChildElement ( "INDEXADOR" ).toElement().text();
    if ( indexador == "true" ) {
        s_indexadorCambiaEstado ( true );
        m_bulmafact->actionIndexador->setChecked ( true );
    } else {
        s_indexadorCambiaEstado ( false );
        m_bulmafact->actionIndexador->setChecked ( false );
    } // end if

    /// Cogemos el ancho del indexador
    m_bulmafact->restoreState ( QByteArray::fromBase64 ( QByteArray ( principal.firstChildElement ( "TOOLBARSDOCKWIDGETS" ).toElement().text().toLatin1() ) ) );

    /// Tratamos cada ventana
    QWidget *activewindow = NULL;
    QDomNodeList nodos = docElem.elementsByTagName ( "VENTANA" );
    for ( int i = 0; i < nodos.count(); i++ ) {
        QDomNode ventana = nodos.item ( i );
        QDomElement e1 = ventana.toElement(); /// try to convert the node to an element.
        if ( !e1.isNull() ) { /// the node was really an element.
            QString vname = e1.firstChildElement ( "VNAME" ).toElement().text();
            for ( int j = 0; j < m_windowListDock->numVentanas(); j++ ) {
                QObject *obj = m_windowListDock->ventana ( j );
                QWidget *wid = ( QWidget * ) obj;
                if ( obj->objectName() == vname ) {
                    QString vx = e1.firstChildElement ( "VX" ).toElement().text();
                    QString vy = e1.firstChildElement ( "VY" ).toElement().text();
                    QString vwidth = e1.firstChildElement ( "VWIDTH" ).toElement().text();
                    QString vheight = e1.firstChildElement ( "VHEIGHT" ).toElement().text();
                    QString vvisible = e1.firstChildElement ( "VVISIBLE" ).toElement().text();
                    QString vmaximized = e1.firstChildElement ( "VMAXIMIZED" ).toElement().text();
                    QString vactivewindow = e1.firstChildElement ( "VACTIVEWINDOW" ).toElement().text();
                    /// Establecemos la geometria de la ventana principal.
                    wid->resize ( vwidth.toInt(), vheight.toInt() );
                    wid->parentWidget() ->move ( vx.toInt(), vy.toInt() );
                    if ( vvisible == "true" ) {
                        wid->showNormal();
                    } // end if
                    if ( vmaximized == "true" ) {
                        wid->showMaximized();
                    }
                    if ( vactivewindow == "true" ) {
                        activewindow = wid;
                    }
                } // end if
            } // end for
        } // end if
    } // end for
    /// Si hay una ventana activa se pone como activa.
    if ( activewindow )
	activewindow->activateWindow();
    
}
开发者ID:i02sopop,项目名称:Bulmages,代码行数:91,代码来源:bfcompany.cpp

示例15: deSerialize

bool ActionCollection::deSerialize(const QDomElement& actionCollectionElem)
{
  if (actionCollectionElem.isNull())
    return false;

  qDeleteAll(listInterfaceCommands);
  listInterfaceCommands.clear();

  QDomElement listsElement = actionCollectionElem.firstChildElement("lists");

  if (listsElement.isNull()) {
    QHash<CommandListElements::Element, VoiceInterfaceCommand*> baseConfig = ScenarioManager::getInstance()->
      getListBaseConfiguration();

    QHashIterator<CommandListElements::Element, VoiceInterfaceCommand*> i(baseConfig);
    while (i.hasNext()) {
      i.next();
      // i.value() is not a valid command
      listInterfaceCommands.insertMulti(i.key(), new VoiceInterfaceCommand(*(i.value())));
    }
  }
  else {
    QDomElement commandElem = listsElement.firstChildElement();

    while (!commandElem.isNull()) {
      VoiceInterfaceCommand *com = VoiceInterfaceCommand::createInstance(commandElem);

      int elementId = commandElem.attribute("element").toInt();

      commandElem = commandElem.nextSiblingElement("voiceInterfaceCommand");

      if (!com) continue;

      listInterfaceCommands.insert((CommandListElements::Element) elementId, com);
    }
  }

  QDomElement autorunElem = actionCollectionElem.firstChildElement("autorun");
  m_autorunActive = autorunElem.attribute("active") == "1";
  m_autorunCommand = autorunElem.firstChildElement("trigger").text();
  m_autorunType = autorunElem.firstChildElement("category").text();

  //clean member
  qDeleteAll(m_actions);
  m_actions.clear();

  QDomElement pluginElem = actionCollectionElem.firstChildElement("plugin");
  while (!pluginElem.isNull()) {
    Action *a = Action::createAction(parentScenario, pluginElem, this);
    if (!a) {
      kDebug() << "Could not load action";
    }
    else {
      //m_actions << a;
      appendAction(a, true /*silent*/);
    }

    pluginElem = pluginElem.nextSiblingElement("plugin");
  }
  proxy->update();
  reset();

  if (m_autorunActive)
  {
    bool succ = triggerCommand(m_autorunType, m_autorunCommand, true /* silent */);
    kDebug() << "Executed autorun command; Success: " << succ;
  }

  return true;
}
开发者ID:KDE,项目名称:simon,代码行数:70,代码来源:actioncollection.cpp


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