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


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

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


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

示例1: createComment

QDomComment QDomDocumentProto::createComment(const QString& data)
{
    QDomDocument *item = qscriptvalue_cast<QDomDocument*>(thisObject());
    if (item)
        return item->createComment(data);
    return QDomComment();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: write

bool XmlNotation::write(const std::vector<Moves> &mv)
{
    QDomDocument doc;

    auto proc = doc.createProcessingInstruction(
            u8"xml", u8"version=\"1.0\" encoding=\"utf-8\"");
    doc.appendChild(proc);

    auto cAuthors = doc.createComment(fromU8Str(impl::comment));
    doc.appendChild(cAuthors), doc.appendChild(doc.createTextNode("\n"));

    auto eRoot = doc.createElementNS(fromU8Str(impl::xmlns),
                                     fromU8Str(impl::eRoot));
    doc.appendChild(eRoot);

    for (auto &i : mv) {
        auto eTurn = doc.createElement(fromU8Str(impl::eTurn));
        eRoot.appendChild(eTurn);

        eTurn.setAttribute(fromU8Str(impl::aWhite),
            QString::fromStdString(i.white_move.to_string()));

        eTurn.setAttribute(fromU8Str(impl::aBlack),
            QString::fromStdString(i.black_move.to_string()));
    }

    QByteArray raw = doc.toByteArray(4);

    std::ofstream f(_pImpl->fileName,
                    std::ios_base::binary |
                    std::ios_base::trunc);
    f.write(raw.data(), raw.count());

    return true;
}
开发者ID:zcsevcik,项目名称:edu,代码行数:35,代码来源:XmlNotation.cpp

示例3: toSld

void QgsSVGFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{
  QDomElement symbolizerElem = doc.createElement( "se:PolygonSymbolizer" );
  if ( !props.value( "uom", "" ).isEmpty() )
    symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
  element.appendChild( symbolizerElem );

  QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );

  QDomElement fillElem = doc.createElement( "se:Fill" );
  symbolizerElem.appendChild( fillElem );

  QDomElement graphicFillElem = doc.createElement( "se:GraphicFill" );
  fillElem.appendChild( graphicFillElem );

  QDomElement graphicElem = doc.createElement( "se:Graphic" );
  graphicFillElem.appendChild( graphicElem );

  if ( !mSvgFilePath.isEmpty() )
  {
    QgsSymbolLayerV2Utils::externalGraphicToSld( doc, graphicElem, mSvgFilePath, "image/svg+xml", mSvgFillColor, mPatternWidth );
  }
  else
  {
    // TODO: create svg from data
    // <se:InlineContent>
    symbolizerElem.appendChild( doc.createComment( "SVG from data not implemented yet" ) );
  }

  if ( mSvgOutlineColor.isValid() || mSvgOutlineWidth >= 0 )
  {
    QgsSymbolLayerV2Utils::lineToSld( doc, graphicElem, Qt::SolidLine, mSvgOutlineColor, mSvgOutlineWidth );
  }

  // <Rotation>
  QString angleFunc;
  bool ok;
  double angle = props.value( "angle", "0" ).toDouble( &ok );
  if ( !ok )
  {
    angleFunc = QString( "%1 + %2" ).arg( props.value( "angle", "0" ) ).arg( mAngle );
  }
  else if ( angle + mAngle != 0 )
  {
    angleFunc = QString::number( angle + mAngle );
  }
  QgsSymbolLayerV2Utils::createRotationElement( doc, graphicElem, angleFunc );

  if ( mOutline )
  {
    // the outline sub symbol should be stored within the Stroke element,
    // but it will be stored in a separated LineSymbolizer because it could
    // have more than one layer
    mOutline->toSld( doc, element, props );
  }
}
开发者ID:badcock4412,项目名称:Quantum-GIS,代码行数:56,代码来源:qgsfillsymbollayerv2.cpp

示例4: meinprocExited

