From f516505287126f4f9dec52323257fbf5981402f5 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 26 Aug 2025 12:33:27 +0200 Subject: [PATCH] fix #LINQT-1910 wrong proxy index when chat list filtered --- Linphone/core/chat/ChatList.cpp | 8 +++----- Linphone/core/chat/ChatList.hpp | 1 - Linphone/core/chat/ChatProxy.cpp | 1 - Linphone/core/chat/ChatProxy.hpp | 1 - Linphone/view/Control/Display/Chat/ChatListView.qml | 8 +++----- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 344301c33..07545b264 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -82,7 +82,7 @@ void ChatList::setSelf(QSharedPointer me) { mModelConnection = SafeConnection::create(me, CoreModel::getInstance()); mModelConnection->makeConnectToCore(&ChatList::lUpdate, [this]() { clearData(); - emit listAboutToBeReset(); + beginResetModel(); mModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(getClassName()); // Avoid copy to lambdas @@ -107,10 +107,8 @@ void ChatList::setSelf(QSharedPointer me) { connectItem(chat); } mustBeInMainThread(getClassName()); - clearData(); - for (auto chat : *chats) { - add(chat); - } + add(*chats); + endResetModel(); delete chats; }); }); diff --git a/Linphone/core/chat/ChatList.hpp b/Linphone/core/chat/ChatList.hpp index 31f9c1764..3623b02f9 100644 --- a/Linphone/core/chat/ChatList.hpp +++ b/Linphone/core/chat/ChatList.hpp @@ -51,7 +51,6 @@ signals: void chatRemoved(ChatGui *chat); void chatAdded(); void chatUpdated(); - void listAboutToBeReset(); private: QString mFilter; diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index 194bef870..47d683415 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -44,7 +44,6 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { connect(this, &ChatProxy::filterTextChanged, newChatList, [this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); connect(newChatList, &ChatList::chatRemoved, this, &ChatProxy::chatRemoved); - connect(newChatList, &ChatList::listAboutToBeReset, this, &ChatProxy::listAboutToBeReset); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); } diff --git a/Linphone/core/chat/ChatProxy.hpp b/Linphone/core/chat/ChatProxy.hpp index 8f4682c42..02a980ed6 100644 --- a/Linphone/core/chat/ChatProxy.hpp +++ b/Linphone/core/chat/ChatProxy.hpp @@ -44,7 +44,6 @@ public: signals: void chatRemoved(ChatGui *chat); - void listAboutToBeReset(); protected: QSharedPointer mList; diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index c7d3bbe0d..fa74ffb69 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -17,9 +17,8 @@ ListView { property string searchText: searchBar?.text property real busyIndicatorSize: Math.round(60 * DefaultStyle.dp) - property ChatGui currentChatGui - onCurrentIndexChanged: currentChatGui = model.getAt(currentIndex) || null - onChatClicked: (chat) => {currentChatGui = chat} + property ChatGui currentChatGui: model.getAt(currentIndex) || null + onChatClicked: (chat) => {selectChat(chat)} signal resultsReceived() signal markAllAsRead() @@ -44,7 +43,7 @@ ListView { onModelReset: { mainItem.resultsReceived() } - onListAboutToBeReset: { + onModelAboutToBeReset: { loading = true } onChatRemoved: { @@ -460,7 +459,6 @@ ListView { chatroomPopup.open() } else { mainItem.chatClicked(modelData) - mainItem.currentIndex = model.index } } }