示例#1
0
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();
}
示例#2
0
void QgsMapLayer::exportSldStyle( QDomDocument &doc, QString &errorMsg )
{
  QDomDocument myDocument = QDomDocument();

  QDomNode header = myDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" );
  myDocument.appendChild( header );

  // Create the root element
  QDomElement root = myDocument.createElementNS( "http://www.opengis.net/sld", "StyledLayerDescriptor" );
  root.setAttribute( "version", "1.1.0" );
  root.setAttribute( "xsi:schemaLocation", "http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
  root.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
  root.setAttribute( "xmlns:se", "http://www.opengis.net/se" );
  root.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
  root.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
  myDocument.appendChild( root );

  // Create the NamedLayer element
  QDomElement namedLayerNode = myDocument.createElement( "NamedLayer" );
  root.appendChild( namedLayerNode );

  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
  if ( !vlayer )
  {
    errorMsg = tr( "Could not save symbology because:\n%1" )
               .arg( "Non-vector layers not supported yet" );
    return;
  }

  if ( !vlayer->writeSld( namedLayerNode, myDocument, errorMsg ) )
  {
    errorMsg = tr( "Could not save symbology because:\n%1" ).arg( errorMsg );
    return;
  }

  doc = myDocument;
}
bool
aBackup::dumpBase(const QString& rcfile, const QString& tmpDirName, int& prg, int totalSteps)
{
	QDomDocument xml;
	xml.setContent(QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
	QDomElement root = xml.createElement( "AnanasDump" );
	xml.appendChild( root );
	aDatabase db;
	if(db.init(rcfile))
	{
		emit (progress(++prg,totalSteps));
		db.exchangeDataSystables ( xml, false );
		emit (progress(++prg,totalSteps));
		db.exchangeDataCatalogues( xml, false );
		emit (progress(++prg,totalSteps));
		db.exchangeDataDocuments ( xml, false );
		emit (progress(++prg,totalSteps));
		db.exchangeDataJournals ( xml, false );
		emit (progress(++prg,totalSteps));
		db.exchangeDataInfoRegisters ( xml, false );
		emit (progress(++prg,totalSteps));
		db.exchangeDataAccumulationRegisters ( xml, false );

		db.exchangeDataUniques ( xml, true );

		aLog::print(aLog::Debug, tr("aBackup dump tables ok"));
	}
	else
	{
		setLastError(tr("Can't connect to database"));
		aLog::print(aLog::Error, tr("aBackup init rc file  %1").arg(rcfile));
		db.done();
		return true;
	}
	qApp->processEvents();
	emit (progress(++prg,totalSteps));
	db.done();
	if(writeXml(tmpDirName+"/content.xml",xml)==true)
	{
		setLastError(tr("Can't write content.xml"));
		aLog::print(aLog::Error, tr("aBackup write content.xml"));
		return true;
	}
	else
	{
		aLog::print(aLog::Info, tr("aBackup dump base to xml compleet"));
	}
	return false;
}
示例#4
0
void VCLabel_Test::saveXML()
{
    QLCFixtureDefCache fdc;
    Doc doc(this, fdc);
    OutputMap om(this, 4);
    InputMap im(this, 4);
    MasterTimer mt(this, &om);
    QWidget w;

    VCLabel label(&w, &doc, &om, &im, &mt);
    label.setCaption("Simo Kuassimo");

    QDomDocument xmldoc;
    QDomElement root = xmldoc.createElement("TestRoot");
    xmldoc.appendChild(root);

    QVERIFY(label.saveXML(&xmldoc, &root) == true);

    QDomNode node = root.firstChild();
    QVERIFY(node.nextSibling().isNull() == true);
    QCOMPARE(node.toElement().tagName(), QString("Label"));
    QCOMPARE(node.toElement().attribute("Caption"), QString("Simo Kuassimo"));
    QVERIFY(node.firstChild().isNull() == false);

    int appearance = 0, windowstate = 0;

    node = node.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == QString("Appearance"))
        {
            appearance++;
        }
        else if (tag.tagName() == QString("WindowState"))
        {
            windowstate++;
        }
        else
        {
            qDebug() << xmldoc.toString();
            QFAIL("Unexpected tag in XML output!");
        }
        node = node.nextSibling();
    }

    QCOMPARE(appearance, 1);
    QCOMPARE(windowstate, 1);
}
/* private slots */
void CreateVirtNetwork_Adv::buildXMLDescription()
{
    QDomDocument doc;
    //qDebug()<<doc.toString();
    QDomElement _xmlDesc, _name, _uuid;
    QDomText data;

    _xmlDesc = doc.createElement("network");
    if ( ipv6->isChecked() ) {
        _xmlDesc.setAttribute("ipv6", "yes");
    };
    _xmlDesc.setAttribute(
                "trustGuestRxFilters",
                (trustGuestRxFilters->isChecked())? "yes":"no");
    _name = doc.createElement("name");
    data = doc.createTextNode(networkName->text());
    _name.appendChild(data);
    _uuid = doc.createElement("uuid");
    data = doc.createTextNode(uuid->text());
    _uuid.appendChild(data);
    _xmlDesc.appendChild(_name);
    _xmlDesc.appendChild(_uuid);

    if ( bridgeWdg->isUsed() ) {
        _xmlDesc.appendChild(
                    bridgeWdg->getDataDocument());
    };
    if ( domainWdg->isUsed() ) {
        _xmlDesc.appendChild(
                    domainWdg->getDataDocument());
    };
    if ( forwardWdg->isUsed() ) {
        _xmlDesc.appendChild(
                    forwardWdg->getDataDocument());
    };
    if ( addressingWdg->isUsed() ) {
        _xmlDesc.appendChild(
                    addressingWdg->getDataDocument());
    };
    if ( QoSWdg->isUsed() ) {
        _xmlDesc.appendChild(
                    QoSWdg->getDataDocument());
    };
    doc.appendChild(_xmlDesc);

    bool read = xml->open();
    if (read) xml->write(doc.toByteArray(4).data());
    xml->close();
}
示例#6
0
TupProjectRequest TupRequestBuilder::createItemRequest(int sceneIndex, int layerIndex, int frameIndex, int itemIndex, QPointF point, TupProject::Mode spaceMode, 
                                                     TupLibraryObject::Type type, int actionId, const QVariant &arg, const QByteArray &data)
{
    QDomDocument doc;

    QDomElement root = doc.createElement("project_request");

    QDomElement scene = doc.createElement("scene");
    scene.setAttribute("index", sceneIndex);

    QDomElement layer = doc.createElement("layer");
    layer.setAttribute("index", layerIndex);

    QDomElement frame = doc.createElement("frame");
    frame.setAttribute("index", frameIndex);

    QDomElement item = doc.createElement("item");
    item.setAttribute("index", itemIndex);

    QDomElement objectType = doc.createElement("objectType");
    objectType.setAttribute("id", type);

    QDomElement position = doc.createElement("position");
    position.setAttribute("x", point.x());
    position.setAttribute("y", point.y());

    QDomElement space = doc.createElement("spaceMode");
    space.setAttribute("current", spaceMode);

    QDomElement action = doc.createElement("action");
    action.setAttribute("id", actionId);
    action.setAttribute("arg", arg.toString());
    action.setAttribute("part", TupProjectRequest::Item);

    TupRequestBuilder::appendData(doc, action, data);
    root.appendChild(action);
    item.appendChild(objectType);
    item.appendChild(position);
    item.appendChild(space);
    frame.appendChild(item);
    layer.appendChild(frame);
    scene.appendChild(layer);
    root.appendChild(scene);

    doc.appendChild(root);
    TupProjectRequest request(doc.toString(0));

    return request;
}
示例#7
0
  QString CRequestCreator::createRequest(QString method, QMap<QString, QString> parameters)
  {
    QDomDocument doc;

    static const int indent = 4;

    QDomElement methodCall = doc.createElement("methodCall");
    QDomElement methodName = doc.createElement("methodName");
    QDomElement params = doc.createElement("params");
    QDomElement param = doc.createElement("param");
    QDomElement value = doc.createElement("value");
    QDomElement xmlStruct = doc.createElement("struct");

    QDomText methodTextName = doc.createTextNode(method);

    doc.appendChild(methodCall);
    methodCall.appendChild(methodName);
    methodName.appendChild(methodTextName);
    methodCall.appendChild(params);
    params.appendChild(param);
    param.appendChild(value);
    value.appendChild(xmlStruct);

    for(QMap<QString, QString>::const_iterator it = parameters.begin(); it != parameters.end(); ++it)
    {
      QDomElement member = doc.createElement("member");
      QDomElement name = doc.createElement("name");
      QDomElement value = doc.createElement("value");
      QDomElement xmlString = doc.createElement("string");

      xmlStruct.appendChild(member);
      member.appendChild(name);

      QDomText parameterName = doc.createTextNode(it.key());
      name.appendChild(parameterName);

      member.appendChild(value);
      value.appendChild(xmlString);

      QDomText parameterValue = doc.createTextNode(it.value());
      xmlString.appendChild(parameterValue);
    }
    QString result;

    QTextStream os(&result);
    doc.save(os, indent);

    return result;
  }
