diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-06-24 14:21:12 +0800 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-06-24 13:01:25 +0200 |
commit | d0df6a0073c8cc01cfd84489a37328d5df0ed18f (patch) | |
tree | 32ad5291f46c0ad97b858c00ebe437a6ce9b9299 | |
parent | e599d58531bc04f46fcc4957252e8848767191b9 (diff) | |
download | subsurface-d0df6a0073c8cc01cfd84489a37328d5df0ed18f.tar.gz |
Desktop: update dive list when dive sites change
Now when we change dive site location or name through a redo, the dive
list is updated as expected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | desktop-widgets/command_divesite.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/desktop-widgets/command_divesite.cpp b/desktop-widgets/command_divesite.cpp index 3ef4231f8..eb03ed4d5 100644 --- a/desktop-widgets/command_divesite.cpp +++ b/desktop-widgets/command_divesite.cpp @@ -186,6 +186,18 @@ static void swap(char *&c, QString &q) q = s; } +// Helper function: collect the dives that are at the given dive site +static QVector<dive *> getDivesForSite(struct dive_site *ds) +{ + QVector<dive *> diveSiteDives; + + for (int i = 0; i < ds->dives.nr; ++i) + diveSiteDives.push_back(ds->dives.dives[i]); + + return diveSiteDives; +} + + EditDiveSiteName::EditDiveSiteName(dive_site *dsIn, const QString &name) : ds(dsIn), value(name) { @@ -201,6 +213,7 @@ void EditDiveSiteName::redo() { swap(ds->name, value); emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::NAME); // Inform frontend of changed dive site. + emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // dive site name can be shown in the dive list } void EditDiveSiteName::undo() @@ -272,6 +285,8 @@ void EditDiveSiteCountry::redo() taxonomy_set_country(&ds->taxonomy, copy_qstring(value), taxonomy_origin::GEOMANUAL); value = old; emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::TAXONOMY); // Inform frontend of changed dive site. + emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // Country can be shown in the dive list + } void EditDiveSiteCountry::undo() @@ -299,6 +314,7 @@ void EditDiveSiteLocation::redo() { std::swap(value, ds->location); emit diveListNotifier.diveSiteChanged(ds, LocationInformationModel::LOCATION); // Inform frontend of changed dive site. + emit diveListNotifier.divesChanged(getDivesForSite(ds), DiveField::DIVESITE); // the globe icon in the dive list shows whether we have coordinates } void EditDiveSiteLocation::undo() |