From 769915f3fe75bcef8029e82fdfed7ae206182390 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 2 May 2020 18:14:44 +0200 Subject: selection: create global single_selected_trip() function The DiveListView had a singleSelectedTrip function that returns the selected trip if exactly one trip is selected. This could be very slow if numerous non-trip items were selected, because all the selection indices were back- translated by the proxy model. This could make selection changes very slow, because the MainTab used said function to determine whether it should show trip or dive data.. Indeed, with a 3500 dive test log, when selecting all dives in tree mode, the updating of the TabWidgets is sped up from 130 ms to 5 ms this commit. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/tab-widgets') diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 00f9d6ad4..7204cd7b0 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -365,7 +365,8 @@ void MainTab::updateDiveInfo() // 2) the filter is reset, potentially erasing the current trip under our feet. // TODO: Don't hard code tab location! bool onDiveSiteTab = ui.tabWidget->currentIndex() == 6; - if ((currentTrip = MainWindow::instance()->diveList->singleSelectedTrip()) != nullptr) { + currentTrip = single_selected_trip(); + if (currentTrip) { // Remember the tab selected for last dive but only if we're not on the dive site tab if (lastSelectedDive && !onDiveSiteTab) lastTabSelectedDive = ui.tabWidget->currentIndex(); @@ -412,7 +413,6 @@ void MainTab::updateDiveInfo() if (!lastSelectedDive && !onDiveSiteTab) ui.tabWidget->setCurrentIndex(lastTabSelectedDive); lastSelectedDive = true; - currentTrip = NULL; // make all the fields visible writeable ui.diveTripLocation->hide(); ui.location->show(); -- cgit v1.2.3-70-g09d2