diff --git a/gui/report.cpp b/gui/report.cpp index cd2c911bd..2f5e150e3 100644 --- a/gui/report.cpp +++ b/gui/report.cpp @@ -17,6 +17,7 @@ */ #include +#include "erroritem.h" #include "report.h" Report::Report(const QString &filename, QObject * parent) : diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index aeab7e85f..e6f7a7945 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -229,10 +229,11 @@ void ResultsView::DisableProgressbar() void ResultsView::ReadErrorsXml(const QString &filename) { XmlReport *report = new XmlReport(filename, this); + QList errors; if (report) { if (report->Open()) - report->Read(); + errors = report->Read(); else { QMessageBox msgBox; @@ -250,4 +251,11 @@ void ResultsView::ReadErrorsXml(const QString &filename) msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); } + + ErrorLine line; + foreach(line, errors) + { + ErrorItem item(line); + mUI.mTree->AddErrorItem(item); + } } diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index 56a58fbd0..57873feba 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "erroritem.h" #include "xmlreport.h" static const char ResultElementName[] = "results"; @@ -96,13 +97,14 @@ void XmlReport::WriteError(const ErrorItem &error) mXmlWriter->writeEndElement(); } -void XmlReport::Read() +QList XmlReport::Read() { + QList errors; bool insideResults = false; if (!mXmlReader) { qDebug() << "You must Open() the file before reading it!"; - return; + return errors; } while (!mXmlReader->atEnd()) { @@ -114,7 +116,10 @@ void XmlReport::Read() // Read error element from inside result element if (insideResults && mXmlReader->name() == ErrorElementName) - ReadError(mXmlReader); + { + ErrorLine line = ReadError(mXmlReader); + errors.append(line); + } break; case QXmlStreamReader::EndElement: @@ -135,18 +140,20 @@ void XmlReport::Read() break; } } + return errors; } -void XmlReport::ReadError(QXmlStreamReader *reader) +ErrorLine XmlReport::ReadError(QXmlStreamReader *reader) { + ErrorLine line; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - QString filename = attribs.value("", FilenameAttribute).toString(); - QString line = attribs.value("", LineAttribute).toString(); - QString id = attribs.value("", IdAttribute).toString(); - QString severity = attribs.value("", SeverityAttribute).toString(); - QString msg = attribs.value("", MsgAttribute).toString(); - qDebug() << "Error: " << filename << " " << line << " " << id << " " << severity << " " << msg; + line.file = attribs.value("", FilenameAttribute).toString(); + line.line = attribs.value("", LineAttribute).toString(); + line.id = attribs.value("", IdAttribute).toString(); + line.severity = attribs.value("", SeverityAttribute).toString(); + line.msg = attribs.value("", MsgAttribute).toString(); } + return line; } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 5cc99d769..f850707c3 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -72,14 +72,14 @@ public: /** * @brief Read contents of the report file. */ - void Read(); + QList Read(); protected: /** * @brief Read and parse error item from XML stream. * @param reader XML stream reader to use. */ - void ReadError(QXmlStreamReader *reader); + ErrorLine ReadError(QXmlStreamReader *reader); private: /**