mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:33:24 +00:00
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>
This commit is contained in:
parent
ce134fb763
commit
e644fe5d97
1 changed files with 7 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue