diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index 5b6d10ca8..5970a95c3 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -396,17 +396,17 @@ void ChatCore::setSelf(const QSharedPointer &me) { } mChatModelConnection->invokeToCore([this, success] { emit participantAddressesChanged(success); }); }); - mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipantAtIndex, [this](int index) { - mChatModelConnection->invokeToModel([this, index]() { mChatModel->removeParticipantAtIndex(index); }); + mChatModelConnection->makeConnectToCore(&ChatCore::lRemoveParticipant, [this](QString sipAddress) { + mChatModelConnection->invokeToModel([this, sipAddress]() { mChatModel->removeParticipant(sipAddress); }); }); mChatModelConnection->makeConnectToCore(&ChatCore::lSetParticipantsAddresses, [this](QStringList addresses) { mChatModelConnection->invokeToModel([this, addresses]() { mChatModel->setParticipantAddresses(addresses); }); }); - mChatModelConnection->makeConnectToCore(&ChatCore::lToggleParticipantAdminStatusAtIndex, [this](int index) { + mChatModelConnection->makeConnectToCore(&ChatCore::lToggleParticipantAdminStatus, [this](QString sipAddress) { mChatModelConnection->invokeToModel( - [this, index]() { mChatModel->toggleParticipantAdminStatusAtIndex(index); }); + [this, sipAddress]() { mChatModel->toggleParticipantAdminStatus(sipAddress); }); }); mCoreModelConnection = SafeConnection::create(me, CoreModel::getInstance()); diff --git a/Linphone/core/chat/ChatCore.hpp b/Linphone/core/chat/ChatCore.hpp index cdea6e163..0491400bf 100644 --- a/Linphone/core/chat/ChatCore.hpp +++ b/Linphone/core/chat/ChatCore.hpp @@ -192,9 +192,9 @@ signals: void lSetMuted(bool muted); void lSetEphemeralLifetime(int time); void lSetSubject(QString subject); - void lRemoveParticipantAtIndex(int index); + void lRemoveParticipant(QString sipAddress); void lSetParticipantsAddresses(QStringList addresses); - void lToggleParticipantAdminStatusAtIndex(int index); + void lToggleParticipantAdminStatus(QString sipAddress); private: QString id; diff --git a/Linphone/model/chat/ChatModel.cpp b/Linphone/model/chat/ChatModel.cpp index 00a14fcbc..f34805b14 100644 --- a/Linphone/model/chat/ChatModel.cpp +++ b/Linphone/model/chat/ChatModel.cpp @@ -221,14 +221,19 @@ void ChatModel::setSubject(QString subject) const { return mMonitor->setSubject(Utils::appStringToCoreString(subject)); } -void ChatModel::removeParticipantAtIndex(int index) const { - auto participant = *std::next(mMonitor->getParticipants().begin(), index); - mMonitor->removeParticipant(participant); +void ChatModel::removeParticipant(const QString &sipAddress) const { + if (!mMonitor) return; + auto addr = Utils::appStringToCoreString(sipAddress); + for (auto &p : mMonitor->getParticipants()) + if (p && p->getAddress()->asStringUriOnly() == addr) return mMonitor->removeParticipant(p); } -void ChatModel::toggleParticipantAdminStatusAtIndex(int index) const { - auto participant = *std::next(mMonitor->getParticipants().begin(), index); - mMonitor->setParticipantAdminStatus(participant, !participant->isAdmin()); +void ChatModel::toggleParticipantAdminStatus(const QString &sipAddress) const { + if (!mMonitor) return; + auto addr = Utils::appStringToCoreString(sipAddress); + for (auto &p : mMonitor->getParticipants()) + if (p && p->getAddress()->asStringUriOnly() == addr) + return mMonitor->setParticipantAdminStatus(p, !p->isAdmin()); } void ChatModel::setParticipantAddresses(const QStringList &addresses) { diff --git a/Linphone/model/chat/ChatModel.hpp b/Linphone/model/chat/ChatModel.hpp index 2c24d6b41..10ce89bf8 100644 --- a/Linphone/model/chat/ChatModel.hpp +++ b/Linphone/model/chat/ChatModel.hpp @@ -81,9 +81,9 @@ public: void setMuted(bool muted); void setEphemeralLifetime(int time); void setSubject(QString subject) const; - void removeParticipantAtIndex(int index) const; + void removeParticipant(const QString &sipAddress) const; void setParticipantAddresses(const QStringList &addresses); - void toggleParticipantAdminStatusAtIndex(int index) const; + void toggleParticipantAdminStatus(const QString &sipAddress) const; signals: void historyDeleted(); diff --git a/Linphone/view/Page/Layout/Chat/GroupChatInfoParticipants.qml b/Linphone/view/Page/Layout/Chat/GroupChatInfoParticipants.qml index 575573528..897334a83 100644 --- a/Linphone/view/Page/Layout/Chat/GroupChatInfoParticipants.qml +++ b/Linphone/view/Page/Layout/Chat/GroupChatInfoParticipants.qml @@ -144,7 +144,7 @@ ColumnLayout { icon.height: Utils.getSizeWithScreenRatio(32) onClicked: { detailOptions.close() - mainItem.chatGui.core.lToggleParticipantAdminStatusAtIndex(index) + mainItem.chatGui.core.lToggleParticipantAdminStatus(participantGui.core.sipAddress) } } IconLabelButton { @@ -181,7 +181,7 @@ ColumnLayout { "", function(confirmed) { if (confirmed) { - mainItem.chatGui.core.lRemoveParticipantAtIndex(index) + mainItem.chatGui.core.lRemoveParticipant(participantGui.core.sipAddress) } }) }