fix chat transfer #LINQT-2246

This commit is contained in:
Gaelle Braud 2025-12-10 11:52:22 +01:00
parent f173a887cd
commit fc42ada7ba
6 changed files with 16 additions and 6 deletions

View file

@ -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<ChatList> App::getChatList() const {
return mChatList;
}
ChatList *App::getChats() const {
return mChatList.get();
}
void App::setChatList(QSharedPointer<ChatList> data) {
if (mChatList != data) {
mChatList = data;

View file

@ -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<ConferenceInfoList> data);
QSharedPointer<ChatList> getChatList() const;
ChatList *getChats() const;
void setChatList(QSharedPointer<ChatList> data);
QSharedPointer<CallList> getCallList() const;

View file

@ -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);

View file

@ -30,6 +30,7 @@
class ChatProxy : public SortFilterProxy, public AbstractObject {
Q_OBJECT
Q_PROPERTY(QAbstractItemModel *model WRITE setSourceModel )
public:
ChatProxy(QObject *parent = Q_NULLPTR);

View file

@ -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

View file

@ -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: {