mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Clean Filters
Code to clean the filters. Maybe I'll also need to call this upon closing the dialog? Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
819d358f8c
commit
d5ffc16c36
2 changed files with 42 additions and 5 deletions
|
@ -2600,15 +2600,14 @@ MultiFilterSortModel *MultiFilterSortModel::instance()
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent)
|
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent), justCleared(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||||
{
|
{
|
||||||
if (models.isEmpty()) {
|
if (justCleared || models.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
bool shouldShow = true;
|
bool shouldShow = true;
|
||||||
Q_FOREACH (MultiFilterInterface *model, models) {
|
Q_FOREACH (MultiFilterInterface *model, models) {
|
||||||
|
@ -2616,7 +2615,6 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
|
||||||
shouldShow = false;
|
shouldShow = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return shouldShow;
|
return shouldShow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2627,7 +2625,6 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
DiveListView *dlv = MainWindow::instance()->dive_list();
|
DiveListView *dlv = MainWindow::instance()->dive_list();
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
// first make sure the trips are no longer shown as selected
|
// first make sure the trips are no longer shown as selected
|
||||||
// (but without updating the selection state of the dives... this just cleans
|
// (but without updating the selection state of the dives... this just cleans
|
||||||
// up an oddity in the filter handling)
|
// up an oddity in the filter handling)
|
||||||
|
@ -2664,6 +2661,40 @@ void MultiFilterSortModel::removeFilterModel(MultiFilterInterface *model)
|
||||||
disconnect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
|
disconnect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiFilterSortModel::clearFilter()
|
||||||
|
{
|
||||||
|
justCleared = true;
|
||||||
|
Q_FOREACH(MultiFilterInterface *iface, models){
|
||||||
|
iface->clearFilter();
|
||||||
|
}
|
||||||
|
justCleared = false;
|
||||||
|
myInvalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuddyFilterModel::clearFilter()
|
||||||
|
{
|
||||||
|
memset(checkState, false, rowCount());
|
||||||
|
checkState[rowCount() - 1] = false;
|
||||||
|
anyChecked = false;
|
||||||
|
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocationFilterModel::clearFilter()
|
||||||
|
{
|
||||||
|
memset(checkState, false, rowCount());
|
||||||
|
checkState[rowCount() - 1] = false;
|
||||||
|
anyChecked = false;
|
||||||
|
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TagFilterModel::clearFilter()
|
||||||
|
{
|
||||||
|
memset(checkState, false, rowCount());
|
||||||
|
checkState[rowCount() - 1] = false;
|
||||||
|
anyChecked = false;
|
||||||
|
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent),
|
ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent),
|
||||||
rows(0)
|
rows(0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -442,6 +442,7 @@ class MultiFilterInterface {
|
||||||
public:
|
public:
|
||||||
MultiFilterInterface() : checkState(NULL){};
|
MultiFilterInterface() : checkState(NULL){};
|
||||||
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const = 0;
|
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const = 0;
|
||||||
|
virtual void clearFilter() = 0;
|
||||||
bool *checkState;
|
bool *checkState;
|
||||||
bool anyChecked;
|
bool anyChecked;
|
||||||
};
|
};
|
||||||
|
@ -454,6 +455,7 @@ public:
|
||||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
||||||
|
void clearFilter();
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
@ -470,6 +472,7 @@ public:
|
||||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
||||||
|
void clearFilter();
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
@ -486,6 +489,7 @@ public:
|
||||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
|
||||||
|
void clearFilter();
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
@ -504,8 +508,10 @@ public:
|
||||||
void removeFilterModel(MultiFilterInterface *model);
|
void removeFilterModel(MultiFilterInterface *model);
|
||||||
public slots:
|
public slots:
|
||||||
void myInvalidate();
|
void myInvalidate();
|
||||||
|
void clearFilter();
|
||||||
private:
|
private:
|
||||||
MultiFilterSortModel(QObject *parent = 0);
|
MultiFilterSortModel(QObject *parent = 0);
|
||||||
QList<MultiFilterInterface*> models;
|
QList<MultiFilterInterface*> models;
|
||||||
|
bool justCleared;
|
||||||
};
|
};
|
||||||
#endif // MODELS_H
|
#endif // MODELS_H
|
||||||
|
|
Loading…
Reference in a new issue