Verified Commit 351e676f authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

taskmanager: Update rootIndex when visibility is changed

When there are two grouped tasks named A and B, and the position
of B is swapped with A (by dragging B), user can still see old
items of A in the textual list of grouped tasks B.

This is because in the original binding expression, both visualParent
and itemIndex are not changed, so QML will not re-evaluate the
expression.

To only update rootIndex when `groupDialog.visible` is true,
`Binding.when` is used, and `Binding.RestoreNone` is to avoid
sudden changes in height.

BUG: 446108
parent 0d847a02
Pipeline #103910 passed with stage
in 2 minutes and 41 seconds
......@@ -6,6 +6,7 @@
*/
import QtQuick 2.15
import QtQml 2.15
import QtQml.Models 2.2
import QtQuick.Window 2.2
......@@ -82,7 +83,11 @@ PlasmaCore.Dialog {
property int maxTextWidth: 0
model: groupDialog.visualParent ? tasksModel : null
rootIndex: groupDialog.visualParent ? tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex) : null
Binding on rootIndex { // Use Binding to re-evaluate rootIndex only when visible is true
value: tasksModel.makeModelIndex(groupDialog.visualParent.itemIndex)
when: groupDialog.visualParent && groupDialog.visible // implicitly using visible as a way to trigger re-evaluation
restoreMode: Binding.RestoreNone // Store rootIndex to avoid sudden changes in height
}
delegate: Task {
visible: true
inPopup: true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment