Changeset View
Changeset View
Standalone View
Standalone View
interfaces/remotesinksmodel.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Nicolas Fella <nicolas.fella@gmx.de> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef REMOTESINKSMODEL_H | ||||
22 | #define REMOTESINKSMODEL_H | ||||
23 | | ||||
24 | #include <QAbstractListModel> | ||||
25 | | ||||
26 | #include "interfaces/dbusinterfaces.h" | ||||
27 | | ||||
28 | struct Sink { | ||||
29 | QString name; | ||||
30 | QString description; | ||||
31 | int maxVolume; | ||||
32 | int volume; | ||||
33 | bool muted; | ||||
34 | }; | ||||
35 | | ||||
36 | class KDECONNECTINTERFACES_EXPORT RemoteSinksModel | ||||
37 | : public QAbstractListModel | ||||
38 | { | ||||
39 | Q_OBJECT | ||||
40 | Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged) | ||||
41 | | ||||
42 | public: | ||||
43 | enum ModelRoles { | ||||
44 | NameRole, | ||||
45 | DescriptionRole, | ||||
46 | MaxVolumeRole, | ||||
47 | VolumeRole, | ||||
48 | MutedRole | ||||
49 | }; | ||||
50 | | ||||
51 | explicit RemoteSinksModel(QObject* parent = nullptr); | ||||
52 | ~RemoteSinksModel() override; | ||||
53 | | ||||
54 | QString deviceId() const; | ||||
55 | void setDeviceId(const QString& deviceId); | ||||
56 | | ||||
57 | QVariant data(const QModelIndex& index, int role) const override; | ||||
58 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; | ||||
59 | | ||||
60 | QHash<int, QByteArray> roleNames() const override; | ||||
61 | | ||||
62 | private Q_SLOTS: | ||||
63 | void refreshSinkList(); | ||||
64 | void clearSinks(); | ||||
65 | | ||||
66 | Q_SIGNALS: | ||||
67 | void deviceIdChanged(const QString& value); | ||||
68 | void rowsChanged(); | ||||
69 | | ||||
70 | private: | ||||
71 | RemoteSystemVolumeDbusInterface* m_dbusInterface; | ||||
72 | QVector<Sink*> m_sinkList; | ||||
73 | QString m_deviceId; | ||||
74 | }; | ||||
75 | | ||||
76 | #endif // DEVICESMODEL_H |