summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divelocationmodel.cpp14
-rw-r--r--qt-models/divelocationmodel.h2
2 files changed, 13 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();
+}
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index ca74ad791..914672725 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -62,11 +62,13 @@ class GPSLocationInformationModel : public QSortFilterProxyModel {
private:
const struct dive_site *ignoreDs;
location_t location;
+ int64_t distance;
bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override;
public:
GPSLocationInformationModel(QObject *parent = nullptr);
void set(const struct dive_site *ignoreDs, const location_t &);
void setCoordinates(const location_t &);
+ void setDistance(int64_t dist); // Distance from coordinates in mm
};
class GeoReferencingOptionsModel : public QStringListModel {