From a9964ab0f98d21b842e60020341688128de8daaf Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 6 May 2019 21:37:34 -0400 Subject: [PATCH] Fix roomCategoryDelegate height stuck to 0 --- harmonyqml/backend/model/sort_filter_proxy.py | 7 +++++++ harmonyqml/components/SidePane/RoomCategoryDelegate.qml | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/harmonyqml/backend/model/sort_filter_proxy.py b/harmonyqml/backend/model/sort_filter_proxy.py index de85ee54..e0526b5a 100644 --- a/harmonyqml/backend/model/sort_filter_proxy.py +++ b/harmonyqml/backend/model/sort_filter_proxy.py @@ -9,6 +9,7 @@ from .list_model import ListModel class SortFilterProxy(QSortFilterProxyModel): sortByRoleChanged = pyqtSignal() + countChanged = pyqtSignal(int) def __init__(self, source_model: ListModel, @@ -24,6 +25,7 @@ class SortFilterProxy(QSortFilterProxyModel): self.setSourceModel(source_model) source_model.rolesSet.connect(self._set_sort_role) + source_model.countChanged.connect(self.countChanged.emit) source_model.changed.connect(self._sort) self._sort_by_role = sort_by_role @@ -60,6 +62,11 @@ class SortFilterProxy(QSortFilterProxyModel): return self.__repr__() + @pyqtProperty(int, notify=countChanged) + def count(self) -> int: + return self.rowCount() + + def roleNames(self) -> Dict[int, bytes]: return self.sourceModel().roleNames() diff --git a/harmonyqml/components/SidePane/RoomCategoryDelegate.qml b/harmonyqml/components/SidePane/RoomCategoryDelegate.qml index b34d7ecf..853ebffc 100644 --- a/harmonyqml/components/SidePane/RoomCategoryDelegate.qml +++ b/harmonyqml/components/SidePane/RoomCategoryDelegate.qml @@ -5,8 +5,11 @@ import "../Base" Column { id: roomCategoryDelegate width: roomCategoriesList.width - height: roomList.model.rowCount() > 0 ? childrenRect.height : 0 - visible: roomList.model.rowCount() > 0 + + property int normalHeight: childrenRect.height // avoid binding loop + + height: roomList.model.count > 0 ? normalHeight : 0 + visible: roomList.model.count > 0 property string roomListUserId: userId property bool expanded: true