summaryrefslogtreecommitdiffstats
path: root/src/pdf/quick/qquickpdfnavigationstack.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-18 21:42:35 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-20 09:48:59 +0100
commitf467edc97e66727be7fa3747913e4e01672d4b71 (patch)
treed55afd400b398585006bbdf092230b053a3358da /src/pdf/quick/qquickpdfnavigationstack.cpp
parent1acd9ad2bfa1c54f19fa8a71fb41e8a90233f76b (diff)
PdfMultiPageView: use TableView; horz. scroll; control page position
TableView is missing some features compared to ListView; so finding out where we currently are (which row) and programmatic positioning on a specific y coordinate of a specific row require some workarounds for now, including helpers in PdfDocument. TableView also assumes (and sporadically enforces) that all cells in a column have the same width. So we need a placeholder Item for each page. This also helps with rotation: the placeholder is now as wide as the window or the image, whichever is wider, and the "paper" is centered within; thus there's always room to rotate it. There's still some problem with setting contentY in goToPage() after the page has been zoomed to a size larger than the window: the values look correct, but it scrolls too far. But on the plus side, horizontal scrolling works. So now we attempt to control the horizontal position too: NavigationStack tracks it, and can go back to a previous position; and links can in theory jump to specific positions and zoom levels, scrolling horizontally such that a specific x coordinate is visible. Includes minor UI tweaks to make it look better on iOS. Change-Id: I643d8ef48ef815aeb49cae77dcb84c3682563d56 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/pdf/quick/qquickpdfnavigationstack.cpp')
-rw-r--r--src/pdf/quick/qquickpdfnavigationstack.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/pdf/quick/qquickpdfnavigationstack.cpp b/src/pdf/quick/qquickpdfnavigationstack.cpp
index 51f65f032..7ba317557 100644
--- a/src/pdf/quick/qquickpdfnavigationstack.cpp
+++ b/src/pdf/quick/qquickpdfnavigationstack.cpp
@@ -80,11 +80,11 @@ void QQuickPdfNavigationStack::forward()
++m_currentHistoryIndex;
m_changing = true;
emit jumped(currentPage(), currentLocation(), currentZoom());
+ if (currentZoomWas != currentZoom())
+ emit currentZoomChanged();
emit currentPageChanged();
if (currentLocationWas != currentLocation())
emit currentLocationChanged();
- if (currentZoomWas != currentZoom())
- emit currentZoomChanged();
if (!backAvailableWas)
emit backAvailableChanged();
if (forwardAvailableWas != forwardAvailable())
@@ -110,11 +110,11 @@ void QQuickPdfNavigationStack::back()
--m_currentHistoryIndex;
m_changing = true;
emit jumped(currentPage(), currentLocation(), currentZoom());
+ if (currentZoomWas != currentZoom())
+ emit currentZoomChanged();
emit currentPageChanged();
if (currentLocationWas != currentLocation())
emit currentLocationChanged();
- if (currentZoomWas != currentZoom())
- emit currentZoomChanged();
if (backAvailableWas != backAvailable())
emit backAvailableChanged();
if (!forwardAvailableWas)
@@ -183,15 +183,16 @@ void QQuickPdfNavigationStack::push(int page, QPointF location, qreal zoom)
m_pageHistory.append(QExplicitlySharedDataPointer<QPdfDestinationPrivate>(new QPdfDestinationPrivate(page, location, zoom)));
m_currentHistoryIndex = m_pageHistory.count() - 1;
}
+ emit currentZoomChanged();
emit currentPageChanged();
emit currentLocationChanged();
- emit currentZoomChanged();
if (m_changing)
return;
if (!backAvailableWas)
emit backAvailableChanged();
if (forwardAvailableWas)
emit forwardAvailableChanged();
+ emit jumped(page, location, zoom);
qCDebug(qLcNav) << "push: index" << m_currentHistoryIndex << "page" << page
<< "@" << location << "zoom" << zoom << "-> history" <<
[this]() {
@@ -212,7 +213,7 @@ void QQuickPdfNavigationStack::push(int page, QPointF location, qreal zoom)
the most-recently-viewed destination rather than the destination that was
last specified by push().
- The \c currentPageChanged, \c currentLocationChanged and \c currentZoomChanged
+ The \c currentZoomChanged, \c currentPageChanged and \c currentLocationChanged
signals will be emitted if the respective properties are actually changed.
The \l jumped signal is not emitted, because this operation
represents smooth movement rather than a navigational jump.
@@ -229,12 +230,12 @@ void QQuickPdfNavigationStack::update(int page, QPointF location, qreal zoom)
m_pageHistory[m_currentHistoryIndex]->page = page;
m_pageHistory[m_currentHistoryIndex]->location = location;
m_pageHistory[m_currentHistoryIndex]->zoom = zoom;
+ if (currentZoomWas != zoom)
+ emit currentZoomChanged();
if (currentPageWas != page)
emit currentPageChanged();
if (currentLocationWas != location)
emit currentLocationChanged();
- if (currentZoomWas != zoom)
- emit currentZoomChanged();
qCDebug(qLcNav) << "update: index" << m_currentHistoryIndex << "page" << page
<< "@" << location << "zoom" << zoom << "-> history" <<
[this]() {
@@ -258,10 +259,8 @@ bool QQuickPdfNavigationStack::forwardAvailable() const
/*!
\qmlsignal PdfNavigationStack::jumped(int page, point location, qreal zoom)
- This signal is emitted when either forward() or back() is called, to
- distinguish navigational jumps from cases when push() is called.
- Contrast with the \c currentPageChanged signal, which is emitted in all
- cases, and does not include the \c page, \c location and \c zoom arguments.
+ This signal is emitted when forward(), back() or push() is called, but not
+ when update() is called.
*/
QT_END_NAMESPACE