diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-05-05 12:18:04 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-05-11 12:06:19 -0700 |
commit | 065423896dee0fe1cc6e2bd13e7e8d1b1cb3e181 (patch) | |
tree | 45b9664321b47bb2d4faae6d8fb233f6f6bd510a /desktop-widgets/tab-widgets | |
parent | cd5489e08d4c76b96ae0d388d9efea24134dde8d (diff) | |
download | subsurface-065423896dee0fe1cc6e2bd13e7e8d1b1cb3e181.tar.gz |
Filter: add reference counting for dive-site mode
The dive-site-edit and dive-site-table tabs both put the filter
into a special dive-site mode. When switching between both, it
could happen that the one got its show befor the other got
its hide event.
Thus, the first would start dive-site filtering and the second
stop it. Now the app was not in filter mode even though it should.
To solve this problem, add reference counting for the filter's
dive-site mode. In both tabs call the enter/exit functions
on show/hide. In the dive-site-table tab, when the selection
changes, use a set function that doesn't modify the reference count.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.cpp | 11 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveSite.h | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveSite.cpp b/desktop-widgets/tab-widgets/TabDiveSite.cpp index 113f8eafe..7deff3d9d 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.cpp +++ b/desktop-widgets/tab-widgets/TabDiveSite.cpp @@ -83,7 +83,7 @@ void TabDiveSite::on_filterText_textChanged(const QString &text) model.setFilter(text); } -void TabDiveSite::updateFilter() +QVector<dive_site *> TabDiveSite::selectedDiveSites() { const QModelIndexList indexes = ui.diveSites->view()->selectionModel()->selectedIndexes(); QVector<dive_site *> sites; @@ -92,7 +92,12 @@ void TabDiveSite::updateFilter() struct dive_site *ds = model.getDiveSite(idx); sites.append(ds); } - MultiFilterSortModel::instance()->startFilterDiveSites(sites); + return sites; +} + +void TabDiveSite::updateFilter() +{ + MultiFilterSortModel::instance()->setFilterDiveSite(selectedDiveSites()); } void TabDiveSite::selectionChanged(const QItemSelection &, const QItemSelection &) @@ -104,7 +109,7 @@ void TabDiveSite::showEvent(QShowEvent *) { // If the user switches to the dive site tab and there was already a selection, // filter on that selection. - updateFilter(); + MultiFilterSortModel::instance()->startFilterDiveSites(selectedDiveSites()); } void TabDiveSite::hideEvent(QHideEvent *) diff --git a/desktop-widgets/tab-widgets/TabDiveSite.h b/desktop-widgets/tab-widgets/TabDiveSite.h index 2f831f71c..ead94af5b 100644 --- a/desktop-widgets/tab-widgets/TabDiveSite.h +++ b/desktop-widgets/tab-widgets/TabDiveSite.h @@ -22,6 +22,7 @@ private slots: private: Ui::TabDiveSite ui; DiveSiteSortedModel model; + QVector<dive_site *> selectedDiveSites(); void updateFilter(); void hideEvent(QHideEvent *) override; void showEvent(QShowEvent *) override; |