From 9397d3a289a21f548cd0dc79d4561c42383fc07f Mon Sep 17 00:00:00 2001 From: Konrad Materka Date: Sat, 26 Dec 2020 13:05:45 +0100 Subject: [PATCH] [applets/systemtray] Simplify rowCount --- .../contents/ui/ExpandedRepresentation.qml | 2 +- .../package/contents/ui/HiddenItemsView.qml | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml b/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml index fa3fc0419..f01c3a250 100644 --- a/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml +++ b/applets/systemtray/package/contents/ui/ExpandedRepresentation.qml @@ -74,7 +74,7 @@ Item { PlasmaComponents.ToolButton { id: backButton - visible: systemTrayState.activeApplet && systemTrayState.activeApplet.expanded && (hiddenItemsView.itemCount > 0) + visible: systemTrayState.activeApplet && systemTrayState.activeApplet.expanded && (hiddenLayout.itemCount > 0) icon.name: LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic" onClicked: systemTrayState.setActiveApplet(null) } diff --git a/applets/systemtray/package/contents/ui/HiddenItemsView.qml b/applets/systemtray/package/contents/ui/HiddenItemsView.qml index 6f7475334..f7c45c86b 100644 --- a/applets/systemtray/package/contents/ui/HiddenItemsView.qml +++ b/applets/systemtray/package/contents/ui/HiddenItemsView.qml @@ -31,7 +31,6 @@ MouseArea { id: hiddenTasksView property alias layout: hiddenTasks - readonly property alias itemCount: hiddenTasks.itemCount hoverEnabled: true onExited: hiddenTasks.currentIndex = -1 @@ -57,11 +56,7 @@ MouseArea { highlight: PlasmaComponents.Highlight {} highlightMoveDuration: 0 - property int itemCount: model.rowCount() - - Component.onCompleted: { - itemCount = model.rowCount() - } + readonly property int itemCount: model.count model: PlasmaCore.SortFilterModel { sourceModel: plasmoid.nativeInterface.systemTrayModel @@ -73,14 +68,4 @@ MouseArea { delegate: ItemLoader {} } } - - Connections { - target: hiddenTasks.model - // hiddenTasks.count is not updated when ListView is hidden and is not rendered - // manually update itemCount so that expander arrow hides/shows itself correctly - function onModelReset() {hiddenTasks.itemCount = hiddenTasks.model.rowCount()} - function onRowsInserted() {hiddenTasks.itemCount = hiddenTasks.model.rowCount()} - function onRowsRemoved() {hiddenTasks.itemCount = hiddenTasks.model.rowCount()} - function onLayoutChanged() {hiddenTasks.itemCount = hiddenTasks.model.rowCount()} - } }