mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Map: highlight correct dive sites in dive site mode
Since changing the highlighting to use the selected dive, dive sites with no dive were never highlighted in dive site mode. Obviously, because there was no dive to be selected. Therefore special-case all dive-site selection code to recognize when we are in dive site mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
fc706a0d72
commit
093adf1ea8
2 changed files with 41 additions and 20 deletions
|
@ -461,16 +461,21 @@ void DiveListView::selectDives(const QList<int> &newDiveSelection)
|
||||||
// the actual reloading of the dive sites will be perfomed
|
// the actual reloading of the dive sites will be perfomed
|
||||||
// by the main-window in response to the divesSelected signal
|
// by the main-window in response to the divesSelected signal
|
||||||
// emitted below.
|
// emitted below.
|
||||||
QVector<dive_site *> selectedSites;
|
// But don't do this if we are in divesite mode, because then
|
||||||
for (int idx: newDiveSelection) {
|
// the dive-site selection is controlled by the filter not
|
||||||
dive *d = get_dive(idx);
|
// by the selected dives.
|
||||||
if (!d)
|
if (!MultiFilterSortModel::instance()->diveSiteMode()) {
|
||||||
continue;
|
QVector<dive_site *> selectedSites;
|
||||||
dive_site *ds = d->dive_site;
|
for (int idx: newDiveSelection) {
|
||||||
if (ds && !selectedSites.contains(ds))
|
dive *d = get_dive(idx);
|
||||||
selectedSites.append(ds);
|
if (!d)
|
||||||
|
continue;
|
||||||
|
dive_site *ds = d->dive_site;
|
||||||
|
if (ds && !selectedSites.contains(ds))
|
||||||
|
selectedSites.append(ds);
|
||||||
|
}
|
||||||
|
MapWidget::instance()->setSelected(selectedSites);
|
||||||
}
|
}
|
||||||
MapWidget::instance()->setSelected(selectedSites);
|
|
||||||
|
|
||||||
// now that everything is up to date, update the widgets
|
// now that everything is up to date, update the widgets
|
||||||
emit divesSelected();
|
emit divesSelected();
|
||||||
|
@ -691,14 +696,19 @@ void DiveListView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||||
// When receiving the divesSelected signal the main window will
|
// When receiving the divesSelected signal the main window will
|
||||||
// instruct the map to update the flags. Thus, make sure that
|
// instruct the map to update the flags. Thus, make sure that
|
||||||
// the selected maps are registered correctly.
|
// the selected maps are registered correctly.
|
||||||
QVector<dive_site *> selectedSites;
|
// But don't do this if we are in divesite mode, because then
|
||||||
for (QModelIndex index: selectionModel()->selection().indexes()) {
|
// the dive-site selection is controlled by the filter not
|
||||||
const QAbstractItemModel *model = index.model();
|
// by the selected dives.
|
||||||
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
if (!MultiFilterSortModel::instance()->diveSiteMode()) {
|
||||||
if (dive && dive->dive_site)
|
QVector<dive_site *> selectedSites;
|
||||||
selectedSites.push_back(dive->dive_site);
|
for (QModelIndex index: selectionModel()->selection().indexes()) {
|
||||||
|
const QAbstractItemModel *model = index.model();
|
||||||
|
struct dive *dive = model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>();
|
||||||
|
if (dive && dive->dive_site)
|
||||||
|
selectedSites.push_back(dive->dive_site);
|
||||||
|
}
|
||||||
|
MapWidget::instance()->setSelected(selectedSites);
|
||||||
}
|
}
|
||||||
MapWidget::instance()->setSelected(selectedSites);
|
|
||||||
emit divesSelected();
|
emit divesSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,7 @@ void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
|
||||||
|
|
||||||
bool MultiFilterSortModel::showDive(const struct dive *d) const
|
bool MultiFilterSortModel::showDive(const struct dive *d) const
|
||||||
{
|
{
|
||||||
// If dive_sites is not empty, we are in a special dive-site filtering mode.
|
if (diveSiteMode())
|
||||||
if (!dive_sites.isEmpty())
|
|
||||||
return dive_sites.contains(d->dive_site);
|
return dive_sites.contains(d->dive_site);
|
||||||
|
|
||||||
if (!filterData.validFilter)
|
if (!filterData.validFilter)
|
||||||
|
@ -267,13 +266,16 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
|
|
||||||
#if !defined(SUBSURFACE_MOBILE)
|
#if !defined(SUBSURFACE_MOBILE)
|
||||||
// The shown maps may have changed -> reload the map widget.
|
// The shown maps may have changed -> reload the map widget.
|
||||||
MapWidget::instance()->reload();
|
// But don't do this in dive site mode, because then we show all
|
||||||
|
// dive sites and only change the selected flag.
|
||||||
|
if (!diveSiteMode())
|
||||||
|
MapWidget::instance()->reload();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
emit filterFinished();
|
emit filterFinished();
|
||||||
|
|
||||||
#if !defined(SUBSURFACE_MOBILE)
|
#if !defined(SUBSURFACE_MOBILE)
|
||||||
if (!dive_sites.isEmpty())
|
if (diveSiteMode())
|
||||||
MainWindow::instance()->diveList->expandAll();
|
MainWindow::instance()->diveList->expandAll();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -303,6 +305,11 @@ void MultiFilterSortModel::startFilterDiveSites(QVector<dive_site *> ds)
|
||||||
} else {
|
} else {
|
||||||
std::sort(ds.begin(), ds.end());
|
std::sort(ds.begin(), ds.end());
|
||||||
dive_sites = ds;
|
dive_sites = ds;
|
||||||
|
#if !defined(SUBSURFACE_MOBILE)
|
||||||
|
// When switching into dive site mode, reload the dive sites.
|
||||||
|
// We won't do this in myInvalidate() once we are in dive site mode.
|
||||||
|
MapWidget::instance()->reload();
|
||||||
|
#endif
|
||||||
myInvalidate();
|
myInvalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,6 +330,10 @@ void MultiFilterSortModel::setFilterDiveSite(QVector<dive_site *> ds)
|
||||||
if (ds == dive_sites)
|
if (ds == dive_sites)
|
||||||
return;
|
return;
|
||||||
dive_sites = ds;
|
dive_sites = ds;
|
||||||
|
|
||||||
|
#if !defined(SUBSURFACE_MOBILE)
|
||||||
|
MapWidget::instance()->setSelected(dive_sites);
|
||||||
|
#endif
|
||||||
myInvalidate();
|
myInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue