本文整理汇总了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;
}
示例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;
}
示例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\"?>";
}
示例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;
}
示例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();
}
}
示例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));
}
示例7: domToString
static QString domToString(const QDomElement &elt)
{
QString result;
QTextStream stream(&result, QIODevice::WriteOnly);
elt.save(stream, 2);
stream.flush();
return result;
}
示例8: output
QString HtmlTidy::output()
{
QDomDocument document;
QDomElement body = output(document);
QString s;
QTextStream ts(&s) ;
body.save(ts, 0);
return s;
}
示例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();
}
示例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;
}
示例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() );
}
}
示例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);
}
示例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");
}
}
示例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);
}
//.........这里部分代码省略.........
示例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);
}