Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPdfPageNavigator Class Reference

Navigation history within a PDF document. More...

#include <qpdfpagenavigator.h>

+ Inheritance diagram for QPdfPageNavigator:
+ Collaboration diagram for QPdfPageNavigator:

Public Slots

void clear ()
 Clear the history and restore \l currentPage, \l currentLocation and \l currentZoom to their default values.
 
void jump (QPdfLink destination)
 Adds the given destination to the history of visited locations.
 
void jump (int page, const QPointF &location, qreal zoom=0)
 Adds the given destination, consisting of page, location, and zoom, to the history of visited locations.
 
void update (int page, const QPointF &location, qreal zoom)
 Modifies the current destination, consisting of page, location and zoom.
 
void 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.
 
void 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.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

void currentPageChanged (int page)
 
void currentLocationChanged (QPointF location)
 
void currentZoomChanged (qreal zoom)
 
void backAvailableChanged (bool available)
 
void forwardAvailableChanged (bool available)
 
void jumped (QPdfLink current)
 This signal is emitted when an abrupt jump occurs, to the current page index, location on the page, and zoom level; but not when simply scrolling through the document one page at a time.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QPdfPageNavigator ()
 
 QPdfPageNavigator (QObject *parent)
 Constructs a page navigation stack with parent object parent.
 
 ~QPdfPageNavigator () override
 Destroys the page navigation stack.
 
int currentPage () const
 
QPointF currentLocation () const
 
qreal currentZoom () const
 
bool backAvailable () const
 
bool forwardAvailable () const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Protected Member Functions

QPdfLink currentLink () const
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

int currentPage
 This property holds the current page that is being viewed.
 
QPointF currentLocation
 This property holds the current location on the page that is being viewed (the location that was last given to jump() or update()).
 
qreal currentZoom
 This property holds the magnification scale (1 logical pixel = 1 point) on the page that is being viewed.
 
bool backAvailable
 \readonly
 
bool forwardAvailable
 \readonly
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

Navigation history within a PDF document.

Since
6.4 \inmodule QtPdf

The QPdfPageNavigator class remembers which destinations the user has visited in a PDF document, and provides the ability to traverse backward and forward. It is used to implement back and forward actions similar to the back and forward buttons in a web browser.

See also
QPdfDocument

Definition at line 15 of file qpdfpagenavigator.h.

Constructor & Destructor Documentation

◆ QPdfPageNavigator() [1/2]

QPdfPageNavigator::QPdfPageNavigator ( )
inline

Definition at line 26 of file qpdfpagenavigator.h.

◆ QPdfPageNavigator() [2/2]

QPdfPageNavigator::QPdfPageNavigator ( QObject * parent)
explicit

Constructs a page navigation stack with parent object parent.

Definition at line 41 of file qpdfpagenavigator.cpp.

References clear(), and QPdfPageNavigatorPrivate::q.

+ Here is the call graph for this function:

◆ ~QPdfPageNavigator()

QPdfPageNavigator::~QPdfPageNavigator ( )
override

Destroys the page navigation stack.

Definition at line 51 of file qpdfpagenavigator.cpp.

Member Function Documentation

◆ back

void QPdfPageNavigator::back ( )
slot

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.

Definition at line 93 of file qpdfpagenavigator.cpp.

References backAvailable, backAvailableChanged(), QPdfPageNavigatorPrivate::changing, QPdfPageNavigatorPrivate::currentHistoryIndex, currentLink(), currentLocation, currentLocationChanged(), currentPage, currentPageChanged(), currentZoom, currentZoomChanged(), emit, forwardAvailable, forwardAvailableChanged(), jumped(), and qCDebug.

+ Here is the call graph for this function:

◆ backAvailable()

bool QPdfPageNavigator::backAvailable ( ) const

◆ backAvailableChanged

void QPdfPageNavigator::backAvailableChanged ( bool available)
signal

Referenced by back(), forward(), jump(), and jump().

+ Here is the caller graph for this function:

◆ clear

void QPdfPageNavigator::clear ( )
slot

Clear the history and restore \l currentPage, \l currentLocation and \l currentZoom to their default values.

Definition at line 168 of file qpdfpagenavigator.cpp.

References QList< T >::append(), QList< T >::clear(), QPdfPageNavigatorPrivate::currentHistoryIndex, and QPdfPageNavigatorPrivate::pageHistory.

