diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-11 17:41:56 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-06 13:58:09 -0700 |
commit | 989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c (patch) | |
tree | 006daeb578ac4d3e68044ecfc36e7e12b1604ee8 /qt-models | |
parent | 282041e228d4a60ff7108fbfd1fc23caffd59ba4 (diff) | |
download | subsurface-989d6a3f96b818e5eacc5a2ccb1cc82e6dd8354c.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 4 | ||||
-rw-r--r-- | qt-models/divetripmodel.cpp | 3 |
2 files changed, 4 insertions, 3 deletions
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; |