revert: SortFilterProxyModel

This commit is contained in:
Richard Ramos 2021-06-22 14:30:51 -04:00 committed by Iuri Matias
parent f8e5b25a09
commit 1d3e5230b2
8 changed files with 79 additions and 94 deletions

View File

@ -6,7 +6,6 @@ import QtQuick.Layouts 1.13
import QtQml.Models 2.13 import QtQml.Models 2.13
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import SortFilterProxyModel 0.2
import "../../../../shared" import "../../../../shared"
import "../../../../shared/status" import "../../../../shared/status"
import "../../../../imports" import "../../../../imports"
@ -277,10 +276,28 @@ ScrollView {
} }
model: messageProxyModel model: messageListDelegate
section.property: "sectionIdentifier" section.property: "sectionIdentifier"
section.criteria: ViewSection.FullString 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 { delegate: Message {
id: msgDelegate id: msgDelegate
fromAuthor: model.fromAuthor fromAuthor: model.fromAuthor
@ -314,32 +331,24 @@ ScrollView {
// This is used in order to have access to the previous message and determine the timestamp // 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 // 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; prevMessageIndex: {
prevMsgTimestamp: prevMessageIndex > -1 ? messageProxyModel.get(prevMessageIndex).timestamp : "" // This is used in order to have access to the previous message and determine the timestamp
nextMessageIndex: msgDelegate.DelegateModel.itemsIndex <= 1 ? -1 : msgDelegate.DelegateModel.itemsIndex - 1; // we can't rely on the index because the sequence of messages is not ordered on the nim side
nextMsgTimestamp: nextMessageIndex > -1 ? messageProxyModel.get(nextMessageIndex).timestamp : "" 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 scrollToBottom: chatLogView.scrollToBottom
timeout: model.timeout 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;
}
}
}
} }
/*##^## /*##^##

View File

@ -66,8 +66,8 @@ Item {
property string authorCurrentMsg: "authorCurrentMsg" property string authorCurrentMsg: "authorCurrentMsg"
property string authorPrevMsg: "authorPrevMsg" property string authorPrevMsg: "authorPrevMsg"
property string prevMsgTimestamp: "" property string prevMsgTimestamp: chatsModel.messageList.getMessageData(prevMessageIndex, "timestamp")
property string nextMsgTimestamp: "" property string nextMsgTimestamp: chatsModel.messageList.getMessageData(nextMessageIndex, "timestamp")
property bool shouldRepeatHeader: ((parseInt(timestamp, 10) - parseInt(prevMsgTimestamp, 10)) / 60 / 1000) > Constants.repeatHeaderInterval property bool shouldRepeatHeader: ((parseInt(timestamp, 10) - parseInt(prevMsgTimestamp, 10)) / 60 / 1000) > Constants.repeatHeaderInterval

View File

@ -3,7 +3,6 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQml.Models 2.3 import QtQml.Models 2.3
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import SortFilterProxyModel 0.2
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../shared/status" import "../../../../shared/status"
@ -107,7 +106,7 @@ ModalPopup {
ListView { ListView {
anchors.fill: parent anchors.fill: parent
model: communitiesProxyModel model: communitiesDelegateModel
spacing: 4 spacing: 4
clip: true clip: true
id: communitiesList id: communitiesList
@ -125,9 +124,27 @@ ModalPopup {
anchors.right: popup.right anchors.right: popup.right
} }
} }
}
DelegateModelGeneralized {
id: communitiesDelegateModel
lessThan: [
function(left, right) {
return left.name.toLowerCase() < right.name.toLowerCase()
}
]
model: chatsModel.communities.list
delegate: Item { 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 width: parent.width
Loader { 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 { footer: StatusButton {

View File

@ -24,6 +24,7 @@ Item {
} }
property string filterCategory: "" property string filterCategory: ""
property string searchStr: ""
property bool isCompact: appSettings.useCompactMode property bool isCompact: appSettings.useCompactMode
property int contentType: 1 property int contentType: 1
property bool muted: false property bool muted: false
@ -42,8 +43,8 @@ Item {
property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : "" property string profileImage: realChatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : ""
// Hide the box if it is filtered out // Hide the box if it is filtered out
property bool isVisible: categoryId === filterCategory property bool isVisible: categoryId === filterCategory && (searchStr === "" || name.includes(searchStr))
id: wrapper id: wrapper
anchors.right: parent.right anchors.right: parent.right
anchors.top: applicationWindow.top anchors.top: applicationWindow.top

View File

@ -1,7 +1,6 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import SortFilterProxyModel 0.2
import "../../../../shared" import "../../../../shared"
import "../../../../imports" import "../../../../imports"
import "../components" import "../components"
@ -20,18 +19,6 @@ Item {
id: timer id: timer
} }
SortFilterProxyModel {
id: channelProxyModel
sourceModel: channelListContent.channelModel
filters: [
RegExpFilter {
roleName: "name"
pattern: channelListContent.searchStr
caseSensitivity: Qt.CaseInsensitive
}
]
}
ListView { ListView {
id: chatGroupsListView id: chatGroupsListView
spacing: 0 spacing: 0
@ -41,7 +28,7 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
interactive: false interactive: false
model: channelProxyModel model: channelListContent.channelModel
delegate: Channel { delegate: Channel {
name: model.name name: model.name
muted: model.muted muted: model.muted
@ -52,6 +39,7 @@ Item {
unviewedMessagesCount: model.unviewedMessagesCount unviewedMessagesCount: model.unviewedMessagesCount
hasMentions: model.hasMentions hasMentions: model.hasMentions
contentType: model.contentType contentType: model.contentType
searchStr: channelListContent.searchStr
categoryId: model.categoryId categoryId: model.categoryId
filterCategory: channelListContent.categoryId filterCategory: channelListContent.categoryId
chatId: model.id chatId: model.id

View File

@ -3,7 +3,6 @@ import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import QtQml.Models 2.13 import QtQml.Models 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import SortFilterProxyModel 0.2
import "../../../imports" import "../../../imports"
import "../../../shared" import "../../../shared"
import "../../../shared/status" import "../../../shared/status"
@ -111,10 +110,18 @@ ScrollView {
flickDeceleration: 10000 flickDeceleration: 10000
interactive: false interactive: false
model: messageProxyModel model: messageListDelegate
section.property: "sectionIdentifier" section.property: "sectionIdentifier"
section.criteria: ViewSection.FullString section.criteria: ViewSection.FullString
}
DelegateModelGeneralized {
id: messageListDelegate
lessThan: [
function(left, right) { return left.clock > right.clock }
]
model: chatsModel.messageList
delegate: Message { delegate: Message {
id: msgDelegate id: msgDelegate
fromAuthor: model.fromAuthor fromAuthor: model.fromAuthor
@ -139,24 +146,16 @@ ScrollView {
isStatusUpdate: true isStatusUpdate: true
// This is used in order to have access to the previous message and determine the timestamp // 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 // 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; prevMessageIndex: {
prevMsgTimestamp: prevMessageIndex > -1 ? messageProxyModel.get(prevMessageIndex).timestamp : "" // This is used in order to have access to the previous message and determine the timestamp
nextMessageIndex: msgDelegate.DelegateModel.itemsIndex <= 1 ? -1 : msgDelegate.DelegateModel.itemsIndex - 1; // we can't rely on the index because the sequence of messages is not ordered on the nim side
nextMsgTimestamp: nextMessageIndex > -1 ? messageProxyModel.get(nextMessageIndex).timestamp : "" if(msgDelegate.DelegateModel.itemsIndex > 0){
return messageListDelegate.items.get(msgDelegate.DelegateModel.itemsIndex - 1).model.index
}
return -1;
}
timeout: model.timeout timeout: model.timeout
} }
} }
SortFilterProxyModel {
id: messageProxyModel
sourceModel: chatsModel.messageList
sorters: ExpressionSorter {
expression: {
return modelLeft.clock > modelRight.clock;
}
}
}
} }
} }

View File

@ -1,7 +1,6 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import SortFilterProxyModel 0.2
import "../imports" import "../imports"
import "./status" import "./status"
// TODO move Contact into shared to get rid of that import // TODO move Contact into shared to get rid of that import
@ -26,12 +25,6 @@ Item {
height: Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) height: Math.min(contactListView.contentHeight, (expanded ? 320 : 192))
SortFilterProxyModel {
id: contactListProxyModel
sourceModel: profileModel.contacts.list
sorters: StringSorter { roleName: "name" }
}
ScrollView { ScrollView {
anchors.fill: parent anchors.fill: parent
@ -43,7 +36,7 @@ Item {
spacing: 0 spacing: 0
clip: true clip: true
id: contactListView id: contactListView
model: contactListProxyModel model: profileModel.contacts.list
delegate: Contact { delegate: Contact {
showCheckbox: root.showCheckbox showCheckbox: root.showCheckbox
isChecked: root.pubKeys.indexOf(model.pubKey) > -1 isChecked: root.pubKeys.indexOf(model.pubKey) > -1

2
vendor/DOtherSide vendored

@ -1 +1 @@
Subproject commit 46ede2811b082d9478d21c679fec275147810bd1 Subproject commit eaa394d711f757b859030349aeaf41a10e1bad2b