From 81449a823a222f3739b12a3a6f01d47b6bb78474 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 13:53:44 +0300 Subject: [PATCH] GUI: Refactoring xmlreport to use pointer to stream writing class. --- gui/xmlreport.cpp | 30 ++++++++++++++++-------------- gui/xmlreport.h | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index f597bd54a..41dbfe5f3 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -21,12 +21,14 @@ #include "xmlreport.h" XmlReport::XmlReport(const QString &filename, QObject * parent) : - Report(filename, parent) + Report(filename, parent), + mXmlWriter(NULL) { } XmlReport::~XmlReport() { + delete mXmlWriter; Close(); } @@ -35,7 +37,7 @@ bool XmlReport::Create() bool success = false; if (Report::Create()) { - mXmlWriter.setDevice(Report::GetFile()); + mXmlWriter = new QXmlStreamWriter(Report::GetFile()); success = true; } return success; @@ -43,15 +45,15 @@ bool XmlReport::Create() void XmlReport::WriteHeader() { - mXmlWriter.setAutoFormatting(true); - mXmlWriter.writeStartDocument(); - mXmlWriter.writeStartElement("results"); + mXmlWriter->setAutoFormatting(true); + mXmlWriter->writeStartDocument(); + mXmlWriter->writeStartElement("results"); } void XmlReport::WriteFooter() { - mXmlWriter.writeEndElement(); - mXmlWriter.writeEndDocument(); + mXmlWriter->writeEndElement(); + mXmlWriter->writeEndDocument(); } void XmlReport::WriteError(const QStringList &files, const QStringList &lines, @@ -63,11 +65,11 @@ void XmlReport::WriteError(const QStringList &files, const QStringList &lines, The callstack seems to be ignored here aswell, instead last item of the stack is used */ - mXmlWriter.writeStartElement("error"); - mXmlWriter.writeAttribute("file", files[files.size() - 1]); - mXmlWriter.writeAttribute("line", lines[lines.size() - 1]); - mXmlWriter.writeAttribute("id", id); - mXmlWriter.writeAttribute("severity", severity); - mXmlWriter.writeAttribute("msg", msg); - mXmlWriter.writeEndElement(); + mXmlWriter->writeStartElement("error"); + mXmlWriter->writeAttribute("file", files[files.size() - 1]); + mXmlWriter->writeAttribute("line", lines[lines.size() - 1]); + mXmlWriter->writeAttribute("id", id); + mXmlWriter->writeAttribute("severity", severity); + mXmlWriter->writeAttribute("msg", msg); + mXmlWriter->writeEndElement(); } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index ab017b43e..cacdd4dec 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -68,7 +68,7 @@ private: /** * @brief XML stream writer for writing the report in XML format. */ - QXmlStreamWriter mXmlWriter; + QXmlStreamWriter *mXmlWriter; }; /// @} #endif // XML_REPORT_H