GUI: Read ErrorItems instead of ErrorLines from XML report.
XML report format 1 only had error "lines" that we promoted to "items" when adding to GUI. XML report format 2 contains error "items" so change the code to read items and do the promotion directly when reading and parsing the data.
This commit is contained in:
parent
0f0f53f919
commit
d31703e452
|
@ -260,7 +260,7 @@ void ResultsView::ReadErrorsXml(const QString &filename)
|
||||||
else if (version == 2)
|
else if (version == 2)
|
||||||
report = new XmlReportV2(filename, this);
|
report = new XmlReportV2(filename, this);
|
||||||
|
|
||||||
QList<ErrorLine> errors;
|
QList<ErrorItem> errors;
|
||||||
if (report)
|
if (report)
|
||||||
{
|
{
|
||||||
if (report->Open())
|
if (report->Open())
|
||||||
|
@ -283,10 +283,9 @@ void ResultsView::ReadErrorsXml(const QString &filename)
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorLine line;
|
ErrorItem item;
|
||||||
foreach(line, errors)
|
foreach(item, errors)
|
||||||
{
|
{
|
||||||
ErrorItem item(line);
|
|
||||||
mUI.mTree->AddErrorItem(item);
|
mUI.mTree->AddErrorItem(item);
|
||||||
}
|
}
|
||||||
mUI.mTree->SetCheckDirectory("");
|
mUI.mTree->SetCheckDirectory("");
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "report.h"
|
#include "report.h"
|
||||||
|
#include "erroritem.h"
|
||||||
|
|
||||||
class QObject;
|
class QObject;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Read contents of the report file.
|
* @brief Read contents of the report file.
|
||||||
*/
|
*/
|
||||||
virtual QList<ErrorLine> Read() = 0;
|
virtual QList<ErrorItem> Read() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Quote the message.
|
* @brief Quote the message.
|
||||||
|
|
|
@ -106,9 +106,9 @@ void XmlReportV1::WriteError(const ErrorItem &error)
|
||||||
mXmlWriter->writeEndElement();
|
mXmlWriter->writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ErrorLine> XmlReportV1::Read()
|
QList<ErrorItem> XmlReportV1::Read()
|
||||||
{
|
{
|
||||||
QList<ErrorLine> errors;
|
QList<ErrorItem> errors;
|
||||||
bool insideResults = false;
|
bool insideResults = false;
|
||||||
if (!mXmlReader)
|
if (!mXmlReader)
|
||||||
{
|
{
|
||||||
|
@ -126,8 +126,8 @@ QList<ErrorLine> XmlReportV1::Read()
|
||||||
// Read error element from inside result element
|
// Read error element from inside result element
|
||||||
if (insideResults && mXmlReader->name() == ErrorElementName)
|
if (insideResults && mXmlReader->name() == ErrorElementName)
|
||||||
{
|
{
|
||||||
ErrorLine line = ReadError(mXmlReader);
|
ErrorItem item = ReadError(mXmlReader);
|
||||||
errors.append(line);
|
errors.append(item);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -152,16 +152,19 @@ QList<ErrorLine> XmlReportV1::Read()
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorLine XmlReportV1::ReadError(QXmlStreamReader *reader)
|
ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader)
|
||||||
{
|
{
|
||||||
ErrorLine line;
|
ErrorItem item;
|
||||||
if (reader->name().toString() == ErrorElementName)
|
if (reader->name().toString() == ErrorElementName)
|
||||||
{
|
{
|
||||||
QXmlStreamAttributes attribs = reader->attributes();
|
QXmlStreamAttributes attribs = reader->attributes();
|
||||||
line.file = attribs.value("", FilenameAttribute).toString();
|
const QString file = attribs.value("", FilenameAttribute).toString();
|
||||||
line.line = attribs.value("", LineAttribute).toString().toUInt();
|
item.file = file;
|
||||||
line.id = attribs.value("", IdAttribute).toString();
|
item.files.push_back(file);
|
||||||
line.severity = attribs.value("", SeverityAttribute).toString();
|
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();
|
||||||
|
|
||||||
// NOTE: This dublicates the message to Summary-field. But since
|
// NOTE: This dublicates the message to Summary-field. But since
|
||||||
// old XML format doesn't have separate summary and verbose messages
|
// old XML format doesn't have separate summary and verbose messages
|
||||||
|
@ -171,8 +174,8 @@ ErrorLine XmlReportV1::ReadError(QXmlStreamReader *reader)
|
||||||
const int ind = summary.indexOf('.');
|
const int ind = summary.indexOf('.');
|
||||||
if (ind != -1)
|
if (ind != -1)
|
||||||
summary = summary.left(ind + 1);
|
summary = summary.left(ind + 1);
|
||||||
line.summary = summary;
|
item.summary = summary;
|
||||||
line.message = attribs.value("", MsgAttribute).toString();
|
item.message = attribs.value("", MsgAttribute).toString();
|
||||||
}
|
}
|
||||||
return line;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,14 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Read contents of the report file.
|
* @brief Read contents of the report file.
|
||||||
*/
|
*/
|
||||||
virtual QList<ErrorLine> Read();
|
virtual QList<ErrorItem> Read();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Read and parse error item from XML stream.
|
* @brief Read and parse error item from XML stream.
|
||||||
* @param reader XML stream reader to use.
|
* @param reader XML stream reader to use.
|
||||||
*/
|
*/
|
||||||
ErrorLine ReadError(QXmlStreamReader *reader);
|
ErrorItem ReadError(QXmlStreamReader *reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -132,9 +132,9 @@ void XmlReportV2::WriteError(const ErrorItem &error)
|
||||||
mXmlWriter->writeEndElement();
|
mXmlWriter->writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ErrorLine> XmlReportV2::Read()
|
QList<ErrorItem> XmlReportV2::Read()
|
||||||
{
|
{
|
||||||
QList<ErrorLine> errors;
|
QList<ErrorItem> errors;
|
||||||
bool insideResults = false;
|
bool insideResults = false;
|
||||||
if (!mXmlReader)
|
if (!mXmlReader)
|
||||||
{
|
{
|
||||||
|
@ -152,8 +152,8 @@ QList<ErrorLine> XmlReportV2::Read()
|
||||||
// Read error element from inside result element
|
// Read error element from inside result element
|
||||||
if (insideResults && mXmlReader->name() == ErrorElementName)
|
if (insideResults && mXmlReader->name() == ErrorElementName)
|
||||||
{
|
{
|
||||||
ErrorLine line = ReadError(mXmlReader);
|
ErrorItem item = ReadError(mXmlReader);
|
||||||
errors.append(line);
|
errors.append(item);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -178,16 +178,19 @@ QList<ErrorLine> XmlReportV2::Read()
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorLine XmlReportV2::ReadError(QXmlStreamReader *reader)
|
ErrorItem XmlReportV2::ReadError(QXmlStreamReader *reader)
|
||||||
{
|
{
|
||||||
ErrorLine line;
|
ErrorItem item;
|
||||||
if (reader->name().toString() == ErrorElementName)
|
if (reader->name().toString() == ErrorElementName)
|
||||||
{
|
{
|
||||||
QXmlStreamAttributes attribs = reader->attributes();
|
QXmlStreamAttributes attribs = reader->attributes();
|
||||||
line.file = attribs.value("", FilenameAttribute).toString();
|
const QString file = attribs.value("", FilenameAttribute).toString();
|
||||||
line.line = attribs.value("", LineAttribute).toString().toUInt();
|
item.file = file;
|
||||||
line.id = attribs.value("", IdAttribute).toString();
|
item.files.push_back(file);
|
||||||
line.severity = attribs.value("", SeverityAttribute).toString();
|
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();
|
||||||
|
|
||||||
// NOTE: This dublicates the message to Summary-field. But since
|
// NOTE: This dublicates the message to Summary-field. But since
|
||||||
// old XML format doesn't have separate summary and verbose messages
|
// old XML format doesn't have separate summary and verbose messages
|
||||||
|
@ -197,8 +200,8 @@ ErrorLine XmlReportV2::ReadError(QXmlStreamReader *reader)
|
||||||
const int ind = summary.indexOf('.');
|
const int ind = summary.indexOf('.');
|
||||||
if (ind != -1)
|
if (ind != -1)
|
||||||
summary = summary.left(ind + 1);
|
summary = summary.left(ind + 1);
|
||||||
line.summary = summary;
|
item.summary = summary;
|
||||||
line.message = attribs.value("", MsgAttribute).toString();
|
item.message = attribs.value("", MsgAttribute).toString();
|
||||||
}
|
}
|
||||||
return line;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,14 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Read contents of the report file.
|
* @brief Read contents of the report file.
|
||||||
*/
|
*/
|
||||||
virtual QList<ErrorLine> Read();
|
virtual QList<ErrorItem> Read();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Read and parse error item from XML stream.
|
* @brief Read and parse error item from XML stream.
|
||||||
* @param reader XML stream reader to use.
|
* @param reader XML stream reader to use.
|
||||||
*/
|
*/
|
||||||
ErrorLine ReadError(QXmlStreamReader *reader);
|
ErrorItem ReadError(QXmlStreamReader *reader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue