aboutsummaryrefslogtreecommitdiff
path: root/include/completion/CommandsModel.hpp
blob: 4f64654161526b9eb3a5f55d492b8758deb8c714 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <QAbstractListModel>
#include <QWidget>
#include <QtCore>

struct Command {
  QString name;
  QString description;
};

// TODO: Combine commands model completion and commands evaluation
const QList<Command> commands = {
    {.name = "open", .description = "Update current URL"},
    {.name = "tabs", .description = "Select a tab"},
    {.name = "tabopen", .description = "Open a url in a new tab"},
    {.name = "tabnext", .description = "Go to next tab"},
    {.name = "tabprev", .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;
};