diff --git a/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp b/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp index d748a3944..f315d329b 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp +++ b/linphone-app/src/components/participant/ParticipantDeviceListModel.cpp @@ -42,6 +42,23 @@ int ParticipantDeviceListModel::rowCount (const QModelIndex &index) const{ return mList.count(); } +int ParticipantDeviceListModel::count(){ + return mList.count(); +} + +void ParticipantDeviceListModel::updateDevices(std::shared_ptr participant){ + std::list> devices = participant->getDevices() ; + beginResetModel(); + mList.clear(); + for(auto device : devices){ + auto deviceModel = std::make_shared(device); + connect(this, &ParticipantDeviceListModel::securityLevelChanged, deviceModel.get(), &ParticipantDeviceModel::onSecurityLevelChanged); + mList << deviceModel; + } + endResetModel(); + emit layoutChanged(); +} + QHash ParticipantDeviceListModel::roleNames () const { QHash roles; roles[Qt::DisplayRole] = "$participantDevice"; diff --git a/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp b/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp index 2e4cc410c..41f1d42fb 100644 --- a/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp +++ b/linphone-app/src/components/participant/ParticipantDeviceListModel.hpp @@ -38,6 +38,9 @@ public: ParticipantDeviceListModel (std::shared_ptr participant, QObject *parent = nullptr); int rowCount (const QModelIndex &index = QModelIndex()) const override; + int count(); + + void updateDevices(std::shared_ptr participant); virtual QHash roleNames () const override; virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; diff --git a/linphone-app/src/components/participant/ParticipantListModel.cpp b/linphone-app/src/components/participant/ParticipantListModel.cpp index ee6b93239..820ebcb4f 100644 --- a/linphone-app/src/components/participant/ParticipantListModel.cpp +++ b/linphone-app/src/components/participant/ParticipantListModel.cpp @@ -170,7 +170,6 @@ bool ParticipantListModel::removeRows (int row, int count, const QModelIndex &pa void ParticipantListModel::updateParticipants () { if( mChatRoomModel) { bool changed = false; - CoreManager *coreManager = CoreManager::getInstance(); auto dbParticipants = mChatRoomModel->getChatRoom()->getParticipants(); auto me = mChatRoomModel->getChatRoom()->getMe(); dbParticipants.push_front(me); diff --git a/linphone-app/src/components/participant/ParticipantModel.cpp b/linphone-app/src/components/participant/ParticipantModel.cpp index 8efa81c90..b59549029 100644 --- a/linphone-app/src/components/participant/ParticipantModel.cpp +++ b/linphone-app/src/components/participant/ParticipantModel.cpp @@ -52,8 +52,12 @@ int ParticipantModel::getSecurityLevel() const{ return (mParticipant ? (int)mParticipant->getSecurityLevel() : 0); } -int ParticipantModel::getDeviceCount() const{ - return (mParticipant ? mParticipant->getDevices().size() : 0); +int ParticipantModel::getDeviceCount(){ + int count = (mParticipant ? mParticipant->getDevices().size() : 0); + if(mParticipant && count != mParticipantDevices->count()){ + mParticipantDevices->updateDevices(mParticipant); + } + return count; } bool ParticipantModel::getInviting() const{ diff --git a/linphone-app/src/components/participant/ParticipantModel.hpp b/linphone-app/src/components/participant/ParticipantModel.hpp index 51de53743..129be7a03 100644 --- a/linphone-app/src/components/participant/ParticipantModel.hpp +++ b/linphone-app/src/components/participant/ParticipantModel.hpp @@ -55,7 +55,7 @@ public: bool getAdminStatus() const; bool isFocus() const; int getSecurityLevel() const; - int getDeviceCount() const; + int getDeviceCount(); bool getInviting() const; void setSipAddress(const QString& address);