diff options
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveSite.cpp')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp index 5b65015da..815627e2b 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.cpp +++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp @@ -21,6 +21,10 @@ TabDiveSite::TabDiveSite(QWidget *parent) : TabBase(parent) ui.diveSites->view()->setColumnHidden(i, true); connect(ui.diveSites, &TableView::addButtonClicked, this, &TabDiveSite::add); + + // Subtle: We depend on this slot being executed after the slot in the model. + // This is realized because the model was constructed as a member object and connects in the constructor. + connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &TabDiveSite::diveSiteChanged); } void TabDiveSite::updateData() @@ -53,3 +57,13 @@ void TabDiveSite::diveSiteAdded(struct dive_site *, int idx) ui.diveSites->view()->setCurrentIndex(localIdx); ui.diveSites->view()->edit(localIdx); } + +void TabDiveSite::diveSiteChanged(struct dive_site *ds, int field) +{ + int idx = get_divesite_idx(ds, &dive_site_table); + if (idx < 0) + return; + QModelIndex globalIdx = LocationInformationModel::instance()->index(idx, field); + QModelIndex localIdx = model.mapFromSource(globalIdx); + ui.diveSites->view()->scrollTo(localIdx); +} |