diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index c9c10545b..320a36093 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "erroritem.h" #include "settings.h" #include "applicationlist.h" @@ -47,7 +48,8 @@ ResultsTree::ResultsTree(QWidget * parent) : QTreeView(parent), mContextItem(0), - mVisibleErrors(false) + mVisibleErrors(false), + mSelectionModel(0) { for (int i = 0; i < SHOW_NONE; i++) mShowTypes[i] = false; @@ -446,6 +448,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) QModelIndex index = indexAt(e->pos()); if (index.isValid()) { + bool multipleSelection = false; + mSelectionModel = selectionModel(); + if (mSelectionModel->selectedRows().count() > 1) + multipleSelection = true; + mContextItem = mModel.itemFromIndex(index); //Create a new context menu @@ -465,6 +472,8 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) { //Create an action for the application QAction *start = new QAction(mApplications->GetApplicationName(i), &menu); + if (multipleSelection) + start->setDisabled(true); //Add it to our list so we can disconnect later on actions << start; @@ -497,6 +506,13 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) QAction *copymessage = new QAction(tr("Copy message"), &menu); QAction *hide = new QAction(tr("Hide"), &menu); + if (multipleSelection) + { + copyfilename->setDisabled(true); + copypath->setDisabled(true); + copymessage->setDisabled(true); + } + menu.addAction(copyfilename); menu.addAction(copypath); menu.addAction(copymessage); @@ -658,12 +674,18 @@ void ResultsTree::CopyMessage() 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 - QVariantMap data = mContextItem->data().toMap(); + QVariantMap data = item->data().toMap(); data["hide"] = true; - mContextItem->setData(QVariant(data)); + item->setData(QVariant(data)); RefreshTree(); emit ResultsHidden(true); diff --git a/gui/resultstree.h b/gui/resultstree.h index 538d4ce97..1140d7400 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -34,6 +34,7 @@ class ErrorItem; class ErrorLine; class QModelIndex; class QWidget; +class QItemSelectionModel; /// @addtogroup GUI /// @{ @@ -411,6 +412,7 @@ protected: bool mVisibleErrors; private: + QItemSelectionModel *mSelectionModel; }; /// @} #endif // RESULTSTREE_H diff --git a/gui/resultsview.ui b/gui/resultsview.ui index 532a873df..1a5bc3b34 100644 --- a/gui/resultsview.ui +++ b/gui/resultsview.ui @@ -56,6 +56,9 @@ 0 + + QAbstractItemView::ExtendedSelection +