Fix roomCategoryDelegate height stuck to 0

This commit is contained in:
miruka 2019-05-06 21:37:34 -04:00
parent a3d0f32dc5
commit a9964ab0f9
2 changed files with 12 additions and 2 deletions

View File

@ -9,6 +9,7 @@ from .list_model import ListModel
class SortFilterProxy(QSortFilterProxyModel): class SortFilterProxy(QSortFilterProxyModel):
sortByRoleChanged = pyqtSignal() sortByRoleChanged = pyqtSignal()
countChanged = pyqtSignal(int)
def __init__(self, def __init__(self,
source_model: ListModel, source_model: ListModel,
@ -24,6 +25,7 @@ class SortFilterProxy(QSortFilterProxyModel):
self.setSourceModel(source_model) self.setSourceModel(source_model)
source_model.rolesSet.connect(self._set_sort_role) source_model.rolesSet.connect(self._set_sort_role)
source_model.countChanged.connect(self.countChanged.emit)
source_model.changed.connect(self._sort) source_model.changed.connect(self._sort)
self._sort_by_role = sort_by_role self._sort_by_role = sort_by_role
@ -60,6 +62,11 @@ class SortFilterProxy(QSortFilterProxyModel):
return self.__repr__() return self.__repr__()
@pyqtProperty(int, notify=countChanged)
def count(self) -> int:
return self.rowCount()
def roleNames(self) -> Dict[int, bytes]: def roleNames(self) -> Dict[int, bytes]:
return self.sourceModel().roleNames() return self.sourceModel().roleNames()

View File

@ -5,8 +5,11 @@ import "../Base"
Column { Column {
id: roomCategoryDelegate id: roomCategoryDelegate
width: roomCategoriesList.width 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 string roomListUserId: userId
property bool expanded: true property bool expanded: true