diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-25 22:18:32 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 8287d86d2b83fb5a343f2638391b1393a73cde72 (patch) | |
tree | 7adfc3dfa1a871c0e400d506f0706ec7c61ce631 /desktop-widgets/locationinformation.cpp | |
parent | 22fe0c14e885161ae9a18a00b71283a77679d06c (diff) | |
download | subsurface-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 'desktop-widgets/locationinformation.cpp')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 1a80486a3..e5e14fadb 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -11,6 +11,7 @@ #include "core/subsurface-qt/DiveListNotifier.h" #include "command.h" #include "core/taxonomy.h" +#include "core/settings/qPrefUnit.h" #include <QDebug> #include <QShowEvent> @@ -20,7 +21,7 @@ #include <QDesktopWidget> #include <QScrollBar> -LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), diveSite(nullptr) +LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), diveSite(nullptr), closeDistance(0) { ui.setupUi(this); ui.diveSiteMessage->setCloseButtonVisible(false); @@ -35,6 +36,8 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo ui.diveSiteCoordinates->installEventFilter(this); connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &LocationInformationWidget::diveSiteChanged); + connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged, this, &LocationInformationWidget::unitsChanged); + unitsChanged(); ui.diveSiteListView->setModel(&filter_model); ui.diveSiteListView->setModelColumn(LocationInformationModel::NAME); @@ -112,6 +115,17 @@ void LocationInformationWidget::updateLabels() ui.locationTags->setText(constructLocationTags(&diveSite->taxonomy, false)); } +void LocationInformationWidget::unitsChanged() +{ + if (prefs.units.length == units::METERS) { + ui.diveSiteDistanceUnits->setText("m"); + ui.diveSiteDistance->setText(QString::number(lrint(closeDistance / 1000.0))); + } else { + ui.diveSiteDistanceUnits->setText("ft"); + ui.diveSiteDistance->setText(QString::number(lrint(mm_to_feet(closeDistance)))); + } +} + void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field) { if (diveSite != ds) @@ -222,6 +236,16 @@ void LocationInformationWidget::on_diveSiteNotes_editingFinished() Command::editDiveSiteNotes(diveSite, ui.diveSiteNotes->toPlainText()); } +void LocationInformationWidget::on_diveSiteDistance_textChanged(const QString &s) +{ + bool ok; + uint64_t d = s.toLongLong(&ok); + if (!ok) + d = 0; + closeDistance = prefs.units.length == units::METERS ? d * 1000 : feet_to_mm(d); + filter_model.setDistance(closeDistance); +} + void LocationInformationWidget::reverseGeocode() { location_t location = parseGpsText(ui.diveSiteCoordinates->text()); |