Get SortProxyFilterModel stuff working?

Came back from a break and forgot what I was fixing
This commit is contained in:
miruka
2020-02-03 16:19:42 -04:00
parent d8e18c3337
commit a653a6160a
8 changed files with 46 additions and 63 deletions

View File

@@ -12,7 +12,7 @@ HTileDelegate {
bottomPadding: topPadding
backgroundColor: theme.mainPane.account.background
opacity: collapsed && ! anyFilter ?
opacity: collapsed && ! mainPane.filter ?
theme.mainPane.account.collapsedOpacity : 1
title.color: theme.mainPane.account.name
@@ -51,8 +51,6 @@ HTileDelegate {
readonly property bool collapsed:
window.uiState.collapseAccounts[model.id] || false
readonly property bool anyFilter: Boolean(mainPaneList.filter)
function toggleCollapse() {
window.uiState.collapseAccounts[model.id] = ! collapsed
@@ -99,7 +97,7 @@ HTileDelegate {
leftPadding: theme.spacing / 2
rightPadding: leftPadding
opacity: ! loading && account.anyFilter ? 0 : 1
opacity: ! loading && mainPane.filter ? 0 : 1
visible: opacity > 0 && Layout.maximumWidth > 0
Layout.fillHeight: true

View File

@@ -1,66 +1,68 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import SortFilterProxyModel 0.2
import ".."
import "../Base"
Column {
id: delegate
// visible: account.opacity > 0
property string userId: model.id
readonly property HListView view: ListView.view
readonly property bool hide:
mainPane.filter &&
roomList.model.count < 1 &&
! utils.filterMatches(mainPane.filter, model.display_name)
Account {
id: account
width: parent.width
view: delegate.view
opacity: hide ?
0 :
collapsed && ! mainPane.filter ?
theme.mainPane.account.collapsedOpacity :
1
scale: hide ? opacity : 1
height: implicitHeight * (hide ? opacity : 1)
Behavior on opacity { HNumberAnimation {} }
}
HListView {
id: roomList
width: parent.width
height: contentHeight * opacity
opacity: account.collapsed ? 0 : 1
visible: opacity > 0
height: hide ? 0 : contentHeight
visible: ! hide
interactive: false
model: ModelStore.get(delegate.userId, "rooms")
// model: HSortFilterProxy {
// model: ModelStore.get(delegate.userId, "rooms")
// comparator: (a, b) =>
// // Sort by membership, then last event date (most recent first)
// // then room display name or ID.
// // Invited rooms are first, then joined rooms, then left rooms.
model: SortFilterProxyModel {
sourceModel: ModelStore.get(delegate.userId, "rooms")
// // Left rooms may still have an inviter_id, so check left first
// [
// a.left,
// b.inviter_id,
filters: [
ExpressionFilter {
expression: ! account.collapsed
enabled: ! mainPane.filter
},
// b.last_event && b.last_event.date ?
// b.last_event.date.getTime() : 0,
// (a.display_name || a.id).toLocaleLowerCase(),
// ] < [
// b.left,
// a.inviter_id,
// a.last_event && a.last_event.date ?
// a.last_event.date.getTime() : 0,
// (b.display_name || b.id).toLocaleLowerCase(),
// ]
// }
ExpressionFilter {
expression: utils.filterMatches(
mainPane.filter, model.display_name,
)
}
]
}
delegate: Room {
width: roomList.width
userId: delegate.userId
}
Behavior on opacity {
HNumberAnimation { easing.type: Easing.InOutCirc }
}
Behavior on height { HNumberAnimation {} }
}
}

View File

@@ -1,20 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import SortFilterProxyModel 0.2
import ".."
import "../Base"
HListView {
id: mainPaneList
model: ModelStore.get("accounts")
// model: HSortFilterProxy {
// model: ModelStore.get("accounts")
// comparator: (a, b) =>
// // Sort by display name or user ID
// (a.display_name || a.id).toLocaleLowerCase() <
// (b.display_name || b.id).toLocaleLowerCase()
// }
delegate: AccountRoomsDelegate {
width: mainPaneList.width
@@ -22,9 +15,6 @@ HListView {
}
readonly property string filter: toolBar.roomFilter
function previous(activate=true) {
decrementCurrentIndex()
if (activate) activateLimiter.restart()
@@ -58,7 +48,7 @@ HListView {
}
function toggleCollapseAccount() {
if (filter) return
if (mainPane.filter) return
if (! currentItem) incrementCurrentIndex()

View File

@@ -11,9 +11,10 @@ HDrawer {
minimumSize: theme.controls.avatar.size + theme.spacing * 2
property bool hasFocus: toolBar.filterField.activeFocus
property alias mainPaneList: mainPaneList
property alias toolBar: toolBar
readonly property bool hasFocus: toolBar.filterField.activeFocus
readonly property alias mainPaneList: mainPaneList
readonly property alias toolBar: toolBar
property alias filter: toolBar.roomFilter
function toggleFocus() {