2
0
mirror of synced 2025-01-20 03:19:26 +00:00

chore(StatusChatList)!: Use SortFilterProxyModel instead of filtering functions (#823)

BREAKING CHANGE: StatusChatList has no longer filterFn, model is
intended to be already filtered externally
This commit is contained in:
Michał 2022-08-04 14:52:12 +02:00 committed by GitHub
parent 40992f6718
commit a563687bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 18 deletions

View File

@ -23,8 +23,6 @@ Column {
property Component popupMenu
property var filterFn
signal chatItemSelected(string categoryId, string id)
signal chatItemUnmuted(string id)
signal chatItemReordered(string id, int from, int to)
@ -45,13 +43,6 @@ Column {
height: statusChatListItem.height
property alias chatListItem: statusChatListItem
visible: {
if (!!statusChatList.filterFn) {
return statusChatList.filterFn(model)
}
return true
}
MouseArea {
id: dragSensor

View File

@ -7,6 +7,8 @@ import StatusQ.Components 0.1
import StatusQ.Popups 0.1
import StatusQ.Core 0.1
import SortFilterProxyModel 0.2
Item {
id: statusChatListAndCategories
@ -75,16 +77,27 @@ Item {
onChatItemUnmuted: statusChatListAndCategories.chatItemUnmuted(id)
onChatItemReordered: statusChatListAndCategories.chatItemReordered(categoryId, id, from, to)
draggableItems: statusChatListAndCategories.draggableItems
model: statusChatListAndCategories.model
filterFn: function (model) {
return !model.isCategory
model: SortFilterProxyModel {
sourceModel: statusChatListAndCategories.model
filters: ValueFilter { roleName: "isCategory"; value: false }
sorters: RoleSorter { roleName: "position" }
}
popupMenu: statusChatListAndCategories.chatListPopupMenu
}
DelegateModel {
id: delegateModel
model: statusChatListAndCategories.model
model: SortFilterProxyModel {
sourceModel: statusChatListAndCategories.model
filters: ValueFilter { roleName: "isCategory"; value: true }
sorters: RoleSorter { roleName: "position" }
}
delegate: Item {
id: draggable
width: statusChatListCategory.width
@ -139,7 +152,11 @@ Item {
showActionButtons: statusChatListAndCategories.showCategoryActionButtons
addButton.onClicked: statusChatListAndCategories.categoryAddButtonClicked(model.itemId)
chatList.model: model.subItems
chatList.model: SortFilterProxyModel {
sourceModel: model.subItems
sorters: RoleSorter { roleName: "position" }
}
chatList.onChatItemSelected: statusChatListAndCategories.chatItemSelected(categoryId, id)
chatList.onChatItemUnmuted: statusChatListAndCategories.chatItemUnmuted(id)
chatList.onChatItemReordered: statusChatListAndCategories.chatItemReordered(model.itemId, id, from, to)

View File

@ -35,7 +35,6 @@ Column {
StatusChatListCategoryItem {
id: statusChatListCategoryItem
title: statusChatListCategory.name
visible: model.isCategory
opened: statusChatListCategory.opened
sensor.pressAndHoldInterval: 150
@ -66,9 +65,6 @@ Column {
anchors.horizontalCenter: parent.horizontalCenter
visible: statusChatListCategory.opened
categoryId: statusChatListCategory.categoryId
filterFn: function (model) {
return !!model.parentItemId && model.parentItemId === statusChatList.categoryId
}
popupMenu: statusChatListCategory.chatListPopupMenu
}