Exemple #1
0
void Vector::write(QXmlStreamWriter& writer) {
	writer.writeStartElement("spirit:vector");

	
    // start the spirit:left tag
    writer.writeStartElement("spirit:left");

    // write the attributes for the element
    XmlUtils::writeAttributes(writer, leftAttributes_);

    // write the value of the element and close the tag
    writer.writeCharacters(QString::number(left_));
    writer.writeEndElement(); // spirit:left

	// start the spirit:right tag
    writer.writeStartElement("spirit:right");

    // write the attributes for the element
    XmlUtils::writeAttributes(writer, rightAttributes_);

    // write the value of the element and close the tag
    writer.writeCharacters(QString::number(right_));
    writer.writeEndElement(); // spirit:right

	writer.writeEndElement(); // spirit:vector
}
Exemple #2
0
void UniAssociation::serialize(QXmlStreamWriter& writer) const {
    beginSerialization(writer, "unidirection");

    if (items.count()) {
        writer.writeStartElement("role");

        if (!_role.name.isEmpty()) {
            writer.writeStartElement("name");
            writer.writeAttribute("trans", QString::number(items[0]->translation()));
            writer.writeAttribute("rot", QString::number(items[0]->rotation()));

            writer.writeCharacters(_role.name);

            writer.writeEndElement();
        }
        if (!_role.multiplicity.isEmpty()) {
            writer.writeStartElement("multiplicity");
            int index = _role.name.isEmpty() ? 0 : 1;
            writer.writeAttribute("trans", QString::number(items[index]->translation()));
            writer.writeAttribute("rot", QString::number(items[index]->rotation()));

            writer.writeCharacters(_role.multiplicity);

            writer.writeEndElement();
        }

        writer.writeTextElement("visibility", Member::visibilityText(_role.visibility));

        writer.writeEndElement();
    }

    endSerialization(writer);
}
void QTableModelHtmlWriter::writeCharacters(QXmlStreamWriter & stream, const QString & text)
{
	if (text.isEmpty()){
		stream.writeCharacters(QChar(QChar::Nbsp));
	} else {
		stream.writeCharacters(text);
	}
}
void CRouteContainer::dumpGPX( QXmlStreamWriter & _rqXmlStreamWriter, bool bOnlySelected ) const
{
  // GPX format reference: see http://www.topografix.com/GPX/1/1/

  // Data
  _rqXmlStreamWriter.writeStartElement( "rte" );
  // ... name
  if( !qsName.isEmpty() )
  {
    _rqXmlStreamWriter.writeStartElement( "name" );
    _rqXmlStreamWriter.writeCharacters( qsName );
    _rqXmlStreamWriter.writeEndElement(); // name
  }
  // ... type
  if( !qsType.isEmpty() )
  {
    _rqXmlStreamWriter.writeStartElement( "type" );
    _rqXmlStreamWriter.writeCharacters( qsType );
    _rqXmlStreamWriter.writeEndElement(); // type
  }
  // ... description
  if( !qsDescription.isEmpty() )
  {
    _rqXmlStreamWriter.writeStartElement( "desc" );
    _rqXmlStreamWriter.writeCDATA( qsDescription );
    _rqXmlStreamWriter.writeEndElement(); // desc
  }
  // ... comment
  if( !qsComment.isEmpty() )
  {
    _rqXmlStreamWriter.writeStartElement( "cmt" );
    _rqXmlStreamWriter.writeCDATA( qsComment );
    _rqXmlStreamWriter.writeEndElement(); // cmt
  }
  // ... url
  if( !qsUrl.isEmpty() )
  {
    _rqXmlStreamWriter.writeStartElement( "link" );
    _rqXmlStreamWriter.writeAttribute( "href", qsUrl );
    _rqXmlStreamWriter.writeEndElement(); // link
  }
  // ... points
  int __iCount = QTreeWidgetItem::childCount();
  for( int __i = 0; __i < __iCount; __i++ )
  {
    CRoutePoint* __poRoutePoint = (CRoutePoint*)QTreeWidgetItem::child( __i );
    if( bOnlySelected && !__poRoutePoint->isMultiSelected() ) continue;
    __poRoutePoint->dumpGPX( _rqXmlStreamWriter );
  }
  // ... [end]
  _rqXmlStreamWriter.writeEndElement(); // rte
}
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 ();
}
Exemple #6
0
void PlatformInfo::WriteXml(QXmlStreamWriter& xml) const
{
	xml.writeStartElement("platform");

	xml.writeStartElement("name");
	xml.writeCharacters(name);
	xml.writeEndElement();

	xml.writeStartElement("version");
	xml.writeCharacters(version);
	xml.writeEndElement();

	xml.writeEndElement();
}
Exemple #7
0
void FileInfo::WriteXml(QXmlStreamWriter& xml, const QString& filename) const
{
	xml.writeStartElement("file");

	xml.writeStartElement("id");
	xml.writeCharacters(QString::number(partitionId));
	xml.writeEndElement();

	xml.writeStartElement("filename");
	xml.writeCharacters(filename);
	xml.writeEndElement();

	xml.writeEndElement();
}
Exemple #8
0
static void _saveQStringList(QXmlStreamWriter &xmlWriter, const QString &sec, const QStringList &list)
{
    foreach(const QString &str, list) {
        xmlWriter.writeStartElement(sec);
        xmlWriter.writeCharacters(str);
        xmlWriter.writeEndElement();
    }
	void RichEditorWidget::handleInsertLink ()
	{
		if (!Ui_.View_->selectedText ().isEmpty ())
		{
			const QString& url = QInputDialog::getText (this,
					tr ("Insert link"), tr ("Enter URL:"));
			const QUrl& guess = QUrl::fromUserInput (url);
			if (guess.isValid ())
				ExecCommand ("createLink", guess.toString ());

			return;
		}

		HyperlinkDialog dia (this);
		if (dia.exec () != QDialog::Accepted)
			return;

		const QString& link = dia.GetLink ();
		const QString& text = dia.GetText ();
		if (link.isEmpty () || text.isEmpty ())
			return;

		QString html;
		QXmlStreamWriter w (&html);
		w.writeStartElement ("a");
		w.writeAttribute ("href", link);
		if (!dia.GetTitle ().isEmpty ())
			w.writeAttribute ("title", dia.GetTitle ());
		if (!dia.GetTarget ().isEmpty ())
			w.writeAttribute ("target", dia.GetTarget ());
		w.writeCharacters (text);
		w.writeEndElement ();

		ExecCommand ("insertHTML", html);
	}
Exemple #10
0
void Livre::sauvegarde(QXmlStreamWriter & stream)
{
    stream.writeStartElement ("media");
    stream.writeTextElement ("nom", nom ());
    if(!cycle ().isEmpty ())
    {
        stream.writeStartElement ("cycle");
        stream.writeAttribute ("tome", QString::number (numeroTome ()));
        stream.writeCharacters (cycle());
        stream.writeEndElement ();
    }
    stream.writeTextElement ("editeur", editeur ());
    stream.writeTextElement ("sortie", date ().toString ());

    if(!url ().isEmpty ())
    {
        stream.writeTextElement ("url", url ().toString ());
    }

    stream.writeTextElement ("genre", genre ());
    stream.writeTextElement ("lu", QString::number (isFini ()));

    foreach(QString atlas, auteur ())
    {
        stream.writeTextElement ("auteur", atlas);
    }
Exemple #11
0
void SymbolSetTool::TranslationEntry::write(QXmlStreamWriter& xml, const QString& language)
{
	if (source.isEmpty())
	{
		QVERIFY(!comment.isEmpty());
		return;
	}
	
	xml.writeStartElement(QLatin1String("message"));
	xml.writeTextElement(QLatin1String("source"), source);
	xml.writeTextElement(QLatin1String("comment"), comment);
	xml.writeStartElement(QLatin1String("translation"));
	for (const auto& translation : translations)
	{
		if (translation.language == language)
		{
			if (!translation.type.isEmpty())
			{
				xml.writeAttribute(QLatin1String("type"), translation.type);
			}
			xml.writeCharacters(translation.translation);		
			break;
		}
	}
	xml.writeEndElement();  //  translation
	xml.writeEndElement();  // message
}
Exemple #12
0
	inline void writeBase64(QXmlStreamWriter &x, const QString &ns, const QString &name, const QByteArray &data)
	{
		x.writeStartElement(ns, name);
		for(int i = 0; i < data.size(); i+=48)
			x.writeCharacters(data.mid(i, 48).toBase64() + "\n");
		x.writeEndElement();
	}
Exemple #13
0
void KDSoapValue::writeElementContents(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace) const
{
    const QVariant value = this->value();

    if (isNil() && d->m_nillable) {
        writer.writeAttribute(KDSoapNamespaceManager::xmlSchemaInstance2001(), QLatin1String("nil"), QLatin1String("true"));
    }

    if (use == EncodedUse) {
        // use=encoded means writing out xsi:type attributes. http://www.eherenow.com/soapfight.htm taught me that.
        QString type;
        if (!this->type().isEmpty()) {
            type = namespacePrefixes.resolve(this->typeNs(), this->type());
        }
        if (type.isEmpty() && !value.isNull()) {
            type = variantToXMLType(value);    // fallback
        }
        if (!type.isEmpty()) {
            writer.writeAttribute(KDSoapNamespaceManager::xmlSchemaInstance2001(), QLatin1String("type"), type);
        }

        // cppcheck-suppress redundantCopyLocalConst
        const KDSoapValueList list = this->childValues();
        const bool isArray = !list.arrayType().isEmpty();
        if (isArray) {
            writer.writeAttribute(KDSoapNamespaceManager::soapEncoding(), QLatin1String("arrayType"), namespacePrefixes.resolve(list.arrayTypeNs(), list.arrayType()) + QLatin1Char('[') + QString::number(list.count()) + QLatin1Char(']'));
        }
    }
    writeChildren(namespacePrefixes, writer, use, messageNamespace, false);

    if (!value.isNull()) {
        writer.writeCharacters(variantToTextValue(value, this->typeNs(), this->type()));
    }
}
void XMLUtility::writeElementAttribute(QXmlStreamWriter& writer, const QString& elementName, const QString& elementValue, const QString& attributeName, const QString& attributeValue)
{
  if (elementName.length() == 0)
  {
    return;
  }
  if (elementValue.length() > 0)
  {
    writer.writeStartElement(elementName);
  }
  else
  {
    writer.writeEmptyElement(elementName);
  }
  if (attributeName.length() > 0 && attributeValue.length() > 0)
  {
    writer.writeAttribute(attributeName, attributeValue);
  }

  if (elementValue.length() > 0)
  {
    writer.writeCharacters(elementValue);
    writer.writeEndElement();
  }
}
Exemple #15
0
void OrthotropicSecantCoefficientOfThermalExpansion::writeXMLparameter(QXmlStreamWriter& stream, Parameter* parameter)
{
    Unit::VUnit * vunit = parameter->getValueUnit();

    stream.writeStartElement("ParameterValue");
    stream.writeAttribute("parameter", parameter->getIdString());
    stream.writeAttribute("format", "float");

    QString values;
    for (std::vector<ParameterValue>::const_iterator it=parameter->getValues().begin();
         it!=parameter->getValues().end();
         ++it) {

        const ParameterValue& pv = *it;
        if (it!=parameter->getValues().begin()) values += ",";
        if (pv.isValueValid()) {
            if (vunit->hasXMLExportUnit()) {
                values += QString::number(vunit->convertToXMLExport(pv.getValue()), 'e', 6);
            } else {
                values += QString::number(pv.getValue(), 'e', 6);
            }
        } else {
            values += undefindedIdentifyerAsString();
        }
    }
    if (parameter->getValues().size()==0) values = undefindedIdentifyerAsString();
    stream.writeTextElement("Data", values);

    stream.writeStartElement("Qualifier");
    stream.writeAttribute("name", "Variable Type");
    stream.writeCharacters("Dependent");
    stream.writeEndElement(); // Qualifier

    stream.writeEndElement(); // ParameterValue
}
void HtmlExporter::writeHtmlLink(QXmlStreamWriter& stream, const QString& url, const QString& text)
{
  stream.writeStartElement("a");
  stream.writeAttribute("href", url);
  stream.writeCharacters(text);
  stream.writeEndElement(); // a
}
Exemple #17
0
void TemplateTrack::saveTypeSpecificTemplateConfiguration(QXmlStreamWriter& xml) const
{
	// Follow map georeferencing XML structure
	xml.writeStartElement(QString::fromLatin1("crs_spec"));
	// TODO: xml.writeAttribute(QString::fromLatin1("language"), "PROJ.4");
	xml.writeCharacters(track_crs_spec);
	xml.writeEndElement(/*crs_spec*/);
}
Exemple #18
0
void SvgItem::save(QXmlStreamWriter &xml) {
  xml.writeStartElement("svg");
  ViewItem::save(xml);
  xml.writeStartElement("data");
  xml.writeCharacters(qCompress(_svgData).toBase64());
  xml.writeEndElement();
  xml.writeEndElement();
}
Exemple #19
0
void Tlevel::writeToXml(QXmlStreamWriter& xml) {
  xml.writeStartElement("level");
    xml.writeAttribute("name", name);
    xml.writeTextElement("description", desc);
  // QUESTIONS
    xml.writeStartElement("questions");
      questionAs.toXml(-1, xml);
      for (int i = 0; i < 4; i++)
        answersAs[i].toXml(i, xml);
      xml.writeTextElement("requireOctave", QVariant(requireOctave).toString());
      xml.writeTextElement("requireStyle", QVariant(requireStyle).toString());
      xml.writeTextElement("showStrNr", QVariant(showStrNr).toString());
      xml.writeTextElement("clef", QVariant((int)clef.type()).toString());
      xml.writeTextElement("instrument", QVariant((int)instrument).toString());
      xml.writeTextElement("onlyLowPos", QVariant(onlyLowPos).toString());
      xml.writeTextElement("onlyCurrKey", QVariant(onlyCurrKey).toString());
      xml.writeTextElement("intonation", QVariant(intonation).toString());
    xml.writeEndElement();
  // ACCIDENTALS
    xml.writeStartElement("accidentals");
      xml.writeTextElement("withSharps", QVariant(withSharps).toString());
      xml.writeTextElement("withFlats", QVariant(withFlats).toString());
      xml.writeTextElement("withDblAcc", QVariant(withDblAcc).toString());
      xml.writeTextElement("useKeySign", QVariant(useKeySign).toString());
      xml.writeStartElement("loKey");
        loKey.toXml(xml);
      xml.writeEndElement(); // loKey
      xml.writeStartElement("hiKey");
        hiKey.toXml(xml);
      xml.writeEndElement(); // hiKey
      xml.writeTextElement("isSingleKey", QVariant(isSingleKey).toString());
      xml.writeTextElement("manualKey", QVariant(manualKey).toString());
      xml.writeTextElement("forceAccids", QVariant(forceAccids).toString());
    xml.writeEndElement(); // accidentals
  // MELODIES
    xml.writeStartElement("melodies");
      xml.writeTextElement("melodyLength", QVariant(melodyLen).toString());
      xml.writeTextElement("endsOnTonic", QVariant(endsOnTonic).toString());
      xml.writeTextElement("requireInTempo", QVariant(requireInTempo).toString());
    xml.writeEndElement(); // melodies
  // RANGE
    xml.writeStartElement("range");
      xml.writeTextElement("loFret", QVariant((qint8)loFret).toString());
      xml.writeTextElement("hiFret", QVariant((qint8)hiFret).toString());
      loNote.toXml(xml, "loNote");
//       tnoteToXml("loNote", loNote, xml);
      hiNote.toXml(xml, "hiNote");
//       tnoteToXml("hiNote", hiNote, xml);
      for (int i = 0; i < 6; i++) {
        xml.writeStartElement("useString");
        xml.writeAttribute("number", QVariant(i + 1).toString());
        xml.writeCharacters(QVariant(usedStrings[i]).toString());
        xml.writeEndElement(); // string
      }
    xml.writeEndElement(); // range

  xml.writeEndElement(); // level
}
Exemple #20
0
void DeviceInfo::WriteXml(QXmlStreamWriter& xml) const
{
	xml.writeStartElement("device");

	xml.writeStartElement("manufacturer");
	xml.writeCharacters(manufacturer);
	xml.writeEndElement();

	xml.writeStartElement("product");
	xml.writeCharacters(product);
	xml.writeEndElement();

	xml.writeStartElement("name");
	xml.writeCharacters(name);
	xml.writeEndElement();

	xml.writeEndElement();
}
static void writeKDSoapValueVariant(QXmlStreamWriter &writer, const KDSoapValue &value)
{
    const QVariant valueToWrite = value.value();
    if (valueToWrite.canConvert(QVariant::String)) {
        writer.writeCharacters(valueToWrite.toString());
    } else
        qWarning("Warning: KDSoapMessageAddressingProperties call to writeKDSoapValueVariant could not write the given KDSoapValue "
                 "value because it could not be converted into a QString");
}
Exemple #22
0
bool TLSFeature::activate()
{
	init();
	QXmlStreamWriter *writer = m_info->writer();
	writer->writeEmptyElement(QLatin1String("starttls"));
	writer->writeDefaultNamespace(NS_TLS);
	writer->writeCharacters(QString());
	return true;
}
Exemple #23
0
void Segment::write( QXmlStreamWriter& writer ) {

	writer.writeStartElement("spirit:segment");

	if (!nameGroup_.name().isEmpty()) {
		writer.writeTextElement("spirit:name", nameGroup_.name());
	}

	if (!nameGroup_.displayName().isEmpty()) {
		writer.writeTextElement("spirit:displayName", nameGroup_.displayName());
	}

	if (!nameGroup_.description().isEmpty()) {
		writer.writeTextElement("spirit:description", nameGroup_.description());
	}

	if (!addressOffset_.isEmpty()) {
		writer.writeStartElement("spirit:addressOffset");
		
		XmlUtils::writeAttributes(writer, offsetAttributes_);
		writer.writeCharacters(addressOffset_);

		writer.writeEndElement(); // spirit:addressOffset
	}

	if (!range_.isEmpty()) {
		writer.writeStartElement("spirit:range");

		XmlUtils::writeAttributes(writer, rangeAttributes_);
		writer.writeCharacters(range_);

		writer.writeEndElement(); // spirit:range
	}

    if (!vendorExtensions_.isEmpty())
    {
        writer.writeStartElement("spirit:vendorExtensions");
        XmlUtils::writeVendorExtensions(writer, vendorExtensions_);
        writer.writeEndElement(); // spirit:vendorExtensions
    }

	writer.writeEndElement(); // spirit:segment
}
Exemple #24
0
//-----------------------------------------------------------------------------
// helper for Root::save()
void rsAddChildNode(QXmlStreamWriter& xmlWriter, const QString nodeName,
    const QString nodeContent)
{
    if (!nodeContent.isEmpty())
    {
		xmlWriter.writeStartElement(nodeName);
		xmlWriter.writeCharacters(nodeContent);
		xmlWriter.writeEndElement();
    }
}
Exemple #25
0
/***********************************
 * Writes application version info
 ***********************************/
void WriteAppInfo(QString Filename, QString MajorVersion, QString MinorVersion)
{
    QString FileName = QApplication::applicationDirPath() + QDir::separator() + Filename;

    if(FileName.isEmpty()) return;

    QFile File(FileName);

    if (!File.open(QIODevice::WriteOnly))
    {
        qDebug() << "Cannot open file";
        return; //Cannot open file
    }

    /*if file is successfully opened then create XML*/
    QXmlStreamWriter* XmlWriter = new QXmlStreamWriter();
    XmlWriter->setAutoFormatting(true);

    /* set the file */
    XmlWriter->setDevice(&File);

    /* Writes a document start with the XML version number version. */
    XmlWriter->writeStartDocument();

    XmlWriter->writeStartElement("Info");

    /* Now write the version */
    XmlWriter->writeStartElement("Major_Version");
    XmlWriter->writeCharacters(MajorVersion);
    XmlWriter->writeEndElement();

    XmlWriter->writeStartElement("Minor_Version");
    XmlWriter->writeCharacters(MinorVersion);
    XmlWriter->writeEndElement();

    XmlWriter->writeEndElement();
    XmlWriter->writeEndDocument();

    File.flush();
    File.close();

    delete XmlWriter;
}
void GaussianBeamWindow::writeView(QXmlStreamWriter& xmlWriter)
{
	xmlWriter.writeTextElement("horizontalRange", QString::number(m_opticsView->horizontalRange()));
	xmlWriter.writeTextElement("verticalRange", QString::number(m_opticsView->verticalRange()));
	xmlWriter.writeTextElement("origin", QString::number(m_opticsView->origin()));
	xmlWriter.writeStartElement("showTargetBeam");
	xmlWriter.writeAttribute("id", "0");
	xmlWriter.writeCharacters(QString::number(m_opticsScene->targetBeamVisible()));
	xmlWriter.writeEndElement();
}
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;
}
Exemple #28
0
void TemplateImage::saveTypeSpecificTemplateConfiguration(QXmlStreamWriter& xml) const
{
	if (is_georeferenced)
	{
		// Follow map georeferencing XML structure
		xml.writeStartElement("crs_spec");
// TODO: xml.writeAttribute("language", "PROJ.4");
		xml.writeCharacters(temp_crs_spec);
		xml.writeEndElement(/*crs_spec*/);
	}
}
void HtmlExporter::writeHtmlFooter(QXmlStreamWriter& stream)
{
  stream.writeStartElement("p");
  stream.writeAttribute("class", "footer");
  stream.writeCharacters(QString(tr("%1 Version %2 (revision %3) by Alexander Barthel. Exported on %4.")).
                         arg(QApplication::applicationName()).
                         arg(QApplication::applicationVersion()).
                         arg(GIT_REVISION).
                         arg(QDateTime::currentDateTime().toString(Qt::DefaultLocaleLongDate)));
  stream.writeEndElement(); // p
}
bool XMLGenerator::createXMLFile() {
    QFile *file = new QFile(projectPath);
    if (!file->open(QIODevice::WriteOnly)) {
        QMessageBox::warning(0, "Read only", "The file is in read only mode");
        return false;
    } else {
        QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
        xmlWriter->setDevice(file);
        xmlWriter->writeStartDocument();
        xmlWriter->writeStartElement("project");

        xmlWriter->writeStartElement("projectName");
        xmlWriter->writeCharacters(projectInfo.projectName["projectName"]);
        xmlWriter->writeEndElement();
        xmlWriter->writeStartElement("coreNum");
        xmlWriter->writeCharacters(projectInfo.coreNum["coreNum"]);
        xmlWriter->writeEndElement();
        xmlWriter->writeStartElement("deviceType");
        xmlWriter->writeCharacters(projectInfo.deviceType["deviceType"]);
        xmlWriter->writeEndElement();
        xmlWriter->writeStartElement("exampleFlag");
        xmlWriter->writeCharacters(projectInfo.exampleFlag["exampleFlag"]);
        xmlWriter->writeEndElement();

        while(!projectInfo.cores.isEmpty()) {
            QMap<QString,QString> core = projectInfo.cores.takeFirst();
            xmlWriter->writeStartElement("core");
            xmlWriter->writeAttribute("id", core["id"]);
            xmlWriter->writeStartElement("fileName");
            xmlWriter->writeCharacters(core["fileName"]);
            xmlWriter->writeEndElement();
            xmlWriter->writeEndElement();
        }

        xmlWriter->writeEndElement();
        xmlWriter->writeEndDocument();

        file->close();
        return true;
    }
}