Fixed #1861 (GUI: Allow hiding error)

This commit is contained in:
Zachary Blair 2010-11-21 10:55:34 -08:00
parent bb745da5f9
commit a16c0dbd5e
6 changed files with 83 additions and 2 deletions

View File

@ -66,7 +66,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>21</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="mMenuFile">
@ -106,6 +106,8 @@
<addaction name="mActionCollapseAll"/>
<addaction name="mActionExpandAll"/>
<addaction name="separator"/>
<addaction name="mActionShowHidden"/>
<addaction name="separator"/>
<addaction name="mActionViewLog"/>
<addaction name="mActionViewStats"/>
</widget>
@ -461,6 +463,11 @@
<string>Show performance warnings</string>
</property>
</action>
<action name="mActionShowHidden">
<property name="text">
<string>Show &amp;hidden</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -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()));

View File

@ -132,6 +132,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item)
//Add user data to that item
QMap<QString, QVariant> 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);

View File

@ -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:
/**

View File

@ -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)

View File

@ -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