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);
105 removeEntry(m_data.
at(m_data.
count() - 1)->index());
107 m_pendingRemovals.
clear();
110 void insert(Type *
object)
114 const int modelIndex = m_data.
count();
116 Q_EMIT aboutToBeAdded(modelIndex);
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)
153 m_pendingRemovals.
insert(index);
155 const int modelIndex = m_data.
indexOf(m_hash.
value(index));
156 Q_EMIT aboutToBeRemoved(modelIndex);
158 auto object = m_hash.
take(index);
159 Q_EMIT removed(modelIndex,
object);
170typedef MapBase<Card, pa_card_info> CardMap;
171typedef MapBase<Client, pa_client_info> ClientMap;
172typedef MapBase<SinkInput, pa_sink_input_info> SinkInputMap;
173typedef MapBase<Sink, pa_sink_info> SinkMap;
174typedef MapBase<Source, pa_source_info> SourceMap;
175typedef MapBase<SourceOutput, pa_source_output_info> SourceOutputMap;
176typedef MapBase<StreamRestore, pa_ext_stream_restore_info> StreamRestoreMap;
177typedef MapBase<Module, pa_module_info> ModuleMap;
Maps a specific index to a specific object pointer.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
The primary namespace of PulseAudioQt.
bool contains(const Key &key) const const
bool isEmpty() const const
T value(const Key &key) const const
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
bool contains(const AT &value) const const
qsizetype count() const const
qsizetype indexOf(const AT &value, qsizetype from) const const
void removeAt(qsizetype i)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
iterator insert(const T &value)
bool remove(const T &value)