summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/filtermodels.cpp12
-rw-r--r--qt-models/filtermodels.h9
2 files changed, 20 insertions, 1 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index bcadce613..ce0d5ff42 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -105,7 +105,8 @@ MultiFilterSortModel *MultiFilterSortModel::instance()
}
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent),
- divesDisplayed(0)
+ divesDisplayed(0),
+ diveSiteRefCount(0)
{
setFilterKeyColumn(-1); // filter all columns
setFilterCaseSensitivity(Qt::CaseInsensitive);
@@ -269,15 +270,24 @@ void MultiFilterSortModel::clearFilter()
void MultiFilterSortModel::startFilterDiveSites(QVector<dive_site *> ds)
{
dive_sites = ds;
+ ++diveSiteRefCount;
myInvalidate();
}
void MultiFilterSortModel::stopFilterDiveSites()
{
+ if (--diveSiteRefCount > 0)
+ return;
dive_sites.clear();
myInvalidate();
}
+void MultiFilterSortModel::setFilterDiveSite(QVector<dive_site *> ds)
+{
+ dive_sites = ds;
+ myInvalidate();
+}
+
const QVector<dive_site *> &MultiFilterSortModel::filteredDiveSites() const
{
return dive_sites;
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index b91b91a04..b726c2d28 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -70,6 +70,7 @@ slots:
void myInvalidate();
void clearFilter();
void startFilterDiveSites(QVector<dive_site *> ds);
+ void setFilterDiveSite(QVector<dive_site *> ds);
void stopFilterDiveSites();
void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
void resetModel(DiveTripModelBase::Layout layout);
@@ -86,6 +87,14 @@ private:
QVector<dive_site *> dive_sites;
void countsChanged();
FilterData filterData;
+
+ // We use ref-counting for the dive site mode. The reason is that when switching
+ // between two tabs that both need dive site mode, the following course of
+ // events may happen:
+ // 1) The new tab appears -> enter dive site mode.
+ // 2) The old tab gets its hide() signal -> exit dive site mode.
+ // The filter is now not in dive site mode, even if it should
+ int diveSiteRefCount;
};
#endif