Remove the use of ElementsCollectionItem and ElementDefinition from qetelementeditor class

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4413 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2016-03-31 17:28:44 +00:00
parent 6d4d1535e5
commit 9a6764ae08
10 changed files with 243 additions and 158 deletions

View File

@@ -220,3 +220,37 @@ QDomElement QETXML::fileSystemElementToXmlCollectionElement(QDomDocument &docume
else
return QDomElement();
}
/**
* @brief QETXML::writeXmlFile
* Export an XML document to an UTF-8 text file indented with 4 spaces, with LF end of lines and no BOM.
* @param xml_document : An XML document to be exported
* @param file_path : Path to the file to be written
* @param error_message : If non-zero, will contain an error message explaining what happened when this function returns false.
* @return false if an error occured, true otherwise
*/
bool QETXML::writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message)
{
QFile file(file_path);
// Note: we do not set QIODevice::Text to avoid generating CRLF end of lines
bool file_opening = file.open(QIODevice::WriteOnly);
if (!file_opening)
{
if (error_message)
{
*error_message = QString(QObject::tr("Impossible d'ouvrir le fichier %1 en écriture, erreur %2 rencontrée.",
"error message when attempting to write an XML file")
).arg(file_path).arg(file.error());
}
return(false);
}
QTextStream out(&file);
out.setCodec("UTF-8");
out.setGenerateByteOrderMark(false);
out << xml_document.toString(4);
file.close();
return(true);
}