From 4181d19631984fc4d8ae4fd211bc41dd7569a4d3 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 15 Jan 2025 18:39:41 +0100 Subject: [PATCH] Synchronize contact list names with contact edition on save. --- Linphone/core/call-history/CallHistoryCore.cpp | 6 ++---- Linphone/core/friend/FriendCore.cpp | 8 ++++++-- Linphone/model/friend/FriendModel.cpp | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index c6ff22317..448bb96ec 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -128,10 +128,8 @@ void CallHistoryCore::setSelf(QSharedPointer me) { }; if (!ToolModel::findFriendByAddress(mRemoteAddress)) mCoreModelConnection->makeConnectToModel(&CoreModel::friendCreated, update); - else { - mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update); - mCoreModelConnection->makeConnectToModel(&CoreModel::friendRemoved, &CallHistoryCore::onRemoved); - } + mCoreModelConnection->makeConnectToModel(&CoreModel::friendUpdated, update); + mCoreModelConnection->makeConnectToModel(&CoreModel::friendRemoved, &CallHistoryCore::onRemoved); } ConferenceInfoGui *CallHistoryCore::getConferenceInfoGui() const { diff --git a/Linphone/core/friend/FriendCore.cpp b/Linphone/core/friend/FriendCore.cpp index 351243a3c..a08b568d8 100644 --- a/Linphone/core/friend/FriendCore.cpp +++ b/Linphone/core/friend/FriendCore.cpp @@ -221,6 +221,10 @@ void FriendCore::setSelf(QSharedPointer me) { updateVerifiedDevicesCount(); }); }); + mCoreModelConnection->makeConnectToCore(&FriendCore::saved, [this]() { + mCoreModelConnection->invokeToModel( + [this, f = mFriendModel->getFriend()]() { emit CoreModel::getInstance()->friendUpdated(f); }); + }); } else { // Create mCoreModelConnection = QSharedPointer>( @@ -624,7 +628,7 @@ void FriendCore::save() { // Save Values to model thisCopy->writeIntoModel(mFriendModel); thisCopy->deleteLater(); mVCardString = mFriendModel->getVCardAsString(); - mFriendModelConnection->invokeToCore([this]() { saved(); }); + mFriendModelConnection->invokeToCore([this]() { emit saved(); }); setIsSaved(true); }); } else { @@ -648,7 +652,7 @@ void FriendCore::save() { // Save Values to model thisCopy->deleteLater(); mVCardString = mFriendModel->getVCardAsString(); }); - saved(); + emit saved(); }); } else { auto contact = core->createFriend(); diff --git a/Linphone/model/friend/FriendModel.cpp b/Linphone/model/friend/FriendModel.cpp index 840131aa3..5df7f3302 100644 --- a/Linphone/model/friend/FriendModel.cpp +++ b/Linphone/model/friend/FriendModel.cpp @@ -58,7 +58,7 @@ FriendModel::FriendModel(const std::shared_ptr &contact, const connect(this, &FriendModel::givenNameChanged, updateFullName); connect(this, &FriendModel::familyNameChanged, updateFullName); - connect(this, &FriendModel::updated, [this]() { emit CoreModel::getInstance()->friendUpdated(mMonitor); }); + connect(CoreModel::getInstance().get(), &CoreModel::friendUpdated, this, &FriendModel::onUpdated); connect(CoreModel::getInstance().get(), &CoreModel::friendRemoved, this, &FriendModel::onRemoved); };