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 --- core/device.cpp | 7 ++----- core/qthelper.cpp | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'core') diff --git a/core/device.cpp b/core/device.cpp index d72f4d481..a5fa3bc2a 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -4,6 +4,7 @@ #include "subsurface-string.h" #include "device.h" #include "errorhelper.h" // for verbose flag +#include "selection.h" #include "core/settings/qPrefDiveComputer.h" /* @@ -305,12 +306,8 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char * for (const DiveComputerNode &node : values) { bool found = false; if (select_only) { - int j; - struct dive *d; - for_each_dive (j, d) { + for (dive *d: getDiveSelection()) { struct divecomputer *dc; - if (!d->selected) - continue; for_each_dc (d, dc) { if (dc->deviceid == node.deviceId) { found = true; diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 25c5fd7ce..7540045b3 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -19,6 +19,7 @@ #include "exif.h" #include "file.h" #include "picture.h" +#include "selection.h" #include "tag.h" #include "trip.h" #include "imagedownloader.h" @@ -387,12 +388,9 @@ static bool lessThan(const QPair &a, const QPair &b) QVector> selectedDivesGasUsed() { - int i, j; - struct dive *d; + int j; QMap gasUsed; - for_each_dive (i, d) { - if (!d->selected) - continue; + for (dive *d: getDiveSelection()) { volume_t *diveGases = get_gas_used(d); for (j = 0; j < d->cylinders.nr; j++) { if (diveGases[j].mliter) { -- cgit v1.2.3-70-g09d2