Commit 57a84010 authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent 39a8ee9f
...@@ -27,8 +27,16 @@ ...@@ -27,8 +27,16 @@
#include "AbstractCodecsModel.hpp" #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) {} AbstractCodecsModel::AbstractCodecsModel (QObject *parent) : QAbstractListModel(parent) {}
int AbstractCodecsModel::rowCount (const QModelIndex &) const { int AbstractCodecsModel::rowCount (const QModelIndex &) const {
...@@ -59,10 +67,10 @@ void AbstractCodecsModel::enableCodec (int id, bool status) { ...@@ -59,10 +67,10 @@ void AbstractCodecsModel::enableCodec (int id, bool status) {
Q_ASSERT(id >= 0 && id < m_codecs.count()); Q_ASSERT(id >= 0 && id < m_codecs.count());
QVariantMap &map = m_codecs[id]; 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); codec->enable(status);
map["enabled"] = status; map["enabled"] = codec->enabled();
emit dataChanged(index(id, 0), index(id, 0)); emit dataChanged(index(id, 0), index(id, 0));
} }
...@@ -71,6 +79,30 @@ void AbstractCodecsModel::moveCodec (int source, int destination) { ...@@ -71,6 +79,30 @@ void AbstractCodecsModel::moveCodec (int source, int destination) {
moveRow(QModelIndex(), source, QModelIndex(), 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 ( bool AbstractCodecsModel::moveRows (
......
...@@ -48,6 +48,9 @@ public: ...@@ -48,6 +48,9 @@ public:
Q_INVOKABLE void enableCodec (int id, bool status); Q_INVOKABLE void enableCodec (int id, bool status);
Q_INVOKABLE void moveCodec (int source, int destination); 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: protected:
bool moveRows ( bool moveRows (
const QModelIndex &source_parent, const QModelIndex &source_parent,
......
...@@ -147,14 +147,18 @@ Column { ...@@ -147,14 +147,18 @@ Column {
text: $codec.clockRate text: $codec.clockRate
} }
TextField { NumericField {
Layout.preferredWidth: CodecsViewerStyle.column.bitrateWidth Layout.preferredWidth: CodecsViewerStyle.column.bitrateWidth
text: $codec.bitrate text: $codec.bitrate
onEditingFinished: view.model.setBitrate(index, text)
} }
TextField { TextField {
Layout.preferredWidth: CodecsViewerStyle.column.recvFmtpWidth Layout.preferredWidth: CodecsViewerStyle.column.recvFmtpWidth
text: $codec.recvFmtp text: $codec.recvFmtp
onEditingFinished: view.model.setRecvFmtp(index, text)
} }
Switch { 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