diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml index 74368a95a6..f44fa2dad5 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml @@ -6,7 +6,6 @@ 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" @@ -277,10 +276,28 @@ ScrollView { } - model: messageProxyModel + model: messageListDelegate 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 fromAuthor: model.fromAuthor @@ -314,32 +331,24 @@ ScrollView { // 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 : "" + 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 + } 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 081c54814d..5c3028918d 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: "" - property string nextMsgTimestamp: "" + property string prevMsgTimestamp: chatsModel.messageList.getMessageData(prevMessageIndex, "timestamp") + property string nextMsgTimestamp: chatsModel.messageList.getMessageData(nextMessageIndex, "timestamp") 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 03988c5bbc..60a5b26096 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml @@ -3,7 +3,6 @@ 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" @@ -107,7 +106,7 @@ ModalPopup { ListView { anchors.fill: parent - model: communitiesProxyModel + model: communitiesDelegateModel spacing: 4 clip: true id: communitiesList @@ -125,9 +124,27 @@ ModalPopup { anchors.right: popup.right } } + } + DelegateModelGeneralized { + id: communitiesDelegateModel + lessThan: [ + function(left, right) { + return left.name.toLowerCase() < right.name.toLowerCase() + } + ] + + model: chatsModel.communities.list delegate: Item { - height: communityImage.height + Style.current.padding + // 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 width: parent.width Loader { @@ -202,28 +219,6 @@ 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 55ef9fb847..cd7161cef6 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml @@ -24,6 +24,7 @@ Item { } property string filterCategory: "" + property string searchStr: "" property bool isCompact: appSettings.useCompactMode property int contentType: 1 property bool muted: false @@ -42,8 +43,8 @@ Item { property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : "" // Hide the box if it is filtered out - property bool isVisible: categoryId === filterCategory - + property bool isVisible: categoryId === filterCategory && (searchStr === "" || name.includes(searchStr)) + id: wrapper anchors.right: parent.right anchors.top: applicationWindow.top diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml b/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml index f192d3a514..e7fcbbd53c 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/ChannelList.qml @@ -1,7 +1,6 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 import QtQuick.Layouts 1.13 -import SortFilterProxyModel 0.2 import "../../../../shared" import "../../../../imports" import "../components" @@ -20,18 +19,6 @@ Item { id: timer } - SortFilterProxyModel { - id: channelProxyModel - sourceModel: channelListContent.channelModel - filters: [ - RegExpFilter { - roleName: "name" - pattern: channelListContent.searchStr - caseSensitivity: Qt.CaseInsensitive - } - ] - } - ListView { id: chatGroupsListView spacing: 0 @@ -41,7 +28,7 @@ Item { anchors.right: parent.right anchors.left: parent.left interactive: false - model: channelProxyModel + model: channelListContent.channelModel delegate: Channel { name: model.name muted: model.muted @@ -52,6 +39,7 @@ 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 d3634f6d42..d026830f36 100644 --- a/ui/app/AppLayouts/Timeline/TimelineLayout.qml +++ b/ui/app/AppLayouts/Timeline/TimelineLayout.qml @@ -3,7 +3,6 @@ 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" @@ -111,10 +110,18 @@ ScrollView { flickDeceleration: 10000 interactive: false - model: messageProxyModel + model: messageListDelegate 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 fromAuthor: model.fromAuthor @@ -139,24 +146,16 @@ ScrollView { isStatusUpdate: true // 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 : "" - + 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; + } 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 acf2d352b5..305f2e2310 100644 --- a/ui/shared/ExistingContacts.qml +++ b/ui/shared/ExistingContacts.qml @@ -1,7 +1,6 @@ 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 @@ -26,12 +25,6 @@ Item { height: Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) - SortFilterProxyModel { - id: contactListProxyModel - sourceModel: profileModel.contacts.list - sorters: StringSorter { roleName: "name" } - } - ScrollView { anchors.fill: parent @@ -43,7 +36,7 @@ Item { spacing: 0 clip: true id: contactListView - model: contactListProxyModel + model: profileModel.contacts.list delegate: Contact { showCheckbox: root.showCheckbox isChecked: root.pubKeys.indexOf(model.pubKey) > -1 diff --git a/vendor/DOtherSide b/vendor/DOtherSide index 46ede2811b..eaa394d711 160000 --- a/vendor/DOtherSide +++ b/vendor/DOtherSide @@ -1 +1 @@ -Subproject commit 46ede2811b082d9478d21c679fec275147810bd1 +Subproject commit eaa394d711f757b859030349aeaf41a10e1bad2b