Referenced by QPdfPageNavigator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentLink()

QPdfLink QPdfPageNavigator::currentLink ( ) const
protected

Definition at line 157 of file qpdfpagenavigator.cpp.

References QList< T >::at(), QPdfPageNavigatorPrivate::currentHistoryIndex, QExplicitlySharedDataPointer< T >::data(), QPdfPageNavigatorPrivate::pageHistory, and QList< T >::size().

Referenced by back(), forward(), jump(), and jump().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentLocation()

QPointF QPdfPageNavigator::currentLocation ( ) const

Definition at line 137 of file qpdfpagenavigator.cpp.

References QList< T >::at(), QPdfPageNavigatorPrivate::currentHistoryIndex, QPdfLinkPrivate::location, QPdfPageNavigatorPrivate::pageHistory, and QList< T >::size().

+ Here is the call graph for this function:

◆ currentLocationChanged

void QPdfPageNavigator::currentLocationChanged ( QPointF location)
signal

Referenced by back(), forward(), jump(), jump(), and update().

+ Here is the caller graph for this function:

◆ currentPage()

int QPdfPageNavigator::currentPage ( ) const

Definition at line 123 of file qpdfpagenavigator.cpp.

References QList< T >::at(), QPdfPageNavigatorPrivate::currentHistoryIndex, QPdfLinkPrivate::page, QPdfPageNavigatorPrivate::pageHistory, and QList< T >::size().

+ Here is the call graph for this function:

◆ currentPageChanged

void QPdfPageNavigator::currentPageChanged ( int page)
signal

Referenced by back(), forward(), jump(), jump(), and update().

+ Here is the caller graph for this function:

◆ currentZoom()

qreal QPdfPageNavigator::currentZoom ( ) const

Definition at line 150 of file qpdfpagenavigator.cpp.

References QList< T >::at(), QPdfPageNavigatorPrivate::currentHistoryIndex, QPdfPageNavigatorPrivate::pageHistory, QList< T >::size(), and QPdfLinkPrivate::zoom.

+ Here is the call graph for this function:

◆ currentZoomChanged

void QPdfPageNavigator::currentZoomChanged ( qreal zoom)
signal

Referenced by back(), forward(), jump(), jump(), and update().

+ Here is the caller graph for this function:

◆ forward

void QPdfPageNavigator::forward ( )
slot

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.

Definition at line 63 of file qpdfpagenavigator.cpp.

References backAvailable, backAvailableChanged(), QPdfPageNavigatorPrivate::changing, QPdfPageNavigatorPrivate::currentHistoryIndex, currentLink(), currentLocation, currentLocationChanged(), currentPage, currentPageChanged(), currentZoom, currentZoomChanged(), emit, forwardAvailable, forwardAvailableChanged(), jumped(), QPdfPageNavigatorPrivate::pageHistory, qCDebug, and QList< T >::size().

+ Here is the call graph for this function:

◆ forwardAvailable()

bool QPdfPageNavigator::forwardAvailable ( ) const

Definition at line 341 of file qpdfpagenavigator.cpp.

References QPdfPageNavigatorPrivate::currentHistoryIndex, QPdfPageNavigatorPrivate::pageHistory, and QList< T >::size().

+ Here is the call graph for this function:

◆ forwardAvailableChanged

void QPdfPageNavigator::forwardAvailableChanged ( bool available)
signal

Referenced by back(), forward(), jump(), and jump().

+ Here is the caller graph for this function:

◆ jump [1/2]

void QPdfPageNavigator::jump ( int page,
const QPointF & location,
qreal zoom = 0 )
slot

Adds the given destination, consisting of page, location, and zoom, to the history of visited locations.

The zoom argument represents magnification (where 1 is the default scale, 1 logical pixel = 1 point). If zoom is not given or is 0, currentZoom keeps its existing value, and currentZoomChanged is not emitted.

The location should be the same as QPdfLink::location() if the user is following a link; and since that is specified as the upper-left corner of the destination, it is best for consistency to always use the location visible in the upper-left corner of the viewport, in points.

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

Definition at line 241 of file qpdfpagenavigator.cpp.

