15#include <pulse/ext-stream-restore.h>
16#include <pulse/pulseaudio.h>
22#include "sinkinput_p.h"
24#include "sourceoutput_p.h"
25#include "streamrestore_p.h"
49 virtual int count()
const = 0;
50 virtual QObject *objectAt(
int index)
const = 0;
51 virtual int indexOfObject(
QObject *
object)
const = 0;
53 void disconnectSignals()
55 disconnect(
this, &MapBaseQObject::aboutToBeAdded,
nullptr,
nullptr);
56 disconnect(
this, &MapBaseQObject::added,
nullptr,
nullptr);
57 disconnect(
this, &MapBaseQObject::aboutToBeRemoved,
nullptr,
nullptr);
58 disconnect(
this, &MapBaseQObject::removed,
nullptr,
nullptr);
62 void aboutToBeAdded(
int index);
63 void added(
int index,
QObject *
object);
64 void aboutToBeRemoved(
int index);
65 void removed(
int index,
QObject *
object);
74template<
typename Type,
typename PAInfo>
85 int count()
const override
87 return m_data.
count();
90 int indexOfObject(
QObject *
object)
const override
92 return m_data.
indexOf(
static_cast<Type *
>(
object));
95 QObject *objectAt(
int index)
const override
97 return m_data.
at(index);
103 removeEntry(m_data.
at(m_data.
count() - 1)->index());
105 m_pendingRemovals.
clear();
108 void insert(Type *
object)
112 const int modelIndex = m_data.
count();
114 Q_EMIT aboutToBeAdded(modelIndex);
116 m_hash[
object->index()] = object;
117 Q_EMIT added(modelIndex,
object);
127 if (m_pendingRemovals.
remove(info->index)) {
132 auto *obj = m_hash.
value(info->index);
135 obj->d->update(info);
138 obj->d->update(info);
142 void removeEntry(quint32 index)
145 m_pendingRemovals.
insert(index);
147 const int modelIndex = m_data.
indexOf(m_hash.
value(index));
148 Q_EMIT aboutToBeRemoved(modelIndex);
150 auto object = m_hash.
take(index);
151 Q_EMIT removed(modelIndex,
object);
162typedef MapBase<Card, pa_card_info> CardMap;
163typedef MapBase<Client, pa_client_info> ClientMap;
164typedef MapBase<SinkInput, pa_sink_input_info> SinkInputMap;
165typedef MapBase<Sink, pa_sink_info> SinkMap;
166typedef MapBase<Source, pa_source_info> SourceMap;
167typedef MapBase<SourceOutput, pa_source_output_info> SourceOutputMap;
168typedef MapBase<StreamRestore, pa_ext_stream_restore_info> StreamRestoreMap;
169typedef MapBase<Module, pa_module_info> ModuleMap;
Maps a specific index to a specific object pointer.
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)