CuteLogger
Fast and simple logging solution for Qt based applications
actionsmodel.h
1/*
2 * Copyright (c) 2022 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef ACTIONSMODEL_H
19#define ACTIONSMODEL_H
20
21#include <QAbstractItemModel>
22
23class QAction;
24
25class ActionsModel : public QAbstractItemModel
26{
27 Q_OBJECT
28
29public:
30 enum Columns {
31
32 COLUMN_ACTION = 0,
33 COLUMN_SEQUENCE1,
34 COLUMN_SEQUENCE2,
35 COLUMN_COUNT
36 };
37 enum {
38 HardKeyRole = Qt::UserRole,
39 DefaultKeyRole,
40 };
41 explicit ActionsModel(QObject *parent = 0);
42 QAction *action(const QModelIndex &index) const;
43
44signals:
45 void editError(const QString &error);
46
47protected:
48 // Implement QAbstractItemModel
49 int rowCount(const QModelIndex &parent) const override;
50 int columnCount(const QModelIndex &parent) const override;
51 QVariant data(const QModelIndex &index, int role) const override;
52 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
53 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
54 QModelIndex index(int row, int column = 0,
55 const QModelIndex &parent = QModelIndex()) const override;
56 QModelIndex parent(const QModelIndex &index) const override;
57 Qt::ItemFlags flags(const QModelIndex &index) const override;
58 QHash<int, QByteArray> roleNames() const override;
59
60private:
61 QList<QAction *> m_actions;
62};
63
64#endif // ACTIONSMODEL_H