From fca66244ab1720def72bfcc27997e7a9982954a2 Mon Sep 17 00:00:00 2001 From: Aniket Kumar Date: Thu, 7 May 2020 18:52:28 +0530 Subject: [PATCH] improved sorting and filtering methods --- smsapp/conversationssortfilterproxymodel.cpp | 16 ++-------------- smsapp/qml/ConversationList.qml | 1 + 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/smsapp/conversationssortfilterproxymodel.cpp b/smsapp/conversationssortfilterproxymodel.cpp index 659b0ce42..f90a26b32 100644 --- a/smsapp/conversationssortfilterproxymodel.cpp +++ b/smsapp/conversationssortfilterproxymodel.cpp @@ -44,19 +44,6 @@ void ConversationsSortFilterProxyModel::setConversationsFilterRole(int role) bool ConversationsSortFilterProxyModel::lessThan(const QModelIndex& leftIndex, const QModelIndex& rightIndex) const { - // This if block checks for multitarget conversations and sorts it at bottom of the list when the filtring is done on the basis of SenderRole - // This keeps the individual contacts with matching address at the top of the list - if (filterRole() == ConversationListModel::AddressesRole) { - const bool isLeftMultitarget = sourceModel()->data(leftIndex, ConversationListModel::MultitargetRole).toBool(); - const bool isRightMultitarget = sourceModel()->data(rightIndex, ConversationListModel::MultitargetRole).toBool(); - if (isLeftMultitarget && !isRightMultitarget) { - return true; - } - if (!isLeftMultitarget && isRightMultitarget) { - return false; - } - } - QVariant leftDataTimeStamp = sourceModel()->data(leftIndex, ConversationListModel::DateRole); QVariant rightDataTimeStamp = sourceModel()->data(rightIndex, ConversationListModel::DateRole); @@ -82,7 +69,8 @@ bool ConversationsSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QM // This block of code compares each address in the multi target conversation to find a match QList addressList = sourceModel()->data(index, ConversationListModel::AddressesRole).value>(); for (const ConversationAddress address : addressList) { - if (address.address().contains(filterRegExp())) { + QString canonicalAddress = SmsHelper::canonicalizePhoneNumber(address.address()); + if (canonicalAddress.contains(filterRegExp())) { return true; } } diff --git a/smsapp/qml/ConversationList.qml b/smsapp/qml/ConversationList.qml index 6e9f0a6c2..0388ff293 100644 --- a/smsapp/qml/ConversationList.qml +++ b/smsapp/qml/ConversationList.qml @@ -213,6 +213,7 @@ Kirigami.ScrollablePage conversationListModel.createConversationForAddress(filter.text) view.currentIndex = 0 } + filter.enabled = true } Shortcut {