From 989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 11 Apr 2020 17:41:56 +0200 Subject: media: use table instead of linked list for media For consistency with equipment, use our table macros for pictures. Generally tables (arrays) are preferred over linked lists, because they allow random access. This is mostly copy & paste of the equipment code. Sadly, our table macros are quite messy and need some revamping. Therefore, the resulting code is likewise somewhat messy. Signed-off-by: Berthold Stoeger --- qt-models/divepicturemodel.cpp | 4 +++- qt-models/divetripmodel.cpp | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 799c49c0e..306030c4e 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -116,8 +116,10 @@ static bool removePictureFromSelectedDive(const char *fileUrl) int i; struct dive *dive; for_each_dive (i, dive) { - if (dive->selected && dive_remove_picture(dive, fileUrl)) + if (dive->selected && remove_picture(&dive->pictures, fileUrl)) { + invalidate_dive_cache(dive); return true; + } } return false; } diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 0af987191..73402cdad 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -302,8 +302,7 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role) } break; case PHOTOS: - if (d->picture_list) - { + if (d->pictures.nr > 0) { IconMetrics im = defaultIconMetrics(); return QIcon(icon_names[countPhotos(d)]).pixmap(im.sz_small, im.sz_small); } // If there are photos, show one of the three photo icons: fish= photos during dive; -- cgit v1.2.3-70-g09d2