forked from qt-creator/qt-creator
QmlProfiler: changes in rangedetails and selection of items
Change-Id: Ic665596cd4f01459b69738363b64ee3b9e5d5b74 Reviewed-on: http://codereview.qt-project.org/6327 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -41,6 +41,8 @@ Rectangle {
|
||||
property int eventCount: 0;
|
||||
property real progress: 0;
|
||||
|
||||
property bool mouseOverSelection : true
|
||||
|
||||
// move the cursor in the editor
|
||||
signal updateCursorPosition
|
||||
property string fileName: ""
|
||||
@@ -58,6 +60,7 @@ Rectangle {
|
||||
root.eventCount = 0;
|
||||
rangeMover.x = 2
|
||||
rangeMover.opacity = 0
|
||||
hideRangeDetails();
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
@@ -87,6 +90,10 @@ Rectangle {
|
||||
rangeMover.x = Math.floor((eventStartTime + eventDuration - startTime) / xs - canvas.canvasWindow.x - rangeMover.zoomWidth/2);
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedEventIndex == -1) {
|
||||
selectionHighlight.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
function nextEvent() {
|
||||
@@ -111,14 +118,12 @@ Rectangle {
|
||||
|
||||
// 0.1 ms minimum zoom
|
||||
if (newZoom * Plotter.xScale(canvas) > 100000) {
|
||||
hideRangeDetails();
|
||||
rangeMover.zoomWidth = newZoom
|
||||
rangeMover.updateZoomControls();
|
||||
}
|
||||
}
|
||||
|
||||
function zoomOut() {
|
||||
hideRangeDetails();
|
||||
// 10%
|
||||
var newZoom = rangeMover.zoomWidth * 1.1;
|
||||
if (newZoom > canvas.width)
|
||||
@@ -193,6 +198,9 @@ Rectangle {
|
||||
rangeDetails.type = ""
|
||||
rangeDetails.file = ""
|
||||
rangeDetails.line = -1
|
||||
|
||||
root.mouseOverSelection = true;
|
||||
selectionHighlight.visible = false;
|
||||
}
|
||||
|
||||
//our main interaction view
|
||||
@@ -209,19 +217,6 @@ Rectangle {
|
||||
|
||||
clip:true
|
||||
|
||||
MouseArea {
|
||||
width: flick.width
|
||||
height: flick.contentHeight
|
||||
x: flick.contentX
|
||||
onClicked: {
|
||||
root.hideRangeDetails();
|
||||
}
|
||||
hoverEnabled: true
|
||||
onExited: {
|
||||
root.hideRangeDetails();
|
||||
}
|
||||
}
|
||||
|
||||
TimelineView {
|
||||
id: view
|
||||
|
||||
@@ -241,7 +236,18 @@ Rectangle {
|
||||
}
|
||||
startTime: rangeMover.value
|
||||
endTime: startTime + (rangeMover.zoomWidth*Plotter.xScale(canvas))
|
||||
onEndTimeChanged: updateTimeline()
|
||||
onEndTimeChanged: {
|
||||
updateTimeline();
|
||||
}
|
||||
|
||||
property real timeSpan: endTime - startTime
|
||||
onTimeSpanChanged: {
|
||||
if (selectedEventIndex != -1 && selectionHighlight.visible) {
|
||||
var spacing = flick.width / timeSpan;
|
||||
selectionHighlight.x = (qmlEventList.getStartTime(selectedEventIndex) - qmlEventList.firstTimeMark()) * spacing;
|
||||
selectionHighlight.width = qmlEventList.getDuration(selectedEventIndex) * spacing;
|
||||
}
|
||||
}
|
||||
|
||||
onCachedProgressChanged: root.progress = 0.5 + cachedProgress * 0.5;
|
||||
onCacheReady: {
|
||||
@@ -259,9 +265,7 @@ Rectangle {
|
||||
|
||||
delegate: Rectangle {
|
||||
id: obj
|
||||
|
||||
property color baseColor: Plotter.colors[type]
|
||||
property color myColor: baseColor
|
||||
property color myColor: Plotter.colors[type]
|
||||
|
||||
function conditionalHide() {
|
||||
if (!mouseArea.containsMouse)
|
||||
@@ -292,52 +296,23 @@ Rectangle {
|
||||
if (isSelected) {
|
||||
enableSelected(0, 0);
|
||||
}
|
||||
else
|
||||
disableSelected();
|
||||
}
|
||||
}
|
||||
|
||||
function enableSelected(x,y) {
|
||||
myColor = Qt.darker(baseColor, 1.2)
|
||||
rangeDetails.duration = qmlEventList.getDuration(index)/1000.0;
|
||||
rangeDetails.label = qmlEventList.getDetails(index);
|
||||
rangeDetails.file = qmlEventList.getFilename(index);
|
||||
rangeDetails.line = qmlEventList.getLine(index);
|
||||
rangeDetails.type = Plotter.names[type]
|
||||
|
||||
var margin = 10;
|
||||
|
||||
var pos = mapToItem(rangeDetails.parent , x, y)
|
||||
var preferredX = pos.x + margin;
|
||||
|
||||
// if over the right side of the window, render it left to the given pos
|
||||
if (preferredX + rangeDetails.width + margin > rangeDetails.parent.width)
|
||||
preferredX = pos.x - rangeDetails.width - margin;
|
||||
|
||||
// if window too narrow, put it at least in "margin" pixels
|
||||
if (preferredX < margin)
|
||||
preferredX = margin;
|
||||
|
||||
rangeDetails.x = preferredX
|
||||
|
||||
// center on current item
|
||||
var preferredY = pos.y + height/2 - rangeDetails.height/2;
|
||||
|
||||
// if too low, put it over the bottom of the window
|
||||
if (preferredY + rangeDetails.height - margin > root.height)
|
||||
preferredY = root.height - rangeDetails.height - margin;
|
||||
|
||||
// but never above the top of the window
|
||||
if (preferredY < margin)
|
||||
preferredY = margin;
|
||||
|
||||
rangeDetails.y = preferredY;
|
||||
|
||||
rangeDetails.visible = true
|
||||
}
|
||||
|
||||
function disableSelected() {
|
||||
myColor = baseColor
|
||||
selectionHighlight.x = obj.x;
|
||||
selectionHighlight.y = obj.y;
|
||||
selectionHighlight.width = width;
|
||||
selectionHighlight.height = height;
|
||||
selectionHighlight.visible = true;
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
@@ -345,36 +320,47 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: {
|
||||
if (root.mouseOverSelection) {
|
||||
root.mouseTracking = true;
|
||||
root.selectedEventIndex = index;
|
||||
enableSelected(mouseX, y);
|
||||
root.mouseTracking = false;
|
||||
}
|
||||
}
|
||||
|
||||
onPressed: {
|
||||
root.mouseTracking = true;
|
||||
root.selectedEventIndex = index;
|
||||
enableSelected(mouseX, y);
|
||||
root.mouseTracking = false;
|
||||
}
|
||||
onExited: {
|
||||
disableSelected();
|
||||
}
|
||||
|
||||
onClicked: root.gotoSourceLocation(rangeDetails.file, rangeDetails.line);
|
||||
root.mouseOverSelection = false;
|
||||
root.gotoSourceLocation(rangeDetails.file, rangeDetails.line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: selectionHighlight
|
||||
color:"transparent"
|
||||
border.width: 2
|
||||
border.color: "blue"
|
||||
radius: 2
|
||||
visible: false
|
||||
z:1
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
x: flick.contentX
|
||||
onClicked: root.hideRangeDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//popup showing the details for the hovered range
|
||||
RangeDetails {
|
||||
id: rangeDetails
|
||||
|
||||
// follow the flickable
|
||||
property int flickableX: flick.contentX;
|
||||
property int lastFlickableX;
|
||||
onXChanged: lastFlickableX = flickableX;
|
||||
onFlickableXChanged: {
|
||||
x = x - flickableX + lastFlickableX;
|
||||
if (visible && (x + width <= 0 || x > root.width)) {
|
||||
root.hideRangeDetails();
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -403,12 +389,6 @@ Rectangle {
|
||||
anchors.right: parent.right
|
||||
color: "#cccccc"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: root.hideRangeDetails();
|
||||
}
|
||||
}
|
||||
|
||||
//bottom border divider
|
||||
|
||||
Reference in New Issue
Block a user