QmlProfiler: improve selection behavior in timeline

When selecting ranges in the timeline the selector would sometimes hang
or behave weirdly when moving back. This was due to incorrect logic in
the selection bounds calculation and because the vertical flicking would
steal mouse events.

Change-Id: I14074463422d1d9a0aa8ecd1f88847e7330c9b6b
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Ulf Hermann
2013-11-20 15:57:07 +01:00
parent 0489adf0cb
commit 2f8f51912c
2 changed files with 22 additions and 9 deletions

View File

@@ -309,8 +309,11 @@ Rectangle {
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
// ScrollView will try to deinteractivate it. We don't want that // ScrollView will try to deinteractivate it. We don't want that
// as the horizontal flickable is interactive, too. // as the horizontal flickable is interactive, too. We do occasionally
onInteractiveChanged: interactive = true // switch to non-interactive ourselves, though.
property bool stayInteractive: true
onInteractiveChanged: interactive = stayInteractive
onStayInteractiveChanged: interactive = stayInteractive
// ***** child items // ***** child items
TimeMarks { TimeMarks {
@@ -429,6 +432,9 @@ Rectangle {
onPressed: { onPressed: {
selectionRange.pressedOnCreation(); selectionRange.pressedOnCreation();
} }
onCanceled: {
selectionRange.releasedOnCreation();
}
onPositionChanged: { onPositionChanged: {
selectionRange.movedOnCreation(); selectionRange.movedOnCreation();
} }

View File

@@ -42,6 +42,7 @@ RangeMover {
property real duration: Math.max(getWidth() * viewTimePerPixel, 500) property real duration: Math.max(getWidth() * viewTimePerPixel, 500)
property real viewTimePerPixel: 1 property real viewTimePerPixel: 1
property int creationState : 0 property int creationState : 0
property int creationReference : 0
Connections { Connections {
target: zoomControl target: zoomControl
@@ -65,6 +66,7 @@ RangeMover {
function reset(setVisible) { function reset(setVisible) {
setRight(getLeft() + 1); setRight(getLeft() + 1);
creationState = 0; creationState = 0;
creationReference = 0;
visible = setVisible; visible = setVisible;
} }
@@ -75,18 +77,21 @@ RangeMover {
pos = width; pos = width;
switch (creationState) { switch (creationState) {
case 1: { case 1:
creationReference = pos;
setLeft(pos); setLeft(pos);
setRight(pos + 1); setRight(pos + 1);
break; break;
} case 2:
case 2: { if (pos > creationReference) {
setLeft(Math.min(getLeft(), pos)); setLeft(creationReference);
setRight(Math.max(getRight(), pos)); setRight(pos);
} else if (pos < creationReference) {
setLeft(pos);
setRight(creationReference);
}
break; break;
} }
default: return;
}
} }
@@ -104,6 +109,7 @@ RangeMover {
function releasedOnCreation() { function releasedOnCreation() {
if (selectionRange.creationState === 2) { if (selectionRange.creationState === 2) {
flick.interactive = true; flick.interactive = true;
vertflick.stayInteractive = true;
selectionRange.creationState = 3; selectionRange.creationState = 3;
selectionRangeControl.enabled = false; selectionRangeControl.enabled = false;
} }
@@ -112,6 +118,7 @@ RangeMover {
function pressedOnCreation() { function pressedOnCreation() {
if (selectionRange.creationState === 1) { if (selectionRange.creationState === 1) {
flick.interactive = false; flick.interactive = false;
vertflick.stayInteractive = false;
selectionRange.setPos(selectionRangeControl.mouseX + flick.contentX); selectionRange.setPos(selectionRangeControl.mouseX + flick.contentX);
selectionRange.creationState = 2; selectionRange.creationState = 2;
} }