summaryrefslogtreecommitdiffstats
path: root/src/pdf/qpdfpagenavigator.h
blob: cec89ef5abcb27d3c355fdfe5c3d924eb358142b (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
// 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

#ifndef QPDFPAGENAVIGATOR_H
#define QPDFPAGENAVIGATOR_H

#include <QtPdf/qtpdfglobal.h>
#include <QtPdf/qpdflink.h>
#include <QtCore/qobject.h>

QT_BEGIN_NAMESPACE

struct QPdfPageNavigatorPrivate;

class Q_PDF_EXPORT QPdfPageNavigator : public QObject
{
    Q_OBJECT

    Q_PROPERTY(int currentPage READ currentPage NOTIFY currentPageChanged)
    Q_PROPERTY(QPointF currentLocation READ currentLocation NOTIFY currentLocationChanged)
    Q_PROPERTY(qreal currentZoom READ currentZoom NOTIFY currentZoomChanged)
    Q_PROPERTY(bool backAvailable READ backAvailable NOTIFY backAvailableChanged)
    Q_PROPERTY(bool forwardAvailable READ forwardAvailable NOTIFY forwardAvailableChanged)

public:
    QPdfPageNavigator() : QPdfPageNavigator(nullptr) {}
    explicit QPdfPageNavigator(QObject *parent);
    ~QPdfPageNavigator() override;

    int currentPage() const;
    QPointF currentLocation() const;
    qreal currentZoom() const;

    bool backAvailable() const;
    bool forwardAvailable() const;

public Q_SLOTS:
    void clear();
    void jump(QPdfLink destination);
    void jump(int page, const QPointF &location, qreal zoom = 0);
    void update(int page, const QPointF &location, qreal zoom);
    void forward();
    void back();

Q_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);

protected:
    QPdfLink currentLink() const;

private:
    QScopedPointer<QPdfPageNavigatorPrivate> d;
};

QT_END_NAMESPACE

#endif // QPDFPAGENAVIGATOR_H