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 { PulseObjectRole = Qt::UserRole + 1 };
29
30 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
31
32 ~AbstractModel() override;
33 QHash<int, QByteArray> roleNames() const final override;
34 int rowCount(const QModelIndex &parent = QModelIndex()) const final override;
35 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
36 bool setData(const QModelIndex &index, const QVariant &value, int role) final override;
37
38 Q_INVOKABLE int role(const QByteArray &roleName) const;
39
40Q_SIGNALS:
41 void countChanged();
42
43protected:
44 AbstractModel(const MapBaseQObject *map, QObject *parent);
45 void initRoleNames(const QMetaObject &qobjectMetaObject);
46 Context *context() const;
47
48private Q_SLOTS:
49 void propertyChanged();
50
51private:
52 void onDataAdded(int index);
53 void onDataRemoved(int index);
54 QMetaMethod propertyChangedMetaMethod() const;
55
56 AbstractModelPrivate *d;
57
58 // Prevent leaf-classes from default constructing as we want to enforce
59 // them passing us a context or explicit nullptrs.
60 AbstractModel()
61 {
62 }
63};
64
65class PULSEAUDIOQT_EXPORT CardModel : public AbstractModel
66{
67 Q_OBJECT
68public:
69 CardModel(QObject *parent = nullptr);
70
71private:
72 void *d;
73};
74
75class PULSEAUDIOQT_EXPORT SinkModel : public AbstractModel
76{
77 Q_OBJECT
78public:
79 enum ItemRole { SortByDefaultRole = PulseObjectRole + 1 };
80 Q_ENUM(ItemRole)
81
82 SinkModel(QObject *parent = nullptr);
83 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
84
85private:
86 void *d;
87};
88
89class PULSEAUDIOQT_EXPORT SinkInputModel : public AbstractModel
90{
91 Q_OBJECT
92public:
93 SinkInputModel(QObject *parent = nullptr);
94
95private:
96 void *d;
97};
98
99class PULSEAUDIOQT_EXPORT SourceModel : public AbstractModel
100{
101 Q_OBJECT
102public:
103 enum ItemRole { SortByDefaultRole = PulseObjectRole + 1 };
104 Q_ENUM(ItemRole)
105
106 SourceModel(QObject *parent = nullptr);
107 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
108
109private:
110 void *d;
111};
112
113class PULSEAUDIOQT_EXPORT SourceOutputModel : public AbstractModel
114{
115 Q_OBJECT
116public:
117 SourceOutputModel(QObject *parent = nullptr);
118
119private:
120 void *d;
121};
122
123class PULSEAUDIOQT_EXPORT StreamRestoreModel : public AbstractModel
124{
125 Q_OBJECT
126public:
127 StreamRestoreModel(QObject *parent = nullptr);
128
129private:
130 void *d;
131};
132
133class PULSEAUDIOQT_EXPORT ModuleModel : public AbstractModel
134{
135 Q_OBJECT
136public:
137 ModuleModel(QObject *parent = nullptr);
138
139private:
140 void *d;
141};
142
143} // PulseAudioQt
144
145#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 Fri May 24 2024 11:54:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.