Esempio n. 1
1
void GenericFeature::saveStreet(QDomDocument& doc, QDomNode& node) {
	// write length node
	QDomElement node_length = doc.createElement("length");
	node.appendChild(node_length);

	for (QMap<float, float>::iterator it = streetLengths.begin(); it != streetLengths.end(); ++it) {
		QDomElement node_length_data = doc.createElement("data");
		QString str;
		str.setNum(it.key());
		node_length_data.setAttribute("key", str);
		node_length.appendChild(node_length_data);

		str.setNum(it.value());
		QDomText node_length_value = doc.createTextNode(str);
		node_length_data.appendChild(node_length_value);
	}

	// write numDirections node
	QDomElement node_numDirections = doc.createElement("numDirections");
	node.appendChild(node_numDirections);

	for (QMap<int, float>::iterator it = streetNumDirections.begin(); it != streetNumDirections.end(); ++it) {
		QDomElement node_numDirections_data = doc.createElement("data");
		QString str;
		str.setNum(it.key());
		node_numDirections_data.setAttribute("key", str);
		node_numDirections.appendChild(node_numDirections_data);

		str.setNum(it.value());
		QDomText node_numDirections_value = doc.createTextNode(str);
		node_numDirections_data.appendChild(node_numDirections_value);
	}
}
Esempio n. 2
0
void QgsMapSettings::writeXml( QDomNode &node, QDomDocument &doc )
{
  // units
  node.appendChild( QgsXmlUtils::writeMapUnits( mapUnits(), doc ) );

  // Write current view extents
  node.appendChild( QgsXmlUtils::writeRectangle( extent(), doc ) );

  // Write current view rotation
  QDomElement rotNode = doc.createElement( QStringLiteral( "rotation" ) );
  rotNode.appendChild(
    doc.createTextNode( qgsDoubleToString( rotation() ) )
  );
  node.appendChild( rotNode );

  // destination CRS
  if ( mDestCRS.isValid() )
  {
    QDomElement srsNode = doc.createElement( QStringLiteral( "destinationsrs" ) );
    node.appendChild( srsNode );
    mDestCRS.writeXml( srsNode, doc );
  }

  //render map tile
  QDomElement renderMapTileElem = doc.createElement( QStringLiteral( "rendermaptile" ) );
  QDomText renderMapTileText = doc.createTextNode( testFlag( QgsMapSettings::RenderMapTile ) ? "1" : "0" );
  renderMapTileElem.appendChild( renderMapTileText );
  node.appendChild( renderMapTileElem );
}
Esempio n. 3
0
void
vleVpm::setOutputGUIplugin(const QString& viewName, const QString& pluginName)
{
    xCreateDom();

    QDomElement docElem = mDocVpm->documentElement();
    QDomNode outGUIplugs =
            mDocVpm->elementsByTagName("outputGUIplugins").item(0);
    if (outGUIplugs.isNull() ) {
        QDomNode metaData = mDocVpm->elementsByTagName(
                "vle_project_metadata").item(0);
        undoStackVpm->snapshot(metaData);
        metaData.appendChild(mDocVpm->createElement("outputGUIplugins"));
        outGUIplugs =  mDocVpm->elementsByTagName("outputGUIplugins").item(0);
    } else {
        undoStackVpm->snapshot(outGUIplugs);
    }
    QDomNodeList plugins =
            outGUIplugs.toElement().elementsByTagName("outputGUIplugin");
    for (int i =0; i< plugins.length(); i++) {
        QDomNode plug = plugins.at(i);
        for (int j=0; j< plug.attributes().size(); j++) {
            if ((plug.attributes().item(j).nodeName() == "view") and
                    (plug.attributes().item(j).nodeValue() == viewName))  {
                plug.toElement().setAttribute("GUIplugin", pluginName);
                return;
            }
        }
    }
    QDomElement el = mDocVpm->createElement("outputGUIplugin");
    el.setAttribute("view", viewName);
    el.setAttribute("GUIplugin", pluginName);
    outGUIplugs.appendChild(el);
}
Esempio n. 4
0
void NewstuffModelPrivate::changeNode( QDomNode &node, QDomDocument &domDocument, const QString &key, const QString &value, NodeAction action )
{
    if ( action == Append ) {
        QDomNode newNode = node.appendChild( domDocument.createElement( key ) );
        newNode.appendChild( domDocument.createTextNode( value ) );
    } else {
        QDomNode oldNode = node.namedItem( key );
        if ( !oldNode.isNull() ) {
            oldNode.removeChild( oldNode.firstChild() );
            oldNode.appendChild( domDocument.createTextNode( value ) );
        }
    }
}
Esempio n. 5
0
QDomNode AudioTrack::get_state( QDomDocument doc, bool istemplate)
{
        QDomElement node = doc.createElement("Track");
        Track::get_state(doc, node, istemplate);

        node.setAttribute("numtakes", m_numtakes);
	node.setAttribute("showclipvolumeautomation", m_showClipVolumeAutomation);
	node.setAttribute("InputBus", m_busInName);


        if (! istemplate ) {
                QDomNode clips = doc.createElement("Clips");

                apill_foreach(AudioClip* clip, AudioClip, m_clips) {
                        if (clip->get_length() == qint64(0)) {
                                PERROR("Clip length is 0! This shouldn't happen!!!!");
                                continue;
                        }

                        QDomElement clipNode = doc.createElement("Clip");
                        clipNode.setAttribute("id", clip->get_id() );
                        clips.appendChild(clipNode);
                }

                node.appendChild(clips);
        }
Esempio n. 6
0
void DataManagerImpl::addXml(QDomNode& parentNode)
{
	QDomDocument doc = parentNode.ownerDocument();
	QDomElement dataManagerNode = doc.createElement("datamanager");
	parentNode.appendChild(dataManagerNode);

	m_rMpr_History->addXml(dataManagerNode);

	QDomElement landmarkPropsNode = doc.createElement("landmarkprops");
	LandmarkPropertyMap::iterator it = mLandmarkProperties.begin();
	for (; it != mLandmarkProperties.end(); ++it)
	{
		QDomElement landmarkPropNode = doc.createElement("landmarkprop");
		it->second.addXml(landmarkPropNode);
		landmarkPropsNode.appendChild(landmarkPropNode);
	}
	dataManagerNode.appendChild(landmarkPropsNode);

	QDomElement landmarksNode = doc.createElement("landmarks");
	mPatientLandmarks->addXml(landmarksNode);
	dataManagerNode.appendChild(landmarksNode);

	QDomElement centerNode = doc.createElement("center");
	centerNode.appendChild(doc.createTextNode(qstring_cast(mCenter)));
	dataManagerNode.appendChild(centerNode);

	for (DataMap::const_iterator iter = mData.begin(); iter != mData.end(); ++iter)
	{
		QDomElement dataNode = doc.createElement("data");
		dataManagerNode.appendChild(dataNode);
		iter->second->addXml(dataNode);
	}
}
Esempio n. 7
0
void loader::writemessages(QDomNode& mess, QDomDocument root){
    QVector<message*> messlist=_boss->_messagedb;
    QVector<message*>::const_iterator it=messlist.begin();
    for(;it!=messlist.end();++it){
        QDomNode message=root.createElement(QString("message"));
        mess.appendChild(message);
        QDomNode sender=root.createElement(QString("sender")),
        recever=root.createElement(QString("recever")),
        object=root.createElement(QString("object")),
        text=root.createElement(QString("text")),
        read=root.createElement(QString("read"));
        message.appendChild(sender);
        message.appendChild(recever);
        message.appendChild(object);
        message.appendChild(text);
        message.appendChild(read);
        QString readed;
        QDomText usersender=root.createTextNode((*it)->sender()->user()->user()),
        userrecever=root.createTextNode((*it)->recever()->user()->user()),
        objecttemp=root.createTextNode((*it)->object()),
        texttemp=root.createTextNode((*it)->text()),
        readtemp=root.createTextNode(readed.setNum((*it)->read()));
        sender.appendChild(usersender);
        recever.appendChild(userrecever);
        object.appendChild(objecttemp);
        text.appendChild(texttemp);
        read.appendChild(readtemp);
    }
}
Esempio n. 8
0
QDomNode QDomNodeProto:: appendChild(const QDomNode& newChild)
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->appendChild(newChild);
  return QDomNode();
}
Esempio n. 9
0
void TextDocumentGeneratorPrivate::generateTitleInfos()
{
    QStack< QPair<int,QDomNode> > parentNodeStack;

    QDomNode parentNode = mDocumentSynopsis;

    parentNodeStack.push( qMakePair( 0, parentNode ) );

    for ( int i = 0; i < mTitlePositions.count(); ++i ) {
        const TitlePosition &position = mTitlePositions[ i ];

        Okular::DocumentViewport viewport = TextDocumentUtils::calculateViewport( mDocument, position.block );

        QDomElement item = mDocumentSynopsis.createElement( position.title );
        item.setAttribute( QStringLiteral("Viewport"), viewport.toString() );

        int headingLevel = position.level;

        // we need a parent, which has to be at a higher heading level than this heading level
        // so we just work through the stack
        while ( ! parentNodeStack.isEmpty() ) {
            int parentLevel = parentNodeStack.top().first;
            if ( parentLevel < headingLevel ) {
                // this is OK as a parent
                parentNode = parentNodeStack.top().second;
                break;
            } else {
                // we'll need to be further into the stack
                parentNodeStack.pop();
            }
        }
        parentNode.appendChild( item );
        parentNodeStack.push( qMakePair( headingLevel, QDomNode(item) ) );
    }
}
void QgsVectorLayerSimpleLabeling::toSld( QDomNode &parent, const QgsStringMap &props ) const
{

  if ( mSettings->drawLabels )
  {
    QDomDocument doc = parent.ownerDocument();

    QDomElement ruleElement = doc.createElement( QStringLiteral( "se:Rule" ) );
    parent.appendChild( ruleElement );

    // scale dependencies
    if ( mSettings->scaleVisibility )
    {
      QgsStringMap scaleProps = QgsStringMap();
      // tricky here, the max scale is expressed as its denominator, but it's still the max scale
      // in other words, the smallest scale denominator....
      scaleProps.insert( "scaleMinDenom", qgsDoubleToString( mSettings->maximumScale ) );
      scaleProps.insert( "scaleMaxDenom", qgsDoubleToString( mSettings->minimumScale ) );
      QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElement, scaleProps );
    }

    writeTextSymbolizer( ruleElement, *mSettings, props );
  }


}
Esempio n. 11
0
bool KOfficePlugin::writeTextNode(QDomDocument & doc,
				  QDomNode & parentNode,
				  const QString  &nodeName,
				  const QString  &value) const
{
  if (parentNode.toElement().isNull()){
    kdDebug(7034) << "Parent node is Null or not an Element, cannot write node "
		  << nodeName << endl;
    return false;
  }

  // If the node does not exist, we create it...
  if (parentNode.namedItem(nodeName).isNull())
    QDomNode ex = parentNode.appendChild(doc.createElement(nodeName));

  // Now, we are sure we have a node
  QDomElement nodeA = parentNode.namedItem(nodeName).toElement();

  // Ooops... existing node were not of the good type...
  if (nodeA.isNull()){
    kdDebug(7034) << "Wrong type of node " << nodeName << ", should be Element"
		  << endl;
    return false;
  }

  QDomText txtNode = doc.createTextNode(value);

  // If the node has already Text Child, we replace it.
  if (nodeA.firstChild().isNull())
    nodeA.appendChild(txtNode);
  else
    nodeA.replaceChild( txtNode, nodeA.firstChild());
  return true;
}
Esempio n. 12
0
void QgsRelation::writeXml( QDomNode &node, QDomDocument &doc ) const
{
  QDomElement elem = doc.createElement( QStringLiteral( "relation" ) );
  elem.setAttribute( QStringLiteral( "id" ), d->mRelationId );
  elem.setAttribute( QStringLiteral( "name" ), d->mRelationName );
  elem.setAttribute( QStringLiteral( "referencingLayer" ), d->mReferencingLayerId );
  elem.setAttribute( QStringLiteral( "referencedLayer" ), d->mReferencedLayerId );
  if ( d->mRelationStrength == RelationStrength::Composition )
  {
    elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Composition" ) );
  }
  else
  {
    elem.setAttribute( QStringLiteral( "strength" ), QStringLiteral( "Association" ) );
  }

  for ( const FieldPair &pair : qgis::as_const( d->mFieldPairs ) )
  {
    QDomElement referenceElem = doc.createElement( QStringLiteral( "fieldRef" ) );
    referenceElem.setAttribute( QStringLiteral( "referencingField" ), pair.first );
    referenceElem.setAttribute( QStringLiteral( "referencedField" ), pair.second );
    elem.appendChild( referenceElem );
  }

  node.appendChild( elem );
}
void MetamodelGeneratorSupport::appendElements(QDomNode parent, QDomNodeList children)
{
	const int count = children.length();
	for (int i = 0; i < count; i++) {
		parent.appendChild(children.at(0));
	}
}
Esempio n. 14
0
void XMLizer::createDouble( QDomDocument &document, QDomNode &parent, QString name, double val )
{
	QDomElement e = document.createElement( name );
	QDomText t = document.createTextNode( QString::number( val, 'e', 17 ) );
	e.appendChild( t );
	parent.appendChild( e );
}
Esempio n. 15
0
void XMLizer::createInt64( QDomDocument &document, QDomNode &parent, QString name, qint64 val )
{
	QDomElement e = document.createElement( name );
	QDomText t = document.createTextNode( QString::number( val ) );
	e.appendChild( t );
	parent.appendChild( e );
}
Esempio n. 16
0
void XMLizer::createText( QDomDocument &document, QDomNode &parent, QString name, QString val )
{
	QDomElement e = document.createElement( name );
	QDomText t = document.createTextNode( val );
	e.appendChild( t );
	parent.appendChild( e );
}
Esempio n. 17
0
void XMLizer::writeClip( QDomDocument &document, QDomNode &parent, Clip *clip )
{
	QDomElement n1 = document.createElement( "Clip" );
	parent.appendChild( n1 );

	if ( clip->getSpeed() != 1.0 )
		n1.setAttribute( "speed", QString::number( clip->getSpeed(), 'e', 17 ) );
	XMLizer::createText( document, n1, "Name", clip->sourcePath() );
	XMLizer::createDouble( document, n1, "PosInTrack", clip->position() );
	XMLizer::createDouble( document, n1, "StartTime", clip->start() );
	XMLizer::createDouble( document, n1, "Length", clip->length() );
	
	for ( int i = 0; i < clip->videoFilters.count(); ++i )
		XMLizer::writeFilter( document, n1, false, clip->videoFilters.at( i ) );
	
	for ( int i = 0; i < clip->audioFilters.count(); ++i )
		XMLizer::writeFilter( document, n1, true, clip->audioFilters.at( i ) );
	
	Transition *trans = clip->getTransition();
	if ( trans ) {
		QDomElement t = document.createElement( "Transition" );
		n1.appendChild( t );
		
		XMLizer::createDouble( document, t, "PosInTrack", trans->position() );
		XMLizer::createDouble( document, t, "Length", trans->length() );
		if ( !trans->getVideoFilter().isNull() )
			XMLizer::writeFilter( document, t, false, trans->getVideoFilter() );
		if ( !trans->getAudioFilter().isNull() )
			XMLizer::writeFilter( document, t, true, trans->getAudioFilter() );
	}
}
Esempio n. 18
0
void PictoProcedure::toXml( QDomDocument& doc, QDomNode& node ) const
{/*{{{*/
     QDomElement item = doc.createElement( "Procedure" );
     node.appendChild( item );
     QDomElement position = doc.createElement( "Position" );
     position.appendChild( doc.createTextNode( QString( "%1;%2" ).arg( scenePos().x() )
                           .arg( scenePos().y() ) ) );
     item.appendChild( position );
     QDomElement style = doc.createElement( "StyleLien" );
     style.appendChild( doc.createTextNode(
                             ( liaison_ ) ?
                             QString::number( static_cast<int>( liaison_->style() ) ) :
                             "1" ) ) ;
     item.appendChild( style );
     QDomElement preAssertion = doc.createElement( "PreAssertion" );
     preAssertion.appendChild( doc.createTextNode( labels_.at( 0 )->label() ) );
     item.appendChild( preAssertion );
     QDomElement postAssertion = doc.createElement( "PostAssertion" );
     postAssertion.appendChild( doc.createTextNode( labels_.at( 2 )->label() ) );
     item.appendChild( postAssertion );
     QDomElement titre = doc.createElement( "Titre" );
     titre.appendChild( doc.createTextNode( labels_.at( 1 )->label() ) );
     item.appendChild( titre );
     QDomElement details = doc.createElement( "DetailsVisible" );
     details.appendChild( doc.createTextNode( detail_ ? "1" : "0" ) );
     item.appendChild( details );
     QDomElement detailsVide = doc.createElement( "DetailsVideVisible" );
     detailsVide.appendChild( doc.createTextNode( emptyDetail_ ? "1" : "0" ) );
     item.appendChild( detailsVide );
     QDomElement enfants = doc.createElement( "Enfants" );
     item.appendChild( enfants );
     AncreItem* picto;
     foreach( picto, children_ )
     static_cast<Pictogramme*>( picto )->toXml( doc, enfants );
}/*}}}*/
bool QgsGraduatedSymbolRenderer::writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const
{
  bool returnval = true;
  QDomElement graduatedsymbol = document.createElement( "graduatedsymbol" );
  layer_node.appendChild( graduatedsymbol );

  //
  // Mode field first ...
  //

  QString modeValue = "";
  if ( mMode == QgsGraduatedSymbolRenderer::Empty )
  {
    modeValue == "Empty";
  }
  else if ( QgsGraduatedSymbolRenderer::Quantile )
  {
    modeValue = "Quantile";
  }
  else //default
  {
    modeValue = "Equal Interval";
  }
  QDomElement modeElement = document.createElement( "mode" );
  QDomText modeText = document.createTextNode( modeValue );
  modeElement.appendChild( modeText );
  graduatedsymbol.appendChild( modeElement );



  //
  // classification field now ...
  //

  QDomElement classificationfield = document.createElement( "classificationfield" );

  const QgsVectorDataProvider* theProvider = vl.dataProvider();
  if ( !theProvider )
  {
    return false;
  }

  QString classificationFieldName;
  if ( vl.pendingFields().contains( mClassificationField ) )
  {
    classificationFieldName = vl.pendingFields()[ mClassificationField ].name();
  }

  QDomText classificationfieldtxt = document.createTextNode( classificationFieldName );
  classificationfield.appendChild( classificationfieldtxt );
  graduatedsymbol.appendChild( classificationfield );
  for ( QList<QgsSymbol*>::const_iterator it = mSymbols.begin(); it != mSymbols.end(); ++it )
  {
    if ( !( *it )->writeXML( graduatedsymbol, document, &vl ) )
    {
      returnval = false;
    }
  }
  return returnval;
}
Esempio n. 20
0
void
vleSmDT::setInitialValue(const QString& varName,
        const vle::value::Value& val)
{
    QDomNode var = nodeVariable(varName);
    if (var.isNull()) {
        return;
    }
    undoStackSm->snapshot(var);
    QDomNodeList initList = var.toElement().elementsByTagName("initial_value");
    if (initList.length() == 0) {
        //TODO see vpz management of vle values
        QDomElement dble = mDocSm->createElement("double");
        dble.appendChild(mDocSm->createTextNode(
                val.writeToString().c_str()));
        QDomElement el = mDocSm->createElement("initial_value");
        el.appendChild(dble);
        var.appendChild(el);
    } else {
        QDomNode init_value = initList.at(0);
        init_value = var.toElement().elementsByTagName("double").at(0);
        if (init_value.nodeName() == "double") {
            QDomText dbleval = init_value.childNodes().item(0).toText();
            dbleval.setData(val.writeToString().c_str());
        }
    }
}
bool QgsUniqueValueRenderer::writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const
{
  const QgsVectorDataProvider* theProvider = vl.dataProvider();
  if ( !theProvider )
  {
    return false;
  }

  QString classificationFieldName;
  const QgsFields& fields = vl.pendingFields();
  if ( mClassificationField >= 0 && mClassificationField < fields.count() )
  {
    classificationFieldName = fields[ mClassificationField ].name();
  }

  bool returnval = true;
  QDomElement uniquevalue = document.createElement( "uniquevalue" );
  layer_node.appendChild( uniquevalue );
  QDomElement classificationfield = document.createElement( "classificationfield" );
  QDomText classificationfieldtxt = document.createTextNode( classificationFieldName );
  classificationfield.appendChild( classificationfieldtxt );
  uniquevalue.appendChild( classificationfield );
  for ( QMap<QString, QgsSymbol*>::const_iterator it = mSymbols.begin(); it != mSymbols.end(); ++it )
  {
    if ( !( it.value()->writeXML( uniquevalue, document, &vl ) ) )
    {
      returnval = false;
    }
  }
  return returnval;
}
Esempio n. 22
0
void AddNewFile::slotWriteNewFile()
{
    /**
     *  No need to search node by name,
     *  we put them in order in combobox
     *  so the index is just enough
     */
    QDomNode task = lst.at(comboBox->currentIndex());
    ProjectTreeItem *taskItem = tasksItem->child(comboBox->currentIndex());

    QDomElement elem = projectXml->createElement("file");
    elem.setAttribute("name", lineEdit->text());
    task.appendChild(elem);

    parent->model->addItem(new ProjectTreeItem(elem, taskItem), taskItem);


    QString path = parent->whcFile;

    path.remove(path.split("/").last());

    path.append("src/" +
                comboBox->itemText(comboBox->currentIndex()) +
                + "/" + lineEdit->text());

    QFile file(path);
    /**
      * Opening a file in write mode
      * will create a new file if it doesn't exist
      */
    file.open(QFile::WriteOnly);
    file.close();
    this->close();
}
Esempio n. 23
0
void
vleVpm::setCondGUIplugin(const QString& condName, const QString& name)
{
    xCreateDom();

    QDomElement docElem = mDocVpm->documentElement();

    QDomNode condsPlugins =
            mDocVpm->elementsByTagName("condPlugins").item(0);
    undoStackVpm->snapshot(condsPlugins);
    QDomNodeList plugins =
            condsPlugins.toElement().elementsByTagName("condPlugin");
    for (int i =0; i< plugins.length(); i++) {
        QDomNode plug = plugins.at(i);
        for (int j=0; j< plug.attributes().size(); j++) {
            if ((plug.attributes().item(j).nodeName() == "cond") and
                    (plug.attributes().item(j).nodeValue() == condName))  {
                plug.toElement().setAttribute("plugin", name);
                return;
            }
        }
    }
    QDomElement el = mDocVpm->createElement("condPlugin");
    el.setAttribute("cond", condName);
    el.setAttribute("plugin", name);
    condsPlugins.appendChild(el);
}
Esempio n. 24
0
void compareLKPTables(QDomNode table,QDomDocument &docB)
{
    QDomNode node;
    node = table;
    while (!node.isNull())
    {
        QDomNode tableFound = findTable(docB,node.toElement().attribute("name",""));
        if (!tableFound.isNull())
        {
            QDomNode field = node.firstChild();
            while (!field.isNull())
            {
                QDomNode fieldFound = findValue(tableFound,field.toElement().attribute("code",""));
                if (!fieldFound.isNull())
                {
                    if (field.toElement().attribute("description","") != fieldFound.toElement().attribute("description",""))
                        fatal("VNS:Value " + field.toElement().attribute("code","") + " of lookup table " + node.toElement().attribute("name","") + " from A not the same in B");
                }
                else
                {
                    log("VNF:Value " + field.toElement().attribute("code","") + " of lookup table " + node.toElement().attribute("name","") + " from A not found in B");
                    tableFound.appendChild(field.cloneNode(true));
                }
                field = field.nextSibling();
            }
        }
        else
        {
            log("TNF:Lookup table " + node.toElement().attribute("name","") + " from A not found in B");
            //Now adds the lookup table
            docB.documentElement().appendChild(node.cloneNode(true));
        }
        node = node.nextSibling();
    }
}
Esempio n. 25
0
void createPixmapNode( QDomDocument& doc, QDomNode& parent,
                       const QString& elementName, const QPixmap& pixmap )
{
    QDomElement pixmapElement = doc.createElement( elementName );
    parent.appendChild( pixmapElement );

    // Convert the pixmap to an image, save that image to an in-memory
    // XPM representation and compress this representation. This
    // conforms to the file format Qt Designer uses.
    QByteArray ba;
    QBuffer buffer( ba );
    buffer.open( IO_WriteOnly );
    QImageIO imgio( &buffer, "XPM" );
    QImage image = pixmap.convertToImage();
    imgio.setImage( image );
    imgio.write();
    buffer.close();
    ulong len = ba.size() * 2;
    QByteArray bazip( len );
    ::compress(  (uchar*) bazip.data(), &len, (uchar*) ba.data(), ba.size() );
    QString dataString;
    static const char hexchars[] = "0123456789abcdef";
    for ( int i = 0; i < (int)len; ++i ) {
        uchar c = (uchar) bazip[i];
        dataString += hexchars[c >> 4];
        dataString += hexchars[c & 0x0f];
    }

    createStringNode( doc, pixmapElement, "Format", "XPM.GZ" );
    createIntNode( doc, pixmapElement, "Length", ba.size() );
    createStringNode( doc, pixmapElement, "Data", dataString );
}
Esempio n. 26
0
bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
{
  // first get the layer element so that we can append the type attribute
  QDomElement mapLayerNode = layer_node.toElement();

  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
  {
    QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
    return false;
  }

  mapLayerNode.setAttribute( QStringLiteral( "type" ), QStringLiteral( "mesh" ) );

  // add provider node
  if ( mDataProvider )
  {
    QDomElement provider  = document.createElement( QStringLiteral( "provider" ) );
    QDomText providerText = document.createTextNode( providerType() );
    provider.appendChild( providerText );
    layer_node.appendChild( provider );
  }

  // renderer specific settings
  QString errorMsg;
  return writeSymbology( layer_node, document, errorMsg, context );
}
Esempio n. 27
0
void CameraData::addTextElement(QDomNode parentNode, QString name, QString value) const
{
	QDomDocument doc = parentNode.ownerDocument();
	QDomElement node = doc.createElement(name);
	node.appendChild(doc.createTextNode(value));
	parentNode.appendChild(node);
}
bool
PolicyDocumentClass::addTransition(const QString& patternName,
                                   const QString& message,
                                   const QString& target)
{
    bool rc = true;

    // test if target is valid
    QDomNode targetNode = getPatternNode(target);
    if (!targetNode.isNull()) {

        // get DOM node of the given pattern //
        QDomNode patternNode = getPatternNode(patternName);

        // create new DOM element for the behaviour //
        QDomElement element = document_->createElement(XML_TAG_TRANSITION);

        // set attributes //
        element.setAttribute("message", message);
        element.setAttribute("target",  target);

        // append element to pattern node //
        patternNode.appendChild(element);

        modified_ = true;
    }
    else {
        rc = false;
    }

    return rc;
}
Esempio n. 29
0
/**
  Creates a DOM element node that represents a frame settings
  object for use in a DOM document.

  \param document the DOM document to which the node will belong
  \param parent the parent node to which the new node will be appended
  \param elementName the name of the new node
  \param settings the frame settings to be represented
  */
