File indexing completed on 2024-05-19 05:29:58
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KCM_ENERGYINFO_BATTERYMODEL_H 0008 #define KCM_ENERGYINFO_BATTERYMODEL_H 0009 0010 #include <QAbstractListModel> 0011 #include <QList> 0012 0013 #include <Solid/Battery> 0014 #include <Solid/Device> 0015 0016 class BatteryModel : public QAbstractListModel 0017 { 0018 Q_OBJECT 0019 0020 Q_PROPERTY(int count READ rowCount NOTIFY countChanged) 0021 0022 public: 0023 explicit BatteryModel(QObject *parent); 0024 0025 enum Roles { 0026 BatteryRole = Qt::UserRole, 0027 UdiRole, 0028 VendorRole, 0029 ProductRole, 0030 }; 0031 Q_ENUM(Roles) 0032 0033 QVariant data(const QModelIndex &index, int role) const override; 0034 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0035 QHash<int, QByteArray> roleNames() const override; 0036 0037 Q_SIGNALS: 0038 void countChanged(); 0039 0040 private: 0041 QList<Solid::Device> m_batteries; 0042 }; 0043 0044 #endif // KCM_ENERGYINFO_BATTERYMODEL_H