diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml index b562d4561c..5f40ca500c 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml @@ -6,6 +6,7 @@ import QtQuick.Layouts 1.13 import QtQml.Models 2.13 import QtGraphicalEffects 1.13 import QtQuick.Dialogs 1.3 +import SortFilterProxyModel 0.2 import "../../../../shared" import "../../../../shared/status" import "../../../../imports" @@ -276,26 +277,9 @@ ScrollView { } - model: messageListDelegate + model: messageProxyModel section.property: "sectionIdentifier" section.criteria: ViewSection.FullString - } - - MessageDialog { - id: sendingMsgFailedPopup - standardButtons: StandardButton.Ok - //% "Failed to send message." - text: qsTrId("failed-to-send-message-") - icon: StandardIcon.Critical - } - - DelegateModelGeneralized { - id: messageListDelegate - lessThan: [ - function(left, right) { return left.clock > right.clock } - ] - - model: messageList delegate: Message { id: msgDelegate @@ -327,24 +311,35 @@ ScrollView { pinnedBy: model.pinnedBy gapFrom: model.gapFrom gapTo: model.gapTo - prevMessageIndex: { - // This is used in order to have access to the previous message and determine the timestamp - // we can't rely on the index because the sequence of messages is not ordered on the nim side - if (msgDelegate.DelegateModel.itemsIndex < messageListDelegate.items.count - 1) { - return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex + 1).model.index - } - return -1; - } - nextMessageIndex: { - if (msgDelegate.DelegateModel.itemsIndex <= 1) { - return -1 - } - return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index - } + + // This is used in order to have access to the previous message and determine the timestamp + // we can't rely on the index because the sequence of messages is not ordered on the nim side + prevMessageIndex: msgDelegate.DelegateModel.itemsIndex < messageProxyModel.count - 1 ? msgDelegate.DelegateModel.itemsIndex + 1 : -1; + prevMsgTimestamp: prevMessageIndex > -1 ? messageProxyModel.get(prevMessageIndex).timestamp : "" + nextMessageIndex: msgDelegate.DelegateModel.itemsIndex <= 1 ? -1 : msgDelegate.DelegateModel.itemsIndex - 1; + nextMsgTimestamp: nextMessageIndex > -1 ? messageProxyModel.get(nextMessageIndex).timestamp : "" scrollToBottom: chatLogView.scrollToBottom timeout: model.timeout } } + + MessageDialog { + id: sendingMsgFailedPopup + standardButtons: StandardButton.Ok + //% "Failed to send message." + text: qsTrId("failed-to-send-message-") + icon: StandardIcon.Critical + } + + SortFilterProxyModel { + id: messageProxyModel + sourceModel: messageList + sorters: ExpressionSorter { + expression: { + return modelLeft.clock > modelRight.clock; + } + } + } } /*##^## diff --git a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml index 27536e0e4f..0c50074c51 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml @@ -66,8 +66,8 @@ Item { property string authorCurrentMsg: "authorCurrentMsg" property string authorPrevMsg: "authorPrevMsg" - property string prevMsgTimestamp: chatsModel.messageList.getMessageData(prevMessageIndex, "timestamp") - property string nextMsgTimestamp: chatsModel.messageList.getMessageData(nextMessageIndex, "timestamp") + property string prevMsgTimestamp: "" + property string nextMsgTimestamp: "" property bool shouldRepeatHeader: ((parseInt(timestamp, 10) - parseInt(prevMsgTimestamp, 10)) / 60 / 1000) > Constants.repeatHeaderInterval diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml index 4d7e472012..03988c5bbc 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import QtQml.Models 2.3 import QtGraphicalEffects 1.13 +import SortFilterProxyModel 0.2 import "../../../../imports" import "../../../../shared" import "../../../../shared/status" @@ -106,7 +107,7 @@ ModalPopup { ListView { anchors.fill: parent - model: communitiesDelegateModel + model: communitiesProxyModel spacing: 4 clip: true id: communitiesList @@ -125,27 +126,8 @@ ModalPopup { } } - } - - DelegateModelGeneralized { - id: communitiesDelegateModel - lessThan: [ - function(left, right) { - return left.name.toLowerCase() < right.name.toLowerCase() - } - ] - - model: chatsModel.communities.list delegate: Item { - // TODO add the search for the name and category once they exist - visible: { - if (!searchBox.text) { - return true - } - const lowerCaseSearchStr = searchBox.text.toLowerCase() - return name.toLowerCase().includes(lowerCaseSearchStr) || description.toLowerCase().includes(lowerCaseSearchStr) - } - height: visible ? communityImage.height + Style.current.padding : 0 + height: communityImage.height + Style.current.padding width: parent.width Loader { @@ -220,6 +202,28 @@ ModalPopup { } } } + + SortFilterProxyModel { + id: communitiesProxyModel + sourceModel: chatsModel.communities.list + sorters: StringSorter { + roleName: "name" + caseSensitivity: Qt.CaseInsensitive + } + filters: AnyOf { + // TODO add the search for the category once it exist + RegExpFilter { + roleName: "name" + pattern: searchBox.text + caseSensitivity: Qt.CaseInsensitive + } + RegExpFilter { + roleName: "description" + pattern: searchBox.text + caseSensitivity: Qt.CaseInsensitive + } + } + } } footer: StatusButton { diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml index beb86f155c..55ef9fb847 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml @@ -24,7 +24,6 @@ Item { } property string filterCategory: "" - property string searchStr: "" property bool isCompact: appSettings.useCompactMode property int contentType: 1 property bool muted: false @@ -43,7 +42,7 @@ Item { property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : "" // Hide the box if it is filtered out - property bool isVisible: categoryId === filterCategory && (searchStr === "" || name.includes(searchStr)) + property bool isVisible: categoryId === filterCategory id: wrapper anchors.right: parent.right diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml b/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml index 20cd9bbcad..83edd0e38d 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml @@ -1,6 +1,7 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 +import SortFilterProxyModel 0.2 import "../../../../shared" import "../../../../imports" import "../components" @@ -19,6 +20,18 @@ Item { id: timer } + SortFilterProxyModel { + id: channelProxyModel + sourceModel: channelListContent.channelModel + filters: [ + RegExpFilter { + roleName: "name" + pattern: channelListContent.searchStr + caseSensitivity: Qt.CaseInsensitive + } + ] + } + ListView { id: chatGroupsListView spacing: 0 @@ -28,7 +41,7 @@ Item { anchors.right: parent.right anchors.left: parent.left interactive: false - model: channelListContent.channelModel + model: channelProxyModel delegate: Channel { name: model.name muted: model.muted @@ -39,7 +52,6 @@ Item { unviewedMessagesCount: model.unviewedMessagesCount hasMentions: model.hasMentions contentType: model.contentType - searchStr: channelListContent.searchStr categoryId: model.categoryId filterCategory: channelListContent.categoryId chatId: model.id diff --git a/ui/app/AppLayouts/Timeline/TimelineLayout.qml b/ui/app/AppLayouts/Timeline/TimelineLayout.qml index 96f80224b0..eaa6affc78 100644 --- a/ui/app/AppLayouts/Timeline/TimelineLayout.qml +++ b/ui/app/AppLayouts/Timeline/TimelineLayout.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.13 import QtGraphicalEffects 1.13 import QtQml.Models 2.13 import QtQuick.Layouts 1.13 +import SortFilterProxyModel 0.2 import "../../../imports" import "../../../shared" import "../../../shared/status" @@ -110,18 +111,9 @@ ScrollView { flickDeceleration: 10000 interactive: false - model: messageListDelegate + model: messageProxyModel section.property: "sectionIdentifier" section.criteria: ViewSection.FullString - } - - DelegateModelGeneralized { - id: messageListDelegate - lessThan: [ - function(left, right) { return left.clock > right.clock } - ] - - model: chatsModel.messageList delegate: Message { id: msgDelegate @@ -145,16 +137,26 @@ ScrollView { messageId: model.messageId emojiReactions: model.emojiReactions isStatusUpdate: true - prevMessageIndex: { - // This is used in order to have access to the previous message and determine the timestamp - // we can't rely on the index because the sequence of messages is not ordered on the nim side - if(msgDelegate.DelegateModel.itemsIndex > 0){ - return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index - } - return -1; - } + // This is used in order to have access to the previous message and determine the timestamp + // we can't rely on the index because the sequence of messages is not ordered on the nim side + prevMessageIndex: msgDelegate.DelegateModel.itemsIndex < messageProxyModel.count - 1 ? msgDelegate.DelegateModel.itemsIndex + 1 : -1; + prevMsgTimestamp: prevMessageIndex > -1 ? messageProxyModel.get(prevMessageIndex).timestamp : "" + nextMessageIndex: msgDelegate.DelegateModel.itemsIndex <= 1 ? -1 : msgDelegate.DelegateModel.itemsIndex - 1; + nextMsgTimestamp: nextMessageIndex > -1 ? messageProxyModel.get(nextMessageIndex).timestamp : "" + timeout: model.timeout } } + + SortFilterProxyModel { + id: messageProxyModel + sourceModel: chatsModel.messageList + sorters: ExpressionSorter { + expression: { + return modelLeft.clock > modelRight.clock; + } + } + } + } } diff --git a/ui/shared/ExistingContacts.qml b/ui/shared/ExistingContacts.qml index a328073259..acf2d352b5 100644 --- a/ui/shared/ExistingContacts.qml +++ b/ui/shared/ExistingContacts.qml @@ -1,6 +1,7 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 +import SortFilterProxyModel 0.2 import "../imports" import "./status" // TODO move Contact into shared to get rid of that import @@ -24,6 +25,13 @@ Item { } height: Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) + + SortFilterProxyModel { + id: contactListProxyModel + sourceModel: profileModel.contacts.list + sorters: StringSorter { roleName: "name" } + } + ScrollView { anchors.fill: parent @@ -35,7 +43,7 @@ Item { spacing: 0 clip: true id: contactListView - model: profileModel.contacts.list + model: contactListProxyModel delegate: Contact { showCheckbox: root.showCheckbox isChecked: root.pubKeys.indexOf(model.pubKey) > -1 diff --git a/vendor/DOtherSide b/vendor/DOtherSide index eaa394d711..46ede2811b 160000 --- a/vendor/DOtherSide +++ b/vendor/DOtherSide @@ -1 +1 @@ -Subproject commit eaa394d711f757b859030349aeaf41a10e1bad2b +Subproject commit 46ede2811b082d9478d21c679fec275147810bd1