Commit 57a84010 authored by Ronan's avatar Ronan
Browse files

feat(ui/modules/Linphone/Codecs): supports fields edition

parent 39a8ee9f
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment