diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 5bef956c1682..6f90e81e71ac 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -324,36 +324,34 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) realfile = tr("Undefined file"); } - bool hide = false; + bool showItem = false; // Ids that are temporarily hidden.. if (mHiddenMessageId.contains(item.errorId)) - hide = true; + showItem = false; //If specified, filter on summary, message, filename, and id - if (!hide && !mFilter.isEmpty()) { + if (showItem && !mFilter.isEmpty()) { if (!item.summary.contains(mFilter, Qt::CaseInsensitive) && !item.message.contains(mFilter, Qt::CaseInsensitive) && !item.errorPath.back().file.contains(mFilter, Qt::CaseInsensitive) && !item.errorId.contains(mFilter, Qt::CaseInsensitive)) { - hide = true; + showItem = false; } } - if (!hide) { + if (showItem) { if (mReportType == ReportType::normal) - hide = !mShowSeverities.isShown(item.severity); + showItem = mShowSeverities.isShown(item.severity); else { const QString& guideline = getGuideline(mReportType, mGuideline, item.errorId); const QString& classification = getClassification(mReportType, guideline); - hide = classification.isEmpty() || !mShowSeverities.isShown(getSeverityFromClassification(classification)); + showItem = !classification.isEmpty() && mShowSeverities.isShown(getSeverityFromClassification(classification)); } } - //if there is at least one error that is not hidden, we have a visible error - if (!hide) { - mVisibleErrors = true; - } + // if there is at least one error that is not hidden, we have a visible error + mVisibleErrors |= showItem; ErrorLine line; line.file = realfile; @@ -372,10 +370,10 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) line.remark = item.remark; //Create the base item for the error and ensure it has a proper //file item as a parent - QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, hide); + QStandardItem* fileItem = ensureFileItem(loc.file, item.file0, !showItem); QStandardItem* stditem = addBacktraceFiles(fileItem, line, - hide, + !showItem, severityToIcon(line.severity), false); @@ -399,7 +397,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) data[SYMBOLNAMES] = item.symbolNames; data[TAGS] = line.tags; data[REMARK] = line.remark; - data[HIDE] = hide; + data[HIDE] = false; stditem->setData(QVariant(data)); //Add backtrace files as children @@ -411,7 +409,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) line.message = line.summary = e.info; QStandardItem *child_item = addBacktraceFiles(stditem, line, - hide, + false, ":images/go-down.png", true); if (!child_item) @@ -434,17 +432,6 @@ bool ResultsTree::addErrorItem(const ErrorItem &item) } } - // Partially refresh the tree: Unhide file item if necessary - setRowHidden(stditem->row(), fileItem->index(), hide); - - bool hideFile = true; - for (int i = 0; i < fileItem->rowCount(); ++i) { - if (!isRowHidden(i, fileItem->index())) { - hideFile = false; - } - } - setRowHidden(fileItem->row(), QModelIndex(), hideFile); - return true; } @@ -656,26 +643,6 @@ void ResultsTree::showHiddenResults() { //Clear the "hide" flag for each item mHiddenMessageId.clear(); - const int filecount = mModel.rowCount(); - for (int i = 0; i < filecount; i++) { - QStandardItem *fileItem = mModel.item(i, 0); - if (!fileItem) - continue; - - QVariantMap data = fileItem->data().toMap(); - data[HIDE] = false; - fileItem->setData(QVariant(data)); - - const int errorcount = fileItem->rowCount(); - for (int j = 0; j < errorcount; j++) { - QStandardItem *child = fileItem->child(j, 0); - if (child) { - data = child->data().toMap(); - data[HIDE] = false; - child->setData(QVariant(data)); - } - } - } refreshTree(); emit resultsHidden(false); } @@ -698,7 +665,7 @@ void ResultsTree::refreshTree() const int errorcount = fileItem->rowCount(); //By default it shouldn't be visible - bool show = false; + bool showFile = false; for (int j = 0; j < errorcount; j++) { //Get the error itself @@ -713,7 +680,7 @@ void ResultsTree::refreshTree() QVariantMap data = userdata.toMap(); //Check if this error should be hidden - bool hide = data[HIDE].toBool(); + bool hide = data[HIDE].toBool() || mHiddenMessageId.contains(data[ERRORID].toString()); if (!hide) { if (mReportType == ReportType::normal) @@ -744,25 +711,16 @@ void ResultsTree::refreshTree() } if (!hide) { + showFile = true; mVisibleErrors = true; } //Hide/show accordingly setRowHidden(j, fileItem->index(), hide); - - //If it was shown then the file itself has to be shown as well - if (!hide) { - show = true; - } - } - - //Hide the file if its "hide" attribute is set - if (fileItem->data().toMap()["hide"].toBool()) { - show = false; } - //Show the file if any of it's errors are visible - setRowHidden(i, QModelIndex(), !show); + // Show the file if any of it's errors are visible + setRowHidden(i, QModelIndex(), !showFile); } } @@ -774,6 +732,8 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin QStandardItem *item = findFileItem(QDir::toNativeSeparators(name)); if (item) { + if (!hide) + setRowHidden(item->row(), QModelIndex(), hide); return item; } @@ -789,7 +749,7 @@ QStandardItem *ResultsTree::ensureFileItem(const QString &fullpath, const QStrin item->setData(QVariant(data)); mModel.appendRow(item); - setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide); + setRowHidden(item->row(), QModelIndex(), hide); return item; } @@ -1192,33 +1152,6 @@ void ResultsTree::hideAllIdResult() mHiddenMessageId.append(messageId); - // hide all errors with that message Id - const int filecount = mModel.rowCount(); - for (int i = 0; i < filecount; i++) { - //Get file i - QStandardItem *file = mModel.item(i, 0); - if (!file) { - continue; - } - - //Get the amount of errors this file contains - const int errorcount = file->rowCount(); - - for (int j = 0; j < errorcount; j++) { - //Get the error itself - QStandardItem *child = file->child(j, 0); - if (!child) { - continue; - } - - QVariantMap userdata = child->data().toMap(); - if (userdata[ERRORID].toString() == messageId) { - userdata[HIDE] = true; - child->setData(QVariant(userdata)); - } - } - } - refreshTree(); emit resultsHidden(true); } diff --git a/gui/test/resultstree/CMakeLists.txt b/gui/test/resultstree/CMakeLists.txt index 9c98e8dcf35e..3e5cc0fe96fd 100644 --- a/gui/test/resultstree/CMakeLists.txt +++ b/gui/test/resultstree/CMakeLists.txt @@ -9,6 +9,7 @@ add_executable(test-resultstree ${CMAKE_SOURCE_DIR}/gui/showtypes.cpp ${CMAKE_SOURCE_DIR}/gui/report.cpp ${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp + ${CMAKE_SOURCE_DIR}/lib/checkers.cpp ) target_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) target_compile_definitions(test-resultstree PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/gui/test/resultstree/resultstree.pro b/gui/test/resultstree/resultstree.pro index d4677d13eea7..27f2c0dda410 100644 --- a/gui/test/resultstree/resultstree.pro +++ b/gui/test/resultstree/resultstree.pro @@ -18,11 +18,14 @@ SOURCES += testresultstree.cpp \ ../../erroritem.cpp \ ../../showtypes.cpp \ ../../report.cpp \ - ../../xmlreportv2.cpp + ../../xmlreportv2.cpp \ + ../../../lib/checkers.cpp HEADERS += testresultstree.h \ ../../resultstree.h \ + ../../common.h \ ../../erroritem.h \ ../../showtypes.h \ ../../report.h \ - ../../xmlreportv2.h + ../../xmlreportv2.h \ + ../../../lib/checkers.h