Working python proxy/filter for room list
This commit is contained in:
@@ -8,26 +8,12 @@ import "../Base"
|
||||
|
||||
HListView {
|
||||
id: roomList
|
||||
add: null // See the XXX comment in HListView.qml
|
||||
model: ModelStore.get("all_rooms")
|
||||
|
||||
model: HStringFilterModel {
|
||||
id: filterModel
|
||||
sourceModel: ModelStore.get("every_room")
|
||||
field: "display_name"
|
||||
|
||||
delegate: Room {
|
||||
id: room
|
||||
width: roomList.width
|
||||
onActivated: showRoomAtIndex(DelegateModel.filteredIndex)
|
||||
ListView.onAdd: ParallelAnimation {
|
||||
HNumberAnimation {
|
||||
target: room; property: "opacity"; from: 0; to: 1;
|
||||
}
|
||||
HNumberAnimation {
|
||||
target: room; property: "scale"; from: 0; to: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate: Room {
|
||||
id: room
|
||||
width: roomList.width
|
||||
onActivated: showRoomAtIndex(model.index)
|
||||
}
|
||||
|
||||
section.property: "for_account"
|
||||
@@ -39,14 +25,16 @@ HListView {
|
||||
accountModel: ModelStore.get("accounts").find(section)
|
||||
}
|
||||
|
||||
onFilterChanged: py.callCoro("set_substring_filter", ["all_rooms", filter])
|
||||
|
||||
property alias filter: filterModel.filter
|
||||
|
||||
property string filter: ""
|
||||
readonly property var sectionIndice: {
|
||||
const sections = {}
|
||||
let currentUserId = null
|
||||
|
||||
for (let i = 0; i < model.filtered.count; i++) {
|
||||
const userId = model.filtered.get(i).model.for_account
|
||||
for (let i = 0; i < model.count; i++) {
|
||||
const userId = model.get(i).for_account
|
||||
|
||||
if (userId !== currentUserId) {
|
||||
sections[userId] = i
|
||||
@@ -68,17 +56,17 @@ HListView {
|
||||
|
||||
function showRoomAtIndex(index=currentIndex) {
|
||||
if (index === -1) index = 0
|
||||
index = Math.min(index, model.filtered.count - 1)
|
||||
index = Math.min(index, model.count - 1)
|
||||
|
||||
const room = model.filtered.get(index).model
|
||||
const room = model.get(index)
|
||||
pageLoader.showRoom(room.for_account, room.id)
|
||||
currentIndex = index
|
||||
}
|
||||
|
||||
function showAccountRoomAtIndex(index) {
|
||||
const currentUserId = model.filtered.get(
|
||||
const currentUserId = model.get(
|
||||
currentIndex === -1 ? 0 : currentIndex
|
||||
).model.for_account
|
||||
).for_account
|
||||
|
||||
showRoomAtIndex(sectionIndice[currentUserId] + index)
|
||||
}
|
||||
|
Reference in New Issue
Block a user