From cd5489e08d4c76b96ae0d388d9efea24134dde8d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 3 May 2019 23:37:42 +0200 Subject: Map: in dive-site-edit mode, select those maps we filter for When dive sites are edited, we shouldn't highlight the sites of the current dive, but the currently edited site(s). Signed-off-by: Berthold Stoeger --- qt-models/filtermodels.cpp | 5 +++++ qt-models/filtermodels.h | 1 + qt-models/maplocationmodel.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'qt-models') diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 663037383..bcadce613 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -278,6 +278,11 @@ void MultiFilterSortModel::stopFilterDiveSites() myInvalidate(); } +const QVector &MultiFilterSortModel::filteredDiveSites() const +{ + return dive_sites; +} + bool MultiFilterSortModel::diveSiteMode() const { return !dive_sites.isEmpty(); diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 7520fbe16..b91b91a04 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -64,6 +64,7 @@ public: int divesDisplayed; bool lessThan(const QModelIndex &, const QModelIndex &) const override; bool diveSiteMode() const; // returns true if we're filtering on dive site + const QVector &filteredDiveSites() const; public slots: void myInvalidate(); diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 1e0fd9c81..1fdedf807 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -136,8 +136,11 @@ void MapLocationModel::reload() #else // In dive site mode (that is when either editing a dive site or on // the dive site tab), we want to show all dive sites, not only those - // of the non-hidden dives. + // of the non-hidden dives. Moreover, the selected dive sites are those + // that we filter for. bool diveSiteMode = MultiFilterSortModel::instance()->diveSiteMode(); + if (diveSiteMode) + m_selectedDs = MultiFilterSortModel::instance()->filteredDiveSites(); #endif for_each_dive(idx, dive) { // Don't show dive sites of hidden dives, unless this is the currently @@ -147,7 +150,7 @@ void MapLocationModel::reload() struct dive_site *ds = get_dive_site_for_dive(dive); if (!dive_site_has_gps_location(ds)) continue; - if (dive->selected && !m_selectedDs.contains(ds)) + if (!diveSiteMode && dive->selected && !m_selectedDs.contains(ds)) m_selectedDs.append(ds); if (locations.contains(ds)) continue; -- cgit v1.2.3-70-g09d2