mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 17:29:19 +00:00
feat(ui/modules/Linphone/Codecs): supports fields edition
This commit is contained in:
parent
39a8ee9fae
commit
57a8401012
3 changed files with 42 additions and 3 deletions
|
|
@ -27,8 +27,16 @@
|
|||
|
||||
#include "AbstractCodecsModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map) {
|
||||
return map.value("__codec").value<shared_ptr<linphone::PayloadType> >();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {}
|
||||
|
||||
int AbstractCodecsModel::rowCount (const QModelIndex &) const {
|
||||
|
|
@ -59,10 +67,10 @@ void AbstractCodecsModel::enableCodec (int id, bool status) {
|
|||
Q_ASSERT(id >= 0 && id < m_codecs.count());
|
||||
|
||||
QVariantMap &map = m_codecs[id];
|
||||
shared_ptr<linphone::PayloadType> codec = map.value("__codec").value<shared_ptr<linphone::PayloadType> >();
|
||||
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
|
||||
|
||||
codec->enable(status);
|
||||
map["enabled"] = status;
|
||||
map["enabled"] = codec->enabled();
|
||||
|
||||
emit dataChanged(index(id, 0), index(id, 0));
|
||||
}
|
||||
|
|
@ -71,6 +79,30 @@ void AbstractCodecsModel::moveCodec (int source, int destination) {
|
|||
moveRow(QModelIndex(), source, QModelIndex(), destination);
|
||||
}
|
||||
|
||||
void AbstractCodecsModel::setBitrate (int id, int bitrate) {
|
||||
Q_ASSERT(id >= 0 && id < m_codecs.count());
|
||||
|
||||
QVariantMap &map = m_codecs[id];
|
||||
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
|
||||
|
||||
codec->setNormalBitrate(bitrate);
|
||||
map["bitrate"] = codec->getNormalBitrate();
|
||||
|
||||
emit dataChanged(index(id, 0), index(id, 0));
|
||||
}
|
||||
|
||||
void AbstractCodecsModel::setRecvFmtp (int id, const QString &recv_fmtp) {
|
||||
Q_ASSERT(id >= 0 && id < m_codecs.count());
|
||||
|
||||
QVariantMap &map = m_codecs[id];
|
||||
shared_ptr<linphone::PayloadType> codec = getCodecFromMap(map);
|
||||
|
||||
codec->setRecvFmtp(::Utils::qStringToLinphoneString(recv_fmtp));
|
||||
map["recvFmtp"] = ::Utils::linphoneStringToQString(codec->getRecvFmtp());
|
||||
|
||||
emit dataChanged(index(id, 0), index(id, 0));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool AbstractCodecsModel::moveRows (
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public:
|
|||
Q_INVOKABLE void enableCodec (int id, bool status);
|
||||
Q_INVOKABLE void moveCodec (int source, int destination);
|
||||
|
||||
Q_INVOKABLE void setBitrate (int id, int bitrate);
|
||||
Q_INVOKABLE void setRecvFmtp (int id, const QString &recv_fmtp);
|
||||
|
||||
protected:
|
||||
bool moveRows (
|
||||
const QModelIndex &source_parent,
|
||||
|
|
|
|||
|
|
@ -147,14 +147,18 @@ Column {
|
|||
text: $codec.clockRate
|
||||
}
|
||||
|
||||
TextField {
|
||||
NumericField {
|
||||
Layout.preferredWidth: CodecsViewerStyle.column.bitrateWidth
|
||||
text: $codec.bitrate
|
||||
|
||||
onEditingFinished: view.model.setBitrate(index, text)
|
||||
}
|
||||
|
||||
TextField {
|
||||
Layout.preferredWidth: CodecsViewerStyle.column.recvFmtpWidth
|
||||
text: $codec.recvFmtp
|
||||
|
||||
onEditingFinished: view.model.setRecvFmtp(index, text)
|
||||
}
|
||||
|
||||
Switch {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue