diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-12-23 15:49:21 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-12-24 08:24:11 -0800 |
commit | 7451517e4a5e9aeffe31f1cd7346b07c0c9e15ac (patch) | |
tree | 328e5aa5c0bb922640a53a2cc54546f36dfa79ec /qt-models/filtermodels.cpp | |
parent | 668635e98eb32e3c5ffd3cb3e65da51c71db2975 (diff) | |
download | subsurface-7451517e4a5e9aeffe31f1cd7346b07c0c9e15ac.tar.gz |
Add select-all, deselect-all and invert-selection options to filters
To every filter list add a menu button that allows selection of all,
selection of none or inversion of selection.
Implements #435.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r-- | qt-models/filtermodels.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 26759571a..0dece6f8f 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -100,6 +100,21 @@ void FilterModelBase::clearFilter() emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0)); } +void FilterModelBase::selectAll() +{ + std::fill(checkState.begin(), checkState.end(), true); + anyChecked = true; + emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0)); +} + +void FilterModelBase::invertSelection() +{ + for (char &b: checkState) + b = !b; + anyChecked = std::any_of(checkState.begin(), checkState.end(), [](char b){return !!b;}); + emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0)); +} + SuitsFilterModel::SuitsFilterModel(QObject *parent) : FilterModelBase(parent) { } |