mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Filter: don't reload when dive sites are set to the same value
When switching between the dive-site-table to the dive-site-edit tabs, the filter would be set to a dive site. Usually, this would be the same dive site as before. Nevertheless, this caused a full map-reload. Detect if the dive-sites to be filtered are the same and turn this operation into a no-op. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
065423896d
commit
83926213ea
1 changed files with 13 additions and 3 deletions
|
@ -270,8 +270,13 @@ void MultiFilterSortModel::clearFilter()
|
|||
void MultiFilterSortModel::startFilterDiveSites(QVector<dive_site *> ds)
|
||||
{
|
||||
dive_sites = ds;
|
||||
++diveSiteRefCount;
|
||||
myInvalidate();
|
||||
if (++diveSiteRefCount > 1) {
|
||||
setFilterDiveSite(ds);
|
||||
} else {
|
||||
std::sort(ds.begin(), ds.end());
|
||||
dive_sites = ds;
|
||||
myInvalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::stopFilterDiveSites()
|
||||
|
@ -284,6 +289,11 @@ void MultiFilterSortModel::stopFilterDiveSites()
|
|||
|
||||
void MultiFilterSortModel::setFilterDiveSite(QVector<dive_site *> ds)
|
||||
{
|
||||
// If the filter didn't change, return early to avoid a full
|
||||
// map reload. For a well-defined comparison, sort the vector first.
|
||||
std::sort(ds.begin(), ds.end());
|
||||
if (ds == dive_sites)
|
||||
return;
|
||||
dive_sites = ds;
|
||||
myInvalidate();
|
||||
}
|
||||
|
@ -295,7 +305,7 @@ const QVector<dive_site *> &MultiFilterSortModel::filteredDiveSites() const
|
|||
|
||||
bool MultiFilterSortModel::diveSiteMode() const
|
||||
{
|
||||
return !dive_sites.isEmpty();
|
||||
return diveSiteRefCount > 0;
|
||||
}
|
||||
|
||||
bool MultiFilterSortModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const
|
||||
|
|
Loading…
Reference in a new issue