示例#8
0
void QrsMetamodelLoader::parseGroup(const qrRepo::RepoApi &repo
		, Metamodel &metamodel, const Id &diagram, const Id &id)
{
	/// @todo: We should not use XML here, PatternType must not parse XML at all.
	QDomDocument document;
	QDomElement groupElement = document.createElement("group");
	groupElement.setAttribute("name", validateName(repo, id));
	groupElement.setAttribute("rootNode", stringProperty(repo, id, "rootNode"));
	document.appendChild(groupElement);
	parseGroupNodes(repo, groupElement, id);
	PatternType *pattern = new PatternType(metamodel);
	pattern->setXml(document.toString(4));
	pattern->setDiagram(repo.name(diagram));
	metamodel.addElement(*pattern);
}
示例#9
0
/**
 * \brief Convert all capabilities info to XML.
 */
void CapsRegistry::save()
{
	// Generate XML
	QDomDocument doc;
	QDomElement capabilities = doc.createElement("capabilities");
	doc.appendChild(capabilities);
	QHash<QString,CapsInfo>::ConstIterator i = capsInfo_.constBegin();
	for( ; i != capsInfo_.end(); i++) {
		QDomElement info = i.value().toXml(&doc);
		info.setAttribute("node",i.key());
		capabilities.appendChild(info);
	}

	saveData(doc.toString().toUtf8());
}
  void StreamMonitor::sendRelVdRecState(QString cameraId)
  {
      QDomDocument doc;
      QDomProcessingInstruction instruction;
      instruction = doc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"UTF-8\"");
      doc.appendChild(instruction);

      QDomElement message = doc.createElement("message");  //<message>
      doc.appendChild(message);
      QDomElement type = doc.createElement("TYPE");//<TYPE>
      QDomText typeStr = doc.createTextNode(QString::number(Send_Rec_State));
      type.appendChild(typeStr);
      message.appendChild(type);

      QDomElement equip = doc.createElement("Equipment");//<Equipment>
      message.appendChild(equip);
      QDomElement camid = doc.createElement("CAMID");//<CAMID>
      QDomText camidStr = doc.createTextNode(cameraId);
      camid.appendChild(camidStr);
      equip.appendChild(camid);

      QString relVdRecXml = doc.toString();
      sendMsg(relVdRecXml);
  }
