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>
This commit is contained in:
Berthold Stoeger 2020-04-25 21:00:41 +02:00 committed by Dirk Hohndel
parent 75ef8b68a1
commit b8e7a600d2
2 changed files with 0 additions and 69 deletions

View file

@ -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)

View file

@ -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;
};