File indexing completed on 2024-04-21 04:56:48

0001 /**
0002  * SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef REMOTESINKSMODEL_H
0008 #define REMOTESINKSMODEL_H
0009 
0010 #include <QAbstractListModel>
0011 
0012 #include "dbusinterfaces.h"
0013 
0014 struct Sink {
0015     QString name;
0016     QString description;
0017     int maxVolume;
0018     int volume;
0019     bool muted;
0020 };
0021 
0022 class KDECONNECTINTERFACES_EXPORT RemoteSinksModel : public QAbstractListModel
0023 {
0024     Q_OBJECT
0025     Q_PROPERTY(QString deviceId READ deviceId WRITE setDeviceId NOTIFY deviceIdChanged)
0026 
0027 public:
0028     enum ModelRoles { NameRole, DescriptionRole, MaxVolumeRole, VolumeRole, MutedRole };
0029 
0030     explicit RemoteSinksModel(QObject *parent = nullptr);
0031     ~RemoteSinksModel() override;
0032 
0033     QString deviceId() const;
0034     void setDeviceId(const QString &deviceId);
0035 
0036     QVariant data(const QModelIndex &index, int role) const override;
0037     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0038     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0039 
0040     QHash<int, QByteArray> roleNames() const override;
0041 
0042 private Q_SLOTS:
0043     void refreshSinkList();
0044 
0045 Q_SIGNALS:
0046     void deviceIdChanged(const QString &value);
0047     void rowsChanged();
0048 
0049 private:
0050     RemoteSystemVolumeDbusInterface *m_dbusInterface;
0051     QVector<Sink> m_sinkList;
0052     QString m_deviceId;
0053 };
0054 
0055 #endif // DEVICESMODEL_H