GUI: Add new short summary to error structures.

Also rename 'msg' in structures to 'message' for consistency.
This commit is contained in:
Kimmo Varis 2010-11-11 22:51:00 +02:00
parent 53e9938afe
commit 999e446777
7 changed files with 21 additions and 16 deletions

View File

@ -65,7 +65,7 @@ void CsvReport::WriteError(const ErrorItem &error)
QString line; QString line;
const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]);
line += QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]); line += QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]);
line += QString("%1,%2").arg(error.severity).arg(error.msg); line += QString("%1,%2").arg(error.severity).arg(error.message);
mTxtWriter << line << endl; mTxtWriter << line << endl;
} }

View File

@ -25,7 +25,8 @@ ErrorItem::ErrorItem(const ErrorItem &item)
lines = item.lines; lines = item.lines;
id = item.id; id = item.id;
severity = item.severity; severity = item.severity;
msg = item.msg; summary = item.summary;
message = item.message;
} }
ErrorItem::ErrorItem(const ErrorLine &line) ErrorItem::ErrorItem(const ErrorLine &line)
@ -35,13 +36,15 @@ ErrorItem::ErrorItem(const ErrorLine &line)
lines.append(line.line); lines.append(line.line);
id = line.id; id = line.id;
severity = line.severity; severity = line.severity;
msg = line.msg; summary = line.summary;
message = line.message;
} }
QString ErrorItem::ToString() const QString ErrorItem::ToString() const
{ {
QString str = file + " - " + id + " - " + severity +"\n"; QString str = file + " - " + id + " - " + severity +"\n";
str += " " + msg; str += " " + summary;
str += "\n" + message;
for (int i = 0; i < files.size(); i++) for (int i = 0; i < files.size(); i++)
str += " " + files[i] + ": " + lines[i] + "\n"; str += " " + files[i] + ": " + lines[i] + "\n";
return str; return str;

View File

@ -50,7 +50,8 @@ public:
QList<unsigned int> lines; QList<unsigned int> lines;
QString id; QString id;
QString severity; QString severity;
QString msg; QString summary;
QString message;
}; };
Q_DECLARE_METATYPE(ErrorItem); Q_DECLARE_METATYPE(ErrorItem);
@ -65,7 +66,8 @@ public:
unsigned int line; unsigned int line;
QString id; QString id;
QString severity; QString severity;
QString msg; QString summary;
QString message;
}; };
/// @} /// @}

View File

@ -107,7 +107,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
line.file = realfile; line.file = realfile;
line.id = item.id; line.id = item.id;
line.line = item.lines[0]; line.line = item.lines[0];
line.msg = item.msg; line.message = item.message;
line.severity = item.severity; line.severity = item.severity;
//Create the base item for the error and ensure it has a proper //Create the base item for the error and ensure it has a proper
//file item as a parent //file item as a parent
@ -122,7 +122,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
//Add user data to that item //Add user data to that item
QMap<QString, QVariant> data; QMap<QString, QVariant> data;
data["severity"] = SeverityToShowType(item.severity); data["severity"] = SeverityToShowType(item.severity);
data["message"] = item.msg; data["message"] = item.message;
data["file"] = item.files[0]; data["file"] = item.files[0];
data["line"] = item.lines[0]; data["line"] = item.lines[0];
data["id"] = item.id; data["id"] = item.id;
@ -142,7 +142,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
//Add user data to that item //Add user data to that item
QMap<QString, QVariant> child_data; QMap<QString, QVariant> child_data;
child_data["severity"] = SeverityToShowType(line.severity); child_data["severity"] = SeverityToShowType(line.severity);
child_data["message"] = line.msg; child_data["message"] = line.message;
child_data["file"] = item.files[i]; child_data["file"] = item.files[i];
child_data["line"] = line.line; child_data["line"] = line.line;
child_data["id"] = line.id; child_data["id"] = line.id;
@ -176,7 +176,7 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
list << CreateItem(QString("%1").arg(item.line)); list << CreateItem(QString("%1").arg(item.line));
//TODO message has parameter names so we'll need changes to the core //TODO message has parameter names so we'll need changes to the core
//cppcheck so we can get proper translations //cppcheck so we can get proper translations
list << CreateItem(tr(item.msg.toLatin1())); list << CreateItem(tr(item.message.toLatin1()));
// Check for duplicate rows and don't add them if found // Check for duplicate rows and don't add them if found
for (int i = 0; i < parent->rowCount(); i++) for (int i = 0; i < parent->rowCount(); i++)
@ -693,7 +693,7 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item)
ErrorItem item; ErrorItem item;
item.severity = ShowTypeToString(VariantToShowType(data["severity"])); item.severity = ShowTypeToString(VariantToShowType(data["severity"]));
item.msg = data["message"].toString(); item.message = data["message"].toString();
item.id = data["id"].toString(); item.id = data["id"].toString();
QString file = StripPath(data["file"].toString(), true); QString file = StripPath(data["file"].toString(), true);
unsigned int line = data["line"].toUInt(); unsigned int line = data["line"].toUInt();

View File

@ -69,7 +69,8 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
item.files = files; item.files = files;
item.id = QString(msg._id.c_str()); item.id = QString(msg._id.c_str());
item.lines = lines; item.lines = lines;
item.msg = QString::fromStdString(msg.verboseMessage()); item.summary = QString::fromStdString(msg.shortMessage());
item.message = QString::fromStdString(msg.verboseMessage());
item.severity = QString::fromStdString(Severity::toString(msg._severity)); item.severity = QString::fromStdString(Severity::toString(msg._severity));
if (msg._severity != Severity::debug) if (msg._severity != Severity::debug)
@ -115,4 +116,3 @@ int ThreadResult::GetFileCount()
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
return mFiles.size(); return mFiles.size();
} }

View File

@ -76,7 +76,7 @@ void TxtReport::WriteError(const ErrorItem &error)
} }
} }
line += QString("(%1) %2").arg(error.severity).arg(error.msg); line += QString("(%1) %2").arg(error.severity).arg(error.message);
mTxtWriter << line << endl; mTxtWriter << line << endl;
} }

View File

@ -99,7 +99,7 @@ void XmlReport::WriteError(const ErrorItem &error)
mXmlWriter->writeAttribute(LineAttribute, line); mXmlWriter->writeAttribute(LineAttribute, line);
mXmlWriter->writeAttribute(IdAttribute, error.id); mXmlWriter->writeAttribute(IdAttribute, error.id);
mXmlWriter->writeAttribute(SeverityAttribute, error.severity); mXmlWriter->writeAttribute(SeverityAttribute, error.severity);
mXmlWriter->writeAttribute(MsgAttribute, error.msg); mXmlWriter->writeAttribute(MsgAttribute, error.message);
mXmlWriter->writeEndElement(); mXmlWriter->writeEndElement();
} }
@ -159,7 +159,7 @@ ErrorLine XmlReport::ReadError(QXmlStreamReader *reader)
line.line = attribs.value("", LineAttribute).toString().toUInt(); line.line = attribs.value("", LineAttribute).toString().toUInt();
line.id = attribs.value("", IdAttribute).toString(); line.id = attribs.value("", IdAttribute).toString();
line.severity = attribs.value("", SeverityAttribute).toString(); line.severity = attribs.value("", SeverityAttribute).toString();
line.msg = attribs.value("", MsgAttribute).toString(); line.message = attribs.value("", MsgAttribute).toString();
} }
return line; return line;
} }