summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.c11
-rw-r--r--dive.h1
-rw-r--r--qt-ui/divelistview.cpp9
3 files changed, 13 insertions, 8 deletions
diff --git a/dive.c b/dive.c
index 065d45529..52a95ef80 100644
--- a/dive.c
+++ b/dive.c
@@ -2269,6 +2269,17 @@ struct picture *alloc_picture()
return pic;
}
+void dive_create_picture(struct dive *d, char *filename, int shift_time)
+{
+ struct picture *p = alloc_picture();
+ if (p->timestamp)
+ p->timestamp += shift_time;
+ p->filename = filename;
+ picture_load_exif_data(p);
+ dive_add_picture(d, p);
+ dive_set_geodata_from_picture(d, p);
+}
+
void dive_add_picture(struct dive *d, struct picture *picture)
{
if (d->picture_list == NULL) {
diff --git a/dive.h b/dive.h
index 737278181..cdef2cd40 100644
--- a/dive.h
+++ b/dive.h
@@ -297,6 +297,7 @@ struct picture {
extern struct picture *alloc_picture();
+extern void dive_create_picture(struct dive *d, char *filename, int shift_time);
extern void dive_add_picture(struct dive *d, struct picture *pic);
extern void dive_remove_picture(struct dive *d, struct picture *pic);
extern unsigned int dive_get_picture_count(struct dive *d);
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 57ad3f21f..78186ecd0 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -775,19 +775,12 @@ void DiveListView::loadImages()
updateLastImageTimeOffset(shiftDialog.amount());
Q_FOREACH(const QString& fileName, fileNames) {
- picture *p = alloc_picture();
- p->filename = qstrdup(fileName.toUtf8().data());
- picture_load_exif_data(p);
-
- if (p->timestamp)
- p->timestamp += shiftDialog.amount(); // TODO: this should be cached and passed to the C-function
int j = 0;
struct dive *dive;
for_each_dive (j, dive) {
if (!dive->selected)
continue;
- dive_add_picture(dive, p);
- dive_set_geodata_from_picture(dive, p);
+ dive_create_picture(dive, qstrdup(fileName.toUtf8().data()), shiftDialog.amount());
}
}