summaryrefslogtreecommitdiffstats
path: root/qt-models/divelocationmodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-25 22:18:32 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit8287d86d2b83fb5a343f2638391b1393a73cde72 (patch)
tree7adfc3dfa1a871c0e400d506f0706ec7c61ce631 /qt-models/divelocationmodel.cpp
parent22fe0c14e885161ae9a18a00b71283a77679d06c (diff)
downloadsubsurface-8287d86d2b83fb5a343f2638391b1393a73cde72.tar.gz
Dive site: add proximity field to dive site list
Merging dive sites is currently only possible if dive sites are at the exact same position. Introduce a field where the user can enter a distance up to which all dive sites should be listed. These can then be merged. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelocationmodel.cpp')
-rw-r--r--qt-models/divelocationmodel.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 538f27e16..3c03c27de 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -302,15 +302,17 @@ GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStrin
bool GPSLocationInformationModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const
{
struct dive_site *ds = sourceModel()->index(sourceRow, LocationInformationModel::DIVESITE, parent).data().value<dive_site *>();
- if (ds == ignoreDs || ds == RECENTLY_ADDED_DIVESITE)
+ if (!ds || ds == ignoreDs || ds == RECENTLY_ADDED_DIVESITE)
return false;
- return ds && same_location(&ds->location, &location);
+ return distance <= 0 ? same_location(&ds->location, &location)
+ : (int64_t)get_distance(&ds->location, &location) * 1000 <= distance; // We need 64 bit to represent distances in mm
}
GPSLocationInformationModel::GPSLocationInformationModel(QObject *parent) : QSortFilterProxyModel(parent),
ignoreDs(nullptr),
- location({{0},{0}})
+ location({{0},{0}}),
+ distance(0)
{
setSourceModel(LocationInformationModel::instance());
}
@@ -327,3 +329,9 @@ void GPSLocationInformationModel::setCoordinates(const location_t &locationIn)
location = locationIn;
invalidate();
}
+
+void GPSLocationInformationModel::setDistance(int64_t dist)
+{
+ distance = dist;
+ invalidate();
+}