From 0c1917b838ed2eb227c3546a4e87618aef53266d Mon Sep 17 00:00:00 2001 From: JesusPoderoso Date: Mon, 13 Nov 2023 11:47:59 +0100 Subject: [PATCH] Refs #19743: [ARS] Refactor tree model filtering Signed-off-by: JesusPoderoso --- qml/StatusTreeView.qml | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/qml/StatusTreeView.qml b/qml/StatusTreeView.qml index 6371a37a..b91447cb 100644 --- a/qml/StatusTreeView.qml +++ b/qml/StatusTreeView.qml @@ -88,7 +88,8 @@ Flickable { Arrow } - property int current_filter_: -2 // backend::ID_ALL + readonly property int filter_all_: -2 // backend::ID_ALL + property int current_filter_: filter_all_ signal entity_status_filtered() property int handleStyle: StatusTreeView.Handle.TriangleSmallOutline @@ -106,7 +107,7 @@ Flickable { { target: root.model function onLayoutChanged() { - root.filter_model() + root.filter_model_by_id(root.current_filter_) } } @@ -176,26 +177,18 @@ Flickable { function clean_filter() { - root.filter_model() - model.filter_proxy(-2) + root.filter_model_by_id(filter_all_) tree.unfilter() } - function filter_model() + function filter_model_by_id(entityId) { - var filter_all = -2 // backend::ID_ALL - - if (current_filter_ != filter_all) + if (current_filter_ != entityId) { - current_filter_ = filter_all - root.filter_model_by_id(current_filter_) + current_filter_ = entityId } - } - - function filter_model_by_id(entityId) - { - model.filter_proxy(entityId) + model.filter_proxy(current_filter_) root.entity_status_filtered() - tree.filter(entityId) + tree.filter(current_filter_) } }