2022-03-17 03:20:36 +00:00
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "qqml.h"
|
|
|
|
|
#include "quicksetting.h"
|
|
|
|
|
|
|
|
|
|
#include <KPluginMetaData>
|
|
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
#include <QQmlListProperty>
|
|
|
|
|
|
2022-03-19 02:58:19 +00:00
|
|
|
/**
|
|
|
|
|
* @short A list model for serving quick settings metadata.
|
|
|
|
|
*
|
|
|
|
|
* @author Devin Lin <devin@kde.org>
|
|
|
|
|
**/
|
2022-03-21 14:00:03 +00:00
|
|
|
class SavedQuickSettingsModel : public QAbstractListModel
|
2022-03-17 03:20:36 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2023-11-02 11:08:17 +00:00
|
|
|
QML_ELEMENT
|
2022-03-17 03:20:36 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SavedQuickSettingsModel(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
|
|
enum {
|
2022-03-19 02:58:19 +00:00
|
|
|
NameRole, /**< The name of the quick setting. */
|
|
|
|
|
IdRole, /**< The plugin id of the quick setting package. */
|
|
|
|
|
IconRole, /**< The icon of the quick setting. */
|
2022-03-17 03:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
|
|
|
QHash<int, QByteArray> roleNames() const override;
|
|
|
|
|
|
|
|
|
|
Q_INVOKABLE void moveRow(int oldIndex, int newIndex);
|
2023-10-16 17:03:13 +00:00
|
|
|
Q_INVOKABLE void insertRow(KPluginMetaData metaData, int index);
|
|
|
|
|
Q_INVOKABLE KPluginMetaData takeRow(int index);
|
2022-03-17 03:20:36 +00:00
|
|
|
Q_INVOKABLE void removeRow(int index);
|
|
|
|
|
|
2023-10-16 17:03:13 +00:00
|
|
|
QList<KPluginMetaData> list() const;
|
2022-03-17 03:20:36 +00:00
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
2023-10-16 17:03:13 +00:00
|
|
|
void updateData(QList<KPluginMetaData> data);
|
2022-03-17 03:20:36 +00:00
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2023-10-16 17:03:13 +00:00
|
|
|
void dataUpdated(QList<KPluginMetaData> data);
|
2022-03-17 03:20:36 +00:00
|
|
|
|
|
|
|
|
private:
|
2023-10-16 17:03:13 +00:00
|
|
|
QList<KPluginMetaData> m_data;
|
2022-03-17 03:20:36 +00:00
|
|
|
};
|