X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=app%2Fpacontrolmodel.cpp;fp=app%2Fpacontrolmodel.cpp;h=fe5de53461aad61bf19a2f87ad4d656e53e73b71;hb=288256f33f6298204cd0166cea3202d1fde100da;hp=bca72c5c7389b6e53c58ba97fedb3c9d8e3ad544;hpb=9e23981d8a86a3530c03be2d541585ce88e7b914;p=apps%2Fmixer.git diff --git a/app/pacontrolmodel.cpp b/app/pacontrolmodel.cpp index bca72c5..fe5de53 100644 --- a/app/pacontrolmodel.cpp +++ b/app/pacontrolmodel.cpp @@ -82,7 +82,8 @@ void PaControl::setVolume(PaControlModel *pacm, const QVariant &volume) { if (volume != m_volume) { m_volume = volume.toUInt(); - emit pacm->volumeChanged(type(), cindex(), channel(), m_volume); + if (pacm) + emit pacm->volumeChanged(type(), cindex(), channel(), m_volume); } } @@ -103,6 +104,26 @@ void PaControlModel::addOneControl(int cindex, QString desc, int type, int chann addControl(PaControl(cindex, desc, type, channel, cdesc, volume)); } +void PaControlModel::changeExternalVolume(uint32_t type, uint32_t cindex, uint32_t channel, uint32_t volume) +{ + QList::iterator i; + int row; + + for (i = m_controls.begin(), row = 0; i < m_controls.end(); ++i, ++row) { + if ((i->type() == type) && + (i->cindex() == cindex) && + (i->channel() == channel)) { + break; + } + } + + i->setVolume(NULL, QVariant(volume)); + QModelIndex qmindex = index(row); + QVector roles; + roles.push_back(VolumeRole); + emit dataChanged(qmindex, qmindex, roles); +} + int PaControlModel::rowCount(const QModelIndex & parent) const { Q_UNUSED(parent); return m_controls.count(); @@ -124,7 +145,9 @@ bool PaControlModel::setData(const QModelIndex &index, const QVariant &value, in control.setCDesc(value); else if (role == VolumeRole) control.setVolume(this, value); - emit dataChanged(index, index); + QVector roles; + roles.push_back(role); + emit dataChanged(index, index, roles); return true; }