void KDChartParams::KDChartFrameSettings::createFrameSettingsNode( QDomDocument& document,
        QDomNode& parent,
        const QString& elementName,
        const KDChartParams::KDChartFrameSettings* settings,
        uint areaId )
{
    QDomElement frameSettingsElement = document.createElement( elementName );
    parent.appendChild( frameSettingsElement );
    if( settings->_frame )
        KDFrame::createFrameNode( document, frameSettingsElement, "Frame",
                                  *settings->_frame );
    KDXML::createIntNode( document, frameSettingsElement, "AreaId",
            areaId );
    KDXML::createIntNode( document, frameSettingsElement, "DataRow",
            settings->_dataRow );
    KDXML::createIntNode( document, frameSettingsElement, "DataCol",
            settings->_dataCol );
    KDXML::createIntNode( document, frameSettingsElement, "Data3rd",
            settings->_data3rd );
    KDXML::createIntNode( document, frameSettingsElement, "OuterGapX",
            settings->_outerGapX );
    KDXML::createIntNode( document, frameSettingsElement, "OuterGapY",
            settings->_outerGapY );
    KDXML::createIntNode( document, frameSettingsElement, "InnerGapX",
            settings->_innerGapX );
    KDXML::createIntNode( document, frameSettingsElement, "InnerGapY",
            settings->_innerGapY );
    KDXML::createBoolNode( document, frameSettingsElement,
            "AddFrameWidthToLayout",
            settings->_addFrameWidthToLayout );
    KDXML::createBoolNode( document, frameSettingsElement,
            "AddFrameHeightToLayout",
            settings->_addFrameHeightToLayout );
}
Esempio n. 30
0
void loader::writeaccdata(const account& acc, QString typeacc, QDomNode& user, QDomDocument root){
    username* usernameacc=acc.user();
    QDomNode userdata=root.createElement(QString("userdata"));
    user.appendChild(userdata);
    QDomNode usern=root.createElement(QString("username")),
    passw=root.createElement(QString("password")),
    typ=root.createElement(QString("type")),
    acctype=root.createElement(QString("acctype"));
    userdata.appendChild(usern);
    userdata.appendChild(passw);
    userdata.appendChild(typ);
    userdata.appendChild(acctype);
    QString _user=usernameacc->user(), _pass=usernameacc->pass(), _acctype;
    _acctype.setNum(acc.type());
    QDomText usertemp=root.createTextNode(_user),
    passtemp=root.createTextNode(_pass),
    typetemp=root.createTextNode(typeacc),
    acctypetemp=root.createTextNode(_acctype);
    usern.appendChild(usertemp);
    passw.appendChild(passtemp);
    typ.appendChild(typetemp);
    acctype.appendChild(acctypetemp);
    if(dynamic_cast<useraccount*>(const_cast<account*>(&acc))){
        QDomNode admin=root.createElement(QString("admin"));
        useraccount* tempacc=dynamic_cast<useraccount*>(const_cast<account*>(&acc));
        QString _admin;
        _admin=_admin.setNum(tempacc->getadmin());
        QDomText admintemp=root.createTextNode(_admin);
        userdata.appendChild(admin);
        admin.appendChild(admintemp);
    }
}