mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
da90c86d61
commit
a2f2751792
2 changed files with 16 additions and 2 deletions
|
@ -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 *>();
|
||||
|
|
|
@ -425,6 +425,7 @@ public:
|
|||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
bool *checkState;
|
||||
bool anyChecked;
|
||||
public
|
||||
slots:
|
||||
void repopulate();
|
||||
|
|
Loading…
Add table
Reference in a new issue