diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-09-20 13:38:24 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-20 18:35:02 -0700 |
commit | a2f27517922f5422e62e57f6ce1279b7235ce2fc (patch) | |
tree | b3944623125ae453e4a054958215b09a7b07dc44 /qt-ui/models.cpp | |
parent | da90c86d61a235d2c56d522f09203694678608f1 (diff) | |
download | subsurface-a2f27517922f5422e62e57f6ce1279b7235ce2fc.tar.gz |
Show everything when nothing is checked.
This patch fixes a bit of the logic used. Now we show every
dive if nothing is chedked.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r-- | qt-ui/models.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 1d28373e1..2cdea6851 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -2171,14 +2171,22 @@ void TagFilterModel::repopulate() setStringList(list); delete[] checkState; checkState = new bool[list.count()]; - memset(checkState, true, list.count()); - checkState[list.count() - 1] = true; + memset(checkState, false, list.count()); + checkState[list.count() - 1] = false; + anyChecked = false; } bool TagFilterModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role == Qt::CheckStateRole) { checkState[index.row()] = value.toBool(); + anyChecked = false; + for (int i = 0; i < rowCount(); i++) { + if (checkState[i] == true) { + anyChecked = true; + break; + } + } dataChanged(index, index); return true; } @@ -2192,6 +2200,11 @@ TagFilterSortModel::TagFilterSortModel(QObject *parent) : QSortFilterProxyModel( bool TagFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { + // If there's nothing checked, this should show everythin. + if (!TagFilterModel::instance()->anyChecked) { + return true; + } + QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent); QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE); struct dive *d = (struct dive *)diveVariant.value<void *>(); |