1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 06:53:53 +00:00

replaced double click in table with a context menu item (edit) because double click was interfering with basic table functionality

This commit is contained in:
Marc Zinnschlag 2013-07-21 17:53:39 +02:00
parent 5dc1aceae1
commit 66534a45da
4 changed files with 29 additions and 8 deletions

View file

@ -26,6 +26,9 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
if (!mEditLock) if (!mEditLock)
{ {
if (selectedRows.size()==1)
menu.addAction (mEditAction);
if (mCreateAction) if (mCreateAction)
menu.addAction (mCreateAction); menu.addAction (mCreateAction);
@ -116,7 +119,9 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q
hideColumn (i); hideColumn (i);
} }
/// \todo make initial layout fill the whole width of the table mEditAction = new QAction (tr ("Edit Record"), this);
connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord()));
addAction (mEditAction);
if (createAndDelete) if (createAndDelete)
{ {
@ -205,6 +210,17 @@ void CSVWorld::Table::deleteRecord()
} }
} }
void CSVWorld::Table::editRecord()
{
if (!mEditLock)
{
QModelIndexList selectedRows = selectionModel()->selectedRows();
if (selectedRows.size()==1)
emit editRequest (selectedRows.begin()->row());
}
}
void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue) void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue)
{ {
int columns = mModel->columnCount(); int columns = mModel->columnCount();

View file

@ -28,6 +28,7 @@ namespace CSVWorld
std::vector<CommandDelegate *> mDelegates; std::vector<CommandDelegate *> mDelegates;
QUndoStack& mUndoStack; QUndoStack& mUndoStack;
QAction *mEditAction;
QAction *mCreateAction; QAction *mCreateAction;
QAction *mRevertAction; QAction *mRevertAction;
QAction *mDeleteAction; QAction *mDeleteAction;
@ -55,6 +56,10 @@ namespace CSVWorld
void updateEditorSetting (const QString &settingName, const QString &settingValue); void updateEditorSetting (const QString &settingName, const QString &settingValue);
signals:
void editRequest (int row);
private slots: private slots:
void createRecord(); void createRecord();
@ -62,6 +67,8 @@ namespace CSVWorld
void revertRecord(); void revertRecord();
void deleteRecord(); void deleteRecord();
void editRecord();
}; };
} }

View file

@ -11,7 +11,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
{ {
setWidget (mTable = new Table (id, document.getData(), document.getUndoStack(), createAndDelete)); setWidget (mTable = new Table (id, document.getData(), document.getUndoStack(), createAndDelete));
connect (mTable, SIGNAL (doubleClicked (const QModelIndex&)), this, SLOT (rowActivated (const QModelIndex&))); connect (mTable, SIGNAL (editRequest (int)), this, SLOT (editRequest (int)));
} }
void CSVWorld::TableSubView::setEditLock (bool locked) void CSVWorld::TableSubView::setEditLock (bool locked)
@ -19,14 +19,12 @@ void CSVWorld::TableSubView::setEditLock (bool locked)
mTable->setEditLock (locked); mTable->setEditLock (locked);
} }
void CSVWorld::TableSubView::rowActivated (const QModelIndex& index) void CSVWorld::TableSubView::editRequest (int row)
{ {
focusId (mTable->getUniversalId (index.row())); focusId (mTable->getUniversalId (row));
} }
void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue) void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
{ {
mTable->updateEditorSetting(settingName, settingValue);
if ( (settingName == "Record Status Display") || settingName == "Referenceable ID Type Display" )
mTable->updateEditorSetting(settingName, settingValue);
} }

View file

@ -28,7 +28,7 @@ namespace CSVWorld
private slots: private slots:
void rowActivated (const QModelIndex& index); void editRequest (int row);
}; };
} }