Add images to all dive computers and refresh profile

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-05-05 12:10:41 +02:00 committed by Dirk Hohndel
parent 7e43a45293
commit 7bcb85dd54

View file

@ -845,6 +845,9 @@ void DiveListView::loadImages()
EXIFInfo exif; EXIFInfo exif;
int retval; int retval;
time_t imagetime; time_t imagetime;
struct divecomputer *dc;
time_t when;
int duration_s;
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Image Files"), lastUsedImageDir(), tr("Image Files (*.jpg *.jpeg *.pnm *.tif *.tiff)")); QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Image Files"), lastUsedImageDir(), tr("Image Files (*.jpg *.jpeg *.pnm *.tif *.tiff)"));
if (fileNames.isEmpty()) if (fileNames.isEmpty())
@ -874,26 +877,32 @@ void DiveListView::loadImages()
for_each_dive(j, dive) { for_each_dive(j, dive) {
if (!dive->selected) if (!dive->selected)
continue; continue;
// FIXME: this adds the events only to the first DC dc = &(dive->dc);
if (dive->when - 3600 < imagetime && dive->when + dive->duration.seconds + 3600 > imagetime) { while (dc) {
if (dive->when > imagetime) { when = dc->when ? dc->when : dive->when;
// Before dive duration_s = dc->duration.seconds ? dc->duration.seconds : dive->duration.seconds;
add_event(&(dive->dc), 0, 123, 0, 0, fileNames.at(i).toUtf8().data()); if (when - 3600 < imagetime && when + duration_s + 3600 > imagetime) {
} else if (dive->when + dive->duration.seconds < imagetime) { if (when > imagetime) {
// After dive // Before dive
add_event(&(dive->dc), dive->duration.seconds, 123, 0, 0, fileNames.at(i).toUtf8().data()); add_event(dc, 0, 123, 0, 0, fileNames.at(i).toUtf8().data());
} else { } else if (when + duration_s < imagetime) {
add_event(&(dive->dc), imagetime - dive->when, 123, 0, 0, fileNames.at(i).toUtf8().data()); // After dive
add_event(dc, duration_s, 123, 0, 0, fileNames.at(i).toUtf8().data());
} else {
add_event(dc, imagetime - when, 123, 0, 0, fileNames.at(i).toUtf8().data());
}
if (!dive->latitude.udeg && !IS_FP_SAME(exif.GeoLocation.Latitude, 0.0)) {
dive->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude);
dive->longitude.udeg = lrint(1000000.0 * exif.GeoLocation.Longitude);
}
mark_divelist_changed(true);
MainWindow::instance()->refreshDisplay();
MainWindow::instance()->graphics()->replot();
} }
if (!dive->latitude.udeg && !IS_FP_SAME(exif.GeoLocation.Latitude, 0.0)) { dc = dc->next;
dive->latitude.udeg = lrint(1000000.0 * exif.GeoLocation.Latitude);
dive->longitude.udeg = lrint(1000000.0 * exif.GeoLocation.Longitude);
}
mark_divelist_changed(true);
} }
} }
} }
MainWindow::instance()->refreshDisplay();
} }
void DiveListView::uploadToDivelogsDE() void DiveListView::uploadToDivelogsDE()