mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 18:15:37 +00:00
Rework Table (view) code to use a TableEditIdAction
This commit is contained in:
parent
6b34845168
commit
464e674a81
2 changed files with 14 additions and 33 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "recordstatusdelegate.hpp"
|
#include "recordstatusdelegate.hpp"
|
||||||
|
#include "tableeditidaction.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
||||||
|
@ -58,33 +59,13 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
|
||||||
|
|
||||||
/// \todo add menu items for select all and clear selection
|
/// \todo add menu items for select all and clear selection
|
||||||
|
|
||||||
|
int currentRow = rowAt(event->y());
|
||||||
|
int currentColumn = columnAt(event->x());
|
||||||
|
if (mEditIdAction->isValidIdCell(currentRow, currentColumn))
|
||||||
{
|
{
|
||||||
// Request UniversalId editing from table columns.
|
mEditIdAction->setCell(currentRow, currentColumn);
|
||||||
|
menu.addAction(mEditIdAction);
|
||||||
int currRow = rowAt( event->y() ),
|
menu.addSeparator();
|
||||||
currCol = columnAt( event->x() );
|
|
||||||
|
|
||||||
currRow = mProxyModel->mapToSource(mProxyModel->index( currRow, 0 )).row();
|
|
||||||
|
|
||||||
CSMWorld::ColumnBase::Display colDisplay =
|
|
||||||
static_cast<CSMWorld::ColumnBase::Display>(
|
|
||||||
mModel->headerData(
|
|
||||||
currCol,
|
|
||||||
Qt::Horizontal,
|
|
||||||
CSMWorld::ColumnBase::Role_Display ).toInt());
|
|
||||||
|
|
||||||
QString cellData = mModel->data(mModel->index( currRow, currCol )).toString();
|
|
||||||
CSMWorld::UniversalId::Type colType = CSMWorld::TableMimeData::convertEnums( colDisplay );
|
|
||||||
|
|
||||||
if ( !cellData.isEmpty()
|
|
||||||
&& colType != CSMWorld::UniversalId::Type_None )
|
|
||||||
{
|
|
||||||
mEditCellAction->setText(tr("Edit '").append(cellData).append("'"));
|
|
||||||
|
|
||||||
menu.addAction( mEditCellAction );
|
|
||||||
|
|
||||||
mEditCellId = CSMWorld::UniversalId( colType, cellData.toUtf8().constData() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mEditLock && !(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Constant))
|
if (!mEditLock && !(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Constant))
|
||||||
|
@ -363,10 +344,6 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
|
connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
|
||||||
addAction (mMoveDownAction);
|
addAction (mMoveDownAction);
|
||||||
|
|
||||||
mEditCellAction = new QAction( tr("Edit Cell"), this );
|
|
||||||
connect( mEditCellAction, SIGNAL(triggered()), this, SLOT(editCell()) );
|
|
||||||
addAction( mEditCellAction );
|
|
||||||
|
|
||||||
mViewAction = new QAction (tr ("View"), this);
|
mViewAction = new QAction (tr ("View"), this);
|
||||||
connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
|
connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
|
||||||
addAction (mViewAction);
|
addAction (mViewAction);
|
||||||
|
@ -387,6 +364,10 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert()));
|
connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert()));
|
||||||
addAction (mExtendedRevertAction);
|
addAction (mExtendedRevertAction);
|
||||||
|
|
||||||
|
mEditIdAction = new TableEditIdAction (*this, this);
|
||||||
|
connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell()));
|
||||||
|
addAction (mEditIdAction);
|
||||||
|
|
||||||
connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (tableSizeUpdate()));
|
this, SLOT (tableSizeUpdate()));
|
||||||
|
|
||||||
|
@ -522,7 +503,7 @@ void CSVWorld::Table::moveDownRecord()
|
||||||
|
|
||||||
void CSVWorld::Table::editCell()
|
void CSVWorld::Table::editCell()
|
||||||
{
|
{
|
||||||
emit editRequest( mEditCellId, std::string() );
|
emit editRequest(mEditIdAction->getCurrentId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::viewRecord()
|
void CSVWorld::Table::viewRecord()
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace CSMWorld
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class CommandDelegate;
|
class CommandDelegate;
|
||||||
|
class TableEditIdAction;
|
||||||
|
|
||||||
///< Table widget
|
///< Table widget
|
||||||
class Table : public DragRecordTable
|
class Table : public DragRecordTable
|
||||||
|
@ -57,15 +58,14 @@ namespace CSVWorld
|
||||||
QAction *mMoveUpAction;
|
QAction *mMoveUpAction;
|
||||||
QAction *mMoveDownAction;
|
QAction *mMoveDownAction;
|
||||||
QAction *mViewAction;
|
QAction *mViewAction;
|
||||||
QAction *mEditCellAction;
|
|
||||||
QAction *mPreviewAction;
|
QAction *mPreviewAction;
|
||||||
QAction *mExtendedDeleteAction;
|
QAction *mExtendedDeleteAction;
|
||||||
QAction *mExtendedRevertAction;
|
QAction *mExtendedRevertAction;
|
||||||
|
TableEditIdAction *mEditIdAction;
|
||||||
CSMWorld::IdTableProxyModel *mProxyModel;
|
CSMWorld::IdTableProxyModel *mProxyModel;
|
||||||
CSMWorld::IdTableBase *mModel;
|
CSMWorld::IdTableBase *mModel;
|
||||||
int mRecordStatusDisplay;
|
int mRecordStatusDisplay;
|
||||||
CSMWorld::CommandDispatcher *mDispatcher;
|
CSMWorld::CommandDispatcher *mDispatcher;
|
||||||
CSMWorld::UniversalId mEditCellId;
|
|
||||||
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
||||||
bool mJumpToAddedRecord;
|
bool mJumpToAddedRecord;
|
||||||
bool mUnselectAfterJump;
|
bool mUnselectAfterJump;
|
||||||
|
|
Loading…
Reference in a new issue