From 039e94b038e47e82feaa1cc1a09ed39d053405b9 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Sun, 26 Apr 2020 23:27:23 -0400 Subject: [PATCH] Implement helm-like filtering (still WIP) --- .../entitycollectionorderproxymodel.cpp | 39 +++++++++++++++++++ src/folder/entitycollectionorderproxymodel.h | 2 + 2 files changed, 41 insertions(+) diff --git a/src/folder/entitycollectionorderproxymodel.cpp b/src/folder/entitycollectionorderproxymodel.cpp index 0ce3bf3..f0c650b 100644 --- a/src/folder/entitycollectionorderproxymodel.cpp +++ b/src/folder/entitycollectionorderproxymodel.cpp @@ -141,6 +141,45 @@ bool EntityCollectionOrderProxyModel::lessThan(const QModelIndex &left, const QM } } +bool EntityCollectionOrderProxyModel::filterAcceptsRow(int source_row, const QModelIndex &parent) const +{ + + QStringList words = filterRegExp().pattern().split(' ',QString::SkipEmptyParts); + if (words.count()>1) { // helm style + bool accept = true; + + for (int i=0;(accept && imanualSortingActive == active) { diff --git a/src/folder/entitycollectionorderproxymodel.h b/src/folder/entitycollectionorderproxymodel.h index 1581c4d..e7f4d9e 100644 --- a/src/folder/entitycollectionorderproxymodel.h +++ b/src/folder/entitycollectionorderproxymodel.h @@ -36,6 +36,8 @@ public: Q_REQUIRED_RESULT bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; + bool filterAcceptsRow(int source_row, const QModelIndex &parent) const override; + void setManualSortingActive(bool active); Q_REQUIRED_RESULT bool isManualSortingActive() const;