diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index d7d4dd5ca1..90ce42b345 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -26,6 +26,9 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) if (!mEditLock) { + if (selectedRows.size()==1) + menu.addAction (mEditAction); + if (mCreateAction) menu.addAction (mCreateAction); @@ -116,7 +119,9 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q 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) { @@ -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) { int columns = mModel->columnCount(); diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 348e800cfd..eedfeb8a1d 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -28,6 +28,7 @@ namespace CSVWorld std::vector mDelegates; QUndoStack& mUndoStack; + QAction *mEditAction; QAction *mCreateAction; QAction *mRevertAction; QAction *mDeleteAction; @@ -55,6 +56,10 @@ namespace CSVWorld void updateEditorSetting (const QString &settingName, const QString &settingValue); + signals: + + void editRequest (int row); + private slots: void createRecord(); @@ -62,6 +67,8 @@ namespace CSVWorld void revertRecord(); void deleteRecord(); + + void editRecord(); }; } diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index 8c86acf312..65cba4b02e 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -11,7 +11,7 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D { 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) @@ -19,14 +19,12 @@ void CSVWorld::TableSubView::setEditLock (bool 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) { - - if ( (settingName == "Record Status Display") || settingName == "Referenceable ID Type Display" ) - mTable->updateEditorSetting(settingName, settingValue); + mTable->updateEditorSetting(settingName, settingValue); } diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index 13db8255a7..ccee50dbc4 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -28,7 +28,7 @@ namespace CSVWorld private slots: - void rowActivated (const QModelIndex& index); + void editRequest (int row); }; }