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:
parent
40992f6718
commit
a563687bf5
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user