diff options
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 22 | ||||
-rw-r--r-- | desktop-widgets/divelistview.h | 1 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 4 |
3 files changed, 4 insertions, 23 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 3e1ec6baa..403165759 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -263,9 +263,8 @@ void DiveListView::rowsInserted(const QModelIndex &parent, int start, int end) // Shouldn't the core-layer call us? void DiveListView::tripChanged(dive_trip *trip, TripField) { - // First check if the trip is already selected (and only - // this trip, as only then is it displayed). Is so, then do nothing. - if (singleSelectedTrip() == trip) + // First check if the trip is already selected (and only this trip, as only then is it displayed). + if (single_selected_trip() == trip) return; unselectDives(); @@ -297,23 +296,6 @@ void DiveListView::unselectDives() selectionModel()->clearSelection(); } -// This function returns a trip if there is one selected trip or NULL. -// Returning all selected trips turned out to be too slow. -dive_trip_t *DiveListView::singleSelectedTrip() -{ - dive_trip_t *res = nullptr; - for (const QModelIndex &index: selectionModel()->selectedRows()) { - if (index.parent().isValid()) - continue; - if (dive_trip_t *trip = index.data(DiveTripModelBase::TRIP_ROLE).value<dive_trip *>()) { - if (res) - return nullptr; // More than one - res = trip; - } - } - return res; -} - bool DiveListView::eventFilter(QObject *, QEvent *event) { if (event->type() != QEvent::KeyPress) diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 2e15b9064..f1a5eba8d 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -25,7 +25,6 @@ public: ~DiveListView(); void setSortOrder(int i, Qt::SortOrder order); // Call to set sort order void reload(); // Call to reload model data - dive_trip *singleSelectedTrip(); static QString lastUsedImageDir(); static void updateLastUsedImageDir(const QString &s); void loadImages(); 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(); |