added remove action to report table context menu

report
Marc Zinnschlag 10 years ago
parent f2fc693325
commit 58f4cc882f

@ -1,6 +1,8 @@
#include "reporttable.hpp" #include "reporttable.hpp"
#include <algorithm>
#include <QHeaderView> #include <QHeaderView>
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
@ -17,7 +19,10 @@ void CSVTools::ReportTable::contextMenuEvent (QContextMenuEvent *event)
QMenu menu (this); QMenu menu (this);
if (!selectedRows.empty()) if (!selectedRows.empty())
{
menu.addAction (mShowAction); menu.addAction (mShowAction);
menu.addAction (mRemoveAction);
}
menu.exec (event->globalPos()); menu.exec (event->globalPos());
} }
@ -50,6 +55,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection())); connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection()));
addAction (mShowAction); 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&))); 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(); for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
++iter) ++iter)
show (*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();
} }

@ -24,6 +24,7 @@ namespace CSVTools
CSMTools::ReportModel *mModel; CSMTools::ReportModel *mModel;
CSVWorld::CommandDelegate *mIdTypeDelegate; CSVWorld::CommandDelegate *mIdTypeDelegate;
QAction *mShowAction; QAction *mShowAction;
QAction *mRemoveAction;
private: private:
@ -46,6 +47,8 @@ namespace CSVTools
void showSelection(); void showSelection();
void removeSelection();
signals: signals:
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint); void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);

Loading…
Cancel
Save