summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-11-11 18:43:02 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-11 13:09:11 -0800
commitd5ffc16c362ce8f2f353f3c4880ecd689c9ea7ee (patch)
tree415c80adf8115a6a6b732e8e76bee326edb8a997 /qt-ui
parent819d358f8c790e4c1846ce4e5ba9b31291acf82a (diff)
downloadsubsurface-d5ffc16c362ce8f2f353f3c4880ecd689c9ea7ee.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/models.cpp41
-rw-r--r--qt-ui/models.h6
2 files changed, 42 insertions, 5 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 199a9c057..04611977f 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -2600,15 +2600,14 @@ MultiFilterSortModel *MultiFilterSortModel::instance()
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
{
- if (models.isEmpty()) {
+ if (justCleared || models.isEmpty())
return true;
- }
bool shouldShow = true;
Q_FOREACH (MultiFilterInterface *model, models) {
@@ -2616,7 +2615,6 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
shouldShow = false;
}
}
-
return shouldShow;
}
@@ -2627,7 +2625,6 @@ void MultiFilterSortModel::myInvalidate()
DiveListView *dlv = MainWindow::instance()->dive_list();
invalidate();
-
// first make sure the trips are no longer shown as selected
// (but without updating the selection state of the dives... this just cleans
// 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()));
}
+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),
rows(0)
{
diff --git a/qt-ui/models.h b/qt-ui/models.h
index 0d385babd..470cf5fbc 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -442,6 +442,7 @@ class MultiFilterInterface {
public:
MultiFilterInterface() : checkState(NULL){};
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const = 0;
+ virtual void clearFilter() = 0;
bool *checkState;
bool anyChecked;
};
@@ -454,6 +455,7 @@ public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
+ void clearFilter();
public
slots:
void repopulate();
@@ -470,6 +472,7 @@ public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
+ void clearFilter();
public
slots:
void repopulate();
@@ -486,6 +489,7 @@ public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual bool filterRow(int source_row, const QModelIndex &source_parent, QAbstractItemModel *sourceModel) const;
+ void clearFilter();
public
slots:
void repopulate();
@@ -504,8 +508,10 @@ public:
void removeFilterModel(MultiFilterInterface *model);
public slots:
void myInvalidate();
+ void clearFilter();
private:
MultiFilterSortModel(QObject *parent = 0);
QList<MultiFilterInterface*> models;
+ bool justCleared;
};
#endif // MODELS_H