| 239 | } |
| 240 | |
| 241 | bool ResultsTree::addErrorItem(const ErrorItem& errorItem) |
| 242 | { |
| 243 | if (errorItem.errorPath.isEmpty()) |
| 244 | return false; |
| 245 | |
| 246 | const QString s = errorItem.toString(); |
| 247 | if (mErrorList.contains(s)) |
| 248 | return false; |
| 249 | mErrorList.append(s); |
| 250 | |
| 251 | QSharedPointer<ErrorItem> errorItemPtr{new ErrorItem(errorItem)}; |
| 252 | |
| 253 | if (mReportType != ReportType::normal) { |
| 254 | errorItemPtr->guideline = getGuideline(mReportType, mGuideline, errorItemPtr->errorId, errorItemPtr->severity); |
| 255 | errorItemPtr->classification = getClassification(mReportType, errorItemPtr->guideline); |
| 256 | } |
| 257 | |
| 258 | const bool showItem = !isErrorItemHidden(errorItemPtr); |
| 259 | |
| 260 | // if there is at least one error that is not hidden, we have a visible error |
| 261 | mVisibleErrors |= showItem; |
| 262 | |
| 263 | if (const ProjectFile *activeProject = ProjectFile::getActiveProject()) |
| 264 | errorItemPtr->tags = activeProject->getWarningTags(errorItemPtr->hash); |
| 265 | //Create the base item for the error and ensure it has a proper |
| 266 | //file item as a parent |
| 267 | ResultItem* fileItem = ensureFileItem(errorItemPtr, !showItem); |
| 268 | ResultItem* stditem = addBacktraceFiles(fileItem, |
| 269 | errorItemPtr, |
| 270 | !showItem, |
| 271 | severityToIcon(getSeverity(mReportType, *errorItemPtr)), |
| 272 | ResultItem::Type::message, |
| 273 | errorItemPtr->getMainLocIndex()); |
| 274 | |
| 275 | if (!stditem) |
| 276 | return false; |
| 277 | |
| 278 | //Add backtrace files as children |
| 279 | if (errorItemPtr->errorPath.size() > 1) { |
| 280 | for (int i = 0; i < errorItemPtr->errorPath.size(); i++) { |
| 281 | addBacktraceFiles(stditem, |
| 282 | errorItemPtr, |
| 283 | false, |
| 284 | ":images/go-down.png", |
| 285 | ResultItem::Type::note, |
| 286 | i); |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | return true; |
| 291 | } |
| 292 | |
| 293 | ResultItem *ResultsTree::addBacktraceFiles(ResultItem *parent, |
| 294 | const QSharedPointer<ErrorItem>& errorItem, |