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


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

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


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

示例1: dump_element

static QString dump_element(const QDomElement &el)
{
	QString ret;
	QTextStream s(&ret);
	el.save(s, QDomNode::EncodingFromDocument);
	return ret;
}
开发者ID:pavelkral,项目名称:quickbox,代码行数:7,代码来源:classeswidget.cpp

示例2: saveSymbol

bool QgsStyle::saveSymbol( const QString& name, QgsSymbol* symbol, int groupid, const QStringList& tags )
{
  // TODO add support for groups
  QDomDocument doc( "dummy" );
  QDomElement symEl = QgsSymbolLayerUtils::saveSymbol( name, symbol, doc );
  if ( symEl.isNull() )
  {
    QgsDebugMsg( "Couldn't convert symbol to valid XML!" );
    return false;
  }

  QByteArray xmlArray;
  QTextStream stream( &xmlArray );
  stream.setCodec( "UTF-8" );
  symEl.save( stream, 4 );
  char *query = sqlite3_mprintf( "INSERT INTO symbol VALUES (NULL, '%q', '%q', %d);",
                                 name.toUtf8().constData(), xmlArray.constData(), groupid );

  if ( !runEmptyQuery( query ) )
  {
    QgsDebugMsg( "Couldn't insert symbol into the database!" );
    return false;
  }

  tagSymbol( SymbolEntity, name, tags );

  emit symbolSaved( name, symbol );

  return true;
}
开发者ID:fritsvanveen,项目名称:QGIS,代码行数:30,代码来源:qgsstyle.cpp

示例3: createRootXmlTags

// createRootXmlTags
//
// This function creates three QStrings, one being an <?xml .. ?> processing
// instruction, and the others being the opening and closing tags of an
// element, <foo> and </foo>.  This basically allows us to get the raw XML
// text needed to open/close an XML stream, without resorting to generating
// the XML ourselves.  This function uses QDom to do the generation, which
// ensures proper encoding and entity output.
static void createRootXmlTags(const QDomElement &root, QString *xmlHeader, QString *tagOpen, QString *tagClose)
{
	QDomElement e = root.cloneNode(false).toElement();

	// insert a dummy element to ensure open and closing tags are generated
	QDomElement dummy = e.ownerDocument().createElement("dummy");
	e.appendChild(dummy);

	// convert to xml->text
	QString str;
	{
		QTextStream ts(&str, QIODevice::WriteOnly);
		e.save(ts, 0);
	}

	// parse the tags out
	int n = str.indexOf('<');
	int n2 = str.indexOf('>', n);
	++n2;
	*tagOpen = str.mid(n, n2-n);
	n2 = str.lastIndexOf('>');
	n = str.lastIndexOf('<');
	++n2;
	*tagClose = str.mid(n, n2-n);

	// generate a nice xml processing header
	*xmlHeader = "<?xml version=\"1.0\"?>";
}
开发者ID:ExtensionHealthcare,项目名称:iris,代码行数:36,代码来源:xmlprotocol.cpp

示例4: saveColorRamp

bool QgsStyle::saveColorRamp( const QString& name, QgsColorRamp* ramp, int groupid, const QStringList& tags )
{
  // insert it into the database
  QDomDocument doc( "dummy" );
  QDomElement rampEl = QgsSymbolLayerUtils::saveColorRamp( name, ramp, doc );
  if ( rampEl.isNull() )
  {
    QgsDebugMsg( "Couldn't convert color ramp to valid XML!" );
    return false;
  }

  QByteArray xmlArray;
  QTextStream stream( &xmlArray );
  stream.setCodec( "UTF-8" );
  rampEl.save( stream, 4 );
  char *query = sqlite3_mprintf( "INSERT INTO colorramp VALUES (NULL, '%q', '%q', %d);",
                                 name.toUtf8().constData(), xmlArray.constData(), groupid );

  if ( !runEmptyQuery( query ) )
  {
    QgsDebugMsg( "Couldn't insert colorramp into the database!" );
    return false;
  }

  tagSymbol( ColorrampEntity, name, tags );

  return true;
}
开发者ID:fritsvanveen,项目名称:QGIS,代码行数:28,代码来源:qgsstyle.cpp

示例5: addGetFeatureLayers

void QgsServerProjectParser::addGetFeatureLayers( const QDomElement& layerElem ) const
{
  QString str;
  QTextStream stream( &str );
  layerElem.save( stream, 2 );

  QRegExp rx( "getFeature\\('([^']*)'" );
  int idx = 0;
  while (( idx = rx.indexIn( str, idx ) ) != -1 )
  {
    QString name = rx.cap( 1 );
    QgsMapLayer* ml = nullptr;
    QHash< QString, QDomElement >::const_iterator layerElemIt = mProjectLayerElementsById.find( name );
    if ( layerElemIt != mProjectLayerElementsById.constEnd() )
    {
      ml = createLayerFromElement( layerElemIt.value() );
    }
    else
    {
      layerElemIt = mProjectLayerElementsByName.find( name );
      if ( layerElemIt != mProjectLayerElementsByName.constEnd() )
      {
        ml = createLayerFromElement( layerElemIt.value() );
      }
    }

    if ( ml )
    {
      QgsMapLayerRegistry::instance()->addMapLayer( ml, false, false );
    }
    idx += rx.matchedLength();
  }
}
开发者ID:V17nika,项目名称:QGIS,代码行数:33,代码来源:qgsserverprojectparser.cpp

示例6: stream

QComponentNode::QComponentNode(const QDomElement& xmlNode, int row, QXmlTreeModel* model, QXmlTreeNode* parent ) : QXmlTreeNode(xmlNode, row, model, parent)
{
	QString data;
	QTextStream stream(&data);
	xmlNode.save(stream, 4);
	unsigned int entityID = GameEngine::entityWorldID( qPrintable(parent->property("Name").toString()) );
	m_valid = GameEngine::setComponentData(entityID, qPrintable( xmlNode.tagName() ), qPrintable(data));
}
开发者ID:algts,项目名称:Horde3D,代码行数:8,代码来源:QComponentNode.cpp

示例7: domToString

static QString domToString(const QDomElement &elt)
{
    QString result;
    QTextStream stream(&result, QIODevice::WriteOnly);
    elt.save(stream, 2);
    stream.flush();
    return result;
}
开发者ID:maxxant,项目名称:qt,代码行数:8,代码来源:widgetboxcategorylistview.cpp

示例8: output

QString HtmlTidy::output()
{
    QDomDocument document;
    QDomElement body = output(document);
    QString s;
    QTextStream ts(&s) ;
    body.save(ts, 0);
    return s;
}
开发者ID:jirislaby,项目名称:plugins,代码行数:9,代码来源:htmltidy.cpp

示例9: stream

/**
 * @brief VExceptionWrongId exception wrong parameter id
 * @param what string with error
 * @param domElement som element
 */
VExceptionWrongId::VExceptionWrongId(const QString &what, const QDomElement &domElement)
    :VException(what), tagText(QString()), tagName(QString()), lineNumber(-1)
{
    Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
    QTextStream stream(&tagText);
    domElement.save(stream, 4);
    tagName = domElement.tagName();
    lineNumber = domElement.lineNumber();
}
开发者ID:a-dilla,项目名称:Valentina,代码行数:14,代码来源:vexceptionwrongid.cpp

示例10: xmlFromId

QString BinController::xmlFromId(const QString & id)
{
    ClipController *controller = m_clipList.value(id);
    if (!controller) return NULL;
    Mlt::Producer original = controller->originalProducer();
    QString xml = getProducerXML(original);
    QDomDocument mltData;
    mltData.setContent(xml);
    QDomElement producer = mltData.documentElement().firstChildElement(QStringLiteral("producer"));
    QString str;
    QTextStream stream(&str);
    producer.save(stream, 4);
    return str;
}
开发者ID:dreamsxin,项目名称:kdenlive,代码行数:14,代码来源:bincontroller.cpp

示例11: stream

StyleItem::StyleItem( QDomElement el, QString colors[], QDomElement defs )
{
    QDomElement name = el.firstChildElement("name");
    this->name = name.text();
    QDomElement svg = el.firstChildElement("svg");
    if ( svg.isNull() ) {
        this->renderer = NULL;
    } else {
        if ( !defs.isNull() ) svg.insertBefore( defs, QDomNode() );
        QDomDocument doc;
        doc.setContent( css );
        svg.insertBefore( doc, QDomNode() );
        QTextStream stream(&(this->svg));
        svg.save(stream, 0);
        this->renderer = new QSvgRenderer( this->makeSvg( colors, STYLE_KEY_COLOR ).toAscii() );
    }
}
开发者ID:Newterm,项目名称:florence,代码行数:17,代码来源:styleitem.cpp

示例12: init

