summaryrefslogtreecommitdiffstats
path: root/src/pdfquick/qquickpdfpagenavigator.cpp
blob: be828c059786efc140cdf037cc9640627be9d7ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qquickpdfpagenavigator_p.h"
#include <QLoggingCategory>

QT_BEGIN_NAMESPACE

Q_LOGGING_CATEGORY(qLcNav, "qt.pdf.pagenavigator")

/*!
    \qmltype PdfPageNavigator
//!    \instantiates QQuickPdfPageNavigator
    \inqmlmodule QtQuick.Pdf
    \ingroup pdf
    \brief History of the destinations visited within a PDF Document.
    \since 5.15

    PdfPageNavigator remembers which destinations the user has visited in a PDF
    document, and provides the ability to traverse backward and forward.
*/

QQuickPdfPageNavigator::QQuickPdfPageNavigator(QObject *parent)
    : QObject(parent)
{
}

/*!
    \internal
*/
QQuickPdfPageNavigator::~QQuickPdfPageNavigator() = default;

/*!
    \internal
*/
QPdfPageNavigator *QQuickPdfPageNavigator::navStack()
{
    return static_cast<QPdfPageNavigator *>(qmlExtendedObject(this));
}

/*!
    \qmlmethod void PdfPageNavigator::forward()

    Goes back to the page, location and zoom level that was being viewed before
    back() was called, and then emits the \l jumped() signal.

    If a new destination was pushed since the last time \l back() was called,
    the forward() function does nothing, because there is a branch in the
    timeline which causes the "future" to be lost.
*/

/*!
    \qmlmethod void PdfPageNavigator::back()

    Pops the stack, updates the \l currentPage, \l currentLocation and
    \l currentZoom properties to the most-recently-viewed destination, and then
    emits the \l jumped() signal.
*/

/*!
    \qmlproperty int PdfPageNavigator::currentPage

    This property holds the current page that is being viewed.
    If there is no current page, it holds \c -1.
*/

/*!
    \qmlproperty point PdfPageNavigator::currentLocation

    This property holds the current location on the page that is being viewed.
*/

/*!
    \qmlproperty real PdfPageNavigator::currentZoom

    This property holds the magnification scale on the page that is being viewed.
*/

/*!
    \qmlmethod void PdfPageNavigator::jump(int page, point location, qreal zoom, bool emitJumped)

    Adds the given destination, consisting of \a page, \a location, and \a zoom,
    to the history of visited locations.  If \a emitJumped is \c false, the
    \l jumped() signal will not be emitted.

    If forwardAvailable is \c true, calling this function represents a branch
    in the timeline which causes the "future" to be lost, and therefore
    forwardAvailable will change to \c false.
*/

/*!
    \qmlmethod void PdfPageNavigator::update(int page, point location, qreal zoom)

    Modifies the current destination, consisting of \a page, \a location and \a zoom.

    This can be called periodically while the user is manually moving around
    the document, so that after back() is called, forward() will jump back to
    the most-recently-viewed destination rather than the destination that was
    last specified by jump().

    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.
*/

/*!
    \qmlproperty bool PdfPageNavigator::backAvailable
    \readonly

    Holds \c true if a \e back destination is available in the history.
*/

/*!
    \qmlproperty bool PdfPageNavigator::forwardAvailable
    \readonly

    Holds \c true if a \e forward destination is available in the history.
*/

/*!
    \qmlsignal PdfPageNavigator::jumped(int page, point location, qreal zoom)

    This signal is emitted when an abrupt jump occurs, to the specified \a page
    index, \a location on the page, and \a zoom level; but \e not when simply
    scrolling through the document one page at a time. That is, forward(),
    back() and jump() always emit this signal; update() does not.
*/

QT_END_NAMESPACE

#include "moc_qquickpdfpagenavigator_p.cpp"