fix #LINQT-1910 wrong proxy index when chat list filtered

This commit is contained in:
Gaelle Braud 2025-08-26 12:33:27 +02:00
parent 4203a9c9c0
commit f516505287
5 changed files with 6 additions and 13 deletions

View file

@ -82,7 +82,7 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
mModelConnection = SafeConnection<ChatList, CoreModel>::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<ChatList> me) {
connectItem(chat);
}
mustBeInMainThread(getClassName());
clearData();
for (auto chat : *chats) {
add(chat);
}
add(*chats);
endResetModel();
delete chats;
});
});

View file

@ -51,7 +51,6 @@ signals:
void chatRemoved(ChatGui *chat);
void chatAdded();
void chatUpdated();
void listAboutToBeReset();
private:
QString mFilter;

View file

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

View file

@ -44,7 +44,6 @@ public:
signals:
void chatRemoved(ChatGui *chat);
void listAboutToBeReset();
protected:
QSharedPointer<ChatList> mList;

View file

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