References QList< T >::append(), backAvailable, backAvailableChanged(), QPdfPageNavigatorPrivate::changing, QPdfPageNavigatorPrivate::currentHistoryIndex, currentLink(), currentLocation, currentLocationChanged(), currentPage, currentPageChanged(), currentZoom, currentZoomChanged(), emit, forwardAvailable, forwardAvailableChanged(), jumped(), QString::number(), page, QPdfPageNavigatorPrivate::pageHistory, qCDebug, qFuzzyCompare(), qFuzzyIsNull(), QList< T >::remove(), ret, and QList< T >::size().

+ Here is the call graph for this function:

◆ jump [2/2]

void QPdfPageNavigator::jump ( QPdfLink destination)
slot

Adds the given destination to the history of visited locations.

In this case, PDF views respond to the \l jumped signal by scrolling to place destination.rectangles in the viewport, as opposed to placing destination.location in the viewport. So it's appropriate to call this method to jump to a search result from QPdfSearchModel (because the rectangles cover the region of text found). To jump to a hyperlink destination, call jump(page, location, zoom) instead, because in that case the QPdfLink object's rectangles cover the hyperlink origin location rather than the destination.

Definition at line 189 of file qpdfpagenavigator.cpp.

References QList< T >::append(), backAvailable, backAvailableChanged(), QPdfPageNavigatorPrivate::changing, QPdfPageNavigatorPrivate::currentHistoryIndex, currentLink(), currentLocation, currentLocationChanged(), currentPage, currentPageChanged(), currentZoom, currentZoomChanged(), destination, emit, forwardAvailable, forwardAvailableChanged(), jumped(), QString::number(), QPdfPageNavigatorPrivate::pageHistory, qCDebug, qFuzzyCompare(), QList< T >::remove(), ret, and QList< T >::size().

+ Here is the call graph for this function:

◆ jumped

void QPdfPageNavigator::jumped ( QPdfLink current)
signal

This signal is emitted when an abrupt jump occurs, to the current page index, location on the page, and zoom level; but not when simply scrolling through the document one page at a time.

That is, jump(), forward() and back() emit this signal, but update() does not.

If {current.rectangles.length > 0}, they are rectangles that cover a specific destination area: a search result that should be made visible; otherwise, {current.location} is the destination location on the page (a hyperlink destination, or during forward/back navigation).

Referenced by back(), forward(), jump(), and jump().

+ Here is the caller graph for this function:

◆ update

void QPdfPageNavigator::update ( int page,
const QPointF & location,
qreal zoom )
slot

Modifies the current destination, consisting of page, location and 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 push().

The currentZoomChanged, currentPageChanged and 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.

Definition at line 294 of file qpdfpagenavigator.cpp.

References QPdfPageNavigatorPrivate::currentHistoryIndex, currentLocation, currentLocationChanged(), currentPage, currentPageChanged(), currentZoom, currentZoomChanged(), emit, QString::number(), page, QPdfPageNavigatorPrivate::pageHistory, qCDebug, ret, and QList< T >::size().

+ Here is the call graph for this function:

Property Documentation

◆ backAvailable

QPdfPageNavigator::backAvailable
read

\readonly

Holds true if a back destination is available in the history: that is, if push() or forward() has been called.

Definition at line 22 of file qpdfpagenavigator.h.

Referenced by back(), forward(), jump(), and jump().

◆ currentLocation

QPdfPageNavigator::currentLocation
read

This property holds the current location on the page that is being viewed (the location that was last given to jump() or update()).

The default is {0, 0}.

Definition at line 20 of file qpdfpagenavigator.h.

Referenced by back(), forward(), jump(), jump(), and update().

◆ currentPage

QPdfPageNavigator::currentPage
read

This property holds the current page that is being viewed.

The default is 0.

Definition at line 19 of file qpdfpagenavigator.h.

Referenced by back(), forward(), jump(), jump(), and update().

◆ currentZoom

QPdfPageNavigator::currentZoom
read

This property holds the magnification scale (1 logical pixel = 1 point) on the page that is being viewed.

The default is 1.

Definition at line 21 of file qpdfpagenavigator.h.

Referenced by back(), forward(), jump(), jump(), and update().

◆ forwardAvailable

QPdfPageNavigator::forwardAvailable
read

\readonly

Holds true if a forward destination is available in the history: that is, if back() has been previously called.

Definition at line 23 of file qpdfpagenavigator.h.

Referenced by back(), forward(), jump(), and jump().


The documentation for this class was generated from the following files: