mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
0935513636
commit
74f03e3537
4 changed files with 45 additions and 25 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue