revert: SortFilterProxyModel
This commit is contained in:
parent
f8e5b25a09
commit
1d3e5230b2
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*##^##
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 46ede2811b082d9478d21c679fec275147810bd1
|
||||
Subproject commit eaa394d711f757b859030349aeaf41a10e1bad2b
|
Loading…
Reference in New Issue