summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-09-21 17:46:17 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-21 10:26:11 -0700
commite644fe5d97b4a6517232ab4d0b7962fc0e412b63 (patch)
tree515223428c31aab1be640296097be162b67d8a06
parentce134fb76344f9ca6e852be62892d5d50b9f08c9 (diff)
downloadsubsurface-e644fe5d97b4a6517232ab4d0b7962fc0e412b63.tar.gz
Fix image offset calculation
It seems this has never worked and nobody ever tested it. There was some confusion with time zones since Qt takes by default local time when converting from/to epoch while the exif library used UTC. For my single test dive, this works now. But this needs more testing!!! Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/simplewidgets.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 7e8bc40e4..baae7cced 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -300,16 +300,18 @@ void ShiftImageTimesDialog::syncCameraClicked()
ui.DCImage->setScene(scene);
dcImageEpoch = picture_get_timestamp(fileNames.at(0).toUtf8().data());
- dcDateTime.setTime_t(dcImageEpoch);
+ dcDateTime.setTime_t(dcImageEpoch - gettimezoneoffset(displayed_dive.when));
ui.dcTime->setDateTime(dcDateTime);
connect(ui.dcTime, SIGNAL(dateTimeChanged(const QDateTime &)), this, SLOT(dcDateTimeChanged(const QDateTime &)));
}
void ShiftImageTimesDialog::dcDateTimeChanged(const QDateTime &newDateTime)
{
+ QDateTime newtime(newDateTime);
if (!dcImageEpoch)
return;
- setOffset(newDateTime.toTime_t() - dcImageEpoch);
+ newtime.setTimeSpec(Qt::UTC);
+ setOffset(newtime.toTime_t() + gettimezoneoffset(displayed_dive.when) - dcImageEpoch);
}
void ShiftImageTimesDialog::matchAllImagesToggled(bool state)
@@ -355,7 +357,8 @@ void ShiftImageTimesDialog::updateInvalid()
bool allValid = true;
ui.warningLabel->hide();
ui.invalidLabel->hide();
- ui.invalidLabel->clear();
+ time.setTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
+ ui.invalidLabel->setText("Dive:" + time.toString() + "\n");
Q_FOREACH (const QString &fileName, fileNames) {
if (picture_check_valid(fileName.toUtf8().data(), m_amount))
@@ -364,7 +367,7 @@ void ShiftImageTimesDialog::updateInvalid()
// We've found invalid image
timestamp = picture_get_timestamp(fileName.toUtf8().data());
dcImageEpoch = timestamp;
- time.setTime_t(timestamp + m_amount);
+ time.setTime_t(timestamp + m_amount - gettimezoneoffset(displayed_dive.when));
ui.invalidLabel->setText(ui.invalidLabel->text() + fileName + " " + time.toString() + "\n");
allValid = false;
}