diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-09-20 16:41:42 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-09-21 08:30:32 -0700 |
commit | a8888eaf26c9355f3f2d20c24526489e17d3404a (patch) | |
tree | b45150112874e018d80dba76cac913faec22393d /qt-gui.cpp | |
parent | acd35995484ba8b0a4ee416b5dcceb76b843439e (diff) | |
download | subsurface-a8888eaf26c9355f3f2d20c24526489e17d3404a.tar.gz |
Allow editing of date & time and air & water temperatures
Add two more rows to the widget - this is getting quite busy.
There still is some weirdness where the focus isn't returned where it
should be and a few other details, but overall getting there.
Added helper functions to parse a temperature and to deal with the
timezone offset - with that latter one I also fixed the time offset bug in
the planner.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r-- | qt-gui.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index f76beed12..e35c22996 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -36,6 +36,8 @@ #include <QMap> #include <QMultiMap> #include <QNetworkProxy> +#include <QDateTime> +#include <QRegExp> const char *default_dive_computer_vendor; const char *default_dive_computer_product; @@ -379,4 +381,33 @@ void call_for_each_dc(FILE *f, void (*callback)(FILE *, const char *, uint32_t, } } +int gettimezoneoffset() +{ + QDateTime dt1 = QDateTime::currentDateTime(); + QDateTime dt2 = dt1.toUTC(); + dt1.setTimeSpec(Qt::UTC); + return dt2.secsTo(dt1); +} + +int parseTemperatureToMkelvin(const QString& text) +{ + int mkelvin; + QString numOnly = text; + numOnly.replace(",",".").remove(QRegExp("[^0-9.]")); + if (numOnly == "") + return 0; + double number = numOnly.toDouble(); + switch (prefs.units.temperature) { + case units::CELSIUS: + mkelvin = C_to_mkelvin(number); + break; + case units::FAHRENHEIT: + mkelvin = F_to_mkelvin(number); + break; + default: + mkelvin = 0; + } + return mkelvin; + +} #include "qt-gui.moc" |