MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / updateFromOldReport

Method updateFromOldReport

gui/resultstree.cpp:1135–1175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1133}
1134
1135void ResultsTree::updateFromOldReport(const QString &filename)
1136{
1137 showColumn(COLUMN_SINCE_DATE);
1138
1139 QList<ErrorItem> oldErrors;
1140 XmlReportV2 oldReport(filename, QString());
1141 if (oldReport.open()) {
1142 oldErrors = oldReport.read();
1143 oldReport.close();
1144 }
1145
1146 // Read current results..
1147 for (int i = 0; i < mModel->rowCount(); i++) {
1148 auto *fileItem = dynamic_cast<ResultItem*>(mModel->item(i,COLUMN_FILE));
1149 for (int j = 0; j < fileItem->rowCount(); j++) {
1150 auto *error = dynamic_cast<ResultItem*>(fileItem->child(j,COLUMN_FILE));
1151 if (!error)
1152 // FIXME..
1153 continue;
1154 const auto it = std::find_if(oldErrors.cbegin(),
1155 oldErrors.cend(),
1156 [error](const ErrorItem& err) {
1157 return ErrorItem::same(err, *error->errorItem);
1158 });
1159 const ErrorItem* oldError = (it == oldErrors.cend()) ? nullptr : &*it;
1160
1161 // New error .. set the "sinceDate" property
1162 if (oldError && !oldError->sinceDate.isEmpty()) {
1163 error->errorItem->sinceDate = oldError->sinceDate;
1164 fileItem->child(j, COLUMN_SINCE_DATE)->setText(error->errorItem->sinceDate);
1165 } else if (oldError == nullptr || error->errorItem->sinceDate.isEmpty()) {
1166 const QString sinceDate = QLocale::system().toString(QDate::currentDate(), QLocale::ShortFormat);
1167 error->errorItem->sinceDate = sinceDate;
1168 fileItem->child(j, COLUMN_SINCE_DATE)->setText(sinceDate);
1169 }
1170
1171 if (oldError && error->errorItem->tags.isEmpty())
1172 error->errorItem->tags = oldError->tags;
1173 }
1174 }
1175}
1176
1177void ResultsTree::updateSettings(bool showFullPath,
1178 bool saveFullPath,

Callers 2

analysisDoneMethod · 0.45
stopAnalysisMethod · 0.45

Calls 7

rowCountMethod · 0.80
isEmptyMethod · 0.80
QStringClass · 0.70
openMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected