aboutsummaryrefslogtreecommitdiff
path: root/include/completion/CommandsModel.hpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-10 22:04:24 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-10 22:13:15 +0530
commit971854bfefad4c644ac3d5f5d6003f24d551bf1d (patch)
tree0f5ee90fd5968d345b157d38964094837315edf0 /include/completion/CommandsModel.hpp
parentd400369084107104f51fe217d5781c8d7bd07ff9 (diff)
downloadnull-browser-971854bfefad4c644ac3d5f5d6003f24d551bf1d.tar.gz
null-browser-971854bfefad4c644ac3d5f5d6003f24d551bf1d.zip
Add completer + simplify command parsing + class generator
Diffstat (limited to 'include/completion/CommandsModel.hpp')
-rw-r--r--include/completion/CommandsModel.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/completion/CommandsModel.hpp b/include/completion/CommandsModel.hpp
new file mode 100644
index 0000000..6cb25f9
--- /dev/null
+++ b/include/completion/CommandsModel.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <QAbstractListModel>
+#include <QWidget>
+#include <QtCore>
+
+struct Command {
+ QString name;
+ QString description;
+};
+
+const QList<Command> commands = {
+ {.name = "open", .description = "Open a url in the current tab"},
+ {.name = "tabopen", .description = "Open a url in a new tab"},
+ {.name = "bnext", .description = "Go to next tab"},
+ {.name = "bprev", .description = "Go to previous tab"},
+};
+
+class CommandsModel : public QAbstractListModel {
+ Q_OBJECT
+
+public:
+ CommandsModel(QObject *parent = nullptr);
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index,
+ int role = Qt::DisplayRole) const override;
+
+private:
+ QList<Command> items;
+};