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 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
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user