diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 3a42941557e5003832dec15e0cac33fcf4d00c7c..0f710b17509468007ccb799e6d347b9351d66347 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -514,17 +514,18 @@ CallAdapter::updateCall(const QString& convUid, const QString& accountId, bool f void CallAdapter::fillParticipantData(QJsonObject& participant) const { - participant["bestName"] = participant["uri"]; + participant[lrc::api::ParticipantsInfosStrings::BESTNAME] + = participant[lrc::api::ParticipantsInfosStrings::URI]; auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId_); - participant["isLocal"] = false; - if (participant["bestName"] == accInfo.profileInfo.uri) { - participant["bestName"] = tr("me"); - participant["isLocal"] = true; + participant[lrc::api::ParticipantsInfosStrings::ISLOCAL] = false; + if (participant[lrc::api::ParticipantsInfosStrings::BESTNAME] == accInfo.profileInfo.uri) { + participant[lrc::api::ParticipantsInfosStrings::BESTNAME] = tr("me"); + participant[lrc::api::ParticipantsInfosStrings::ISLOCAL] = true; } else { try { - participant["bestName"] = lrcInstance_->getCurrentAccountInfo() - .contactModel->bestNameForContact( - participant["uri"].toString()); + participant[lrc::api::ParticipantsInfosStrings::BESTNAME] + = lrcInstance_->getCurrentAccountInfo().contactModel->bestNameForContact( + participant[lrc::api::ParticipantsInfosStrings::URI].toString()); } catch (...) { } } @@ -741,8 +742,8 @@ CallAdapter::maximizeParticipant(const QString& uri) auto participants = getConferencesInfos(); for (auto part : participants) { auto participant = part.toJsonObject(); - if (participant["uri"].toString() == uri) { - auto active = participant["active"].toBool(); + if (participant[lrc::api::ParticipantsInfosStrings::URI].toString() == uri) { + auto active = participant[lrc::api::ParticipantsInfosStrings::ACTIVE].toBool(); // Else, continue. if (!active) { callModel->setActiveParticipant(confId, uri); @@ -772,8 +773,8 @@ CallAdapter::minimizeParticipant(const QString& uri) auto participants = getConferencesInfos(); for (auto& part : participants) { auto participant = part.toJsonObject(); - if (participant["uri"].toString() == uri) { - auto active = participant["active"].toBool(); + if (participant[lrc::api::ParticipantsInfosStrings::URI].toString() == uri) { + auto active = participant[lrc::api::ParticipantsInfosStrings::ACTIVE].toBool(); if (active) { if (call.layout == lrc::api::call::Layout::ONE) { callModel->setConferenceLayout(confId, diff --git a/src/callparticipantsmodel.cpp b/src/callparticipantsmodel.cpp index 6bdd2ca06b45b08e5945bc3b24ffa91c7ee7d2ab..21ddc8ce58ada844555851fa33977f9a83e4f78e 100644 --- a/src/callparticipantsmodel.cpp +++ b/src/callparticipantsmodel.cpp @@ -27,6 +27,8 @@ #include <QSortFilterProxyModel> #include <QQuickItem> +#include <api/callparticipantsmodel.h> + CallParticipantsModel::CallParticipantsModel(LRCInstance* instance, QObject* parent) : QAbstractListModel(parent) , lrcInstance_(instance) @@ -53,33 +55,46 @@ CallParticipantsModel::data(const QModelIndex& index, int role) const switch (role) { case Role::Uri: - return QVariant::fromValue(participant.item.value("uri")); + return QVariant::fromValue(participant.item.value(lrc::api::ParticipantsInfosStrings::URI)); case Role::BestName: - return QVariant::fromValue(participant.item.value("bestName")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::BESTNAME)); case Role::Active: - return QVariant::fromValue(participant.item.value("active")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::ACTIVE)); case Role::AudioLocalMuted: - return QVariant::fromValue(participant.item.value("audioLocalMuted")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::AUDIOLOCALMUTED)); case Role::AudioModeratorMuted: - return QVariant::fromValue(participant.item.value("audioModeratorMuted")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::AUDIOMODERATORMUTED)); case Role::VideoMuted: - return QVariant::fromValue(participant.item.value("videoMuted")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::VIDEOMUTED)); case Role::IsModerator: - return QVariant::fromValue(participant.item.value("isModerator")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::ISMODERATOR)); case Role::IsLocal: - return QVariant::fromValue(participant.item.value("isLocal")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::ISLOCAL)); case Role::IsContact: - return QVariant::fromValue(participant.item.value("isContact")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::ISCONTACT)); case Role::Avatar: - return QVariant::fromValue(participant.item.value("avatar")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::AVATAR)); case Role::SinkId: - return QVariant::fromValue(participant.item.value("sinkId")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::SINKID)); case Role::Height: - return QVariant::fromValue(participant.item.value("height")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::HEIGHT)); case Role::Width: - return QVariant::fromValue(participant.item.value("width")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::WIDTH)); case Role::HandRaised: - return QVariant::fromValue(participant.item.value("handRaised")); + return QVariant::fromValue( + participant.item.value(lrc::api::ParticipantsInfosStrings::HANDRAISED)); } return QVariant(); } @@ -108,7 +123,7 @@ CallParticipantsModel::addParticipant(int index, const QVariant& infos) endInsertRows(); - callId_ = participants_[index].item["callId"].toString(); + callId_ = participants_[index].item[lrc::api::ParticipantsInfosStrings::CALLID].toString(); } void @@ -121,7 +136,7 @@ CallParticipantsModel::updateParticipant(int index, const QVariant& infos) auto it = participants_.begin() + index; (*it) = CallParticipant::Item {infos.toJsonObject()}; - callId_ = participants_[index].item["callId"].toString(); + callId_ = participants_[index].item[lrc::api::ParticipantsInfosStrings::CALLID].toString(); } Q_EMIT dataChanged(createIndex(index, 0), createIndex(index, 0)); } @@ -132,7 +147,7 @@ CallParticipantsModel::removeParticipant(int index) std::lock_guard<std::mutex> lk(participantsMtx_); if (participants_.size() <= index) return; - callId_ = participants_[index].item["callId"].toString(); + callId_ = participants_[index].item[lrc::api::ParticipantsInfosStrings::CALLID].toString(); beginRemoveRows(QModelIndex(), index, index);