2
0
mirror of synced 2025-02-01 01:07:28 +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 Component popupMenu
property var filterFn
signal chatItemSelected(string categoryId, string id) signal chatItemSelected(string categoryId, string id)
signal chatItemUnmuted(string id) signal chatItemUnmuted(string id)
signal chatItemReordered(string id, int from, int to) signal chatItemReordered(string id, int from, int to)
@ -45,13 +43,6 @@ Column {
height: statusChatListItem.height height: statusChatListItem.height
property alias chatListItem: statusChatListItem property alias chatListItem: statusChatListItem
visible: {
if (!!statusChatList.filterFn) {
return statusChatList.filterFn(model)
}
return true
}
MouseArea { MouseArea {
id: dragSensor id: dragSensor

View File

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

View File

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