19 : IndexedPulseObject(parent)
20 , d(
new CardPrivate(
this))
22 connect(Context::instance(), &Context::sinkAdded,
this, &Card::sinksChanged);
23 connect(Context::instance(), &Context::sinkRemoved,
this, &Card::sinksChanged);
25 connect(Context::instance(), &Context::sourceAdded,
this, &Card::sourcesChanged);
26 connect(Context::instance(), &Context::sourceRemoved,
this, &Card::sourcesChanged);
33CardPrivate::CardPrivate(Card *q)
38CardPrivate::~CardPrivate()
42void CardPrivate::update(
const pa_card_info *info)
44 q->IndexedPulseObject::d->updatePulseObject(info);
45 q->PulseObject::d->updateProperties(info);
50 for (
const Profile *profile : std::as_const(m_profiles)) {
51 existingProfiles << profile->name();
54 for (
auto **it = info->profiles2; it && *it !=
nullptr; ++it) {
58 if (existingProfiles.
contains(name)) {
59 profile = m_profiles[existingProfiles.
indexOf(name)];
62 m_profiles << profile;
64 profile->d->setInfo(*it);
71 if (!newProfiles.
contains(profile->name())) {
77 for (
Profile *profile : std::as_const(m_profiles)) {
79 m_activeProfileIndex = m_profiles.indexOf(profile);
83 Q_EMIT q->profilesChanged();
84 Q_EMIT q->activeProfileIndexChanged();
89 for (
const Port *port : std::as_const(m_ports)) {
90 existingPorts << port->name();
92 for (
auto **it = info->ports; it && *it !=
nullptr; ++it) {
97 port = m_ports[existingPorts.
indexOf(name)];
102 port->d->setInfo(*it);
106 for (
auto port : std::as_const(m_ports)) {
107 if (!newPorts.
contains(port->name())) {
111 for (
auto port : std::as_const(toDiscard)) {
112 m_ports.removeOne(port);
116 Q_EMIT q->portsChanged();
121 return d->m_profiles;
124quint32 Card::activeProfileIndex()
const
126 return d->m_activeProfileIndex;
129void Card::setActiveProfileIndex(quint32 profileIndex)
132 Context::instance()->setCardProfile(index(), profile->name());
144 const auto allSinks = Context::instance()->sinks();
145 for (
Sink *sink : allSinks) {
146 if (sink->cardIndex() == IndexedPulseObject::d->m_index) {
158 const auto allSources = Context::instance()->sources();
159 for (
Source *source : allSources) {
160 if (source->cardIndex() == IndexedPulseObject::d->m_index) {