diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-10-22 14:00:53 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-23 22:45:30 +0100 |
commit | 6248ddf5296538fb7c3b092624c318ebf5f56027 (patch) | |
tree | 0eccd7ae999adbc7d591fbedf0f85786bb2170f7 /qt-models/divelistmodel.h | |
parent | 51e7603d7ee10328c66b5eb7ab75a3e50cf86912 (diff) | |
download | subsurface-6248ddf5296538fb7c3b092624c318ebf5f56027.tar.gz |
Mobile/filtering: roll our own filtering for performance reasons
The regular expression based generic filtering made things very slow on a cell
phone or other, slower device. With this the results seem more reasonable.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.h')
-rw-r--r-- | qt-models/divelistmodel.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index caf2616a7..dcfc573ee 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -12,6 +12,7 @@ class DiveListSortModel : public QSortFilterProxyModel Q_OBJECT public: DiveListSortModel(QObject *parent = 0); + void setSourceModel(QAbstractItemModel *sourceModel); Q_INVOKABLE void addAllDives(); Q_INVOKABLE void clear(); public slots: @@ -20,6 +21,12 @@ public slots: void setFilter(QString f); void resetFilter(); int shown(); +protected: + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; +private: + std::vector<unsigned char> filteredRows; // using unsigned char because using 'bool' turns this into a bitfield + QString filterString; + void updateFilterState(); }; class DiveListModel : public QAbstractListModel |