File indexing completed on 2024-11-10 04:56:47
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #pragma once 0007 0008 #include <KDecoration2/DecorationButton> 0009 #include <QAbstractListModel> 0010 0011 namespace KDecoration2 0012 { 0013 0014 namespace Preview 0015 { 0016 class PreviewBridge; 0017 0018 class ButtonsModel : public QAbstractListModel 0019 { 0020 Q_OBJECT 0021 public: 0022 explicit ButtonsModel(const QList<DecorationButtonType> &buttons, QObject *parent = nullptr); 0023 explicit ButtonsModel(QObject *parent = nullptr); 0024 ~ButtonsModel() override; 0025 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0026 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0027 QHash<int, QByteArray> roleNames() const override; 0028 0029 QList<DecorationButtonType> buttons() const 0030 { 0031 return m_buttons; 0032 } 0033 0034 Q_INVOKABLE void clear(); 0035 Q_INVOKABLE void remove(int index); 0036 Q_INVOKABLE void up(int index); 0037 Q_INVOKABLE void down(int index); 0038 Q_INVOKABLE void move(int sourceIndex, int targetIndex); 0039 0040 void replace(const QList<DecorationButtonType> &buttons); 0041 void add(DecorationButtonType type); 0042 Q_INVOKABLE void add(int index, int type); 0043 0044 private: 0045 QList<DecorationButtonType> m_buttons; 0046 }; 0047 0048 } 0049 }