From 387cf24e389854ecc97f6236fdd6acbc2486dd52 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 15 Mar 2025 19:17:03 +0530 Subject: Replaced QCompleter with custom implementation --- src/completion/FuzzySearchProxyModel.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/completion/FuzzySearchProxyModel.cpp (limited to 'src/completion/FuzzySearchProxyModel.cpp') 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 +#include + +#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; +} -- cgit v1.3.1