PulseAudio Qt Bindings
15#include <pulse/ext-stream-restore.h>
16#include <pulse/pulseaudio.h>
20#include "debug_object.h"
22#include "pulseobject_p.h"
24#include "sinkinput_p.h"
26#include "sourceoutput_p.h"
27#include "streamrestore_p.h"
51 virtual int count()
const = 0;
52 virtual QObject *objectAt(
int index)
const = 0;
53 virtual int indexOfObject(
QObject *
object)
const = 0;
55 void disconnectSignals()
57 disconnect(
this, &MapBaseQObject::aboutToBeAdded,
nullptr,
nullptr);
58 disconnect(
this, &MapBaseQObject::added,
nullptr,
nullptr);
59 disconnect(
this, &MapBaseQObject::aboutToBeRemoved,
nullptr,
nullptr);
60 disconnect(
this, &MapBaseQObject::removed,
nullptr,
nullptr);
64 void aboutToBeAdded(
int index);
65 void added(
int index,
QObject *
object);
66 void aboutToBeRemoved(
int index);
67 void removed(
int index,
QObject *
object);
76template<
typename Type,
typename PAInfo>
87 int count()
const override
89 return m_data.
count();
92 int indexOfObject(
QObject *
object)
const override
94 return m_data.indexOf(
static_cast<Type *
>(
object));
97 QObject *objectAt(
int index)
const override
99 return m_data.at(index);
104 while (!m_hash.isEmpty()) {
105 removeEntry(m_data.at(m_data.count() - 1)->index());
107 m_pendingRemovals.clear();
110 void insert(Type *
object)
112 Q_ASSERT(!m_data.contains(
object));
114 const int modelIndex = m_data.count();
116 Q_EMIT aboutToBeAdded(modelIndex);
117 m_data.append(
object);
118 m_hash[
object->index()] = object;
119 Q_EMIT added(modelIndex,
object);
129 if (m_pendingRemovals.remove(info->index)) {
134 auto *obj = m_hash.value(info->index);
138 obj->d->update(info);
142 obj->d->update(info);
145#if !defined(UNDER_TEST)
146 qCDebug(PAOBJECT).noquote() << type << qobject_cast<PulseObject *>(obj)->d.get();
150 void removeEntry(quint32 index)
152 if (!m_hash.contains(index)) {
153 m_pendingRemovals.insert(index);
155 const int modelIndex = m_data.indexOf(m_hash.value(index));
156 Q_EMIT aboutToBeRemoved(modelIndex);
157 m_data.removeAt(modelIndex);
158 auto object = m_hash.take(index);
159 Q_EMIT removed(modelIndex,
object);
Maps a specific index to a specific object pointer.
The primary namespace of PulseAudioQt.
qsizetype count() const const
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:40 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.