void Shape::init(const QString &shape)
{
	if (shape.isEmpty())
		return;

	QString error = "";
	int errorLine = 0;
	int errorCol = 0;
	QDomDocument doc;
	if (!doc.setContent(shape, false, &error, &errorLine, &errorCol))
		return;

	QDomElement graphics = doc.firstChildElement("graphics");

	QDomElement picture = graphics.firstChildElement("picture");
	QTextStream out(&mPicture);
	picture.save(out, 4);

	mWidth = graphics.firstChildElement("picture").attribute("sizex", "88").toInt();
	mHeight = graphics.firstChildElement("picture").attribute("sizey", "88").toInt();

	initLabels(graphics);
	initPorts(graphics);
}
开发者ID:fsulima,项目名称:qreal,代码行数:24,代码来源:shape.cpp

示例13: stream

QPositionNode::QPositionNode(const QDomElement& xmlNode, int row, QXmlTreeModel* model, QXmlTreeNode* parent) : QXmlTreeNode(xmlNode, row, model, parent),
m_dynamicProperty(false)
{
	QString data;
	QTextStream stream(&data);
	xmlNode.save(stream, 4);
	m_entityID = GameEngine::entityWorldID( qPrintable(parent->property("Name").toString()) );
	GameEngine::setComponentData(m_entityID, qPrintable( xmlNode.tagName() ), qPrintable(data));
	QXmlTreeNode* root = static_cast<AttachmentTreeModel*>(model)->sceneNodeParent();
	// If the entity has no position we have to create one for the crowd particle
	if( !root->property("Position").isValid() )
	{
		QVec3f pos( m_xmlNode.attribute("x").toFloat(), m_xmlNode.attribute("y").toFloat(), m_xmlNode.attribute("z").toFloat() );
		// Since the parent doesn't have a position yet we create one dynamically (not necessary if the particle is a child of 
		// an entity created by an attachment of a Horde3D scene graph node )
		m_dynamicProperty = true;
		root->setProperty( "Position", QVariant::fromValue(pos) );
		// We have to add scale too, otherwise the transformation changes in the editor are not possible
		root->setProperty( "Scale", QVariant::fromValue( QVec3f(1, 1, 1) ) );
		root->installEventFilter(this);
		QVariant transProp = root->property("__AbsoluteTransformation");
		if( !transProp.isValid() )
		{
			root->setProperty("__AbsoluteTransformation", 
				QVariant::fromValue(QMatrix4f::TransMat( pos.X, pos.Y, pos.Z) ) );
			root->setProperty("__RelativeTransformation", 
				QVariant::fromValue(QMatrix4f::TransMat( pos.X, pos.Y, pos.Z) ) );
		}
	}
	else // Remove any position attribute, since the position should be used from the scene node
	{
		m_xmlNode.removeAttribute("x");
		m_xmlNode.removeAttribute("y");
		m_xmlNode.removeAttribute("z");
	}
}
开发者ID:dreamsxin,项目名称:nawia,代码行数:36,代码来源:QPositionNode.cpp

示例14: importFromXml