示例#11
0
bool MessageManager::sendTypingNotification( QString jid, bool start_typing )
{
	if( !tlen_manager->isConnected() )
		return false;
	
	QDomDocument doc;
	
	QDomElement typing_notification = doc.createElement( "m" );
	typing_notification.setAttribute( "to", jid );
	
	typing_notification.setAttribute( "tp", start_typing ? "t" : "u" );
	doc.appendChild( typing_notification );
	
	return tlen_manager->writeXml( doc );
}
示例#12
0
QDomDocument SecLabels::getDataDocument() const
{
    QDomDocument doc;
    if ( !useSecLabel->isChecked() ) return doc;
    QDomElement _data;
    _data = doc.createElement("data");
    for (int i=0; i<list->count(); i++) {
        QDomDocument _secLabel;
        _secLabel.setContent(list->item(i)->text());
        _data.appendChild(_secLabel);
    };
    doc.appendChild(_data);
    //qDebug()<<doc.toString();
    return doc;
}
示例#13
0
QDomDocument
IPod::ScrobbleList::xml() const
{    
    QDomDocument xml;
    QDomElement root = xml.createElement( "submissions" );
    root.setAttribute( "product", "Twiddly" );

    QListIterator<Track> i( *this );
    while (i.hasNext())
        root.appendChild( i.next().toDomElement( xml ) );
    
    xml.appendChild( root );
    
    return xml;
}
示例#14
0
void ImgToXml::makeXml(QString xmlFile) {
    QDomDocument sampleXml ("NeuralNetworkSample");
    QDomElement sample = sampleXml.createElement("sample");
    sample.setAttribute("countOfImages", mCountOfImages);
    sample.setAttribute("width", mImgSizeX);
    sample.setAttribute("height", mImgSizeY);
    sampleXml.appendChild(sample);
    for (int i = 0; i < mCountOfImages; i++) {
        sample.appendChild(saveImage(sampleXml, i));
    }
    QFile saveSample(xmlFile);
    saveSample.open(QIODevice::WriteOnly);
    QTextStream(&saveSample) << sampleXml.toString();
    saveSample.close();
}
示例#15
0
//	clearDir(mWorkingDir);
	foreach (LogicObject *object, objects) {
		QString filePath = createDirectory(object->id());

		QDomDocument doc;
		QDomElement root = doc.createElement("LogicObject");
		doc.appendChild(root);
		root.setAttribute("id", object->id().toString());

		root.appendChild(idListToXml("parents", object->parents(), doc));
		root.appendChild(idListToXml("children", object->children(), doc));
		root.appendChild(propertiesToXml(object, doc));

		OutFile out(filePath);
		doc.save(out(), 2);
	}
