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

3
.gitmodules vendored
View File

@ -10,3 +10,6 @@
[submodule "submodules/gel"] [submodule "submodules/gel"]
path = submodules/gel path = submodules/gel
url = https://github.com/Cutehacks/gel url = https://github.com/Cutehacks/gel
[submodule "submodules/SortFilterProxyModel"]
path = submodules/SortFilterProxyModel
url = https://github.com/oKcerG/SortFilterProxyModel

View File

@ -43,8 +43,7 @@ executables.files = $$TARGET
# Libraries includes # Libraries includes
include(submodules/qsyncable/qsyncable.pri) include(submodules/SortFilterProxyModel/SortFilterProxyModel.pri)
include(submodules/gel/com_cutehacks_gel.pri)
# Custom functions # Custom functions

View File

@ -45,11 +45,6 @@ class Account(ModelItem):
other_name = other.display_name or other.id[1:] other_name = other.display_name or other.id[1:]
return name.lower() < other_name.lower() return name.lower() < other_name.lower()
@property
def filter_string(self) -> str:
"""Filter based on display name."""
return self.display_name
@dataclass @dataclass
class Room(ModelItem): class Room(ModelItem):
@ -106,12 +101,6 @@ class Room(ModelItem):
(other.display_name or other.id).lower(), (other.display_name or other.id).lower(),
) )
@property
def filter_string(self) -> str:
"""Filter based on room display name, topic, and last event content."""
return " ".join((self.display_name, self.topic))
@dataclass @dataclass
class Member(ModelItem): class Member(ModelItem):

View File

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

View File

@ -1,66 +1,68 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12 import QtQuick 2.12
import SortFilterProxyModel 0.2
import ".." import ".."
import "../Base" import "../Base"
Column { Column {
id: delegate id: delegate
// visible: account.opacity > 0
property string userId: model.id property string userId: model.id
readonly property HListView view: ListView.view readonly property HListView view: ListView.view
readonly property bool hide:
mainPane.filter &&
roomList.model.count < 1 &&
! utils.filterMatches(mainPane.filter, model.display_name)
Account { Account {
id: account id: account
width: parent.width width: parent.width
view: delegate.view 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 { HListView {
id: roomList id: roomList
width: parent.width width: parent.width
height: contentHeight * opacity height: hide ? 0 : contentHeight
opacity: account.collapsed ? 0 : 1 visible: ! hide
visible: opacity > 0
interactive: false interactive: false
model: ModelStore.get(delegate.userId, "rooms") model: SortFilterProxyModel {
// model: HSortFilterProxy { sourceModel: ModelStore.get(delegate.userId, "rooms")
// 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.
// // Left rooms may still have an inviter_id, so check left first filters: [
// [ ExpressionFilter {
// a.left, expression: ! account.collapsed
// b.inviter_id, enabled: ! mainPane.filter
},
// b.last_event && b.last_event.date ? ExpressionFilter {
// b.last_event.date.getTime() : 0, expression: utils.filterMatches(
mainPane.filter, model.display_name,
// (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(),
// ]
// }
delegate: Room { delegate: Room {
width: roomList.width width: roomList.width
userId: delegate.userId userId: delegate.userId
} }
Behavior on opacity { Behavior on height { HNumberAnimation {} }
HNumberAnimation { easing.type: Easing.InOutCirc }
}
} }
} }

View File

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

View File

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

@ -0,0 +1 @@
Subproject commit 36befddf5d57faad990e72c88c5844794f274145