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


C++ QXmlStreamWriter::setAutoFormatting方法代码示例

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


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

示例1: rewriteXMLFile

int Generate_Xml::rewriteXMLFile(QVector<QLineEdit *> p,int j,int track_tabsibling)
{
	bool tab;
	int tab_get;
	QFile Default("default1.xml");
	
	QXmlStreamWriter *xmlWriter = new QXmlStreamWriter();
	QXmlStreamWriter *newline = new QXmlStreamWriter();
	xmlWriter->setDevice(&Default);
	newline->setDevice(&Default);
	xmlWriter->setAutoFormatting (true);
	xmlWriter->setAutoFormatting(true);
	tab=xmlWriter->autoFormatting();
	
	xmlWriter->setAutoFormattingIndent(-10);
	tab_get=xmlWriter->autoFormattingIndent();
	
		
	
	if (!Default.open(QIODevice::Append))
	{
	/* show wrror message if not able to open file */
	QMessageBox::warning(0, "Read only", "The file is in read only mode");
	}	
	QString temp1;
	QString temp2;
		 
		 
	temp1=(p.at(j))->displayText();
		
	newline->writeEndDocument();

	for(int i=0;i<track_tabsibling;i++)//changed tab here actaully multiplied by two
	xmlWriter->writeCharacters("\t");

	xmlWriter->writeStartElement(temp1);
		
	j++;
				
	while(p.at(j)!=0)
	{
	temp1=(p.at(j))->displayText();
	j++;
	temp2=(p.at(j))->displayText();
	j++;
	xmlWriter->writeAttribute(temp1,temp2);
	}

	xmlWriter->writeEndElement();

	Default.close();
	delete xmlWriter;
	delete newline;
	return j;
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:55,代码来源:Xml_Generator.cpp

示例2: wrap

QString AlterNote::wrap() {

    QString returnValue;
    QXmlStreamWriter *writer = new QXmlStreamWriter(&returnValue);
    writer->setAutoFormatting(true);
    writer->setCodec("UTF-8");
    writer->writeStartDocument();
    writer->writeDTD("<!DOCTYPE NixNote-Query>");
    writer->writeStartElement("nixnote-alternote");
    writer->writeAttribute("version", "2");
    writer->writeAttribute("application", "NixNote");
    writer->writeAttribute("applicationVersion", "2.x");
    writer->writeStartElement("AlterNote");
    for (int i=0; i<lids.size(); i++)
        writer->writeTextElement("id", QString::number(lids[i]));
    writer->writeTextElement("Notebook", notebook);
    writer->writeTextElement("Query", query);
    for (int i=0; i<addTagNames.size(); i++)
        writer->writeTextElement("AddTag", addTagNames[i]);
    for (int i=0; i<delTagNames.size(); i++)
        writer->writeTextElement("DelTag", delTagNames[i]);
    if (clearReminder)
        writer->writeTextElement("ClearReminder", "true");
    if (reminderCompleted)
        writer->writeTextElement("ReminderComplete", "true");
    writer->writeEndElement();
    writer->writeEndElement();
    writer->writeEndDocument();
    return returnValue;
}
开发者ID:zhtengw,项目名称:nixnote2,代码行数:30,代码来源:alternote.cpp

示例3: saveToFile

/*
  Zapisuje ca³y kontener do pliku XML
  Ka¿da para atrybut wartoœæ ma tak¹ sam¹ reprezentacjê w pliku XML.
  Obiekty s¹ rozró¿niane za pomoc¹ tag'u rozpoczynaj¹cego który okreœla typ.
  W przypadku komplikacji wyœwietlany jest MessageBox

*/
void MK::saveToFile(std::string filename){
    QFile file(filename.c_str());

    if (!file.open(QIODevice::WriteOnly)){
        QMessageBox::warning(0,"B³¹d pliku",
                             "Plik jest zablokowany przed zapisem",
                             QMessageBox::Ok);
    } else {
        QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
        xmlWriter->setDevice(&file);
        xmlWriter->setAutoFormatting(true);
        xmlWriter->writeStartDocument();
        xmlWriter->writeStartElement("eksponaty");

        MKontener::iterator mk_it;
        QList<QPair<QString, QString> >::iterator it;
        QList<QPair<QString, QString> > l_toFile;
        mk_it = m_kontener.begin();
        while( mk_it!=m_kontener.end() ){
            l_toFile = (*mk_it)->saveElement();
            it = l_toFile.begin();
            xmlWriter->writeStartElement(l_toFile[1].second.simplified().replace(" ",""));
            while (it != l_toFile.end() ){
                xmlWriter->writeAttribute((*it).first.simplified().replace(" ",""),(*it).second);
                it++;
            }
            xmlWriter->writeEndElement();
            mk_it++;
        }
        xmlWriter->writeEndElement();
        xmlWriter->writeEndDocument();
    }
}
开发者ID:bzyx,项目名称:MuzeumGUI,代码行数:40,代码来源:muzeumkontener.cpp

示例4: writeConfigFile

bool ConfigXml::writeConfigFile(const QString fileName)
{
    QXmlStreamWriter writer;
    QFile configFile(fileName);

    if (!configFile.open(QFile::Truncate | QFile::WriteOnly | QFile::Text)) {
        qDebug() << "Error: Cannot write file " << qPrintable(fileName) <<
                    ": " << qPrintable(configFile.errorString());
        return false;
    }

    writer.setDevice(&configFile);
    writer.setAutoFormatting(true);
    writer.writeStartDocument();
    writer.writeStartElement("config");

    writeEntries(&writer);

    writer.writeEndDocument();
    configFile.close();
    if (configFile.error()) {
        qDebug() << "Error: Cannot write file " << qPrintable(fileName) <<
                    ": " << qPrintable(configFile.errorString());
        return false;
    }
    return true;
}
开发者ID:sriemer,项目名称:dmmctr,代码行数:27,代码来源:configxml.cpp

示例5: main

int main ( int argc, char** argv )
{
	QApplication app(argc, argv );
	QFile wiki ( "../tests/input.wiki" );
	QFile html ( "output.html" );

	if ( wiki.open ( QIODevice::ReadOnly ) && html.open ( QIODevice::WriteOnly ) )
	{
		StateMachineBase::Context ctx;
		QXmlStreamWriter qout ( &html );
		qout.setAutoFormatting(true);
		qout.writeStartDocument();
		qout.writeStartElement("html");
		qout.writeStartElement("head");
		qout.writeEndElement();
		qout.writeStartElement("body");

		ctx.lexer = new WikiLexer;
		ctx.observer = new XHTMLObserver ( "", &qout );
		ctx.nextState = new Parser;

		ctx.lexer->setInput ( QString::fromUtf8( wiki.readAll() ) );
		ctx.observer->startPage( "Test Wiki" );
		while ( ctx.nextState != 0 )
			ctx.nextState->exec ( &ctx );
		ctx.observer->endPage();
		qout.writeEndDocument();
		html.close();
		QDesktopServices::openUrl ( html.fileName() );
		wiki.close();
	}
}
开发者ID:AlanLZY,项目名称:textroom,代码行数:32,代码来源:main.cpp

示例6: startFile

bool HtmlExporter::startFile(QFile& file,
                             const QString& basename,
                             QXmlStreamWriter& stream,
                             int currentPage,
                             int totalPages)
{
  if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
  {
    errorHandler->handleIOError(file);
    return false;
  }

  stream.setDevice(&file);
  stream.setAutoFormatting(true);
  stream.setAutoFormattingIndent(2);
  stream.setCodec("utf-8");

  // Get the CSS either from the resources or from the settings directory
  writeHtmlStart(stream,
                 atools::settings::Settings::getOverloadedPath(":/littlenavmap/resources/css/export.css"));
  writeHtmlHeader(stream);
  writeHtmlNav(stream, basename, currentPage, totalPages);

  stream.writeStartElement("table");
  stream.writeStartElement("tbody");
  return true;
}
开发者ID:albar965,项目名称:littlenavmap,代码行数:27,代码来源:htmlexporter.cpp

示例7: init

	void init( QFile &file, QXmlStreamWriter &stream )
	{
		stream.setDevice( &file );
		stream.setAutoFormatting(true);
		stream.writeStartDocument("1.0");
		stream.writeDTD("<!DOCTYPE IMAGE>");

		stream.writeStartElement("image");
	}
开发者ID:kerautret,项目名称:TKDetection,代码行数:9,代码来源:v3dexport.cpp

示例8: nowSave

void Xml_Generator::nowSave()
{
	QXmlStreamWriter *xmlWriter = new QXmlStreamWriter();
	QFile Default("default.xml");
	
	Default.open(QIODevice::Append);
	xmlWriter->setDevice(&Default);
	
	xmlWriter->writeStartElement("/ProjectDefinition");
	xmlWriter->writeCharacters(" ");
	
	xmlWriter->setAutoFormatting (true);
	xmlWriter->setAutoFormatting(true);
	Default.close();
	delete xmlWriter;
	QMessageBox::warning(0, "Saved Status", "Your file has been saved by the name default1.xml");


}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:19,代码来源:Xml_Generator.cpp

示例9: composeXml

QString MessageXmlParser::composeXml (AbstractXmlData* data)
{
    QString xml;
    QXmlStreamWriter writer (&xml);
    writer.setAutoFormatting (true);
    writer.writeStartDocument();
    writer.writeTextElement ("message", static_cast<MessageXmlData*>(data)->message);
    writer.writeEndDocument();
    return xml;
}
开发者ID:shaan7,项目名称:Kapotah,代码行数:10,代码来源:messagexmlparser.cpp

示例10: gererateQtCreatorWorkspaceFile

bool ROSUtils::gererateQtCreatorWorkspaceFile(QXmlStreamWriter &xmlFile, const QStringList &watchDirectories, const QStringList &includePaths)
{
  xmlFile.setAutoFormatting(true);
  xmlFile.writeStartDocument();
  xmlFile.writeStartElement(QLatin1String("Workspace"));

  xmlFile.writeStartElement(QLatin1String("WatchDirectories"));
  foreach (QString str, watchDirectories)
  {
    xmlFile.writeTextElement(QLatin1String("Directory"), str);
  }
开发者ID:phvass,项目名称:ros_qtc_plugin,代码行数:11,代码来源:ros_utils.cpp

示例11: saveToXmlStream

bool SM_ModelBackend::saveToXmlStream(QXmlStreamWriter &stream)
{
    stream.setAutoFormatting(true);
    stream.writeStartDocument();

    stream.writeStartElement("SubnetMap");
    stream.writeAttribute("fileformat", "2");
    stream.writeAttribute("writer", "SubnetMapper");
    stream.writeAttribute("version", qApp->applicationVersion().toUtf8());

    for (int row = 0; row < SubnetList.count(); ++row) {

        Subnet *subnet = SubnetList.at(row);
        stream.writeStartElement("subnet");

        if (subnet->getIPversion()==Subnet::IPv4) {

            quint32 momip = ((Subnet_v4*)subnet)->getIP();
            quint32 momnm = ((Subnet_v4*)subnet)->getNM();
            QColor momcol = subnet->getColor();

            stream.writeAttribute("ipversion","IPv4");
            stream.writeTextElement("identifier",subnet->getIdentifier());
            stream.writeTextElement("address",((Subnet_v4*)subnet)->IP2String(momip));
            stream.writeTextElement("netmask",((Subnet_v4*)subnet)->IP2String(momnm));
            stream.writeTextElement("description",subnet->getDescription());
            stream.writeTextElement("notes",subnet->getNotes());
            stream.writeTextElement("color",momcol.name());

        } else {

            QPair<quint64,quint64> momip = ((Subnet_v6*)subnet)->getIP();
            QPair<quint64,quint64> momnm = ((Subnet_v6*)subnet)->getNM();
            QColor momcol = subnet->getColor();

            stream.writeAttribute("ipversion","IPv6");
            stream.writeTextElement("identifier",((Subnet_v6*)subnet)->getIdentifier());
            stream.writeTextElement("address",((Subnet_v6*)subnet)->IP2String(momip));
            stream.writeTextElement("netmask",((Subnet_v6*)subnet)->IP2String(momnm));
            stream.writeTextElement("description",((Subnet_v6*)subnet)->getDescription());
            stream.writeTextElement("notes",((Subnet_v6*)subnet)->getNotes());
            stream.writeTextElement("color",momcol.name());

        }

        stream.writeEndElement(); // Element: subnet
    }

    stream.writeEndElement(); // Element: SubnetMapper2
    stream.writeEndDocument();

    return true;

}
开发者ID:lordwolfchild,项目名称:subnetmapper,代码行数:54,代码来源:sm_modelbackend.cpp

示例12: SaveFile

bool CParseChannelSettingConfig::SaveFile()
{
    QString tempFile = "channel_temp.xml";
    if( QFile::exists( tempFile ) )
    {
        if( !QFile::remove( tempFile ) )
            return false;
    }
    QFile writeFile( tempFile );
    if( !writeFile.open(QFile::ReadWrite| QFile::Text) )
        return false;

    QXmlStreamWriter   XmlWrite;
    XmlWrite.setDevice( &writeFile );
    XmlWrite.setAutoFormatting( true );
    XmlWrite.writeStartDocument();
    XmlWrite.writeStartElement( ROOT_NODE );
    int nCount = m_vecNewChannelSettingInfo.count();
    for( int i=0; i<nCount; ++i )
    {
        CHANNEL_SETTING_INFO channelSettingInfo =m_vecNewChannelSettingInfo[i];
        XmlWrite.writeStartElement( CHANNEL_NODE );

        XmlWrite.writeTextElement( NUM_NODE, QString::number(channelSettingInfo.nChannelNum) );
        XmlWrite.writeTextElement( QUALITY_NODE, QString::number(channelSettingInfo.enuQuality) );
        XmlWrite.writeTextElement( RTMP_ENABLE_NODE1, QString::number(channelSettingInfo.bRtmpEnable1? 1:0) );
        XmlWrite.writeTextElement( RTMP_ADDR_NODE1, channelSettingInfo.strRtmpAddr1 );
        XmlWrite.writeTextElement( RTMP_AUDIO_DELAY_NODE1, QString::number(channelSettingInfo.nRtmpAudioDelay1) );

        XmlWrite.writeTextElement( RTMP_ENABLE_NODE2, QString::number(channelSettingInfo.bRtmpEnable2? 1:0) );
        XmlWrite.writeTextElement( RTMP_ADDR_NODE2, channelSettingInfo.strRtmpAddr2 );
        XmlWrite.writeTextElement( RTMP_AUDIO_DELAY_NODE2, QString::number(channelSettingInfo.nRtmpAudioDelay2) );

        XmlWrite.writeTextElement( UDP_RTP_ENABLE_NODE, QString::number(channelSettingInfo.bUdpOrRtpEnable? 1:0) );
        XmlWrite.writeTextElement( UDP_RTP_ADDR_NODE, QString::number(channelSettingInfo.bUdpOrRtpAddr?1:0) );
        XmlWrite.writeTextElement( UDP_RTP_IP_NODE, channelSettingInfo.strUdpOrRtpIp );
        XmlWrite.writeTextElement( UDP_RTP_PORT_NODE, QString::number(channelSettingInfo.nUdpOrRtpPort) );
        XmlWrite.writeTextElement( UDP_RTP_AUDIO_DELAY_NODE, QString::number(channelSettingInfo.nUdpOrRtpAudioDelay) );
        XmlWrite.writeTextElement( INPUT_VIDEO_FORMAT_NODE, QString::number(channelSettingInfo.nInputVideoFormat));
        XmlWrite.writeTextElement( OUTPUT_VIDEO_FORMAT_NODE, QString::number(channelSettingInfo.nOutputVideoFormat));
        XmlWrite.writeEndElement();
    }

    XmlWrite.writeEndDocument();
    writeFile.close();

    // 临时文件写完后,将临时文件copy到备份文件
    QString strSaveFile = CHANNEL_SETTING_CONFIG_FILE;
    QFile::remove( strSaveFile );
    bool bRet = QFile::rename( tempFile, strSaveFile );
    sync();
    return bRet;
}
开发者ID:nanflower,项目名称:transcode-intel-media,代码行数:53,代码来源:parse_channel_setting_config.cpp

示例13: file

void
SoundSettings::saveXML (
        const QString   &xmlFileName,
        const QString   &origFileName,
        const QString   &copyFileName,
        const QString   &title)
{
    QXmlStreamWriter *writer;
    QFile             file (xmlFileName);

    SYS_DEBUG ("-----------------------------------------------------");
    SYS_DEBUG ("*** xmlFileName = %s", SYS_STR(xmlFileName));

    if (!file.open(QIODevice::WriteOnly)) {
        SYS_WARNING ("Unable to open file for writing: %s",
                SYS_STR(xmlFileName));
        return;
    }

    /*
     *
     */
    writer = new QXmlStreamWriter();
    writer->setDevice (&file);
    writer->setAutoFormatting(true);
    writer->setCodec ("UTF-8");
    writer->writeStartDocument ();
    writer->writeStartElement ("soundsettings-applet");

    writer->writeStartElement("orig-file");
        writer->writeCharacters (origFileName);
    writer->writeEndElement ();

    writer->writeStartElement("copy-file");
        writer->writeCharacters (copyFileName);
    writer->writeEndElement ();

    writer->writeStartElement("title");
        writer->writeCharacters (title);
    writer->writeEndElement ();

    /*
     *
     */
    writer->writeEndElement();
    writer->writeEndDocument();

    delete writer;
    file.close ();
}
开发者ID:deztructor,项目名称:meegotouch-controlpanelapplets,代码行数:50,代码来源:soundsettingsutils.cpp

示例14: save_to_dir

bool NPushReportSpeed::save_to_dir(QString &dirName)
{

    QString reportFilename = (dirName + FSC_FSYS_SLASH) + "Speed.xml";
    QFile reportFile(reportFilename);

    reportFile.open(QFile::WriteOnly | QFile::Text);

    QXmlStreamWriter xml;

    xml.setDevice(&reportFile);
    xml.setAutoFormatting(true);

    xml.writeStartDocument();

    dataAccessMutex.lock();


    xml.writeStartElement("SpeedReport");

    xml.writeStartElement("stats");

    xml.writeAttribute("max", QString::number(Speed_max));
    xml.writeAttribute("avg", QString::number(Speed_avg));

    xml.writeEndElement();//stats

    xml.writeStartElement("graph");

    SelfShrinkingList::iterator it;
    for(it = graphPoints.begin(); it != graphPoints.end() ; ++it)
    {
        xml.writeStartElement("point");
        xml.writeAttribute("val", QString::number(*it));
        xml.writeEndElement();
    }

    xml.writeEndElement();//graph

    xml.writeEndElement();//SpeedReport
    dataAccessMutex.unlock();

    xml.writeEndDocument();

    reportFile.close();

    qDebug() << "Speed -> Ended";
    return true;
}
开发者ID:otso,项目名称:Push-Snowboarding,代码行数:49,代码来源:npushreportspeed.cpp

示例15: createCurrentConfigurationString

/**
 * Creates the current configuration string.
 * @return
 *      The string.
 */
QString CreateSceFile::createCurrentConfigurationString()
{
    QBuffer xmlBuffer;

    QXmlStreamWriter xmlWriter;
    xmlWriter.setAutoFormatting(true);
    xmlWriter.setAutoFormattingIndent(2);
    xmlBuffer.open(QIODevice::WriteOnly);
    xmlWriter.setDevice(&xmlBuffer);

    xmlWriter.writeStartElement("SceConfiguration");

    xmlWriter.writeStartElement("Files");
    for(int i = 0; i < ui->filesTableWidget->rowCount(); i++)
    {
        QComboBox* box = static_cast<QComboBox*>(ui->filesTableWidget->cellWidget(i, COLUMN_TYPE));
        QString subDirectory = ui->filesTableWidget->item(i, COLUMN_SUBDIR)->text();
        QString source = MainWindow::convertToRelativePath(m_configFileName, ui->filesTableWidget->item(i, COLUMN_SOURCE)->text());

        xmlWriter.writeStartElement("File");
        xmlWriter.writeAttribute("subDirectory", subDirectory);
        xmlWriter.writeAttribute("type", box->currentText());
        xmlWriter.writeAttribute("source", source);
        xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("ScriptArguments");
    for(int i = 0; i < ui->argumentsListWidget->count(); i++)
    {
        xmlWriter.writeStartElement("ScriptArgument");
        xmlWriter.writeAttribute("value", ui->argumentsListWidget->item(i)->text());
        xmlWriter.writeEndElement();
    }
    xmlWriter.writeEndElement();

    xmlWriter.writeStartElement("ScriptWindowState");
    xmlWriter.writeAttribute("withScriptWindow", QString("%1").arg(ui->withScriptWindowCheckBox->isChecked()));
    xmlWriter.writeAttribute("notMinimized", QString("%1").arg(ui->notMinimized->isChecked()));
    xmlWriter.writeAttribute("minScVersion", QString("%1.%2").arg(ui->minScVersionMajor->value()).arg(ui->minScVersionMinor->value()));
    xmlWriter.writeAttribute("sceFileName", MainWindow::convertToRelativePath(m_configFileName, ui->fileLineEdit->text()));
    xmlWriter.writeEndElement();

    xmlWriter.writeEndElement();//SceConfiguration

    return xmlBuffer.data();
}
开发者ID:szieke,项目名称:ScriptCommunicator_serial-terminal,代码行数:52,代码来源:createSceFile.cpp


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