diff --git a/Linphone/core/call-history/CallHistoryCore.cpp b/Linphone/core/call-history/CallHistoryCore.cpp index b03b33be8..f06ad29ab 100644 --- a/Linphone/core/call-history/CallHistoryCore.cpp +++ b/Linphone/core/call-history/CallHistoryCore.cpp @@ -66,7 +66,7 @@ CallHistoryCore::CallHistoryCore(const std::shared_ptr &callL auto inFriend = Utils::findFriendByAddress(mRemoteAddress); if (inFriend) { auto friendGui = inFriend->getValue().value(); - if (friendGui) mDisplayName = friendGui->getCore()->getDisplayName(); + if (friendGui) mDisplayName = friendGui->getCore()->getFullName(); } } } @@ -89,7 +89,7 @@ void CallHistoryCore::setSelf(QSharedPointer me) { QString displayName; if (inFriend) { auto friendGui = inFriend->getValue().value(); - if (friendGui) displayName = friendGui->getCore()->getDisplayName(); + if (friendGui) displayName = friendGui->getCore()->getFullName(); } if (!displayName.isEmpty()) { mCoreModelConnection->invokeToCore([this, displayName]() { diff --git a/Linphone/core/friend/FriendCore.cpp b/Linphone/core/friend/FriendCore.cpp index 470142acb..2e3fd9b73 100644 --- a/Linphone/core/friend/FriendCore.cpp +++ b/Linphone/core/friend/FriendCore.cpp @@ -70,9 +70,9 @@ FriendCore::FriendCore(const std::shared_ptr &contact, bool is mFullName = Utils::coreStringToAppString(vcard->getFullName()); mVCardString = Utils::coreStringToAppString(vcard->asVcard4String()); } - if (defaultAddress) { - if (mGivenName.isEmpty()) mGivenName = Utils::coreStringToAppString(defaultAddress->getUsername()); - } + if (mFullName.isEmpty()) mFullName = Utils::coreStringToAppString(contact->getName()); + if (mFullName.isEmpty()) mFullName = Utils::coreStringToAppString(contact->getOrganization()); + auto addresses = contact->getAddresses(); for (auto &address : addresses) { mAddressList.append( @@ -108,8 +108,12 @@ FriendCore::FriendCore(const std::shared_ptr &contact, bool is mIsLdap = ToolModel::friendIsInFriendList(ToolModel::getLdapFriendList(), contact); connect(this, &FriendCore::addressChanged, &FriendCore::allAddressesChanged); connect(this, &FriendCore::phoneNumberChanged, &FriendCore::allAddressesChanged); - connect(this, &FriendCore::givenNameChanged, &FriendCore::displayNameChanged); - connect(this, &FriendCore::familyNameChanged, &FriendCore::displayNameChanged); + auto updateFullName = [this] { + auto name = (mGivenName.isEmpty() ? "" : mGivenName) + (mFamilyName.isEmpty() ? "" : mFamilyName); + if (!name.isEmpty()) setFullName(name); + }; + connect(this, &FriendCore::givenNameChanged, updateFullName); + connect(this, &FriendCore::familyNameChanged, updateFullName); } FriendCore::FriendCore(const FriendCore &friendCore) { @@ -248,11 +252,18 @@ void FriendCore::reset(const FriendCore &contact) { setIsSaved(mFriendModel != nullptr); } -QString FriendCore::getDisplayName() const { +QString FriendCore::getFullName() const { if (mFullName.isEmpty()) return mGivenName + " " + mFamilyName; else return mFullName; } +void FriendCore::setFullName(const QString &name) { + if (mFullName != name) { + mFullName = name; + emit fullNameChanged(name); + } +} + QString FriendCore::getGivenName() const { return mGivenName; } @@ -527,9 +538,8 @@ void FriendCore::writeIntoModel(std::shared_ptr model) const { mustBeInLinphoneThread(QString("[") + gClassName + "] " + Q_FUNC_INFO); model->getFriend()->edit(); // needed to create the vcard if not created yet - model->setName(mFullName.isEmpty() - ? mGivenName + (mFamilyName.isEmpty() || mGivenName.isEmpty() ? "" : " ") + mFamilyName - : mFullName); + auto name = mGivenName + (mFamilyName.isEmpty() || mGivenName.isEmpty() ? "" : " ") + mFamilyName; + model->setName(name.isEmpty() ? (mFullName.isEmpty() ? mOrganization : mFullName) : name); auto core = CoreModel::getInstance()->getCore(); std::list> addresses; diff --git a/Linphone/core/friend/FriendCore.hpp b/Linphone/core/friend/FriendCore.hpp index 4c2a33e14..b0db873df 100644 --- a/Linphone/core/friend/FriendCore.hpp +++ b/Linphone/core/friend/FriendCore.hpp @@ -57,7 +57,7 @@ class FriendCore : public QObject, public AbstractObject { Q_PROPERTY(int verifiedDeviceCount MEMBER mVerifiedDeviceCount NOTIFY verifiedDevicesChanged) Q_PROPERTY(QString givenName READ getGivenName WRITE setGivenName NOTIFY givenNameChanged) Q_PROPERTY(QString familyName READ getFamilyName WRITE setFamilyName NOTIFY familyNameChanged) - Q_PROPERTY(QString displayName READ getDisplayName NOTIFY displayNameChanged) + Q_PROPERTY(QString fullName READ getFullName NOTIFY fullNameChanged) Q_PROPERTY(QString organization READ getOrganization WRITE setOrganization NOTIFY organizationChanged) Q_PROPERTY(QString job READ getJob WRITE setJob NOTIFY jobChanged) Q_PROPERTY(QString defaultAddress READ getDefaultAddress WRITE setDefaultAddress NOTIFY defaultAddressChanged) @@ -81,7 +81,8 @@ public: void setSelf(SafeSharedPointer me); void reset(const FriendCore &contact); - QString getDisplayName() const; + QString getFullName() const; + void setFullName(const QString &name); QString getFamilyName() const; void setFamilyName(const QString &name); @@ -154,8 +155,9 @@ protected: signals: void contactUpdated(); void displayNameChanged(); - void givenNameChanged(const QString &name); - void familyNameChanged(const QString &name); + void givenNameChanged(QString name); + void familyNameChanged(QString name); + void fullNameChanged(QString name); void starredChanged(); void phoneNumberChanged(); void addressChanged(); diff --git a/Linphone/core/search/MagicSearchProxy.cpp b/Linphone/core/search/MagicSearchProxy.cpp index 376c402e2..af37aab7d 100644 --- a/Linphone/core/search/MagicSearchProxy.cpp +++ b/Linphone/core/search/MagicSearchProxy.cpp @@ -215,8 +215,8 @@ bool MagicSearchProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, c bool rIsStored = r->getIsStored(); if (lIsStored && !rIsStored) return true; else if (!lIsStored && rIsStored) return false; - auto lName = l->getDisplayName().toLower(); - auto rName = r->getDisplayName().toLower(); + auto lName = l->getFullName().toLower(); + auto rName = r->getFullName().toLower(); return lName < rName; } return true; diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 226d3cb12..65f29d0c0 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -83,7 +83,6 @@ QString ToolModel::getDisplayName(const std::shared_ptr if (address) { auto linFriend = CoreModel::getInstance()->getCore()->findFriend(address); if (linFriend) { - if (auto vcard = linFriend->getVcard()) displayName = Utils::coreStringToAppString(vcard->getFullName()); if (displayName.isEmpty()) displayName = Utils::coreStringToAppString(linFriend->getName()); } if (displayName.isEmpty()) { diff --git a/Linphone/view/Control/Container/Call/CallHistoryLayout.qml b/Linphone/view/Control/Container/Call/CallHistoryLayout.qml index 86e7aca8e..e184d5949 100644 --- a/Linphone/view/Control/Container/Call/CallHistoryLayout.qml +++ b/Linphone/view/Control/Container/Call/CallHistoryLayout.qml @@ -17,7 +17,7 @@ ColumnLayout { property var computedContactNameObj: UtilsCpp.getDisplayName(contactAddress) property string computedContactName: computedContactNameObj ? computedContactNameObj.value: "" property string contactName: contact - ? contact.core.displayName + ? contact.core.fullName : conferenceInfo ? conferenceInfo.core.subject : computedContactName diff --git a/Linphone/view/Control/Display/Contact/Avatar.qml b/Linphone/view/Control/Display/Contact/Avatar.qml index ca19cb63d..6ab5b669a 100644 --- a/Linphone/view/Control/Display/Contact/Avatar.qml +++ b/Linphone/view/Control/Display/Contact/Avatar.qml @@ -26,8 +26,8 @@ Loader{ property var displayNameObj: UtilsCpp.getDisplayName(_address) property string displayNameVal: account && account.core.displayName ? account.core.displayName - : contact && contact.core.displayName - ? contact.core.displayName + : contact && contact.core.fullName + ? contact.core.fullName : displayNameObj ? displayNameObj.value : "" diff --git a/Linphone/view/Control/Display/Contact/ContactListItem.qml b/Linphone/view/Control/Display/Contact/ContactListItem.qml index cb34c84a2..1fed51d46 100644 --- a/Linphone/view/Control/Display/Contact/ContactListItem.qml +++ b/Linphone/view/Control/Display/Contact/ContactListItem.qml @@ -28,7 +28,7 @@ FocusScope { property var previousInitial // Use directly previous initial property int itemsRightMargin: 39 * DefaultStyle.dp - property var displayName: searchResultItem.core.displayName + property var displayName: searchResultItem.core.fullName property string initial: displayName ? displayName[0].toLocaleLowerCase(ConstantsCpp.DefaultLocale) : '' signal clicked(var mouse) diff --git a/Linphone/view/Page/Main/Contact/ContactPage.qml b/Linphone/view/Page/Main/Contact/ContactPage.qml index 6cba677dd..280945e0c 100644 --- a/Linphone/view/Page/Main/Contact/ContactPage.qml +++ b/Linphone/view/Page/Main/Contact/ContactPage.qml @@ -57,11 +57,11 @@ AbstractMainPage { if (!contact) return var mainWin = UtilsCpp.getMainWindow() mainWin.showConfirmationLambdaPopup("", - qsTr("%1 sera supprimé des contacts. Voulez-vous continuer ?").arg(contact.core.displayName), + qsTr("%1 sera supprimé des contacts. Voulez-vous continuer ?").arg(contact.core.fullName), "", function (confirmed) { if (confirmed) { - var name = contact.core.displayName + var name = contact.core.fullName contact.core.remove() UtilsCpp.showInformationPopup(qsTr("Supprimé"), qsTr("%1 a été supprimé").arg(name)) } } @@ -339,7 +339,7 @@ AbstractMainPage { property var computedContactNameObj: UtilsCpp.getDisplayName(contactAddress) property string computedContactName: computedContactNameObj ? computedContactNameObj.value : "" property string contactName: contact - ? contact.core.displayName + ? contact.core.fullName : computedContactName component LabelButton: ColumnLayout { id: labelButton diff --git a/Linphone/view/Page/Window/AbstractWindow.qml b/Linphone/view/Page/Window/AbstractWindow.qml index f31f669fc..125659dd2 100644 --- a/Linphone/view/Page/Window/AbstractWindow.qml +++ b/Linphone/view/Page/Window/AbstractWindow.qml @@ -149,7 +149,7 @@ ApplicationWindow { if (parentItem == undefined) parentItem = mainWindow.contentItem startCallPopup.parent = parentItem if (contact) { - console.log("START CALL WITH", contact.core.displayName, "addresses count", contact.core.allAddresses.length) + console.log("START CALL WITH", contact.core.fullName, "addresses count", contact.core.allAddresses.length) if (contact.core.allAddresses.length > 1) { startCallPopup.contact = contact startCallPopup.videoEnabled = videoEnabled @@ -171,7 +171,7 @@ ApplicationWindow { if (parentItem == undefined) parentItem = mainWindow.contentItem startCallPopup.parent = parentItem if (contact) { - console.log("[AbstractWindow] Transfer call to", contact.core.displayName, "addresses count", contact.core.allAddresses.length, call) + console.log("[AbstractWindow] Transfer call to", contact.core.fullName, "addresses count", contact.core.allAddresses.length, call) if (contact.core.allAddresses.length > 1) { startCallPopup.contact = contact startCallPopup.currentCall = call diff --git a/Linphone/view/Page/Window/Call/CallsWindow.qml b/Linphone/view/Page/Window/Call/CallsWindow.qml index 008893a84..314e12a71 100644 --- a/Linphone/view/Page/Window/Call/CallsWindow.qml +++ b/Linphone/view/Page/Window/Call/CallsWindow.qml @@ -572,7 +572,7 @@ AbstractWindow { var callsWin = UtilsCpp.getCallsWindow() if (contact) callsWin.showConfirmationLambdaPopup( qsTr("Confirmer le transfert ?"), - qsTr("Vous allez transférer %1 à %2.").arg(mainWindow.call.core.remoteName).arg(contact.core.displayName), + qsTr("Vous allez transférer %1 à %2.").arg(mainWindow.call.core.remoteName).arg(contact.core.fullName), "", function (confirmed) { if (confirmed) {