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;
54 void aboutToBeAdded(
int index);
55 void added(
int index,
QObject *
object);
56 void aboutToBeRemoved(
int index);
57 void removed(
int index,
QObject *
object);
66template<
typename Type,
typename PAInfo>
77 int count()
const override
79 return m_data.
count();
82 int indexOfObject(
QObject *
object)
const override
84 return m_data.
indexOf(
static_cast<Type *
>(
object));
87 QObject *objectAt(
int index)
const override
89 return m_data.
at(index);
95 removeEntry(m_data.
at(m_data.
count() - 1)->index());
97 m_pendingRemovals.
clear();
100 void insert(Type *
object)
104 const int modelIndex = m_data.
count();
106 Q_EMIT aboutToBeAdded(modelIndex);
108 m_hash[
object->index()] = object;
109 Q_EMIT added(modelIndex,
object);
119 if (m_pendingRemovals.
remove(info->index)) {
124 auto *obj = m_hash.
value(info->index);
127 obj->d->update(info);
130 obj->d->update(info);
134 void removeEntry(quint32 index)
137 m_pendingRemovals.
insert(index);
139 const int modelIndex = m_data.
indexOf(m_hash.
value(index));
140 Q_EMIT aboutToBeRemoved(modelIndex);
142 auto object = m_hash.
take(index);
143 Q_EMIT removed(modelIndex,
object);
154typedef MapBase<Card, pa_card_info> CardMap;
155typedef MapBase<Client, pa_client_info> ClientMap;
156typedef MapBase<SinkInput, pa_sink_input_info> SinkInputMap;
157typedef MapBase<Sink, pa_sink_info> SinkMap;
158typedef MapBase<Source, pa_source_info> SourceMap;
159typedef MapBase<SourceOutput, pa_source_output_info> SourceOutputMap;
160typedef MapBase<StreamRestore, pa_ext_stream_restore_info> StreamRestoreMap;
161typedef 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)
QObject * parent() const const
iterator insert(const T &value)
bool remove(const T &value)