示例#16
0
void MainWindow::saveProject(){

    if(!project_open){
        return;
    }

    const QString pathName =  current_project_directory.dirName();
    QString fileName = current_project_directory.filePath(current_project_name + ".trx");

    QDomDocument doc;

    QDomElement el = doc.createElement("trproject");
    el.appendChild(doc.createTextNode(current_project_name));
    doc.appendChild(el);

    QDomElement subel = doc.createElement("requirements");
    subel.appendChild(doc.createTextNode(requirements->getName()));
    el.appendChild(subel);
    requirements->saveDocument(current_project_directory.dirName() + "/" + requirements->getName());

    QHash<DocumentView*, QStandardItemModel*> *traceModelList = traceability->getTraceModelList();

    for(DocumentView* document : traceModelList->keys()){

        qDebug() << "filename: " << current_project_directory.dirName() + "/" + document->getName();
        document->saveDocument(current_project_directory.dirName() + "/" + document->getName());
        traceability->saveMatrix(current_project_directory.dirName() + "/" + document->getName() + "_matrix", traceModelList->value(document));

        QDomElement subel = doc.createElement("entry");
        QDomElement docel = doc.createElement("document");
        docel.appendChild(doc.createTextNode(document->getName()));
        QDomElement matel = doc.createElement("matrix");
        matel.appendChild(doc.createTextNode(document->getName()));
        subel.appendChild(docel);
        subel.appendChild(matel);
        el.appendChild(subel);
    }

    QFile file(fileName);

    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
           return;

     file.write(doc.toByteArray());
     file.close();


}
示例#17
0
KoFilter::ConversionStatus MSWordImport::convert( const QCString& from, const QCString& to )
{
    // check for proper conversion
    if ( to != "application/x-kword" || from != "application/msword" )
        return KoFilter::NotImplemented;

    kdDebug(30513) << "######################## MSWordImport::convert ########################" << endl;

    QDomDocument mainDocument;
    QDomElement framesetsElem;
    prepareDocument( mainDocument, framesetsElem );

    QDomDocument documentInfo;
    documentInfo.appendChild (documentInfo.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );

    Document document( QFile::encodeName( m_chain->inputFile() ).data(), mainDocument, documentInfo, framesetsElem, m_chain );

    if ( !document.hasParser() )
        return KoFilter::WrongFormat;
    if ( !document.parse() )
        return KoFilter::ParsingError;
    document.processSubDocQueue();
    document.finishDocument();
    if ( !document.bodyFound() )
        return KoFilter::WrongFormat;

    KoStoreDevice* out = m_chain->storageFile( "root", KoStore::Write );
    if ( !out ) {
        kdError(30502) << "Unable to open output file!" << endl;
        return KoFilter::StorageCreationError;
    }
    QCString cstr = mainDocument.toCString();
    // WARNING: we cannot use KoStore::write(const QByteArray&) because it gives an extra NULL character at the end.
    out->writeBlock( cstr, cstr.length() );
    out->close();

    out = m_chain->storageFile( "documentinfo.xml", KoStore::Write );
    if ( !out ) {
	return KoFilter::StorageCreationError;
    }

    cstr = documentInfo.toCString();
    out->writeBlock( cstr, cstr.length() );
    out->close();

    kdDebug(30513) << "######################## MSWordImport::convert done ####################" << endl;
    return KoFilter::OK;
}
示例#18
0
bool ResourceFile::save()
{
    m_error_message.clear();

    if (m_file_name.isEmpty()) {
        m_error_message = msgFileNameEmpty();
        return false;
    }

    QFile file(m_file_name);
    if (!file.open(QIODevice::WriteOnly)) {
        m_error_message = file.errorString();
        return false;
    }

    QDomDocument doc;
    QDomElement root = doc.createElement(QLatin1String("RCC"));
    doc.appendChild(root);

    const QStringList name_list = prefixList();

    foreach (const QString &name, name_list) {
        FileList file_list;
        QString lang;
        foreach (const Prefix *pref, m_prefix_list) {
            if (pref->name == name){
                file_list += pref->file_list;
                lang = pref->lang;
            }
        }

        QDomElement relt = doc.createElement(QLatin1String("qresource"));
        root.appendChild(relt);
        relt.setAttribute(QLatin1String("prefix"), name);
        if (!lang.isEmpty())
            relt.setAttribute(QLatin1String("lang"), lang);

        foreach (const File *f, file_list) {
            const File &file = *f;
            QDomElement felt = doc.createElement(QLatin1String("file"));
            relt.appendChild(felt);
            const QString conv_file = relativePath(file.name).replace(QDir::separator(), QLatin1Char('/'));
            const QDomText text = doc.createTextNode(conv_file);
            felt.appendChild(text);
            if (!file.alias.isEmpty())
                felt.setAttribute(QLatin1String("alias"), file.alias);
        }
    }
示例#19
0
void task_list::writeXml(QString fileName)
{
    QFile file(fileName);
    QDomDocument doc;
    QDomElement root = doc.createElement("lists");
    doc.appendChild(root);

    for(int i=0; i<this->topLevelItemCount(); i++)
    {
        QDomElement list_node = doc.createElement("list");
        list_node.setAttribute("name", this->topLevelItem(i)->text(NAME_COL));
        root.appendChild(list_node);

        QTreeWidgetItem* parent_loc = this->topLevelItem(i);
        for(int j=0; j<parent_loc->childCount(); j++)
        {
            QDomElement task_node = doc.createElement("task");
            task_node.setAttribute("name", parent_loc->child(j)->text(NAME_COL));
            task_node.setAttribute("tag", parent_loc->child(j)->text(TAG_COL));
            task_node.setAttribute("note", parent_loc->child(j)->text(NOTE_COL));
            task_node.setAttribute("due", parent_loc->child(j)->text(DATE_COL));
            if( parent_loc->child(j)->checkState(CHECK_COL)==Qt::Checked)
            {
                task_node.setAttribute("status", "done");
            }
            else
            {
                task_node.setAttribute("status", "not done");
            }
            task_node.setAttribute("plain_note", parent_loc->child(j)->text(PLAINTEXT_COL));
            list_node.appendChild(task_node);
        }
    }

    if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QMessageBox::information(this, tr("Can write to the file"), file.errorString());
        return;
    }
    else
    {
        QTextStream stream(&file);
        stream << doc.toString();
        file.close();
    }
    this->file_location = fileName;

}
示例#20
0
DelCommand::DelCommand( Report::ItemInterface* item, mainWindow* mw )
{
	m_mainWindow = mw;
	m_parentName = dynamic_cast<Report::ItemInterface*>( item->parent() ) ? dynamic_cast<Report::ItemInterface*>( item->parent() )->objectName() : QString();
	m_itemName = item->objectName();
//    m_page = dynamic_cast<Report::PageInterface*>((item)->scene());
	m_pageName = mw->m_tw->tabText( mw->m_tw->currentIndex() );

	QDomDocument doc;
	doc.appendChild( mw->m_reportEngine.objectProperties(( QObject * )item, &doc ) );
	m_domObject = doc.toString( 0 );

	const char* itemClassName = item->metaObject()->className();
	setText( QObject::tr( "Delete %1" )
	                .arg( createCommandString( itemClassName, item->pos() ) ) );
}
示例#21
0
void Serializer::saveToDisk(QList<Object*> const &objects) const
{
	Q_ASSERT_X(!mWorkingFile.isEmpty()
		, "Serializer::saveToDisk(...)"
		, "may be Repository of RepoApi (see Models constructor also) has been initialised with empty filename?");

	foreach (Object const * const object, objects) {
		QString const filePath = createDirectory(object->id(), object->isLogicalObject());

		QDomDocument doc;
		QDomElement root = object->serialize(doc);
		doc.appendChild(root);

		OutFile out(filePath);
		doc.save(out(), 2);
	}
示例#22
0
文件: tlen.cpp 项目: partition/kadu
// "<iq type="get" id="tr" to="tuba"><query xmlns="jabber:iq:register"/></iq>"
void tlen::getPubDirInfoRequest() {
	kdebugf();

	QDomDocument doc;
	QDomElement iq = doc.createElement( "iq" );
	iq.setAttribute( "to", "tuba" );
	iq.setAttribute( "type", "get" );
	iq.setAttribute( "id", "tr" );

	QDomElement query = doc.createElement( "query" );
	query.setAttribute( "xmlns", "jabber:iq:register" );
	iq.appendChild( query );

	doc.appendChild( iq );
	write(doc);
}
/*!
  Renders the list of strings \a list as XML document.
*/
bool TActionController::renderXml(const QStringList &list)
{
    QDomDocument doc;
    QDomElement root = doc.createElement("list");
    doc.appendChild(root);

    for (QStringListIterator it(list); it.hasNext(); ) {
        const QString &str = it.next();
        QDomElement tag = doc.createElement("string");
        root.appendChild(tag);
        QDomText text = doc.createTextNode(str);
        tag.appendChild(text);
    }

    return renderXml(doc);
}
示例#24
0
void Profile::toXml(QDomDocument &document) const
{
    QDomElement profile = document.createElement("profile");
    profile.setAttribute("version", 1);
    profile.setAttribute("name", name());
    if (color().isValid()) {
        profile.setAttribute("color", color().name());
    }
    profile.setAttribute("avatar", info().avatar);
    profile.setAttribute("information", info().info);
    profile.setAttribute("winningMessage", info().winning);
    profile.setAttribute("tieMessage", info().tie);
    profile.setAttribute("losingMessage", info().losing);

    document.appendChild(profile);
}
示例#25
0
bool LocalXmlBackend::taskToDom(const ITask *task, QDomDocument &doc)
{
  QDomElement root = doc.documentElement();

  if ( !root.isElement() ) {
    root = doc.createElement( "task" );
    doc.appendChild( root );
  }

  root.setAttribute( "id", task->uuid().toString() );
  root.setAttribute( "done", task->done() ? "true" : "false" );
  root.setAttribute( "title", task->title() );
  root.setAttribute( "weight", task->weight() );

  return true;
}
示例#26
0
void CollectionTest::serializeCollection()
{
    Collection c;
    c.setRemoteId(QStringLiteral("c11"));
    c.setName(QStringLiteral("Inbox"));
    c.setContentMimeTypes(QStringList() << Collection::mimeType() << QStringLiteral("message/rfc822"));
    c.attribute<EntityDisplayAttribute>(Collection::AddIfMissing)->setDisplayName(QStringLiteral("Posteingang"));
    c.attribute<EntityDisplayAttribute>()->setIconName(QStringLiteral("mail-folder-inbox"));

    QDomDocument doc;
    QDomElement root = doc.createElement(QStringLiteral("test"));
    doc.appendChild(root);
    XmlWriter::writeCollection(c, root);

    QCOMPARE(doc.toString(), QString::fromUtf8(collection1));
}
示例#27
0
void fileTransferThread::send() {
	QDomDocument doc;
	QDomElement f=doc.createElement("f");
//send: <f t="%receiver%" n="%filename%" e="1" i="%rndid%" c="%file_count%" s="%filesize%" v="1"/>
	f.setAttribute("t", owner);
	f.setAttribute("i", rndid);
	f.setAttribute("c", fc);
	f.setAttribute("s", allSize);
	f.setAttribute("e", "1");
	f.setAttribute("v", "1");
	if(fc==1)
		f.setAttribute("n", fileMap.at(0)->text(0) );
	doc.appendChild(f);
	Tlen->write(doc);
	emit prepareTransfering();
}
示例#28
0
bool SparrowExporter::Export(QByteArray& out) {
    QDomDocument doc;
    QDomElement root = doc.createElement("font");
    doc.appendChild(root);
    QDomElement info = doc.createElement("info");
    root.appendChild(info);
    info.setAttribute("face", fontConfig()->family());
    info.setAttribute("size", fontConfig()->size());
    QDomElement common = doc.createElement("common");
    root.appendChild(common);
    int height = metrics().height;
    common.setAttribute("lineHeight", height);
    QDomElement pages = doc.createElement("pages");
    root.appendChild(pages);
    QDomElement page = doc.createElement("page");
    pages.appendChild(page);
    page.setAttribute("id", "0");
    page.setAttribute("file", texFilename());
    QDomElement chars = doc.createElement("chars");
    root.appendChild(chars);
    chars.setAttribute("count", symbols().size());
    QDomElement kernings = doc.createElement("kernings");
    int kernNumber = 0;
    foreach(const Symbol& c , symbols()) {
        QDomElement ch = doc.createElement("char");
        ch.setAttribute("id", QString::number(c.id));
        ch.setAttribute("x", QString::number(c.placeX));
        ch.setAttribute("y", QString::number(c.placeY));
        ch.setAttribute("width", QString::number(c.placeW));
        ch.setAttribute("height", QString::number(c.placeH));
        ch.setAttribute("xoffset", QString::number(c.offsetX));
        ch.setAttribute("yoffset", QString::number(height - c.offsetY));
        ch.setAttribute("xadvance", QString::number(c.advance));
        ch.setAttribute("page", "0");
        ch.setAttribute("chnl", "0");
        ch.setAttribute("letter", c.id==32 ? "space" : QString().append(c.id));
        chars.appendChild(ch);
        typedef QMap<uint,int>::ConstIterator Kerning;
        for ( Kerning k = c.kerning.begin();k!=c.kerning.end();k++) {
            QDomElement ker = doc.createElement("kerning");
            ker.setAttribute("first", QString::number(c.id));
            ker.setAttribute("second", QString::number(k.key()));
            ker.setAttribute("amount", k.value());
            kernings.appendChild(ker);
            kernNumber ++;
        }
    }
示例#29
0
文件: doc_test.cpp 项目: speakman/qlc
QDomElement Doc_Test::createFixtureNode(QDomDocument& doc, t_fixture_id id)
{
	QDomElement root = doc.createElement("Fixture");
	doc.appendChild(root);

	QDomElement chs = doc.createElement("Channels");
	QDomText chsText = doc.createTextNode("18");
	chs.appendChild(chsText);
	root.appendChild(chs);

	QDomElement name = doc.createElement("Name");
	QDomText nameText = doc.createTextNode(QString("Fixture %1").arg(id));
	name.appendChild(nameText);
	root.appendChild(name);

	QDomElement uni = doc.createElement("Universe");
	QDomText uniText = doc.createTextNode("3");
	uni.appendChild(uniText);
	root.appendChild(uni);

	QDomElement model = doc.createElement("Model");
	QDomText modelText = doc.createTextNode("Foobar");
	model.appendChild(modelText);
	root.appendChild(model);

	QDomElement mode = doc.createElement("Mode");
	QDomText modeText = doc.createTextNode("Foobar");
	mode.appendChild(modeText);
	root.appendChild(mode);

	QDomElement type = doc.createElement("Manufacturer");
	QDomText typeText = doc.createTextNode("Foobar");
	type.appendChild(typeText);
	root.appendChild(type);

	QDomElement fxi_id = doc.createElement("ID");
	QDomText fxi_idText = doc.createTextNode(QString("%1").arg(id));
	fxi_id.appendChild(fxi_idText);
	root.appendChild(fxi_id);

	QDomElement addr = doc.createElement("Address");
	QDomText addrText = doc.createTextNode("21");
	addr.appendChild(addrText);
	root.appendChild(addr);

	return root;
}
// Сохранение значений настроек в файл
bool ProjectSettingsLoader::save(const QString settingsFolder)
{
    QDomDocument mainXML;
    QDomElement rootElement;
    QDomElement element;
    QDomElement subElement;

    bool writeFail = false;

    rootElement = mainXML.createElement("settings");
    rootElement = mainXML.appendChild(rootElement).toElement();
    if (rootElement.isNull())
        return false;

    // Настройки проекта
    element = mainXML.createElement("projectSettings");
    rootElement.appendChild(element);

    // Количество закладок
    subElement = mainXML.createElement("unitsCount");
    subElement.appendChild(mainXML.createTextNode(QString::number(mUnitsCount)));
    subElement = element.appendChild(subElement).toElement();
    if (subElement.isNull())
        writeFail = true;

    // Название проекта
    subElement = mainXML.createElement("projectName");
    subElement.appendChild(mainXML.createTextNode(mProjectName));
    subElement = element.appendChild(subElement).toElement();
    if (subElement.isNull())
        writeFail = true;

    // Файл для записи
    mSettingsFolder = settingsFolder;
    QFile file(mSettingsFolder + mSlash + mFileName);
    file.open(QIODevice::WriteOnly);

    // XML-документ создан без ошибок
    if (!writeFail)
    {
        QTextStream xmlTS(&file);
        xmlTS.setCodec(QTextCodec::codecForName("UTF-8"));
        xmlTS<<mainXML.toString();
    }

    return !writeFail;
}