forked from qt-creator/qt-creator
Timeline: Drop manual control of scale updates
The assumption that the scale entries only have to be updated when their stable index changes was wrong. The repeater can shuffle around, stash and restore items at will. It might restore some item at the same position, but the timestamp it refers to might have changed. Thus, the value being displayed was wrong until the timeline got scrolled. By using a proper binding we avoid this. In turn the blockStartTime might get re-evaluated twice for a single update to row.firstBlock. That would be bad as we would constantly re-render all the texts. Experiments show that the current implementation of the QML engine happens to order the bindings in a way where this doesn't happen and we cannot get better than this without huge overhead. Also, we simplify some of the expressions involved. Change-Id: I93848f89bdbefd28c3dbf30f13551c9476dabd37 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -82,12 +82,12 @@ Item {
|
||||
}
|
||||
|
||||
Item {
|
||||
x: Math.floor(firstBlock * timeDisplay.pixelsPerBlock - timeDisplay.offsetX)
|
||||
x: -(timeDisplay.offsetX % timeDisplay.pixelsPerBlock)
|
||||
y: 0
|
||||
id: row
|
||||
|
||||
property int firstBlock: timeDisplay.offsetX / timeDisplay.pixelsPerBlock
|
||||
property int offset: firstBlock % repeater.model
|
||||
property int offset: repeater.model - (firstBlock % repeater.model);
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
@@ -98,19 +98,16 @@ Item {
|
||||
|
||||
// Changing the text in text nodes is expensive. We minimize the number of changes
|
||||
// by rotating the nodes during scrolling.
|
||||
property int stableIndex: row.offset > index ? repeater.model - row.offset + index :
|
||||
index - row.offset
|
||||
property int stableIndex: (index + row.offset) % repeater.model
|
||||
|
||||
height: timeDisplay.height
|
||||
y: 0
|
||||
x: width * stableIndex
|
||||
width: timeDisplay.pixelsPerBlock
|
||||
|
||||
// Manually control this. We don't want it to happen when firstBlock
|
||||
// changes before stableIndex changes.
|
||||
onStableIndexChanged: block = row.firstBlock + stableIndex
|
||||
property int block: -1
|
||||
property double blockStartTime: block * timeDisplay.timePerBlock +
|
||||
timeDisplay.alignedWindowStart
|
||||
property double blockStartTime: (row.firstBlock + stableIndex)
|
||||
* timeDisplay.timePerBlock
|
||||
+ timeDisplay.alignedWindowStart
|
||||
|
||||
TimelineText {
|
||||
id: timeLabel
|
||||
|
||||
Reference in New Issue
Block a user