mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Map: show all dive sites when in dive-site filter mode
When on the dive site tab or editing a dive site, we want to show all dive sites so that the user can related different dive sites. Therefore export a "in dive site mode" flag from the filter model and don't filter in that case in MapWidgetHelper. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
23cf85e89c
commit
3e05d61eb9
3 changed files with 19 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
||||||
#include "core/divesite.h"
|
#include "core/divesite.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "qt-models/maplocationmodel.h"
|
#include "qt-models/maplocationmodel.h"
|
||||||
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
#include "qt-models/filtermodels.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
|
#define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0
|
||||||
#define SMALL_CIRCLE_RADIUS_PX 26.0
|
#define SMALL_CIRCLE_RADIUS_PX 26.0
|
||||||
|
@ -114,10 +117,18 @@ void MapWidgetHelper::reloadMapLocations()
|
||||||
QVector<struct dive_site *> locations;
|
QVector<struct dive_site *> locations;
|
||||||
qreal latitude, longitude;
|
qreal latitude, longitude;
|
||||||
|
|
||||||
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
bool diveSiteMode = false;
|
||||||
|
#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.
|
||||||
|
bool diveSiteMode = MultiFilterSortModel::instance()->diveSiteMode();
|
||||||
|
#endif
|
||||||
for_each_dive(idx, dive) {
|
for_each_dive(idx, dive) {
|
||||||
// Don't show dive sites of hidden dives, unless this is the currently
|
// Don't show dive sites of hidden dives, unless this is the currently
|
||||||
// displayed (edited) dive.
|
// displayed (edited) dive or we're in dive site edit mode.
|
||||||
if (dive->hidden_by_filter && dive != current_dive)
|
if (!diveSiteMode && dive->hidden_by_filter && dive != current_dive)
|
||||||
continue;
|
continue;
|
||||||
struct dive_site *ds = get_dive_site_for_dive(dive);
|
struct dive_site *ds = get_dive_site_for_dive(dive);
|
||||||
if (!dive_site_has_gps_location(ds) || locations.contains(ds))
|
if (!dive_site_has_gps_location(ds) || locations.contains(ds))
|
||||||
|
|
|
@ -278,6 +278,11 @@ void MultiFilterSortModel::stopFilterDiveSites()
|
||||||
myInvalidate();
|
myInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MultiFilterSortModel::diveSiteMode() const
|
||||||
|
{
|
||||||
|
return !dive_sites.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
bool MultiFilterSortModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const
|
bool MultiFilterSortModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const
|
||||||
{
|
{
|
||||||
// Hand sorting down to the source model.
|
// Hand sorting down to the source model.
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
bool updateDive(struct dive *d); // returns true if visibility status changed
|
bool updateDive(struct dive *d); // returns true if visibility status changed
|
||||||
int divesDisplayed;
|
int divesDisplayed;
|
||||||
bool lessThan(const QModelIndex &, const QModelIndex &) const override;
|
bool lessThan(const QModelIndex &, const QModelIndex &) const override;
|
||||||
|
bool diveSiteMode() const; // returns true if we're filtering on dive site
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void myInvalidate();
|
void myInvalidate();
|
||||||
|
|
Loading…
Add table
Reference in a new issue