From 00abc04913d8aef45be4e30f23d5ebc9914c8d54 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 30 Sep 2020 00:01:24 +0200 Subject: 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 --- qt-models/divepicturemodel.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'qt-models') 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(); -- cgit v1.2.3-70-g09d2