Changeset View
Changeset View
Standalone View
Standalone View
src/battery_p.h
- This file was copied from src/imports/declarativedevicesmodel.h.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * BluezQt - Asynchronous Bluez wrapper library | 2 | * BluezQt - Asynchronous Bluez wrapper library | ||
3 | * | 3 | * | ||
4 | * Copyright (C) 2014 David Rosca <nowrep@gmail.com> | 4 | * Copyright (C) 2019 Kai Uwe Broulik <kde@broulik.de> | ||
5 | * | 5 | * | ||
6 | * This library is free software; you can redistribute it and/or | 6 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | 7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | 8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) version 3, or any | 9 | * version 2.1 of the License, or (at your option) version 3, or any | ||
10 | * later version accepted by the membership of KDE e.V. (or its | 10 | * later version accepted by the membership of KDE e.V. (or its | ||
11 | * successor approved by the membership of KDE e.V.), which shall | 11 | * successor approved by the membership of KDE e.V.), which shall | ||
12 | * act as a proxy defined in Section 6 of version 3 of the license. | 12 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
13 | * | 13 | * | ||
14 | * This library is distributed in the hope that it will be useful, | 14 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | 17 | * Lesser General Public License for more details. | ||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | #ifndef DECLARATIVEDEVICESMODEL_H | 23 | #ifndef BLUEZQT_BATTERY_P_H | ||
24 | #define DECLARATIVEDEVICESMODEL_H | 24 | #define BLUEZQT_BATTERY_P_H | ||
25 | 25 | | |||
26 | #include <QSortFilterProxyModel> | 26 | #include <QObject> | ||
27 | 27 | | |||
28 | #include "devicesmodel.h" | 28 | #include "battery.h" | ||
29 | 29 | | |||
30 | class DeclarativeManager; | 30 | namespace BluezQt | ||
31 | { | ||||
31 | 32 | | |||
32 | class DeclarativeDevicesModel : public QSortFilterProxyModel | 33 | class BatteryPrivate : public QObject | ||
33 | { | 34 | { | ||
34 | Q_OBJECT | 35 | Q_OBJECT | ||
35 | Q_PROPERTY(DeclarativeManager* manager READ manager WRITE setManager) | | |||
36 | 36 | | |||
37 | public: | 37 | public: | ||
38 | enum DeclarativeDeviceRoles { | 38 | explicit BatteryPrivate(const QString &path, const QVariantMap &properties); | ||
39 | DeviceRole = BluezQt::DevicesModel::LastRole + 1, | | |||
40 | AdapterRole = BluezQt::DevicesModel::LastRole + 2, | | |||
41 | MediaPlayerRole = BluezQt::DevicesModel::LastRole + 3 | | |||
42 | }; | | |||
43 | | ||||
44 | explicit DeclarativeDevicesModel(QObject *parent = nullptr); | | |||
45 | 39 | | |||
46 | DeclarativeManager *manager() const; | 40 | void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated); | ||
47 | void setManager(DeclarativeManager *manager); | | |||
48 | 41 | | |||
49 | QHash<int, QByteArray> roleNames() const override; | 42 | QWeakPointer<Battery> q; | ||
50 | QVariant data(const QModelIndex &index, int role) const override; | | |||
51 | 43 | | |||
52 | private: | 44 | QString m_path; | ||
53 | DeclarativeManager *m_manager; | 45 | int m_percentage = 0; | ||
54 | BluezQt::DevicesModel *m_model; | | |||
55 | }; | 46 | }; | ||
56 | 47 | | |||
57 | #endif // DECLARATIVEMANAGER_H | 48 | } // namespace BluezQt | ||
58 | 49 | | |||
50 | #endif // BLUEZQT_BATTERY_P_H |