From 3cdc2661d2a2417e557042abe1a0d9e5107822eb Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 11 Dec 2018 22:30:57 +0100 Subject: Dive media: add media to closest dive Currently, when selecting "Load media files even if time does not match the dive time", the media are added to *all* selected dives. Instead add it to the closest dive. This seems like the less surprising behavior. Of course now if the user really wants to add a media file to multiple dives, they will have to do it manually. To avoid a messy interface, this is solved by moving the iterate- over-selected-dives loop to the core. Thus, a helper-function can be made local to its translation unit. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 804bf9b9b..9a9330473 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -969,15 +969,8 @@ void DiveListView::matchImagesToDives(QStringList fileNames) return; updateLastImageTimeOffset(shiftDialog.amount()); - Q_FOREACH (const QString &fileName, fileNames) { - int j = 0; - struct dive *dive; - for_each_dive (j, dive) { - if (!dive->selected) - continue; - dive_create_picture(dive, qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll()); - } - } + for (const QString &fileName: fileNames) + create_picture(qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll()); mark_divelist_changed(true); copy_dive(current_dive, &displayed_dive); -- cgit v1.2.3-70-g09d2