Tracing: Untangle dependencies between CategoryLabel and TimelineLabels

CategoryLabel only needs a parent for the dragger and a way to position
itself. It doesn't need all the other properties of TimelineLabels.

Change-Id: I33b94ec6ae7bf2a54e233e9e6c1b3e30ff9c19d2
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Ulf Hermann
2022-03-16 13:53:01 +01:00
parent ffbd1ed7b5
commit df8d01dd1e
2 changed files with 9 additions and 4 deletions

View File

@@ -41,7 +41,10 @@ Item {
property int visualIndex property int visualIndex
property int dragOffset property int dragOffset
property Item draggerParent property Item draggerParent
property int contentBottom: draggerParent.contentY + draggerParent.height - dragOffset property real contentY: 0
property real contentHeight: draggerParent.height
property real visibleHeight: contentHeight
property int contentBottom: contentY + visibleHeight - dragOffset
signal dragStarted; signal dragStarted;
signal dragStopped; signal dragStopped;
@@ -59,7 +62,7 @@ Item {
drag.target: dragger drag.target: dragger
cursorShape: dragging ? Qt.ClosedHandCursor : Qt.OpenHandCursor cursorShape: dragging ? Qt.ClosedHandCursor : Qt.OpenHandCursor
drag.minimumY: dragging ? 0 : -dragOffset // Account for parent change below drag.minimumY: dragging ? 0 : -dragOffset // Account for parent change below
drag.maximumY: draggerParent.height - (dragging ? 0 : dragOffset) drag.maximumY: visibleHeight - (dragging ? 0 : dragOffset)
drag.axis: Drag.YAxis drag.axis: Drag.YAxis
hoverEnabled: true hoverEnabled: true
ToolTip { ToolTip {
@@ -112,8 +115,7 @@ Item {
// Initially y == 0 for all the items. Don't enable them until they have been moved // Initially y == 0 for all the items. Don't enable them until they have been moved
// into place. // into place.
property int offset: (index === 0 || y > 0) ? (y + txt.height) property int offset: (index === 0 || y > 0) ? (y + txt.height) : contentHeight
: draggerParent.contentHeight
active: contentBottom > offset active: contentBottom > offset
width: labelContainer.width width: labelContainer.width
height: labelsArea.parentModel ? labelsArea.parentModel.rowHeight(index + 1) : 0 height: labelsArea.parentModel ? labelsArea.parentModel.rowHeight(index + 1) : 0

View File

@@ -102,6 +102,9 @@ Flickable {
onDragStarted: categories.dragging = true onDragStarted: categories.dragging = true
onDragStopped: categories.dragging = false onDragStopped: categories.dragging = false
draggerParent: categories draggerParent: categories
contentY: categories.contentY
contentHeight: categories.contentHeight
visibleHeight: categories.height
width: 150 width: 150
height: parent.height height: parent.height
dragOffset: loader.y dragOffset: loader.y