Enable removal of pictures from different dives at the same moment

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-12-11 21:40:06 +01:00 committed by Dirk Hohndel
parent 7bc77947f6
commit 82170579ad
3 changed files with 12 additions and 4 deletions

View file

@ -3838,9 +3838,10 @@ struct picture *clone_picture(struct picture *src)
return dst; return dst;
} }
void dive_remove_picture(char *filename) // Return true if picture was found and deleted
bool dive_remove_picture(struct dive *d, char *filename)
{ {
struct picture **picture = &current_dive->picture_list; struct picture **picture = &d->picture_list;
while (*picture && !same_string((*picture)->filename, filename)) while (*picture && !same_string((*picture)->filename, filename))
picture = &(*picture)->next; picture = &(*picture)->next;
if (*picture) { if (*picture) {
@ -3848,7 +3849,9 @@ void dive_remove_picture(char *filename)
picture_free(*picture); picture_free(*picture);
*picture = temp; *picture = temp;
invalidate_dive_cache(current_dive); invalidate_dive_cache(current_dive);
return true;
} }
return false;
} }
/* this always acts on the current divecomputer of the current dive */ /* this always acts on the current divecomputer of the current dive */

View file

@ -421,7 +421,7 @@ extern struct picture *clone_picture(struct picture *src);
extern bool dive_check_picture_time(struct dive *d, int shift_time, timestamp_t timestamp); extern bool dive_check_picture_time(struct dive *d, int shift_time, timestamp_t timestamp);
extern void dive_create_picture(struct dive *d, const char *filename, int shift_time, bool match_all); extern void dive_create_picture(struct dive *d, const char *filename, int shift_time, bool match_all);
extern void dive_add_picture(struct dive *d, struct picture *newpic); extern void dive_add_picture(struct dive *d, struct picture *newpic);
extern void dive_remove_picture(char *filename); extern bool dive_remove_picture(struct dive *d, char *filename);
extern unsigned int dive_get_picture_count(struct dive *d); extern unsigned int dive_get_picture_count(struct dive *d);
extern bool picture_check_valid(const char *filename, int shift_time); extern bool picture_check_valid(const char *filename, int shift_time);
extern void picture_load_exif_data(struct picture *p); extern void picture_load_exif_data(struct picture *p);

View file

@ -119,7 +119,12 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const
void DivePictureModel::removePicture(const QString &fileUrl, bool last) void DivePictureModel::removePicture(const QString &fileUrl, bool last)
{ {
dive_remove_picture(fileUrl.toUtf8().data()); int i;
struct dive *dive;
for_each_dive (i, dive) {
if (dive->selected && dive_remove_picture(dive, fileUrl.toUtf8().data()))
break;
}
if (last) { if (last) {
copy_dive(current_dive, &displayed_dive); copy_dive(current_dive, &displayed_dive);
updateDivePictures(); updateDivePictures();