diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index 7e2011a92..e6068ed8c 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -180,28 +180,67 @@ QList XmlReportV2::Read() ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader) { + /* + Error example from the core program in xml + + + + + */ + ErrorItem item; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - const QString file = attribs.value("", FilenameAttribute).toString(); - item.file = file; - item.files.push_back(file); - const int line = attribs.value("", LineAttribute).toString().toUInt(); - item.lines.push_back(line); item.id = attribs.value("", IdAttribute).toString(); item.severity = attribs.value("", SeverityAttribute).toString(); + item.summary = attribs.value("", MsgAttribute).toString(); + item.message = attribs.value("", VerboseAttribute).toString(); - // NOTE: This dublicates the message to Summary-field. But since - // old XML format doesn't have separate summary and verbose messages - // we must add same message to both data so it shows up in GUI. - // Check if there is full stop and cut the summary to it. - QString summary = attribs.value("", MsgAttribute).toString(); - const int ind = summary.indexOf('.'); - if (ind != -1) - summary = summary.left(ind + 1); - item.summary = summary; - item.message = attribs.value("", MsgAttribute).toString(); + ReadLocations(item); } return item; } + +void XmlReportV2::ReadLocations(ErrorItem &item) +{ + QList errors; + bool allRead = false; + while (!allRead && !mXmlReader->atEnd()) + { + switch (mXmlReader->readNext()) + { + case QXmlStreamReader::StartElement: + if (mXmlReader->name() != LocationElementName) + continue; // Skip other than location elements + { + QXmlStreamAttributes attribs = mXmlReader->attributes(); + const QString file = attribs.value("", FilenameAttribute).toString(); + if (item.file.isEmpty()) + item.file = file; + item.files.push_back(file); + const int line = attribs.value("", LineAttribute).toString().toUInt(); + item.lines.push_back(line); + } + break; + + case QXmlStreamReader::EndElement: + if (mXmlReader->name() == LocationElementName) + allRead = true; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } +} diff --git a/gui/xmlreportv2.h b/gui/xmlreportv2.h index 6b1a2841c..d60b71126 100644 --- a/gui/xmlreportv2.h +++ b/gui/xmlreportv2.h @@ -81,6 +81,12 @@ protected: */ ErrorItem ReadError(QXmlStreamReader *reader); + /** + * @brief Read and parse error items location elements from XML stream. + * @param item ErrorItem to write the location data. + */ + void ReadLocations(ErrorItem &item); + private: /** * @brief XML stream reader for reading the report in XML format.