From f42b529adb3310824451e110174cfa6421ec62b7 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 26 Feb 2026 11:40:13 +0100 Subject: [PATCH] display exact matching result on the top of the suggestions list #LINQT-2433 --- Linphone/core/search/MagicSearchList.cpp | 4 ++++ Linphone/core/search/MagicSearchList.hpp | 1 + Linphone/core/search/MagicSearchProxy.cpp | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/Linphone/core/search/MagicSearchList.cpp b/Linphone/core/search/MagicSearchList.cpp index cddbfe1f0..05f7339de 100644 --- a/Linphone/core/search/MagicSearchList.cpp +++ b/Linphone/core/search/MagicSearchList.cpp @@ -193,6 +193,10 @@ void MagicSearchList::setSearch(const QString &search) { } } +QString MagicSearchList::getSearch() const { + return mSearchFilter; +} + int MagicSearchList::getSourceFlags() const { return mSourceFlags; } diff --git a/Linphone/core/search/MagicSearchList.hpp b/Linphone/core/search/MagicSearchList.hpp index bcb33bb41..3ece077f2 100644 --- a/Linphone/core/search/MagicSearchList.hpp +++ b/Linphone/core/search/MagicSearchList.hpp @@ -43,6 +43,7 @@ public: void setSelf(const QSharedPointer &me); void connectContact(FriendCore *data); void setSearch(const QString &search); + QString getSearch() const; void setResults(const QList> &contacts); void add(QSharedPointer contact); diff --git a/Linphone/core/search/MagicSearchProxy.cpp b/Linphone/core/search/MagicSearchProxy.cpp index 3da478af7..47cc9ce20 100644 --- a/Linphone/core/search/MagicSearchProxy.cpp +++ b/Linphone/core/search/MagicSearchProxy.cpp @@ -129,6 +129,7 @@ void MagicSearchProxy::setSearchText(const QString &search) { if (mSearchText != search) { mSearchText = search; mList->setSearch(mSearchText); + emit searchTextChanged(); } } @@ -233,6 +234,8 @@ bool MagicSearchProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QMo bool MagicSearchProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { auto l = getItemAtSource(sourceLeft.row()); auto r = getItemAtSource(sourceRight.row()); + auto list = dynamic_cast(sourceModel()); + QString filter = list ? list->getSearch() : QString(); if (l && r) { bool lIsStored = l->getIsStored() || l->isLdap() || l->isCardDAV(); @@ -241,6 +244,8 @@ bool MagicSearchProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, c else if (!lIsStored && rIsStored) return false; auto lName = l->getFullName().toLower(); auto rName = r->getFullName().toLower(); + if (lName == filter) return true; + else if (rName == filter) return false; return lName < rName; } return true;