void TOC::meinprocExited( int exitCode, QProcess::ExitStatus exitStatus)
{
    KProcess *meinproc = static_cast<KProcess *>(sender());
    KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );

    if ( exitStatus == QProcess::CrashExit || exitCode != 0 ) {
        kError() << "running" << meinproc->program() << "failed with exitCode" << exitCode;
        kError() << "stderr output:" << meinproc->readAllStandardError(); 
        if (mainWindow && !m_alreadyWarned) {
            ; // add warning message box with don't display again option 
              // http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classKDialog.html
            m_alreadyWarned = true;
        }
        delete meinproc;
        return;
    }

    delete meinproc;

    // add a timestamp to the meinproc4 created xml file
    QFile f( m_cacheFile );
    if ( !f.open( QIODevice::ReadWrite ) )
        return;

    QDomDocument doc;
    if ( !doc.setContent( &f ) )
        return;

    QDomComment timestamp = doc.createComment( QString::number( sourceFileCTime() ) );
    doc.documentElement().appendChild( timestamp );

    // write back updated xml content 
    f.seek( 0 );
    QTextStream stream( &f );
    stream.setCodec( "UTF-8" );
#ifdef Q_WS_WIN
    /*
      the problem that on german systems umlauts are displayed as '?' for unknown (Qt'r related ?) reasons
      is caused by wrong encoding type conversations and has been fixed in kdelibs/kdoctools
      To have propper encoding tags in the xml file, QXmlDocument::save() is used. 
    */
    doc.save(stream, 1, QDomNode::EncodingFromTextStream);

#else
    stream << doc.toString();
#endif
    f.close();
    fillTree();
}
开发者ID:KDE,项目名称:kde-runtime,代码行数:49,代码来源:toc.cpp

示例5: importFile

/**
 * @details
 * Imports and appends a file to the given \p parent XML node.
 * All element nodes under (but not including) the root node of the
 * file are copied to the \p document.
 *
 * If not an absolute path, the name of the file to import must be relative
 * to the executable.
 *
 * @param[in] document A reference to the XML document.
 * @param[in] parent   A reference to the parent XML node.
 * @param[in] name     Name of the file to import.
 */
void Config::importFile(QDomDocument& document,
        QDomNode& parent, const QString& name)
{
    // Return if name is empty.
    if (name.isEmpty()) return;

    // find the file
    QString filename = searchFile(name);

    // Write comment.
    parent.appendChild(document.createComment(
            "% Imported file " + filename) );

    // Import the file.
    QDomDocument newDoc = read(filename);

    // Loop over each child under the root node of the file, and append it.
    QDomNodeList list = newDoc.documentElement().childNodes();
    for (int j = 0; j < list.size(); j++) {
        parent.appendChild(list.at(j).cloneNode());
    }
}
开发者ID:chrisjwilliams,项目名称:pelican,代码行数:35,代码来源:Config.cpp

示例6: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    // Prepare the XML file
    QFile file("list.xml");
    file.remove();
    QDomDocument xml;
    QDomNode declaration = xml.createProcessingInstruction("xml",QString("version=\"1.0\" encoding=\"UTF-8\""));
    xml.insertBefore(declaration,xml.firstChild());
    QDomComment comment = xml.createComment("Do not edit this file, it is regenerated automatically!");
    xml.appendChild(comment);
    QDomNode root = xml.createElement("files");
    xml.appendChild(root);

    // Liste tous les fichiers
    QStringList liste;
    QDirIterator it(".", QDir::Files, QDirIterator::Subdirectories);
    while (it.hasNext()) {
        if(QString(it.hasNext()).startsWith("./Assets/Modules/Custom_Civilizations_MCP/"))
        {}
        else{
            // Add the file to the list
            QDomElement entity = xml.createElement("file");
            entity.appendChild(xml.createTextNode(it.next()));
            entity.setAttribute("md5", checkMd5(it.next()));
            root.appendChild(entity);
        }
    }

    // Save the file
    file.open(QIODevice::Truncate | QIODevice::WriteOnly);
    QTextStream ts(&file);
    xml.save(ts, 4);
    file.close();

    return a.exec();
}
开发者ID:dbkblk,项目名称:rand_helper_tools,代码行数:37,代码来源:main.cpp

示例7: switch

void QgsMarkerLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const
{
  for ( int i = 0; i < mMarker->symbolLayerCount(); i++ )
  {
    QDomElement symbolizerElem = doc.createElement( "se:LineSymbolizer" );
    if ( !props.value( "uom", "" ).isEmpty() )
      symbolizerElem.setAttribute( "uom", props.value( "uom", "" ) );
    element.appendChild( symbolizerElem );

    // <Geometry>
    QgsSymbolLayerV2Utils::createGeometryElement( doc, symbolizerElem, props.value( "geom", "" ) );

    QString gap;
    switch ( mPlacement )
    {
      case FirstVertex:
        symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "firstPoint" ) );
        break;
      case LastVertex:
        symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "lastPoint" ) );
        break;
      case CentralPoint:
        symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "centralPoint" ) );
        break;
      case Vertex:
        // no way to get line/polygon's vertices, use a VendorOption
        symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "placement", "points" ) );
        break;
      default:
        gap = QString::number( mInterval );
        break;
    }

    if ( !mRotateMarker )
    {
      // markers in LineSymbolizer must be drawn following the line orientation,
      // use a VendorOption when no marker rotation
      symbolizerElem.appendChild( QgsSymbolLayerV2Utils::createVendorOptionElement( doc, "rotateMarker", "0" ) );
    }

    // <Stroke>
    QDomElement strokeElem = doc.createElement( "se:Stroke" );
    symbolizerElem.appendChild( strokeElem );

    // <GraphicStroke>
    QDomElement graphicStrokeElem = doc.createElement( "se:GraphicStroke" );
    strokeElem.appendChild( graphicStrokeElem );

    QgsSymbolLayerV2 *layer = mMarker->symbolLayer( i );
    QgsMarkerSymbolLayerV2 *markerLayer = static_cast<QgsMarkerSymbolLayerV2 *>( layer );
    if ( !markerLayer )
    {
      graphicStrokeElem.appendChild( doc.createComment( QString( "MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( markerLayer->layerType() ) ) );
    }
    else
    {
      markerLayer->writeSldMarker( doc, graphicStrokeElem, props );
    }

    if ( !gap.isEmpty() )
    {
      QDomElement gapElem = doc.createElement( "se:Gap" );
      QgsSymbolLayerV2Utils::createFunctionElement( doc, gapElem, gap );
      graphicStrokeElem.appendChild( gapElem );
    }

    if ( !qgsDoubleNear( mOffset, 0.0 ) )
    {
      QDomElement perpOffsetElem = doc.createElement( "se:PerpendicularOffset" );
      perpOffsetElem.appendChild( doc.createTextNode( QString::number( mOffset ) ) );
      symbolizerElem.appendChild( perpOffsetElem );
    }
  }
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:74,代码来源:qgslinesymbollayerv2.cpp

示例8: writeTextSymbolizer

void QgsAbstractVectorLayerLabeling::writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, const QgsStringMap &props ) const
{
  QDomDocument doc = parent.ownerDocument();

  // text symbolizer
  QDomElement textSymbolizerElement = doc.createElement( QStringLiteral( "se:TextSymbolizer" ) );
  parent.appendChild( textSymbolizerElement );

  // label
  QgsTextFormat format = settings.format();
  QFont font = format.font();
  QDomElement labelElement = doc.createElement( QStringLiteral( "se:Label" ) );
  textSymbolizerElement.appendChild( labelElement );
  if ( settings.isExpression )
  {
    labelElement.appendChild( doc.createComment( QStringLiteral( "SE Export for %1 not implemented yet" ).arg( settings.getLabelExpression()->dump() ) ) );
    labelElement.appendChild( doc.createTextNode( "Placeholder" ) );
  }
  else
  {
    if ( font.capitalization() == QFont::AllUppercase )
    {
      appendSimpleFunction( doc, labelElement, QStringLiteral( "strToUpperCase" ), settings.fieldName );
    }
    else if ( font.capitalization() == QFont::AllLowercase )
    {
      appendSimpleFunction( doc, labelElement, QStringLiteral( "strToLowerCase" ), settings.fieldName );
    }
    else if ( font.capitalization() == QFont::Capitalize )
    {
      appendSimpleFunction( doc, labelElement, QStringLiteral( "strCapitalize" ), settings.fieldName );
    }
    else
    {
      QDomElement propertyNameElement = doc.createElement( QStringLiteral( "ogc:PropertyName" ) );
      propertyNameElement.appendChild( doc.createTextNode( settings.fieldName ) );
      labelElement.appendChild( propertyNameElement );
    }
  }

  // font
  QDomElement fontElement = doc.createElement( QStringLiteral( "se:Font" ) );
  textSymbolizerElement.appendChild( fontElement );
  fontElement.appendChild( QgsSymbolLayerUtils::createSvgParameterElement( doc, QStringLiteral( "font-family" ), font.family() ) );
  double fontSize = QgsSymbolLayerUtils::rescaleUom( format.size(), format.sizeUnit(), props );
  fontElement.appendChild( QgsSymbolLayerUtils::createSvgParameterElement( doc, QStringLiteral( "font-size" ), QString::number( fontSize ) ) );
  if ( format.font().italic() )
  {
    fontElement.appendChild( QgsSymbolLayerUtils::createSvgParameterElement( doc, QStringLiteral( "font-style" ), QStringLiteral( "italic" ) ) );
  }
  if ( format.font().bold() )
  {
    fontElement.appendChild( QgsSymbolLayerUtils::createSvgParameterElement( doc, QStringLiteral( "font-weight" ), QStringLiteral( "bold" ) ) );
  }

  // label placement
  QDomElement labelPlacement = doc.createElement( QStringLiteral( "se:LabelPlacement" ) );
  textSymbolizerElement.appendChild( labelPlacement );
  double maxDisplacement = 0;
  double repeatDistance = 0;
  switch ( settings.placement )
  {
    case QgsPalLayerSettings::OverPoint:
    {
      QDomElement pointPlacement = doc.createElement( "se:PointPlacement" );
      labelPlacement.appendChild( pointPlacement );
      // anchor point
      QPointF anchor = quadOffsetToSldAnchor( settings.quadOffset );
      QgsSymbolLayerUtils::createAnchorPointElement( doc, pointPlacement, anchor );
      // displacement
      if ( settings.xOffset > 0 || settings.yOffset > 0 )
      {
        QgsUnitTypes::RenderUnit offsetUnit =  settings.offsetUnits;
        double dx = QgsSymbolLayerUtils::rescaleUom( settings.xOffset, offsetUnit, props );
        double dy = QgsSymbolLayerUtils::rescaleUom( settings.yOffset, offsetUnit, props );
        QgsSymbolLayerUtils::createDisplacementElement( doc, pointPlacement, QPointF( dx, dy ) );
      }
      // rotation
      if ( settings.angleOffset != 0 )
      {
        QDomElement rotation = doc.createElement( "se:Rotation" );
        pointPlacement.appendChild( rotation );
        rotation.appendChild( doc.createTextNode( QString::number( settings.angleOffset ) ) );
      }
    }
    break;
    case QgsPalLayerSettings::AroundPoint:
    case QgsPalLayerSettings::OrderedPositionsAroundPoint:
    {
      QDomElement pointPlacement = doc.createElement( "se:PointPlacement" );
      labelPlacement.appendChild( pointPlacement );

      // SLD cannot do either, but let's do a best effort setting the distance using
      // anchor point and displacement
      QgsSymbolLayerUtils::createAnchorPointElement( doc, pointPlacement, QPointF( 0, 0.5 ) );
      QgsUnitTypes::RenderUnit distUnit = settings.distUnits;
      double radius = QgsSymbolLayerUtils::rescaleUom( settings.dist, distUnit, props );
      double offset = std::sqrt( radius * radius / 2 ); // make it start top/right
      maxDisplacement = radius + 1; // lock the distance
      QgsSymbolLayerUtils::createDisplacementElement( doc, pointPlacement, QPointF( offset, offset ) );
//.........这里部分代码省略.........
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:101,代码来源:qgsvectorlayerlabeling.cpp

示例9: toSld

void QgsVectorFieldSymbolLayer::toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const
{
  element.appendChild( doc.createComment( "VectorField not implemented yet..." ) );
  mLineSymbol->toSld( doc, element, props );
}
开发者ID:Nald,项目名称:Quantum-GIS,代码行数:5,代码来源:qgsvectorfieldsymbollayer.cpp

示例10: fopMeta


//.........这里部分代码省略.........
    
    QDomElement rafter = dom.createElement("fo:region-after");
	rafter.setAttribute ("region-name","xsl-region-after");
    rafter.setAttribute ("background-color",hc.foName(area[1].bg));
    rafter.setAttribute ("extent",metrics(body.margin_bottom));
	pmaster.appendChild( rafter );
    
    
    QDomElement rstart = dom.createElement("fo:region-start");
	rstart.setAttribute ("region-name","xsl-region-start");
    rstart.setAttribute ("background-color",hc.foName(area[2].bg));
    rstart.setAttribute ("extent",metrics(body.margin_left));
	pmaster.appendChild( rstart );
    
    QDomElement rend = dom.createElement("fo:region-end");
	rend.setAttribute ("region-name","xsl-region-end");
    rend.setAttribute ("background-color",hc.foName(area[3].bg));
    rend.setAttribute ("extent",metrics(body.margin_right));
	pmaster.appendChild( rend );
    
    
  	QDomElement pageseq1 = dom.createElement("fo:page-sequence");
	pageseq1.setAttribute ("master-reference","scribe");
	basexslforoot.appendChild( pageseq1 );
    
    QDomElement txt_1 = dom.createElement("fo:static-content");
    txt_1.setAttribute ("flow-name","xsl-region-before");
    QDomElement a_txt_1 = dom.createElement("fo:block-container");
    txt_1.appendChild( a_txt_1 );
    QDomElement b_txt_1 = dom.createElement("fo:block");
    b_txt_1.setAttribute ("color",hc.foName(area[0].bg));
    b_txt_1.appendChild( dom.createTextNode ( "." )  );
    a_txt_1.appendChild( b_txt_1 );
    b_txt_1.appendChild( dom.createComment(QString("Header region / xsl-region-before ")) );
    pageseq1.appendChild( txt_1 );
    
    
    QDomElement txt_2 = dom.createElement("fo:static-content");
    txt_2.setAttribute ("flow-name","xsl-region-after");
    QDomElement a_txt_2 = dom.createElement("fo:block-container");
    txt_2.appendChild( a_txt_2 );
    QDomElement b_txt_2 = dom.createElement("fo:block");
    b_txt_2.setAttribute ("color",hc.foName(area[1].bg));
    b_txt_2.appendChild( dom.createTextNode ( "." )  );
    a_txt_2.appendChild( b_txt_2 );
    b_txt_2.appendChild( dom.createComment(QString("Footer region / xsl-region-after ")) );
    pageseq1.appendChild( txt_2 );
    
    
    QDomElement txt_3 = dom.createElement("fo:static-content");
    txt_3.setAttribute ("flow-name","xsl-region-start");
    QDomElement a_txt_3 = dom.createElement("fo:block-container");
    txt_3.appendChild( a_txt_3 );
    QDomElement b_txt_3 = dom.createElement("fo:block");
    b_txt_3.setAttribute ("color",hc.foName(area[2].bg));
    b_txt_3.appendChild( dom.createTextNode ( "." )  );
    a_txt_3.appendChild( b_txt_3 );
    b_txt_3.appendChild( dom.createComment(QString("Left  region / xsl-region-start ")) );
    pageseq1.appendChild( txt_3 );
    
    
    QDomElement txt_4 = dom.createElement("fo:static-content");
    txt_4.setAttribute ("flow-name","xsl-region-end");
    QDomElement a_txt_4 = dom.createElement("fo:block-container");
    txt_4.appendChild( a_txt_4 );
    QDomElement b_txt_4 = dom.createElement("fo:block");
开发者ID:SorinS,项目名称:fop-miniscribus,代码行数:67,代码来源:PageFormatGroup.cpp


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