diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-07 21:53:50 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-08-08 09:03:33 -0700 |
commit | 344c85f4993176148e4fff718278d9692bcf39b7 (patch) | |
tree | e86b7d8a780c494508639e4e2ef583e3cc71e143 /desktop-widgets/tab-widgets/maintab.cpp | |
parent | 826387a4b0f177c5b645c2483ca4fb11c76e01dc (diff) | |
download | subsurface-344c85f4993176148e4fff718278d9692bcf39b7.tar.gz |
Desktop: display trip time on main-tab
On the main tab, the trip time was not shown when switching to
a trip. Implement showing of the trip date in a function, as the
undo-code will also have to update the trip date in certain
circumstances.
Fixes #2207
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/maintab.cpp')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index a6a3f541f..5d06bca4b 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -392,16 +392,27 @@ void MainTab::updateMode(struct dive *d) MainWindow::instance()->graphics->recalcCeiling(); } -void MainTab::updateDateTime(struct dive *d) +static QDateTime timestampToDateTime(timestamp_t when) { // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC - QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000*d->when, Qt::UTC); + QDateTime localTime = QDateTime::fromMSecsSinceEpoch(1000 * when, Qt::UTC); localTime.setTimeSpec(Qt::UTC); + return localTime; +} +void MainTab::updateDateTime(const struct dive *d) +{ + QDateTime localTime = timestampToDateTime(d->when); ui.dateEdit->setDate(localTime.date()); ui.timeEdit->setTime(localTime.time()); } +void MainTab::updateTripDate(const struct dive_trip *t) +{ + QDateTime localTime = timestampToDateTime(trip_date(t)); + ui.dateEdit->setDate(localTime.date()); +} + void MainTab::updateDiveSite(struct dive *d) { struct dive_site *ds = d->dive_site; @@ -487,6 +498,7 @@ void MainTab::updateDiveInfo() // rename the remaining fields and fill data from selected trip ui.LocationLabel->setText(tr("Trip location")); ui.diveTripLocation->setText(currentTrip->location); + updateTripDate(currentTrip); ui.locationTags->clear(); //TODO: Fix this. //ui.location->setText(currentTrip->location); |