KWin
Loading...
Searching...
No Matches
buttonsmodel.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6#pragma once
7
8#include <KDecoration2/DecorationButton>
9#include <QAbstractListModel>
10
11namespace KDecoration2
12{
13
14namespace Preview
15{
16class PreviewBridge;
17
18class ButtonsModel : public QAbstractListModel
19{
20 Q_OBJECT
21public:
22 explicit ButtonsModel(const QList<DecorationButtonType> &buttons, QObject *parent = nullptr);
23 explicit ButtonsModel(QObject *parent = nullptr);
24 ~ButtonsModel() override;
25 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
26 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
27 QHash<int, QByteArray> roleNames() const override;
28
29 QList<DecorationButtonType> buttons() const
30 {
31 return m_buttons;
32 }
33
34 Q_INVOKABLE void clear();
35 Q_INVOKABLE void remove(int index);
36 Q_INVOKABLE void up(int index);
37 Q_INVOKABLE void down(int index);
38 Q_INVOKABLE void move(int sourceIndex, int targetIndex);
39
40 void replace(const QList<DecorationButtonType> &buttons);
41 void add(DecorationButtonType type);
42 Q_INVOKABLE void add(int index, int type);
43
44private:
45 QList<DecorationButtonType> m_buttons;
46};
47
48}
49}
void replace(const QList< DecorationButtonType > &buttons)
ButtonsModel(const QList< DecorationButtonType > &buttons, QObject *parent=nullptr)
void add(DecorationButtonType type)
QHash< int, QByteArray > roleNames() const override
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Q_INVOKABLE void down(int index)
Q_INVOKABLE void move(int sourceIndex, int targetIndex)
QList< DecorationButtonType > buttons() const
Q_INVOKABLE void up(int index)
Q_INVOKABLE void remove(int index)
int rowCount(const QModelIndex &parent=QModelIndex()) const override