PulseAudio Qt Bindings

models.h
1/*
2 SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
3 SPDX-FileCopyrightText: 2016 David Rosca <nowrep@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef PULSEAUDIO_H
9#define PULSEAUDIO_H
10
11#include <QAbstractListModel>
12
13#include "pulseaudioqt_export.h"
14
15namespace PulseAudioQt
16{
17class Context;
18class MapBaseQObject;
19class Sink;
20class Source;
21class AbstractModelPrivate;
22class SinkModelPrivate;
23
24class PULSEAUDIOQT_EXPORT AbstractModel : public QAbstractListModel
25{
26 Q_OBJECT
27public:
28 enum ItemRole {
29 PulseObjectRole = Qt::UserRole + 1
30 };
31
32 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
33
34 // Prevent leaf-classes from default constructing as we want to enforce
35 // them passing us a context or explicit nullptrs.
36 AbstractModel() = delete;
37 ~AbstractModel() override;
38 QHash<int, QByteArray> roleNames() const final override;
39 int rowCount(const QModelIndex &parent = QModelIndex()) const final override;
40 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
41 bool setData(const QModelIndex &index, const QVariant &value, int role) final override;
42
43 Q_INVOKABLE int role(const QByteArray &roleName) const;
44
45Q_SIGNALS:
46 void countChanged();
47
48protected:
49 AbstractModel(const MapBaseQObject *map, QObject *parent);
50 void initRoleNames(const QMetaObject &qobjectMetaObject);
51 Context *context() const;
52
53private Q_SLOTS:
54 void propertyChanged();
55
56private:
57 void onDataAdded(int index);
58 void onDataRemoved(int index);
59 QMetaMethod propertyChangedMetaMethod() const;
60
61 std::unique_ptr<class AbstractModelPrivate> d;
62};
63
64class PULSEAUDIOQT_EXPORT CardModel : public AbstractModel
65{
66 Q_OBJECT
67public:
68 CardModel(QObject *parent = nullptr);
69
70private:
71 void *d;
72};
73
74class PULSEAUDIOQT_EXPORT SinkModel : public AbstractModel
75{
76 Q_OBJECT
77public:
78 enum ItemRole {
79 SortByDefaultRole = PulseObjectRole + 1
80 };
81 Q_ENUM(ItemRole)
82
83 SinkModel(QObject *parent = nullptr);
84 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
85
86private:
87 void *d;
88};
89
90class PULSEAUDIOQT_EXPORT SinkInputModel : public AbstractModel
91{
92 Q_OBJECT
93public:
94 SinkInputModel(QObject *parent = nullptr);
95
96private:
97 void *d;
98};
99
100class PULSEAUDIOQT_EXPORT SourceModel : public AbstractModel
101{
102 Q_OBJECT
103public:
104 enum ItemRole {
105 SortByDefaultRole = PulseObjectRole + 1
106 };
107 Q_ENUM(ItemRole)
108
109 SourceModel(QObject *parent = nullptr);
110 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
111
112private:
113 void *d;
114};
115
116class PULSEAUDIOQT_EXPORT SourceOutputModel : public AbstractModel
117{
118 Q_OBJECT
119public:
120 SourceOutputModel(QObject *parent = nullptr);
121
122private:
123 void *d;
124};
125
126class PULSEAUDIOQT_EXPORT StreamRestoreModel : public AbstractModel
127{
128 Q_OBJECT
129public:
130 StreamRestoreModel(QObject *parent = nullptr);
131
132private:
133 void *d;
134};
135
136class PULSEAUDIOQT_EXPORT ModuleModel : public AbstractModel
137{
138 Q_OBJECT
139public:
140 ModuleModel(QObject *parent = nullptr);
141
142private:
143 void *d;
144};
145
146} // PulseAudioQt
147
148#endif // PULSEAUDIO_H
The primary namespace of PulseAudioQt.
Definition card.cpp:17
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.