1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 11:23:51 +00:00

Feature #1226: Request UniversalId editing from table column

This commit is contained in:
Stanislav 2014-09-15 23:15:32 +06:00
parent 71c868aa94
commit 8574d2330c
2 changed files with 50 additions and 0 deletions

View file

@ -54,6 +54,42 @@ 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
{
// Feature #1226 "Request UniversalId editing from table columns".
if ( mGotoRefUid )
{
delete mGotoRefUid;
mGotoRefUid = 0;
}
int currRow = rowAt( event->y() ),
currCol = columnAt( event->x() );
currRow = mProxyModel->mapToSource(mProxyModel->index( currRow, 0 )).row();
CSMWorld::ColumnBase::Display colType =
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 colUidType = CSMWorld::TableMimeData::convertEnums( colType );
if ( !cellData.isEmpty()
&& colUidType != CSMWorld::UniversalId::Type::Type_None )
{
menu.addAction( mGotoRefAction );
menu.addSeparator();
mGotoRefUid =
new CSMWorld::UniversalId( colUidType, cellData.toUtf8().constData() );
}
}
if (!mEditLock && !(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Constant)) if (!mEditLock && !(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_Constant))
{ {
if (selectedRows.size()==1) if (selectedRows.size()==1)
@ -219,6 +255,10 @@ 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);
mGotoRefAction = new QAction( tr("Go to Reference"), this );
connect( mGotoRefAction, SIGNAL(triggered()), this, SLOT(gotoReference()) );
addAction( mGotoRefAction );
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);
@ -364,6 +404,11 @@ void CSVWorld::Table::moveDownRecord()
} }
} }
void CSVWorld::Table::gotoReference()
{
emit editRequest( *mGotoRefUid, std::string() );
}
void CSVWorld::Table::viewRecord() void CSVWorld::Table::viewRecord()
{ {
QModelIndexList selectedRows = selectionModel()->selectedRows(); QModelIndexList selectedRows = selectionModel()->selectedRows();

View file

@ -45,6 +45,7 @@ namespace CSVWorld
QAction *mMoveUpAction; QAction *mMoveUpAction;
QAction *mMoveDownAction; QAction *mMoveDownAction;
QAction *mViewAction; QAction *mViewAction;
QAction *mGotoRefAction;
QAction *mPreviewAction; QAction *mPreviewAction;
QAction *mExtendedDeleteAction; QAction *mExtendedDeleteAction;
QAction *mExtendedRevertAction; QAction *mExtendedRevertAction;
@ -53,6 +54,8 @@ namespace CSVWorld
int mRecordStatusDisplay; int mRecordStatusDisplay;
CSMWorld::CommandDispatcher *mDispatcher; CSMWorld::CommandDispatcher *mDispatcher;
CSMWorld::UniversalId *mGotoRefUid = 0;
private: private:
void contextMenuEvent (QContextMenuEvent *event); void contextMenuEvent (QContextMenuEvent *event);
@ -93,6 +96,8 @@ namespace CSVWorld
private slots: private slots:
void gotoReference();
void editRecord(); void editRecord();
void cloneRecord(); void cloneRecord();