Fix roomCategoryDelegate height stuck to 0
This commit is contained in:
parent
a3d0f32dc5
commit
a9964ab0f9
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user