File indexing completed on 2024-09-08 05:00:58
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 * SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "qqml.h" 0011 #include "quicksetting.h" 0012 #include "savedquicksettings.h" 0013 #include "savedquicksettingsmodel.h" 0014 0015 #include <QAbstractListModel> 0016 #include <QQmlListProperty> 0017 0018 class QuickSettingsModel : public QAbstractListModel, public QQmlParserStatus 0019 { 0020 Q_OBJECT 0021 Q_INTERFACES(QQmlParserStatus) 0022 QML_ELEMENT 0023 0024 Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 0025 0026 public: 0027 QuickSettingsModel(QObject *parent = nullptr); 0028 0029 QVariant data(const QModelIndex &index, int role) const override; 0030 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0031 QHash<int, QByteArray> roleNames() const override; 0032 0033 void classBegin() override; 0034 void componentComplete() override; 0035 0036 Q_SIGNALS: 0037 void countChanged(); 0038 0039 private: 0040 void loadQuickSettings(); 0041 void availabilityChanged(); 0042 0043 bool m_loaded = false; 0044 QList<QuickSetting *> m_quickSettings; 0045 SavedQuickSettings *m_savedQuickSettings; 0046 };