aboutsummaryrefslogtreecommitdiff
path: root/src/completion/FuzzySearchProxyModel.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-15 19:17:03 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-15 20:08:30 +0530
commit387cf24e389854ecc97f6236fdd6acbc2486dd52 (patch)
treea51b51de0064fb10685d2da85d11748c4a32ce73 /src/completion/FuzzySearchProxyModel.cpp
parent05ae8976a8e1ab5411058de244c4e2fcc87ec369 (diff)
downloadnull-browser-387cf24e389854ecc97f6236fdd6acbc2486dd52.tar.gz
null-browser-387cf24e389854ecc97f6236fdd6acbc2486dd52.zip
Replaced QCompleter with custom implementation
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;
+}