From 4b57f6c82153ece3ce0e2f8ca90ef94dc49c5236 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 16 May 2015 08:05:12 +1000 Subject: [PATCH] Modifying an object instance (e.g. 3D edit) triggers the instances table to scroll to the corresponding record. Should resolve Feature #2554. --- apps/opencs/model/settings/usersettings.cpp | 5 +++++ apps/opencs/view/world/table.cpp | 25 ++++++++++++++++----- apps/opencs/view/world/table.hpp | 4 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 41ce593b7..fe9aa9d02 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -214,6 +214,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() "Jump to the added or cloned record."); jumpToAdded->setDefaultValue (defaultValue); jumpToAdded->setDeclaredValues (jumpValues); + + Setting *jumpToModified = createSetting (Type_CheckBox, "jump-to-modified", "Jump to modified Record"); + jumpToModified->setDefaultValue ("true"); + jumpToModified->setToolTip ("Whether to jump to the modified record. This setting effects the instances table only." + "\nCan be useful in finding the moved or modified object instance while 3D editing."); } declareSection ("search", "Search & Replace"); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 86daf8af7..c54f2e24b 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -370,10 +370,14 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int))); - /// \note This signal could instead be connected to a slot that filters out changes not affecting - /// the records status column (for permanence reasons) - connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), - this, SLOT (tableSizeUpdate())); + if (id == CSMWorld::UniversalId::Type_References) + connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), + this, SLOT (dataChangedEvent(const QModelIndex&, const QModelIndex&))); + else + /// \note This signal could instead be connected to a slot that filters out changes not affecting + /// the records status column (for permanence reasons) + connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), + this, SLOT (tableSizeUpdate())); connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); @@ -640,7 +644,7 @@ void CSVWorld::Table::tableSizeUpdate() case CSMWorld::RecordBase::State_BaseOnly: ++size; break; case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; - case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; + case CSMWorld::RecordBase::State_Deleted: ++deleted; ++modified; break; } } } @@ -743,6 +747,7 @@ std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, int end) { tableSizeUpdate(); + if(mJumpToAddedRecord) { selectRow(end); @@ -751,3 +756,13 @@ void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, in clearSelection(); } } + +void CSVWorld::Table::dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + tableSizeUpdate(); + + // this event is assumed to be infreqent, don't bother keeping a member variable + CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); + if (settings.setting("table-input/jump-to-modified", "true") == "true") + selectRow(bottomRight.row()); +} diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index becb21f65..f1d87d79a 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -142,7 +142,9 @@ namespace CSVWorld void updateUserSetting (const QString &name, const QStringList &list); - void rowsInsertedEvent(const QModelIndex& parent, int start, int end); + void rowsInsertedEvent(const QModelIndex &parent, int start, int end); + + void dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight); }; }