diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-19 16:48:53 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-06 13:58:09 -0700 |
commit | 74f03e3537ee530000d4b11013bb12de91cb21dd (patch) | |
tree | d534e7ee2718318b9ae0bba9578ec84001a5dff9 /desktop-widgets/divelistview.cpp | |
parent | 093551363602e723864467af0812f13f4525855f (diff) | |
download | subsurface-74f03e3537ee530000d4b11013bb12de91cb21dd.tar.gz |
media: move addition of pictures out of create_picture()
If we want to make addition of pictures undoable, then create_picture()
must not add directly to the dive. Instead, return the dive to which the
picture should be added and let the caller perform the addition.
This means that the picture-test has to be adapted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelistview.cpp')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 403165759..fc7d34047 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -11,6 +11,7 @@ #include "desktop-widgets/divepicturewidget.h" #include "core/selection.h" #include "core/divefilter.h" +#include "core/divesite.h" // for dive_site_table. TODO: remove once adding pictures is undoified #include <unistd.h> #include <QSettings> #include <QKeyEvent> @@ -890,8 +891,16 @@ void DiveListView::matchImagesToDives(QStringList fileNames) return; updateLastImageTimeOffset(shiftDialog.amount()); - for (const QString &fileName: fileNames) - create_picture(qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll()); + for (const QString &fileName: fileNames) { + struct dive *d; + picture *pic = create_picture(qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll(), &d); + if (!pic) + continue; + add_picture(&d->pictures, *pic); + dive_set_geodata_from_picture(d, pic, &dive_site_table); + invalidate_dive_cache(d); + free(pic); + } mark_divelist_changed(true); copy_dive(current_dive, &displayed_dive); |