Correctly edit dive date/time when editing manually entered dives

While the existing code worked fine for editing that start date or time of
dives downloaded from a dive computer or imported from some other source,
for manually entered dives this did not work and the date or time was
always reset to the original time once the changes were saved.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-10-20 17:25:13 -07:00
parent 4de44e6c9f
commit e1db94ea0c

View file

@ -973,22 +973,22 @@ void MainTab::on_dateEdit_dateChanged(const QDate &date)
{
if (editMode == IGNORE)
return;
markChangedWidget(ui.dateEdit);
QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
dateTime.setTimeSpec(Qt::UTC);
dateTime.setDate(date);
displayed_dive.when = dateTime.toTime_t();
markChangedWidget(ui.dateEdit);
DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
}
void MainTab::on_timeEdit_timeChanged(const QTime &time)
{
if (editMode == IGNORE)
return;
markChangedWidget(ui.timeEdit);
QDateTime dateTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
dateTime.setTimeSpec(Qt::UTC);
dateTime.setTime(time);
displayed_dive.when = dateTime.toTime_t();
markChangedWidget(ui.timeEdit);
DivePlannerPointsModel::instance()->getDiveplan().when = displayed_dive.when = dateTime.toTime_t();
}
// changing the tags on multiple dives is semantically strange - what's the right thing to do?