bool Deck::importFromXml(QString fileName)
{
    QDomDocument domDocument;
    QString errorStr;
    int errorLine;
    int errorColumn;
    QFile file(fileName);

    file.open(QIODevice::ReadOnly | QIODevice::Text);

    if(!file.isOpen())
        return false;

    if (!domDocument.setContent(&file, true, &errorStr, &errorLine,
                                &errorColumn)) {
        qDebug() << QString("Parse error at line %1, column %2:\n%3")
                                 .arg(errorLine)
                                 .arg(errorColumn)
                                 .arg(errorStr);
        return false;
    }

    QDomElement root = domDocument.documentElement();
    if (root.tagName().toLower() != XML_TAG_ROOT) {
        qDebug() << "root node is mismatched.";

        return false;
    }

    QDomElement nodeDeck;
    QDomElement nodeCards;
    QDomElement elnode;

    nodeDeck = root.firstChildElement(XML_TAG_DECK);
    if(nodeDeck.isNull()) {
        qDebug() << "deck node is mismatched.";

        return false;
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_NAME);
    if(!elnode.isNull()) {
        name=elnode.text();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_DESC);
    if(!elnode.isNull()) {
        desc=elnode.text();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_ICON);
    if(!elnode.isNull()) {
        
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_GUID);
    if(!elnode.isNull()) {
        guid=QUuid(elnode.text());
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_CREATED);
    if(!elnode.isNull()) {
        createdTime=QDateTime::fromString(elnode.text());
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_UPDATED);
    if(!elnode.isNull()) {
        updatedTime=QDateTime::fromString(elnode.text());
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_AUTHOR);
    if(!elnode.isNull()) {
        author=elnode.text();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_TAGS);
    if(!elnode.isNull()) {
        tags=elnode.text();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_FLAGS);
    if(!elnode.isNull()) {
        flags=elnode.text().toUInt();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_INHAND);
    if(!elnode.isNull()) {
        inhand=elnode.text().toInt();
    }

    elnode = nodeDeck.firstChildElement(XML_TAG_FORMAT);
    if(!elnode.isNull()) {
        //// Converting QDomElement to QString
        //// http://qt-project.org/doc/qt-5/qdomnode.html#save
        QString str;
        QTextStream stream(&str);
        elnode.save(stream, 4);
        format.fromString(str);
    }

//.........这里部分代码省略.........
开发者ID:m-o-s-t-a-f-a,项目名称:dana,代码行数:101,代码来源:deck.cpp

示例15: setPointLists

/*
    <name>Lines</name>
    <description>Lines from top to bottom</description>
    <author>Marco Gittler</author>
    <properties tag="lines" id="lines" />
    <parameter default="5" type="constant" value="5" min="0" name="num" max="255" >
      <name>Num</name>
    </parameter>
    <parameter default="4" type="constant" value="4" min="0" name="width" max="255" >
      <name>Width</name>
    </parameter>
  </effect>

*/
void ParameterPlotter::setPointLists(const QDomElement& d, const QString& paramName, int startframe, int endframe)
{

    //QListIterator <QPair <QString, QMap< int , QVariant > > > nameit(params);
    m_paramName = paramName;
    m_itemParameter = d;
    QDomNodeList namenode = d.elementsByTagName("parameter");

    m_max_y = 0;
    m_min_y = 0;
    removeAllPlotObjects();
    m_stretchFactors.clear();
    m_parameterNameList.clear();
    m_plotobjects.clear();

    QString dat;
    QTextStream stre(&dat);
    d.save(stre, 2);
    //qDebug() << dat;
    int i = 0;
    while (!namenode.item(i).isNull() && namenode.item(i).toElement().attribute("name") != m_paramName)
        ++i;

    if (namenode.count()) {
        QDomElement pa = namenode.item(i).toElement();
        //QDomNode na = pa.firstChildElement("name");

        m_parameterNameList << pa.attribute("namedesc").split(';');
        emit parameterList(m_parameterNameList);

        //max_y=pa.attributes().namedItem("max").nodeValue().toInt();
        //int val=pa.attributes().namedItem("value").nodeValue().toInt();
        QStringList defaults;
        if (pa.attribute("start").contains(';'))
            defaults = pa.attribute("start").split(';');
        else if (pa.attribute("value").contains(';'))
            defaults = pa.attribute("value").split(';');
        else if (pa.attribute("default").contains(';'))
            defaults = pa.attribute("default").split(';');
        QStringList maxv = pa.attribute("max").split(';');
        QStringList minv = pa.attribute("min").split(';');
        for (int i = 0; i < maxv.size() && i < minv.size(); ++i) {
            if (m_max_y < maxv[i].toInt()) m_max_y = maxv[i].toInt();
            if (m_min_y > minv[i].toInt()) m_min_y = minv[i].toInt();
        }
        for (int i = 0; i < m_parameterNameList.count(); ++i) {
            KPlotObject *plot = new KPlotObject(m_colors[m_plotobjects.size()%m_colors.size()]);
            plot->setShowLines(true);
            if (!m_stretchFactors.contains(i) && i < maxv.size()) {
                if (maxv[i].toInt() != 0)
                    m_stretchFactors[i] = m_max_y / maxv[i].toInt();
                else
                    m_stretchFactors[i] = 1.0;
            }
            if (i < defaults.size() && defaults[i].toDouble() > m_max_y)
                defaults[i] = m_max_y;
            int def = 0;
            if (i < defaults.size())
                def = (int)(defaults[i].toInt() * m_stretchFactors[i]);
            QString name = "";
            if (i < m_parameterNameList.size())
                name = m_parameterNameList[i];
            plot->addPoint(startframe, def, name);
            //add keyframes here
            plot->addPoint(endframe, def);

            m_plotobjects.append(plot);
        }

        /*TODO keyframes
        while (pointit.hasNext()){
         pointit.next();
         plot->addPoint(QPointF(pointit.key(),pointit.value().toDouble()),item.first,1);
         if (pointit.value().toInt() >maxy)
          max_y=pointit.value().toInt();
        }*/

    }
    setLimits(-1, endframe + 1, m_min_y - 10, m_max_y + 10);

    addPlotObjects(m_plotobjects);

}
开发者ID:rugubara,项目名称:kdenlive-15.08.1,代码行数:97,代码来源:parameterplotter.cpp


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