diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index 87778d97a..c021e1b93 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -25,7 +25,7 @@ DEFINE_ABSTRACT_OBJECT(ChatProxy) -ChatProxy::ChatProxy(QObject *parent) : LimitProxy(parent) { +ChatProxy::ChatProxy(QObject *parent) { mList = ChatList::create(); setSourceModel(mList.get()); setDynamicSortFilter(true); @@ -35,7 +35,7 @@ ChatProxy::~ChatProxy() { } void ChatProxy::setSourceModel(QAbstractItemModel *model) { - auto oldChatList = getListModel(); + auto oldChatList = dynamic_cast(sourceModel()); if (oldChatList) { disconnect(this, &ChatProxy::filterTextChanged, oldChatList, nullptr); disconnect(oldChatList, &ChatList::chatAdded, this, nullptr); @@ -52,20 +52,16 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); } - auto firstList = new SortFilterList(model, Qt::AscendingOrder); - firstList->setDynamicSortFilter(true); - setSourceModels(firstList); + QSortFilterProxyModel::setSourceModel(newChatList); sort(0); } int ChatProxy::findChatIndex(ChatGui *chatGui) { - auto chatList = getListModel(); + auto chatList = dynamic_cast(sourceModel()); if (chatList) { auto listIndex = chatList->findChatIndex(chatGui); if (listIndex != -1) { - listIndex = - dynamic_cast(sourceModel())->mapFromSource(chatList->index(listIndex, 0)).row(); - if (mMaxDisplayItems <= listIndex) setMaxDisplayItems(listIndex + mDisplayItemsStep); + listIndex = mapFromSource(chatList->index(listIndex, 0)).row(); return listIndex; } } @@ -73,17 +69,13 @@ int ChatProxy::findChatIndex(ChatGui *chatGui) { } void ChatProxy::addChatInList(ChatGui *chatGui) { - auto chatList = getListModel(); + auto chatList = dynamic_cast(sourceModel()); if (chatList && chatGui) { chatList->addChatInList(chatGui->mCore); } } -bool ChatProxy::SortFilterList::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { - return true; -} - -bool ChatProxy::SortFilterList::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { +bool ChatProxy::lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const { if (!mFilterText.isEmpty()) return false; auto l = getItemAtSource(sourceLeft.row()); auto r = getItemAtSource(sourceRight.row()); diff --git a/Linphone/core/chat/ChatProxy.hpp b/Linphone/core/chat/ChatProxy.hpp index f15ae999f..3f25ef2b5 100644 --- a/Linphone/core/chat/ChatProxy.hpp +++ b/Linphone/core/chat/ChatProxy.hpp @@ -21,24 +21,24 @@ #ifndef CHAT_PROXY_H_ #define CHAT_PROXY_H_ -#include "../proxy/LimitProxy.hpp" +#include "../proxy/SortFilterProxy.hpp" #include "core/chat/ChatGui.hpp" #include "core/chat/ChatList.hpp" #include "tool/AbstractObject.hpp" // ============================================================================= -class ChatProxy : public LimitProxy, public AbstractObject { +class ChatProxy : public SortFilterProxy, public AbstractObject { Q_OBJECT public: - DECLARE_SORTFILTER_CLASS() - ChatProxy(QObject *parent = Q_NULLPTR); ~ChatProxy(); void setSourceModel(QAbstractItemModel *sourceModel) override; + bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override; + Q_INVOKABLE int findChatIndex(ChatGui *chatGui); Q_INVOKABLE void addChatInList(ChatGui *chatGui); signals: diff --git a/Linphone/core/proxy/SortFilterProxy.cpp b/Linphone/core/proxy/SortFilterProxy.cpp index a7078f99e..887aad0d6 100644 --- a/Linphone/core/proxy/SortFilterProxy.cpp +++ b/Linphone/core/proxy/SortFilterProxy.cpp @@ -26,6 +26,9 @@ SortFilterProxy::SortFilterProxy(QAbstractItemModel *list) : QSortFilterProxyMod setSourceModel(list); } +SortFilterProxy::SortFilterProxy() { +} + SortFilterProxy::SortFilterProxy(QAbstractItemModel *list, Qt::SortOrder order) : SortFilterProxy(list) { sort(0, order); } diff --git a/Linphone/core/proxy/SortFilterProxy.hpp b/Linphone/core/proxy/SortFilterProxy.hpp index f604de42f..57a623d91 100644 --- a/Linphone/core/proxy/SortFilterProxy.hpp +++ b/Linphone/core/proxy/SortFilterProxy.hpp @@ -41,6 +41,7 @@ public: Q_PROPERTY(int filterType READ getFilterType WRITE setFilterType NOTIFY filterTypeChanged) Q_PROPERTY(QString filterText READ getFilterText WRITE setFilterText NOTIFY filterTextChanged) + SortFilterProxy(); SortFilterProxy(QAbstractItemModel *parent); SortFilterProxy(QAbstractItemModel *parent, Qt::SortOrder order); virtual ~SortFilterProxy(); diff --git a/Linphone/data/languages/de.ts b/Linphone/data/languages/de.ts index 7c925a107..bda7aaa3c 100644 --- a/Linphone/data/languages/de.ts +++ b/Linphone/data/languages/de.ts @@ -2112,65 +2112,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… - + chat_message_draft_sending_text - + chat_room_delete "Delete" Löschen - + chat_room_mute - + chat_room_unmute "Mute" - + chat_room_mark_as_read "Mark as read" - + chat_room_leave "leave" - + chat_list_leave_chat_popup_title leave the conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? - + chat_list_delete_chat_popup_title Delete the conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? @@ -2567,32 +2567,32 @@ Error - + chat_action_start_new_chat "New chat" - + chat_start_group_chat_title "Nouveau groupe" - + chat_action_start_group_chat "Créer" Erstellen - - - + + + information_popup_error_title Fehler - + information_popup_chat_creation_failed_message "La création a échoué" @@ -2603,25 +2603,25 @@ Error Der Codec konnte nicht installiert werden. - + group_chat_error_must_have_name "Un nom doit être donné au groupe - + group_chat_error_no_participant "Please select at least one participant - + group_call_error_not_connected "Vous n'etes pas connecté" Sie sind nicht verbunden - + chat_creation_in_progress Creation de la conversation en cours … @@ -3784,58 +3784,58 @@ Error EventLogCore - + conference_created_event - + conference_created_terminated - + conference_participant_added_event - + conference_participant_removed_event - - + + conference_security_event - + conference_ephemeral_message_enabled_event - + conference_ephemeral_message_lifetime_changed_event - + conference_ephemeral_message_disabled_event - + conference_subject_changed_event - + conference_participant_unset_admin_event - + conference_participant_set_admin_event diff --git a/Linphone/data/languages/en.ts b/Linphone/data/languages/en.ts index 39c40120a..cb1d33aa7 100644 --- a/Linphone/data/languages/en.ts +++ b/Linphone/data/languages/en.ts @@ -2089,65 +2089,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 is writing… - + chat_message_draft_sending_text Draft : %1 - + chat_room_delete "Delete" Delete - + chat_room_mute Mute - + chat_room_unmute "Mute" Unmute - + chat_room_mark_as_read "Mark as read" Mark as read - + chat_room_leave "leave" Leave - + chat_list_leave_chat_popup_title leave the conversation ? Leave the conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? - + chat_list_delete_chat_popup_title Delete the conversation ? Delete the conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? This conversation and all its messages will be deleted. Do You want to continue ? @@ -2541,56 +2541,56 @@ Only your correspondent can decrypt them. No conversation in history - + chat_action_start_new_chat "New chat" New conversation - + chat_start_group_chat_title "Nouveau groupe" New group - + chat_action_start_group_chat "Créer" Create - - - + + + information_popup_error_title Error - + information_popup_chat_creation_failed_message "La création a échoué" Creation failed - + group_chat_error_must_have_name "Un nom doit être donné au groupe A name must be set for the group - + group_chat_error_no_participant "Please select at least one participant Please select at least one participant - + group_call_error_not_connected "Vous n'etes pas connecté" You are not connected - + chat_creation_in_progress Creation de la conversation en cours … Chat creation pending… @@ -3703,59 +3703,59 @@ Only your correspondent can decrypt them. EventLogCore - + conference_created_event You have joined the group - + conference_created_terminated You have left the group - + conference_participant_added_event %1 has joined - + conference_participant_removed_event %1 is no longer in the conversation - + conference_participant_set_admin_event %1 is now an admin - + conference_participant_unset_admin_event %1 is no longer an admin - - + + conference_security_event Security level degraded by %1 - + conference_ephemeral_message_enabled_event Ephemeral messages enabled Expiration : %1 - + conference_ephemeral_message_disabled_event Ephemeral messages disabled - + conference_subject_changed_event New subject: %1 - + conference_ephemeral_message_lifetime_changed_event Ephemeral messages updated Expiration : %1 diff --git a/Linphone/data/languages/fr.ts b/Linphone/data/languages/fr.ts index 528b3566b..ef4b1efa6 100644 --- a/Linphone/data/languages/fr.ts +++ b/Linphone/data/languages/fr.ts @@ -2089,65 +2089,65 @@ ChatListView - + chat_message_is_writing_info %1 is writing… %1 est en train d'écrire… - + chat_message_draft_sending_text Brouillon : %1 - + chat_room_delete "Delete" Supprimer - + chat_room_mute Mettre en sourdine - + chat_room_unmute "Mute" Enlever la sourdine - + chat_room_mark_as_read "Mark as read" Marquer comme lu - + chat_room_leave "leave" Quitter la conversation - + chat_list_leave_chat_popup_title leave the conversation ? Quitter la conversation ? - + chat_list_leave_chat_popup_message You will not be able to send or receive messages in this conversation anymore. Do You want to continue ? Vous ne pourrez plus envoyer ou recevoir de messages dans cette conversation. Souhaitez-vous continuer ? - + chat_list_delete_chat_popup_title Delete the conversation ? Supprimer la conversation ? - + chat_list_delete_chat_popup_message This conversation and all its messages will be deleted. Do You want to continue ? La conversation et tous ses messages seront supprimés. Souhaitez-vous continuer ? @@ -2541,56 +2541,56 @@ en bout. Seul votre correspondant peut les déchiffrer. Aucune conversation dans votre historique - + chat_action_start_new_chat "New chat" Nouvelle conversation - + chat_start_group_chat_title "Nouveau groupe" Nouveau groupe - + chat_action_start_group_chat "Créer" Créer - - - + + + information_popup_error_title Erreur - + information_popup_chat_creation_failed_message "La création a échoué" La création a échoué - + group_chat_error_must_have_name "Un nom doit être donné au groupe Un nom doit être donné au groupe - + group_chat_error_no_participant "Please select at least one participant Veuillez sélectionner au moins un participant - + group_call_error_not_connected "Vous n'etes pas connecté" Vous n'êtes pas connecté - + chat_creation_in_progress Creation de la conversation en cours … Création de la conversation en cours… @@ -3703,60 +3703,60 @@ en bout. Seul votre correspondant peut les déchiffrer. EventLogCore - + conference_created_event Vous avez rejoint le groupe - + conference_created_terminated Vous avez quitté le groupe - + conference_participant_added_event %1 a rejoint le groupe - + conference_participant_removed_event %1 ne fait plus partie du groupe - - + + conference_security_event Niveau de sécurité dégradé par %1 - + conference_ephemeral_message_enabled_event Messages éphémères activés Expiration : %1 - + conference_ephemeral_message_lifetime_changed_event Messages éphémères mis à jour Expiration : %1 - + conference_ephemeral_message_disabled_event Messages éphémères désactivés - + conference_subject_changed_event Nouveau sujet : %1 - + conference_participant_unset_admin_event %1 n'est plus admin - + conference_participant_set_admin_event %1 est maintenant admin diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 18be99133..49d905162 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -40,11 +40,12 @@ ListView { onFilterTextChanged: { chatToSelectLater = currentChatGui } - initialDisplayItems: Math.max(20, Math.round(2 * mainItem.height / Utils.getSizeWithScreenRatio(56))) - displayItemsStep: 3 * initialDisplayItems / 2 onModelAboutToBeReset: { loading = true } + onModelReset: { + loading = false + } onRowsRemoved: { var index = mainItem.currentIndex mainItem.currentIndex = -1