mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
826387a4b0
commit
344c85f499
3 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
- Desktop: fix display of trip time
|
||||
---
|
||||
* Always add new entries at the very top of this file above other existing entries and this note.
|
||||
* Use this layout for new entries: `[Area]: [Details about the change] [reference thread / issue]`
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -52,7 +52,8 @@ slots:
|
|||
void updateDiveInfo();
|
||||
void updateNotes(const struct dive *d);
|
||||
void updateMode(struct dive *d);
|
||||
void updateDateTime(struct dive *d);
|
||||
void updateDateTime(const struct dive *d);
|
||||
void updateTripDate(const struct dive_trip *t);
|
||||
void updateDiveSite(struct dive *d);
|
||||
void acceptChanges();
|
||||
void rejectChanges();
|
||||
|
|
Loading…
Add table
Reference in a new issue