summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/filterwidget2.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-20 21:01:00 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-22 10:01:22 +1200
commitb28e0bf0b9bf9ae0613aec25440eff2e2a7e85c3 (patch)
treebd26af8d5394a2154f614229c318286c79b338df /desktop-widgets/filterwidget2.cpp
parente8b0d165a78e802c09edc7dd0ea4ae5bed1d46d6 (diff)
downloadsubsurface-b28e0bf0b9bf9ae0613aec25440eff2e2a7e85c3.tar.gz
Filter: support imperial units
1) Choose the correct conversion function for comparison. 2) Add a unit suffix to the fields. 3) Update the suffixes on change of preferences. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/filterwidget2.cpp')
-rw-r--r--desktop-widgets/filterwidget2.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index d6a8acad5..f1898ca38 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -1,5 +1,7 @@
#include "desktop-widgets/filterwidget2.h"
#include "desktop-widgets/simplewidgets.h"
+#include "core/qthelper.h"
+#include "core/settings/qPrefUnit.h"
#include <QDoubleSpinBox>
@@ -32,6 +34,9 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent)
ui.toDate->setDate(data.toDate.date());
ui.toTime->setTime(data.toTime);
+ // Initialize temperature fields to display correct unit.
+ temperatureChanged();
+
connect(ui.maxRating, &StarWidget::valueChanged,
this, &FilterWidget2::updateFilter);
@@ -80,6 +85,19 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent)
connect(ui.logged, SIGNAL(stateChanged(int)), this, SLOT(updateLogged(int)));
connect(ui.planned, SIGNAL(stateChanged(int)), this, SLOT(updatePlanned(int)));
+
+ // Update temperature fields if user changes temperature-units in preferences.
+ connect(qPrefUnits::instance(), &qPrefUnits::temperatureChanged, this, &FilterWidget2::temperatureChanged);
+ connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged, this, &FilterWidget2::temperatureChanged);
+}
+
+void FilterWidget2::temperatureChanged()
+{
+ QString temp = get_temp_unit();
+ ui.minAirTemp->setSuffix(temp);
+ ui.maxAirTemp->setSuffix(temp);
+ ui.minWaterTemp->setSuffix(temp);
+ ui.maxWaterTemp->setSuffix(temp);
}
void FilterWidget2::updateFilter()