summaryrefslogtreecommitdiffstats
path: root/src/pdf/quick
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-04-30 22:11:47 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2020-04-30 22:24:45 +0200
commit4a08034ca3b274e0309530bed4630521b8ad91c9 (patch)
tree11ab1e6c71d9ea6eecb31cfc68156e773e665db1 /src/pdf/quick
parentb918fed6ede79b5a1a1bb5f6d36ade9cb6d0a3f1 (diff)
PdfMultiPageView: add workaround to deal with scale change
TableViewExtra positionViewAtCell() / positionViewAtRow() merely set contentY (also contentX if needed); but if the delegates are changing in size, it goes undetected until one tries to scroll into a certain range where Flickable detects that originY needs to be adjusted. Getting TableView to do scheduleRebuildTable(RebuildOption::All) forces it to start over with delegate sizes too, as if the model was a QAIM that emitted modelReset(). Since our model is just a number, one way we can trigger that same behavior is to reassign it. This won't be needed when we have the newer TableView with positionViewAtCell() as a built-in function. Change-Id: I18e305b4ab19302464e289e2fc403b97346b1faa Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/pdf/quick')
-rw-r--r--src/pdf/quick/qml/PdfMultiPageView.qml12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml
index 9de9e1767..416026efc 100644
--- a/src/pdf/quick/qml/PdfMultiPageView.qml
+++ b/src/pdf/quick/qml/PdfMultiPageView.qml
@@ -119,7 +119,14 @@ Item {
id: tableView
anchors.fill: parent
anchors.leftMargin: 2
- model: root.document === undefined ? 0 : root.document.pageCount
+ model: modelInUse && root.document !== undefined ? root.document.pageCount : 0
+ // workaround to make TableView do scheduleRebuildTable(RebuildOption::All) in cases when forceLayout() doesn't
+ property bool modelInUse: true
+ function rebuild() {
+ modelInUse = false
+ modelInUse = true
+ }
+ // end workaround
rowSpacing: 6
property real rotationNorm: Math.round((360 + (root.pageRotation % 360)) % 360)
property bool rot90: rotationNorm == 90 || rotationNorm == 270
@@ -362,7 +369,8 @@ Item {
// and don't force layout either, because positionViewAtCell() will do that
if (navigationStack.jumping)
return
- tableView.forceLayout()
+ // make TableView rebuild from scratch, because otherwise it doesn't know the delegates are changing size
+ tableView.rebuild()
var cell = tableHelper.cellAtPos(root.width / 2, root.height / 2)
var currentItem = tableHelper.itemAtCell(cell)
if (currentItem) {