From fc42ada7baccd0a00a12b11f57f9ae10b3ce3a59 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 10 Dec 2025 11:52:22 +0100 Subject: [PATCH] fix chat transfer #LINQT-2246 --- Linphone/core/App.cpp | 7 +++++++ Linphone/core/App.hpp | 2 ++ Linphone/core/chat/ChatProxy.cpp | 8 +++----- Linphone/core/chat/ChatProxy.hpp | 1 + Linphone/view/Control/Display/Chat/ChatListView.qml | 1 + Linphone/view/Page/Main/Chat/ChatPage.qml | 3 ++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 5a407517f..f97789d5f 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -635,6 +635,9 @@ void App::initCore() { }); if (!mCallList) setCallList(CallList::create()); else mCallList->lUpdate(); + if (!mChatList) setChatList(ChatList::create()); + else mChatList->lUpdate(); + if (!mSettings) { mSettings = settings; setLocale(settings->getConfigLocale()); @@ -1204,6 +1207,10 @@ QSharedPointer App::getChatList() const { return mChatList; } +ChatList *App::getChats() const { + return mChatList.get(); +} + void App::setChatList(QSharedPointer data) { if (mChatList != data) { mChatList = data; diff --git a/Linphone/core/App.hpp b/Linphone/core/App.hpp index 3168d39de..240fe4c49 100644 --- a/Linphone/core/App.hpp +++ b/Linphone/core/App.hpp @@ -47,6 +47,7 @@ class App : public SingleApplication, public AbstractObject { Q_PROPERTY(bool coreStarted READ getCoreStarted WRITE setCoreStarted NOTIFY coreStartedChanged) Q_PROPERTY(AccountList *accounts READ getAccounts NOTIFY accountsChanged) Q_PROPERTY(CallList *calls READ getCalls NOTIFY callsChanged) + Q_PROPERTY(ChatList *chats READ getChats NOTIFY chatsChanged) Q_PROPERTY(QString shortApplicationVersion READ getShortApplicationVersion CONSTANT) Q_PROPERTY(QString qtVersion READ getQtVersion CONSTANT) Q_PROPERTY(QString gitBranchName READ getGitBranchName CONSTANT) @@ -160,6 +161,7 @@ public: void setConferenceInfoList(QSharedPointer data); QSharedPointer getChatList() const; + ChatList *getChats() const; void setChatList(QSharedPointer data); QSharedPointer getCallList() const; diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index d56be470a..3440cef29 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -26,11 +26,7 @@ DEFINE_ABSTRACT_OBJECT(ChatProxy) ChatProxy::ChatProxy(QObject *parent) { - if (!App::getInstance()->getChatList()) { - mList = ChatList::create(); - App::getInstance()->setChatList(mList); - } - mList = App::getInstance()->getChatList(); + mList = ChatList::create(); setSourceModel(mList.get()); setDynamicSortFilter(true); } @@ -51,6 +47,8 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { [this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); + connect(newChatList, &ChatList::modelAboutToBeReset, this, &ChatProxy::modelAboutToBeReset); + connect(newChatList, &ChatList::modelReset, this, &ChatProxy::modelReset); } QSortFilterProxyModel::setSourceModel(newChatList); sort(0); diff --git a/Linphone/core/chat/ChatProxy.hpp b/Linphone/core/chat/ChatProxy.hpp index f9e6c48cf..63164f076 100644 --- a/Linphone/core/chat/ChatProxy.hpp +++ b/Linphone/core/chat/ChatProxy.hpp @@ -30,6 +30,7 @@ class ChatProxy : public SortFilterProxy, public AbstractObject { Q_OBJECT + Q_PROPERTY(QAbstractItemModel *model WRITE setSourceModel ) public: ChatProxy(QObject *parent = Q_NULLPTR); diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 3718f5498..6066b7b3a 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -15,6 +15,7 @@ ListView { property SearchBar searchBar property bool loading: false property string searchText: searchBar?.text + property alias chatProxy: chatProxy property real busyIndicatorSize: Utils.getSizeWithScreenRatio(60) property ChatGui currentChatGui: model.getAt(currentIndex) || null diff --git a/Linphone/view/Page/Main/Chat/ChatPage.qml b/Linphone/view/Page/Main/Chat/ChatPage.qml index 19b0bd7ad..44a143cba 100644 --- a/Linphone/view/Page/Main/Chat/ChatPage.qml +++ b/Linphone/view/Page/Main/Chat/ChatPage.qml @@ -62,7 +62,7 @@ AbstractMainPage { if (selectedChatGui) { if (!listStackView.currentItem || listStackView.currentItem.objectName !== "chatListItem") { listStackView.popToIndex(0) - if (listStackView.depth === 0 || listStackView.currentItem.objectName !== "chatListItem") listStackView.push(chatListItem) + if (listStackView.depth === 0 || listStackView.currentItem && listStackView.currentItem.objectName !== "chatListItem") listStackView.push(chatListItem) } } AppCpp.currentChat = visible ? selectedChatGui : null @@ -214,6 +214,7 @@ AbstractMainPage { Layout.fillHeight: true Layout.topMargin: Utils.getSizeWithScreenRatio(39) searchBar: searchBar + chatProxy.sourceModel: AppCpp.chats Control.ScrollBar.vertical: scrollbar onCurrentChatGuiChanged: {