|
47 | 47 | #include "showtypes.h" |
48 | 48 | #include "threadhandler.h" |
49 | 49 | #include "path.h" |
| 50 | +#include "xmlreportv2.h" |
| 51 | + |
| 52 | +// These must match column headers given in ResultsTree::translate() |
| 53 | +static const unsigned int COLUMN_SINCE_DATE = 6; |
| 54 | +static const unsigned int COLUMN_TAG = 7; |
50 | 55 |
|
51 | 56 | ResultsTree::ResultsTree(QWidget * parent) : |
52 | 57 | QTreeView(parent), |
@@ -154,6 +159,8 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) |
154 | 159 | line.summary = item.summary; |
155 | 160 | line.message = item.message; |
156 | 161 | line.severity = item.severity; |
| 162 | + line.sinceDate = item.sinceDate; |
| 163 | + line.tag = item.tag; |
157 | 164 | //Create the base item for the error and ensure it has a proper |
158 | 165 | //file item as a parent |
159 | 166 | QStandardItem* fileItem = ensureFileItem(item.errorPath.back().file, item.file0, hide); |
@@ -232,7 +239,22 @@ QStandardItem *ResultsTree::addBacktraceFiles(QStandardItem *parent, |
232 | 239 | << createLineNumberItem(QString::number(item.line)) |
233 | 240 | << createNormalItem(childOfMessage ? QString() : item.errorId) |
234 | 241 | << (childOfMessage ? createNormalItem(QString()) : createCheckboxItem(item.inconclusive)) |
235 | | - << createNormalItem(item.summary); |
| 242 | + << createNormalItem(item.summary) |
| 243 | + << createNormalItem(item.sinceDate); |
| 244 | + switch (item.tag) { |
| 245 | + case ErrorItem::NONE: |
| 246 | + list << createNormalItem(""); |
| 247 | + break; |
| 248 | + case ErrorItem::FP: |
| 249 | + list << createNormalItem("fp"); |
| 250 | + break; |
| 251 | + case ErrorItem::IGNORE: |
| 252 | + list << createNormalItem("ignore"); |
| 253 | + break; |
| 254 | + case ErrorItem::BUG: |
| 255 | + list << createNormalItem("bug"); |
| 256 | + break; |
| 257 | + }; |
236 | 258 | //TODO message has parameter names so we'll need changes to the core |
237 | 259 | //cppcheck so we can get proper translations |
238 | 260 |
|
@@ -1003,19 +1025,101 @@ void ResultsTree::saveErrors(Report *report, QStandardItem *fileItem) const |
1003 | 1025 | } |
1004 | 1026 | } |
1005 | 1027 |
|
| 1028 | + |
| 1029 | +QList<ErrorItem> ResultsTree::getAllErrorItems() const |
| 1030 | +{ |
| 1031 | + QList<ErrorItem> ret; |
| 1032 | + for (int i = 0; i < mModel.rowCount(); i++) { |
| 1033 | + const QStandardItem *item = mModel.item(i,0); |
| 1034 | + for (int j = 0; j < item->rowCount(); j++) { |
| 1035 | + const QStandardItem *error = item->child(j,0); |
| 1036 | + ErrorItem errorItem; |
| 1037 | + readErrorItem(error, &errorItem); |
| 1038 | + ret << errorItem; |
| 1039 | + } |
| 1040 | + } |
| 1041 | + return ret; |
| 1042 | +} |
| 1043 | + |
| 1044 | +static int indexOf(const QList<ErrorItem> &list, const ErrorItem &item) |
| 1045 | +{ |
| 1046 | + for (int i = 0; i < list.size(); i++) { |
| 1047 | + if (list[i].errorId == item.errorId && |
| 1048 | + list[i].errorPath == item.errorPath && |
| 1049 | + list[i].file0 == item.file0 && |
| 1050 | + list[i].message == item.message && |
| 1051 | + list[i].inconclusive == item.inconclusive && |
| 1052 | + list[i].severity == item.severity) { |
| 1053 | + return i; |
| 1054 | + } |
| 1055 | + } |
| 1056 | + return -1; |
| 1057 | +} |
| 1058 | + |
| 1059 | +void ResultsTree::updateFromOldReport(const QString &filename) |
| 1060 | +{ |
| 1061 | + QList<ErrorItem> oldErrors; |
| 1062 | + XmlReportV2 oldReport(filename); |
| 1063 | + if (oldReport.open()) { |
| 1064 | + oldErrors = oldReport.read(); |
| 1065 | + oldReport.close(); |
| 1066 | + } |
| 1067 | + |
| 1068 | + // Read current results.. |
| 1069 | + for (int i = 0; i < mModel.rowCount(); i++) { |
| 1070 | + QStandardItem *fileItem = mModel.item(i,0); |
| 1071 | + for (int j = 0; j < fileItem->rowCount(); j++) { |
| 1072 | + QStandardItem *error = fileItem->child(j,0); |
| 1073 | + ErrorItem errorItem; |
| 1074 | + readErrorItem(error, &errorItem); |
| 1075 | + int oldErrorIndex = indexOf(oldErrors, errorItem); |
| 1076 | + QVariantMap data = error->data().toMap(); |
| 1077 | + |
| 1078 | + // New error .. set the "sinceDate" property |
| 1079 | + if (oldErrorIndex < 0 || data["sinceDate"].toString().isEmpty()) { |
| 1080 | + const QString sinceDate = QDate::currentDate().toString(Qt::SystemLocaleShortDate); |
| 1081 | + data["sinceDate"] = sinceDate; |
| 1082 | + error->setData(data); |
| 1083 | + fileItem->child(j, COLUMN_SINCE_DATE)->setText(sinceDate); |
| 1084 | + if (oldErrorIndex < 0) |
| 1085 | + continue; |
| 1086 | + } |
| 1087 | + |
| 1088 | + if (errorItem.tag != ErrorItem::NONE) |
| 1089 | + continue; |
| 1090 | + |
| 1091 | + const ErrorItem &oldErrorItem = oldErrors[oldErrorIndex]; |
| 1092 | + |
| 1093 | + if (oldErrorItem.tag == ErrorItem::FP) |
| 1094 | + data["tag"] = "fp"; |
| 1095 | + else if (oldErrorItem.tag == ErrorItem::IGNORE) |
| 1096 | + data["tag"] = "ignore"; |
| 1097 | + else if (oldErrorItem.tag == ErrorItem::BUG) |
| 1098 | + data["tag"] = "bug"; |
| 1099 | + error->setData(data); |
| 1100 | + } |
| 1101 | + } |
| 1102 | +} |
| 1103 | + |
1006 | 1104 | void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) const |
1007 | 1105 | { |
1008 | | - //Get error's user data |
1009 | | - QVariant userdata = error->data(); |
1010 | | - //Convert it to QVariantMap |
1011 | | - QVariantMap data = userdata.toMap(); |
| 1106 | + // Get error's user data |
| 1107 | + QVariantMap data = error->data().toMap(); |
1012 | 1108 |
|
1013 | 1109 | item->severity = ShowTypes::ShowTypeToSeverity(ShowTypes::VariantToShowType(data["severity"])); |
1014 | 1110 | item->summary = data["summary"].toString(); |
1015 | 1111 | item->message = data["message"].toString(); |
1016 | 1112 | item->errorId = data["id"].toString(); |
1017 | 1113 | item->inconclusive = data["inconclusive"].toBool(); |
1018 | 1114 | item->file0 = data["file0"].toString(); |
| 1115 | + item->sinceDate = data["sinceDate"].toString(); |
| 1116 | + QString tag = data["tag"].toString(); |
| 1117 | + if (tag == "fp") |
| 1118 | + item->tag = ErrorItem::FP; |
| 1119 | + else if (tag == "ignore") |
| 1120 | + item->tag = ErrorItem::IGNORE; |
| 1121 | + else if (tag == "bug") |
| 1122 | + item->tag = ErrorItem::BUG; |
1019 | 1123 |
|
1020 | 1124 | if (error->rowCount() == 0) { |
1021 | 1125 | QErrorPathItem e; |
@@ -1161,7 +1265,7 @@ bool ResultsTree::hasResults() const |
1161 | 1265 | void ResultsTree::translate() |
1162 | 1266 | { |
1163 | 1267 | QStringList labels; |
1164 | | - labels << tr("File") << tr("Severity") << tr("Line") << tr("Id") << tr("Inconclusive") << tr("Summary"); |
| 1268 | + labels << tr("File") << tr("Severity") << tr("Line") << tr("Id") << tr("Inconclusive") << tr("Summary") << tr("Since date") << tr("Tag"); |
1165 | 1269 | mModel.setHorizontalHeaderLabels(labels); |
1166 | 1270 | //TODO go through all the errors in the tree and translate severity and message |
1167 | 1271 | } |
|
0 commit comments