From a16c0dbd5e77dc0c0cc123ca1c2fd2776271cf2a Mon Sep 17 00:00:00 2001 From: Zachary Blair Date: Sun, 21 Nov 2010 10:55:34 -0800 Subject: [PATCH] Fixed #1861 (GUI: Allow hiding error) --- gui/main.ui | 9 +++++++- gui/mainwindow.cpp | 1 + gui/resultstree.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++- gui/resultstree.h | 11 +++++++++ gui/resultsview.cpp | 5 +++++ gui/resultsview.h | 5 +++++ 6 files changed, 83 insertions(+), 2 deletions(-) diff --git a/gui/main.ui b/gui/main.ui index 2e6c75260..c6600c14d 100644 --- a/gui/main.ui +++ b/gui/main.ui @@ -66,7 +66,7 @@ 0 0 640 - 21 + 25 @@ -106,6 +106,8 @@ + + @@ -461,6 +463,11 @@ Show performance warnings + + + Show &hidden + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index be70038fb..63be090a7 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -69,6 +69,7 @@ MainWindow::MainWindow() : connect(mUI.mActionUncheckAll, SIGNAL(triggered()), this, SLOT(UncheckAll())); connect(mUI.mActionCollapseAll, SIGNAL(triggered()), mUI.mResults, SLOT(CollapseAllResults())); connect(mUI.mActionExpandAll, SIGNAL(triggered()), mUI.mResults, SLOT(ExpandAllResults())); + connect(mUI.mActionShowHidden, SIGNAL(triggered()), mUI.mResults, SLOT(ShowHiddenResults())); connect(mUI.mActionViewLog, SIGNAL(triggered()), this, SLOT(ShowLogView())); connect(mUI.mActionViewStats, SIGNAL(triggered()), this, SLOT(ShowStatistics())); diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index c3a02b526..48784b95d 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -132,6 +132,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item) //Add user data to that item QMap data; + data["hide"] = false; data["severity"] = SeverityToShowType(item.severity); data["summary"] = item.summary; data["message"] = item.message; @@ -313,6 +314,35 @@ void ResultsTree::ShowResults(ShowTypes type, bool show) } } +void ResultsTree::ShowHiddenResults() +{ + //Clear the "hide" flag for each item + int filecount = mModel.rowCount(); + for (int i = 0; i < filecount; i++) + { + QStandardItem *file = mModel.item(i, 0); + if (!file) + continue; + + QVariantMap data = file->data().toMap(); + data["hide"] = false; + file->setData(QVariant(data)); + + int errorcount = file->rowCount(); + for (int j = 0; j < errorcount; j++) + { + QStandardItem *child = file->child(j, 0); + if (child) + { + data = child->data().toMap(); + data["hide"] = false; + child->setData(QVariant(data)); + } + } + } + RefreshTree(); +} + void ResultsTree::RefreshTree() { @@ -350,7 +380,7 @@ void ResultsTree::RefreshTree() QVariantMap data = userdata.toMap(); //Check if this error should be hidden - bool hide = !mShowTypes[VariantToShowType(data["severity"])]; + bool hide = (data["hide"].toBool() || !mShowTypes[VariantToShowType(data["severity"])]); if (!hide) { @@ -367,6 +397,12 @@ void ResultsTree::RefreshTree() } } + //Hide the file if its "hide" attribute is set + if (file->data().toMap()["hide"].toBool()) + { + show = false; + } + //Show the file if any of it's errors are visible setRowHidden(i, QModelIndex(), !show); } @@ -463,14 +499,17 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) QAction *copyfilename = new QAction(tr("Copy filename"), &menu); QAction *copypath = new QAction(tr("Copy full path"), &menu); QAction *copymessage = new QAction(tr("Copy message"), &menu); + QAction *hide = new QAction(tr("Hide"), &menu); menu.addAction(copyfilename); menu.addAction(copypath); menu.addAction(copymessage); + menu.addAction(hide); connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename())); connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath())); connect(copymessage, SIGNAL(triggered()), this, SLOT(CopyMessage())); + connect(hide, SIGNAL(triggered()), this, SLOT(HideResult())); } //Start the menu @@ -621,6 +660,19 @@ void ResultsTree::CopyMessage() } } +void ResultsTree::HideResult() +{ + if (mContextItem) + { + //Set the "hide" flag for this item + QVariantMap data = mContextItem->data().toMap(); + data["hide"] = true; + mContextItem->setData(QVariant(data)); + + RefreshTree(); + } +} + void ResultsTree::Context(int application) { StartApplication(mContextItem, application); diff --git a/gui/resultstree.h b/gui/resultstree.h index 8ade837c2..3c807f4ca 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -71,6 +71,11 @@ public: */ void ShowResults(ShowTypes type, bool show); + /** + * @brief Function to show results that were previous hidden with HideResult() + */ + void ShowHiddenResults(); + /** * @brief Save results to a text stream * @@ -150,6 +155,12 @@ protected slots: */ void CopyMessage(); + /** + * @brief Slot for context menu item to hide the current error message + * + */ + void HideResult(); + protected: /** diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 8d28b44b1..12786743c 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -89,6 +89,11 @@ void ResultsView::ExpandAllResults() mUI.mTree->expandAll(); } +void ResultsView::ShowHiddenResults() +{ + mUI.mTree->ShowHiddenResults(); +} + void ResultsView::Save(const QString &filename, Report::Type type) { if (!mErrorsFound) diff --git a/gui/resultsview.h b/gui/resultsview.h index cb66a5749..59ac1f7d6 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -173,6 +173,11 @@ public slots: */ void ExpandAllResults(); + /** + * @brief Show hidden results in the result list. + */ + void ShowHiddenResults(); + protected: /** * @brief Have any errors been found