summaryrefslogtreecommitdiffstats
path: root/qt-models/divelocationmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-08 19:01:45 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:25:32 -0700
commitf39596df0628c567f2ffd45cfa5fe809fbb7cf75 (patch)
treeb8ffa384adf6fb48e8238259edade9f64319e72d /qt-models/divelocationmodel.h
parentac02854a8aa98dcd6876c9249654ac9e1d949c92 (diff)
downloadsubsurface-f39596df0628c567f2ffd45cfa5fe809fbb7cf75.tar.gz
Map: remove access to displayed_dive_site in GPS-filter model
The location information shows a list of dive sites at the same location as the edited dive site. This was done by passing a function to an "SsrfSortFilterProxyModel". Unfortunately, the latter does only support function pointers without state and therefore had to access the global "displayed_dive_site" object. Replace the SsrfSortFilterProxyModel by a proper subclass of QSortFilterProxyModel that contains information on the position and id of the currently edited dive site. Update the filter model if the location of the dive site changes. This introduces a behavioral change: editing the GPS location will lead to an updated list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelocationmodel.h')
-rw-r--r--qt-models/divelocationmodel.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index 8dbc8f3e6..048b2c0a3 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -10,9 +10,6 @@
#define RECENTLY_ADDED_DIVESITE 1
-bool filter_same_gps_cb (QAbstractItemModel *m, int sourceRow, const QModelIndex& parent);
-
-
class LocationInformationModel : public QAbstractTableModel {
Q_OBJECT
public:
@@ -36,6 +33,19 @@ private:
QStringList locationNames;
};
+// To access only divesites at the given GPS coordinates with the exception of a given dive site
+class GPSLocationInformationModel : public QSortFilterProxyModel {
+Q_OBJECT
+private:
+ uint32_t ignoreUuid;
+ degrees_t latitude, longitude;
+ bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override;
+public:
+ GPSLocationInformationModel(QObject *parent = nullptr);
+ void set(uint32_t ignoreUuid, degrees_t latitude, degrees_t longitude);
+ void setCoordinates(degrees_t latitude, degrees_t longitude);
+};
+
class GeoReferencingOptionsModel : public QStringListModel {
Q_OBJECT
public: