aboutsummaryrefslogtreecommitdiff
path: root/include/completion/Completer.hpp
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 /include/completion/Completer.hpp
parent05ae8976a8e1ab5411058de244c4e2fcc87ec369 (diff)
downloadnull-browser-387cf24e389854ecc97f6236fdd6acbc2486dd52.tar.gz
null-browser-387cf24e389854ecc97f6236fdd6acbc2486dd52.zip
Replaced QCompleter with custom implementation
Diffstat (limited to 'include/completion/Completer.hpp')
-rw-r--r--include/completion/Completer.hpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/include/completion/Completer.hpp b/include/completion/Completer.hpp
index b67de61..9ad03d4 100644
--- a/include/completion/Completer.hpp
+++ b/include/completion/Completer.hpp
@@ -1,14 +1,39 @@
#pragma once
#include <QCompleter>
+#include <QSortFilterProxyModel>
#include <QWidget>
#include <QtCore>
+#include <QtWidgets/qtreeview.h>
+#include <cstdint>
-class Completer : public QCompleter {
+#include "completion/CompleterDelegate.hpp"
+#include "completion/FuzzySearchProxyModel.hpp"
+#include "utils.hpp"
+
+class Completer : public QWidget {
Q_OBJECT
public:
- Completer(QObject *parent = nullptr);
+ Completer();
+ void setSourceModel(QAbstractItemModel *model);
+
+ DELEGATE((&proxyModel), sourceModel, sourceModel)
+
+signals:
+ void accepted(QString text);
+
+public slots:
+ void onTextChange(QString text);
+ bool onKeyPressEvent(QKeyEvent *event);
+
+protected:
+ void keyPressEvent(QKeyEvent *event) override { onKeyPressEvent(event); }
+ void setHighlightedRow(uint32_t);
+ void acceptHighlighted();
- // bool eventFilter(QObject *watched, QEvent *event) override;
+private:
+ QTreeView *view;
+ FuzzySearchProxyModel proxyModel;
+ CompleterDelegate *viewDelegate;
};