forked from mirror/openmw-tes3mp
added context menu to report table
This commit is contained in:
parent
350b0cb93c
commit
f2fc693325
2 changed files with 35 additions and 0 deletions
|
@ -2,11 +2,26 @@
|
||||||
#include "reporttable.hpp"
|
#include "reporttable.hpp"
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "../../model/tools/reportmodel.hpp"
|
#include "../../model/tools/reportmodel.hpp"
|
||||||
|
|
||||||
#include "../../view/world/idtypedelegate.hpp"
|
#include "../../view/world/idtypedelegate.hpp"
|
||||||
|
|
||||||
|
void CSVTools::ReportTable::contextMenuEvent (QContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
// create context menu
|
||||||
|
QMenu menu (this);
|
||||||
|
|
||||||
|
if (!selectedRows.empty())
|
||||||
|
menu.addAction (mShowAction);
|
||||||
|
|
||||||
|
menu.exec (event->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::mouseMoveEvent (QMouseEvent *event)
|
void CSVTools::ReportTable::mouseMoveEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
|
@ -31,6 +46,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||||
|
|
||||||
setItemDelegateForColumn (0, mIdTypeDelegate);
|
setItemDelegateForColumn (0, mIdTypeDelegate);
|
||||||
|
|
||||||
|
mShowAction = new QAction (tr ("Show"), this);
|
||||||
|
connect (mShowAction, SIGNAL (triggered()), this, SLOT (showSelection()));
|
||||||
|
addAction (mShowAction);
|
||||||
|
|
||||||
connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
connect (this, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (show (const QModelIndex&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,3 +77,12 @@ void CSVTools::ReportTable::show (const QModelIndex& index)
|
||||||
{
|
{
|
||||||
emit editRequest (mModel->getUniversalId (index.row()), mModel->getHint (index.row()));
|
emit editRequest (mModel->getUniversalId (index.row()), mModel->getHint (index.row()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVTools::ReportTable::showSelection()
|
||||||
|
{
|
||||||
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
|
for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end();
|
||||||
|
++iter)
|
||||||
|
show (*iter);
|
||||||
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "../world/dragrecordtable.hpp"
|
#include "../world/dragrecordtable.hpp"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
namespace CSMTools
|
namespace CSMTools
|
||||||
{
|
{
|
||||||
class ReportModel;
|
class ReportModel;
|
||||||
|
@ -21,9 +23,12 @@ namespace CSVTools
|
||||||
|
|
||||||
CSMTools::ReportModel *mModel;
|
CSMTools::ReportModel *mModel;
|
||||||
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
||||||
|
QAction *mShowAction;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void contextMenuEvent (QContextMenuEvent *event);
|
||||||
|
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -39,6 +44,8 @@ namespace CSVTools
|
||||||
|
|
||||||
void show (const QModelIndex& index);
|
void show (const QModelIndex& index);
|
||||||
|
|
||||||
|
void showSelection();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
|
|
Loading…
Reference in a new issue