Skip to content

Commit

Permalink
fix test-resultstree
Browse files Browse the repository at this point in the history
  • Loading branch information
danmar committed Jun 30, 2024
1 parent 95591d6 commit 3c78a93
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 90 deletions.
109 changes: 21 additions & 88 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions gui/test/resultstree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
7 changes: 5 additions & 2 deletions gui/test/resultstree/resultstree.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3c78a93

Please sign in to comment.