mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 04:45:32 +00:00
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 <QHeaderView>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
#include "../../model/tools/reportmodel.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)
|
||||
{
|
||||
if (event->buttons() & Qt::LeftButton)
|
||||
|
@ -31,6 +46,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
|||
|
||||
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&)));
|
||||
}
|
||||
|
||||
|
@ -57,4 +76,13 @@ void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStrin
|
|||
void CSVTools::ReportTable::show (const QModelIndex& index)
|
||||
{
|
||||
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"
|
||||
|
||||
class QAction;
|
||||
|
||||
namespace CSMTools
|
||||
{
|
||||
class ReportModel;
|
||||
|
@ -21,9 +23,12 @@ namespace CSVTools
|
|||
|
||||
CSMTools::ReportModel *mModel;
|
||||
CSVWorld::CommandDelegate *mIdTypeDelegate;
|
||||
QAction *mShowAction;
|
||||
|
||||
private:
|
||||
|
||||
void contextMenuEvent (QContextMenuEvent *event);
|
||||
|
||||
void mouseMoveEvent (QMouseEvent *event);
|
||||
|
||||
public:
|
||||
|
@ -39,6 +44,8 @@ namespace CSVTools
|
|||
|
||||
void show (const QModelIndex& index);
|
||||
|
||||
void showSelection();
|
||||
|
||||
signals:
|
||||
|
||||
void editRequest (const CSMWorld::UniversalId& id, const std::string& hint);
|
||||
|
|
Loading…
Reference in a new issue