12 #include "indexedpulseobject_p.h"
14 #include "profile_p.h"
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);
34 CardPrivate::CardPrivate(Card *q)
39 CardPrivate::~CardPrivate()
43 void CardPrivate::update(
const pa_card_info *info)
45 q->IndexedPulseObject::d->updatePulseObject(info);
46 q->PulseObject::d->updateProperties(info);
51 for (
const Profile *profile : qAsConst(m_profiles)) {
52 existingProfiles << profile->name();
55 for (
auto **it = info->profiles2; it && *it !=
nullptr; ++it) {
59 if (existingProfiles.
contains(name)) {
60 profile = m_profiles[existingProfiles.
indexOf(name)];
63 m_profiles << profile;
65 profile->d->setInfo(*it);
68 for (
Profile *profile : qAsConst(m_profiles)) {
69 if (!newProfiles.
contains(profile->name())) {
70 m_profiles.removeOne(profile);
75 for (
Profile *profile : qAsConst(m_profiles)) {
76 if (info->active_profile2->name == profile->name()) {
77 m_activeProfileIndex = m_profiles.indexOf(profile);
81 Q_EMIT q->profilesChanged();
82 Q_EMIT q->activeProfileIndexChanged();
87 for (
const Port *port : qAsConst(m_ports)) {
88 existingPorts << port->name();
90 for (
auto **it = info->ports; it && *it !=
nullptr; ++it) {
95 port = m_ports[existingPorts.
indexOf(name)];
100 port->d->setInfo(*it);
103 for (
CardPort *port : qAsConst(m_ports)) {
104 if (!newPorts.
contains(port->name())) {
105 m_ports.removeOne(port);
110 Q_EMIT q->portsChanged();
115 return d->m_profiles;
118 quint32 Card::activeProfileIndex()
const
120 return d->m_activeProfileIndex;
123 void Card::setActiveProfileIndex(quint32 profileIndex)
125 const Profile *profile = qobject_cast<Profile *>(profiles().at(profileIndex));
126 Context::instance()->setCardProfile(index(), profile->name());
138 const auto allSinks = Context::instance()->sinks();
139 for (
Sink *sink : allSinks) {
140 if (sink->cardIndex() == IndexedPulseObject::d->m_index) {
152 const auto allSources = Context::instance()->sources();
153 for (
Source *source : allSources) {
154 if (source->cardIndex() == IndexedPulseObject::d->m_index) {