mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 17:19:56 +00:00
Add Edit 'ID' action for nested tables
Conflicts: apps/opencs/view/world/nestedtable.cpp
This commit is contained in:
parent
561c3bd553
commit
09a95f276f
3 changed files with 40 additions and 8 deletions
|
@ -567,6 +567,11 @@ void CSVWorld::EditWidget::remake(int row)
|
||||||
|
|
||||||
tablesLayout->addWidget(label);
|
tablesLayout->addWidget(label);
|
||||||
tablesLayout->addWidget(table);
|
tablesLayout->addWidget(table);
|
||||||
|
|
||||||
|
connect(table,
|
||||||
|
SIGNAL(editRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||||
|
this,
|
||||||
|
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)));
|
||||||
}
|
}
|
||||||
else if (!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List))
|
else if (!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
#include "nestedtable.hpp"
|
#include "nestedtable.hpp"
|
||||||
#include "../../model/world/nestedtableproxymodel.hpp"
|
|
||||||
#include "../../model/world/universalid.hpp"
|
|
||||||
#include "../../model/world/commands.hpp"
|
|
||||||
#include "../../model/world/commanddispatcher.hpp"
|
|
||||||
#include "util.hpp"
|
|
||||||
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "../../model/world/nestedtableproxymodel.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
|
#include "tableeditidaction.hpp"
|
||||||
|
#include "util.hpp"
|
||||||
|
|
||||||
CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
||||||
CSMWorld::UniversalId id,
|
CSMWorld::UniversalId id,
|
||||||
CSMWorld::NestedTableProxyModel* model,
|
CSMWorld::NestedTableProxyModel* model,
|
||||||
QWidget* parent,
|
QWidget* parent,
|
||||||
bool editable)
|
bool editable)
|
||||||
: DragRecordTable(document, parent),
|
: DragRecordTable(document, parent),
|
||||||
mAddNewRowAction(0),
|
mEditIdAction(0),
|
||||||
mRemoveRowAction(0),
|
|
||||||
mModel(model)
|
mModel(model)
|
||||||
{
|
{
|
||||||
setSelectionBehavior (QAbstractItemView::SelectRows);
|
setSelectionBehavior (QAbstractItemView::SelectRows);
|
||||||
|
@ -61,6 +63,9 @@ CSVWorld::NestedTable::NestedTable(CSMDoc::Document& document,
|
||||||
|
|
||||||
connect(mRemoveRowAction, SIGNAL(triggered()),
|
connect(mRemoveRowAction, SIGNAL(triggered()),
|
||||||
this, SLOT(removeRowActionTriggered()));
|
this, SLOT(removeRowActionTriggered()));
|
||||||
|
|
||||||
|
mEditIdAction = new TableEditIdAction(*this, this);
|
||||||
|
connect(mEditIdAction, SIGNAL(triggered()), this, SLOT(editCell()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,13 +77,22 @@ std::vector<CSMWorld::UniversalId> CSVWorld::NestedTable::getDraggedRecords() co
|
||||||
|
|
||||||
void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
void CSVWorld::NestedTable::contextMenuEvent (QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
if (!mRemoveRowAction || !mAddNewRowAction)
|
if (!mEditIdAction)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
|
int currentRow = rowAt(event->y());
|
||||||
|
int currentColumn = columnAt(event->x());
|
||||||
|
if (mEditIdAction->isValidIdCell(currentRow, currentColumn))
|
||||||
|
{
|
||||||
|
mEditIdAction->setCell(currentRow, currentColumn);
|
||||||
|
menu.addAction(mEditIdAction);
|
||||||
|
menu.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
if (selectionModel()->selectedRows().size() == 1)
|
if (selectionModel()->selectedRows().size() == 1)
|
||||||
menu.addAction(mRemoveRowAction);
|
menu.addAction(mRemoveRowAction);
|
||||||
|
|
||||||
|
@ -102,3 +116,8 @@ void CSVWorld::NestedTable::addNewRowActionTriggered()
|
||||||
selectionModel()->selectedRows().size(),
|
selectionModel()->selectedRows().size(),
|
||||||
mModel->getParentColumn()));
|
mModel->getParentColumn()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::NestedTable::editCell()
|
||||||
|
{
|
||||||
|
emit editRequest(mEditIdAction->getCurrentId(), "");
|
||||||
|
}
|
||||||
|
|
|
@ -22,12 +22,15 @@ namespace CSMDoc
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
class TableEditIdAction;
|
||||||
|
|
||||||
class NestedTable : public DragRecordTable
|
class NestedTable : public DragRecordTable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QAction *mAddNewRowAction;
|
QAction *mAddNewRowAction;
|
||||||
QAction *mRemoveRowAction;
|
QAction *mRemoveRowAction;
|
||||||
|
TableEditIdAction *mEditIdAction;
|
||||||
CSMWorld::NestedTableProxyModel* mModel;
|
CSMWorld::NestedTableProxyModel* mModel;
|
||||||
CSMWorld::CommandDispatcher *mDispatcher;
|
CSMWorld::CommandDispatcher *mDispatcher;
|
||||||
|
|
||||||
|
@ -47,6 +50,11 @@ namespace CSVWorld
|
||||||
void removeRowActionTriggered();
|
void removeRowActionTriggered();
|
||||||
|
|
||||||
void addNewRowActionTriggered();
|
void addNewRowActionTriggered();
|
||||||
|
|
||||||
|
void editCell();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void editRequest(const CSMWorld::UniversalId &id, const std::string &hint);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue