GUI: Allow selecting multiple items in results tree.
If multiple items are selected then other than "Hide" context menu items are disabled.
This commit is contained in:
parent
85735e382f
commit
e0702d3ef8
|
@ -37,6 +37,7 @@
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QItemSelectionModel>
|
||||||
#include "erroritem.h"
|
#include "erroritem.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "applicationlist.h"
|
#include "applicationlist.h"
|
||||||
|
@ -47,7 +48,8 @@
|
||||||
ResultsTree::ResultsTree(QWidget * parent) :
|
ResultsTree::ResultsTree(QWidget * parent) :
|
||||||
QTreeView(parent),
|
QTreeView(parent),
|
||||||
mContextItem(0),
|
mContextItem(0),
|
||||||
mVisibleErrors(false)
|
mVisibleErrors(false),
|
||||||
|
mSelectionModel(0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SHOW_NONE; i++)
|
for (int i = 0; i < SHOW_NONE; i++)
|
||||||
mShowTypes[i] = false;
|
mShowTypes[i] = false;
|
||||||
|
@ -446,6 +448,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
QModelIndex index = indexAt(e->pos());
|
QModelIndex index = indexAt(e->pos());
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
{
|
{
|
||||||
|
bool multipleSelection = false;
|
||||||
|
mSelectionModel = selectionModel();
|
||||||
|
if (mSelectionModel->selectedRows().count() > 1)
|
||||||
|
multipleSelection = true;
|
||||||
|
|
||||||
mContextItem = mModel.itemFromIndex(index);
|
mContextItem = mModel.itemFromIndex(index);
|
||||||
|
|
||||||
//Create a new context menu
|
//Create a new context menu
|
||||||
|
@ -465,6 +472,8 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
{
|
{
|
||||||
//Create an action for the application
|
//Create an action for the application
|
||||||
QAction *start = new QAction(mApplications->GetApplicationName(i), &menu);
|
QAction *start = new QAction(mApplications->GetApplicationName(i), &menu);
|
||||||
|
if (multipleSelection)
|
||||||
|
start->setDisabled(true);
|
||||||
|
|
||||||
//Add it to our list so we can disconnect later on
|
//Add it to our list so we can disconnect later on
|
||||||
actions << start;
|
actions << start;
|
||||||
|
@ -497,6 +506,13 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
|
||||||
QAction *copymessage = new QAction(tr("Copy message"), &menu);
|
QAction *copymessage = new QAction(tr("Copy message"), &menu);
|
||||||
QAction *hide = new QAction(tr("Hide"), &menu);
|
QAction *hide = new QAction(tr("Hide"), &menu);
|
||||||
|
|
||||||
|
if (multipleSelection)
|
||||||
|
{
|
||||||
|
copyfilename->setDisabled(true);
|
||||||
|
copypath->setDisabled(true);
|
||||||
|
copymessage->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
menu.addAction(copyfilename);
|
menu.addAction(copyfilename);
|
||||||
menu.addAction(copypath);
|
menu.addAction(copypath);
|
||||||
menu.addAction(copymessage);
|
menu.addAction(copymessage);
|
||||||
|
@ -658,12 +674,18 @@ void ResultsTree::CopyMessage()
|
||||||
|
|
||||||
void ResultsTree::HideResult()
|
void ResultsTree::HideResult()
|
||||||
{
|
{
|
||||||
if (mContextItem)
|
if (!mSelectionModel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QModelIndexList selectedRows = mSelectionModel->selectedRows();
|
||||||
|
QModelIndex index;
|
||||||
|
foreach(index, selectedRows)
|
||||||
{
|
{
|
||||||
|
QStandardItem *item = mModel.itemFromIndex(index);
|
||||||
//Set the "hide" flag for this item
|
//Set the "hide" flag for this item
|
||||||
QVariantMap data = mContextItem->data().toMap();
|
QVariantMap data = item->data().toMap();
|
||||||
data["hide"] = true;
|
data["hide"] = true;
|
||||||
mContextItem->setData(QVariant(data));
|
item->setData(QVariant(data));
|
||||||
|
|
||||||
RefreshTree();
|
RefreshTree();
|
||||||
emit ResultsHidden(true);
|
emit ResultsHidden(true);
|
||||||
|
|
|
@ -34,6 +34,7 @@ class ErrorItem;
|
||||||
class ErrorLine;
|
class ErrorLine;
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
class QItemSelectionModel;
|
||||||
|
|
||||||
/// @addtogroup GUI
|
/// @addtogroup GUI
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -411,6 +412,7 @@ protected:
|
||||||
bool mVisibleErrors;
|
bool mVisibleErrors;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QItemSelectionModel *mSelectionModel;
|
||||||
};
|
};
|
||||||
/// @}
|
/// @}
|
||||||
#endif // RESULTSTREE_H
|
#endif // RESULTSTREE_H
|
||||||
|
|
|
@ -56,6 +56,9 @@
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QTextEdit" name="mDetails">
|
<widget class="QTextEdit" name="mDetails">
|
||||||
<property name="undoRedoEnabled">
|
<property name="undoRedoEnabled">
|
||||||
|
|
Loading…
Reference in New Issue