mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
acd3599548
commit
a8888eaf26
6 changed files with 154 additions and 22 deletions
31
qt-gui.cpp
31
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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue