Changeset View
Changeset View
Standalone View
Standalone View
Modules/energy/batterymodel.h
Show All 32 Lines | 30 | { | |||
---|---|---|---|---|---|
33 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | 33 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | ||
34 | 34 | | |||
35 | public: | 35 | public: | ||
36 | explicit BatteryModel(QObject *parent); | 36 | explicit BatteryModel(QObject *parent); | ||
37 | virtual ~BatteryModel() = default; | 37 | virtual ~BatteryModel() = default; | ||
38 | 38 | | |||
39 | enum Roles { | 39 | enum Roles { | ||
40 | BatteryRole = Qt::UserRole, | 40 | BatteryRole = Qt::UserRole, | ||
41 | UdiRole | 41 | UdiRole, | ||
42 | VendorRole, | ||||
43 | ProductRole | ||||
42 | }; | 44 | }; | ||
43 | 45 | | |||
44 | Q_INVOKABLE Solid::Battery *get(int index) const; | 46 | Q_INVOKABLE Solid::Battery *get(int index) const; | ||
47 | Q_INVOKABLE QString vendor(int index) const; | ||||
48 | Q_INVOKABLE QString product(int index) const; | ||||
45 | Q_INVOKABLE QString udi(int index) const; | 49 | Q_INVOKABLE QString udi(int index) const; | ||
46 | 50 | | |||
47 | QVariant data(const QModelIndex &index, int role) const override; | 51 | QVariant data(const QModelIndex &index, int role) const override; | ||
48 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | 52 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||
49 | QHash<int, QByteArray> roleNames() const override; | 53 | QHash<int, QByteArray> roleNames() const override; | ||
50 | 54 | | |||
51 | signals: | 55 | signals: | ||
52 | void countChanged(); | 56 | void countChanged(); | ||
53 | 57 | | |||
54 | private: | 58 | private: | ||
55 | QList<Solid::Device> m_batteries; | 59 | QList<Solid::Device> m_batteries; | ||
56 | }; | 60 | }; | ||
57 | 61 | | |||
58 | #endif // KCM_ENERGYINFO_BATTERYMODEL_H | 62 | #endif // KCM_ENERGYINFO_BATTERYMODEL_H |