summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-30 00:01:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-03 10:01:13 -0700
commit00abc04913d8aef45be4e30f23d5ebc9914c8d54 (patch)
tree1a9d51c8680a6edb9278191510278d6ac8a62def /qt-models
parent7b196a5ef90ee96435ea762c7045ef47a6811a28 (diff)
downloadsubsurface-00abc04913d8aef45be4e30f23d5ebc9914c8d54.tar.gz
cleanup: use getDiveSelection() to loop over selected dives
getDiveSelection() returns a vector of the selected dives. Use that instead of looping over the dive table and checking manually. This removes a few lines of code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divepicturemodel.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 7c9fb18c2..e73377d32 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -5,6 +5,7 @@
#include "core/imagedownloader.h"
#include "core/picture.h"
#include "core/qthelper.h"
+#include "core/selection.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "commands/command.h"
@@ -87,19 +88,15 @@ void DivePictureModel::updateDivePictures()
Thumbnailer::instance()->clearWorkQueue();
}
- int i;
- struct dive *dive;
- for_each_dive (i, dive) {
- if (dive->selected) {
- size_t first = pictures.size();
- FOR_EACH_PICTURE(dive)
- pictures.push_back(PictureEntry(dive, *picture));
-
- // Sort pictures of this dive by offset.
- // Thus, the list will be sorted by (dive, offset).
- std::sort(pictures.begin() + first, pictures.end(),
- [](const PictureEntry &a, const PictureEntry &b) { return a.offsetSeconds < b.offsetSeconds; });
- }
+ for (struct dive *dive: getDiveSelection()) {
+ size_t first = pictures.size();
+ FOR_EACH_PICTURE(dive)
+ pictures.push_back(PictureEntry(dive, *picture));
+
+ // Sort pictures of this dive by offset.
+ // Thus, the list will be sorted by (dive, offset).
+ std::sort(pictures.begin() + first, pictures.end(),
+ [](const PictureEntry &a, const PictureEntry &b) { return a.offsetSeconds < b.offsetSeconds; });
}
updateThumbnails();