forked from qt-creator/qt-creator
Tracing: Update selection range when timeline width changes
The viewTimePerPixel needs to be adapted then. Change-Id: Ie057c780cc75099f1b9df18c79c5e133411ef8e6 Fixes: QTCREATORBUG-22094 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -55,19 +55,7 @@ Rectangle {
|
||||
onRangeChanged: {
|
||||
zoomSliderToolBar.updateZoomLevel();
|
||||
content.scroll();
|
||||
|
||||
// If you select something in the main view and then resize the current range by some
|
||||
// other means, the selection should stay where it was.
|
||||
var oldTimePerPixel = selectionRange.viewTimePerPixel;
|
||||
selectionRange.viewTimePerPixel = zoomControl.rangeDuration / content.width;
|
||||
if (selectionRange.creationState === selectionRange.creationFinished &&
|
||||
oldTimePerPixel != selectionRange.viewTimePerPixel) {
|
||||
var newWidth = selectionRange.rangeWidth * oldTimePerPixel /
|
||||
selectionRange.viewTimePerPixel;
|
||||
selectionRange.rangeLeft = selectionRange.rangeLeft * oldTimePerPixel /
|
||||
selectionRange.viewTimePerPixel;
|
||||
selectionRange.rangeRight = selectionRange.rangeLeft + newWidth;
|
||||
}
|
||||
selectionRange.update();
|
||||
}
|
||||
onWindowChanged: {
|
||||
content.scroll();
|
||||
@@ -216,6 +204,8 @@ Rectangle {
|
||||
buttonsBar.updateLockButton(selectionLocked);
|
||||
}
|
||||
|
||||
onWidthChanged: selectionRange.update();
|
||||
|
||||
onPropagateSelection: {
|
||||
if (lockItemSelection || (newModel === selectedModel && newItem === selectedItem))
|
||||
return;
|
||||
@@ -314,6 +304,18 @@ Rectangle {
|
||||
root.selectionRangeMode = false;
|
||||
}
|
||||
|
||||
function update() {
|
||||
// If you select something in the main view and then resize the current range by some
|
||||
// other means, the selection should stay where it was.
|
||||
var oldTimePerPixel = viewTimePerPixel;
|
||||
viewTimePerPixel = zoomControl.rangeDuration / content.width;
|
||||
if (creationState === creationFinished && oldTimePerPixel != viewTimePerPixel) {
|
||||
var newWidth = rangeWidth * oldTimePerPixel / viewTimePerPixel;
|
||||
rangeLeft = rangeLeft * oldTimePerPixel / viewTimePerPixel;
|
||||
rangeRight = rangeLeft + newWidth;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user