aboutsummaryrefslogtreecommitdiff
path: root/src/completion/FuzzySearchProxyModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/completion/FuzzySearchProxyModel.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/completion/FuzzySearchProxyModel.cpp b/src/completion/FuzzySearchProxyModel.cpp
new file mode 100644
index 0000000..151f60e
--- /dev/null
+++ b/src/completion/FuzzySearchProxyModel.cpp
@@ -0,0 +1,24 @@
+#include <QWidget>
+#include <QtCore>
+
+#include "completion/FuzzySearchProxyModel.hpp"
+
+bool FuzzySearchProxyModel::filterAcceptsRow(
+ int sourceRow, const QModelIndex &sourceParent) const {
+ QAbstractItemModel *model = sourceModel();
+ QString filterText = filterRegularExpression().pattern();
+ qDebug() << "Searching: " << filterText;
+
+ for (int col = 0; col < model->columnCount(); ++col) {
+ QModelIndex index = model->index(sourceRow, col, sourceParent);
+ QString data = model->data(index, Qt::AccessibleDescriptionRole).toString();
+
+ qDebug() << " against: " << data;
+
+ // TODO: Fuzzy eet up
+ if (data.contains(filterText, Qt::CaseInsensitive)) {
+ return true;
+ }
+ }
+ return false;
+}