diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-25 21:00:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-04-25 13:20:25 -0700 |
commit | b8e7a600d2d2a30f7e0646fc164ab6e57fd4782f (patch) | |
tree | 8c11dd9e57346e47499b1b2ee110de6eb3ea9029 /desktop-widgets | |
parent | 75ef8b68a1d5147ab15fd63b227bed0aa92940b1 (diff) | |
download | subsurface-b8e7a600d2d2a30f7e0646fc164ab6e57fd4782f.tar.gz |
cleanup: remove DiveListView::selectDives()
This was used by the map to select dives. However, the map now calls
the core function directly, so this can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 67 | ||||
-rw-r--r-- | desktop-widgets/divelistview.h | 2 |
2 files changed, 0 insertions, 69 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index b83ff169b..311fc5e6e 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -306,73 +306,6 @@ QList<dive_trip_t *> DiveListView::selectedTrips() return ret; } -void DiveListView::selectDive(int i) -{ - if (i == -1) - return; - QAbstractItemModel *m = model(); - QModelIndexList match = m->match(m->index(0, 0), DiveTripModelBase::DIVE_IDX, i, 2, Qt::MatchRecursive); - if (match.isEmpty()) - return; - QModelIndex idx = match.first(); - - selectionModel()->setCurrentIndex(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); - if (idx.parent().isValid()) { - setAnimated(false); - expand(idx.parent()); - setAnimated(true); - } -} - -void DiveListView::selectDives(const QList<int> &newDiveSelection) -{ - if (!newDiveSelection.count()) - return; - - // First, clear the old selection - unselectDives(); - - // select the dives, highest index first - this way the oldest of the dives - // becomes the selected_dive that we scroll to - QList<int> sortedSelection = newDiveSelection; - std::sort(sortedSelection.begin(), sortedSelection.end()); - - while (!sortedSelection.isEmpty()) - selectDive(sortedSelection.takeLast()); - - QAbstractItemModel *m = model(); - QModelIndexList idxList = m->match(m->index(0, 0), DiveTripModelBase::DIVE_IDX, get_divenr(current_dive), 2, Qt::MatchRecursive); - if (!idxList.isEmpty()) { - QModelIndex idx = idxList.first(); - if (idx.parent().isValid()) - scrollTo(idx.parent()); - scrollTo(idx); - } - - // update the selected-flag for the dive sites. - // the actual reloading of the dive sites will be perfomed - // by the main-window in response to the divesSelected signal - // emitted below. - // But don't do this if we are in divesite mode, because then - // the dive-site selection is controlled by the filter not - // by the selected dives. - if (!DiveFilter::instance()->diveSiteMode()) { - QVector<dive_site *> selectedSites; - for (int idx: newDiveSelection) { - dive *d = get_dive(idx); - if (!d) - continue; - dive_site *ds = d->dive_site; - if (ds && !selectedSites.contains(ds)) - selectedSites.append(ds); - } - MapWidget::instance()->setSelected(selectedSites); - } - - // now that everything is up to date, update the widgets - selectionChangeDone(); -} - bool DiveListView::eventFilter(QObject *, QEvent *event) { if (event->type() != QEvent::KeyPress) diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index ffaf6c78f..317be2b70 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -30,7 +30,6 @@ public: void reload(); // Call to reload model data bool eventFilter(QObject *, QEvent *); void unselectDives(); - void selectDives(const QList<int> &newDiveSelection); void contextMenuEvent(QContextMenuEvent *event); QList<dive_trip *> selectedTrips(); static QString lastUsedImageDir(); @@ -86,7 +85,6 @@ private: void addToTrip(int delta); void matchImagesToDives(QStringList fileNames); void loadImageFromURL(QUrl url); - void selectDive(int dive_table_idx); QNetworkAccessManager manager; }; |