diff --git a/apps/opencs/view/tools/reporttable.cpp b/apps/opencs/view/tools/reporttable.cpp index ec2ba74d2..eee1da35f 100644 --- a/apps/opencs/view/tools/reporttable.cpp +++ b/apps/opencs/view/tools/reporttable.cpp @@ -1,6 +1,8 @@ #include "reporttable.hpp" +#include + #include #include #include @@ -17,7 +19,10 @@ void CSVTools::ReportTable::contextMenuEvent (QContextMenuEvent *event) QMenu menu (this); if (!selectedRows.empty()) + { menu.addAction (mShowAction); + menu.addAction (mRemoveAction); + } menu.exec (event->globalPos()); } @@ -50,6 +55,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document, connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection())); addAction (mShowAction); + mRemoveAction = new QAction (tr ("Remove from list"), this); + connect (mRemoveAction, SIGNAL (triggered()), this, SLOT (removeSelection())); + addAction (mRemoveAction); + connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&))); } @@ -85,4 +94,17 @@ void CSVTools::ReportTable::showSelection() for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); ++iter) show (*iter); +} + +void CSVTools::ReportTable::removeSelection() +{ + QModelIndexList selectedRows = selectionModel()->selectedRows(); + + std::reverse (selectedRows.begin(), selectedRows.end()); + + for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); + ++iter) + mModel->removeRows (iter->row(), 1); + + selectionModel()->clear(); } \ No newline at end of file diff --git a/apps/opencs/view/tools/reporttable.hpp b/apps/opencs/view/tools/reporttable.hpp index 75b6e8553..2f53425d4 100644 --- a/apps/opencs/view/tools/reporttable.hpp +++ b/apps/opencs/view/tools/reporttable.hpp @@ -24,6 +24,7 @@ namespace CSVTools CSMTools::ReportModel *mModel; CSVWorld::CommandDelegate *mIdTypeDelegate; QAction *mShowAction; + QAction *mRemoveAction; private: @@ -46,6 +47,8 @@ namespace CSVTools void showSelection(); + void removeSelection(); + signals: void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);