From 1be26e4402c6aaca0a6262d3ceb7d449fa1fd7c9 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 27 Apr 2022 13:36:09 +0200 Subject: doc: Document QPdfBookmarkModel and QPdfLinkModel QML docs were already in place since 303c25e79ab12d5d48523aa890f2091e98d3b560 and ccbd6fbdbe071f42e1c060ca579786758701f358; but QPdfBookmarkModel existed since 398880564621b06a79a4ba245baf350022ad438a (5ccb928983e8ff5e51989fab60ea413a5b418f29 in the qtpdf repo). Change-Id: Id3e91b4e98e25cf035868e55a22cf69262ee5afc Reviewed-by: Shawn Rutledge --- src/pdf/doc/src/qtpdf-index.qdoc | 4 +++- src/pdf/qpdfbookmarkmodel.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ src/pdf/qpdflinkmodel.cpp | 44 ++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) (limited to 'src/pdf') diff --git a/src/pdf/doc/src/qtpdf-index.qdoc b/src/pdf/doc/src/qtpdf-index.qdoc index 986a8011b..b6c627780 100644 --- a/src/pdf/doc/src/qtpdf-index.qdoc +++ b/src/pdf/doc/src/qtpdf-index.qdoc @@ -38,7 +38,9 @@ class manages a queue that collects all render requests. The \l QPdfPageNavigator class handles the navigation through a PDF document. The \l QPdfSearchModel class searches for a string - and holds the search results. The \l QPdfView widget is a complete + and holds the search results. The QPdfBookmarkModel class holds the + table of contents, if present. The QPdfLinkModel holds information + about hyperlinks on a page. The \l QPdfView widget is a complete PDF viewer, and the \l {PDF Viewer Example} shows how to use it. For Qt Quick applications, three kinds of full-featured viewer diff --git a/src/pdf/qpdfbookmarkmodel.cpp b/src/pdf/qpdfbookmarkmodel.cpp index 63712f431..f455a111c 100644 --- a/src/pdf/qpdfbookmarkmodel.cpp +++ b/src/pdf/qpdfbookmarkmodel.cpp @@ -258,6 +258,33 @@ struct QPdfBookmarkModelPrivate }; +/*! + \class QPdfBookmarkModel + \since 5.10 + \inmodule QtPdf + \inherits QAbstractItemModel + + \brief The QPdfBookmarkModel class holds a tree of of links (anchors) + within a PDF document, such as the table of contents. + + This is used in the \l {Model/View Programming} paradigm to display a + table of contents in the form of a tree or list. +*/ + +/*! + \enum QPdfBookmarkModel::Role + + \value Title The name of the bookmark for display. + \value Level The level of indentation. + \value Page The page number of the destination (int). + \value Location The position of the destination (QPointF). + \value Zoom The suggested zoom level (qreal). + \omitvalue _Count +*/ + +/*! + Constructs a new bookmark model with parent object \a parent. +*/ QPdfBookmarkModel::QPdfBookmarkModel(QObject *parent) : QAbstractItemModel(parent), d(new QPdfBookmarkModelPrivate) { @@ -268,6 +295,9 @@ QPdfBookmarkModel::QPdfBookmarkModel(QObject *parent) m_roleNames.insert(r, QByteArray(rolesMetaEnum.valueToKey(r)).toLower()); } +/*! + Destroys the model. +*/ QPdfBookmarkModel::~QPdfBookmarkModel() = default; QPdfDocument* QPdfBookmarkModel::document() const @@ -292,17 +322,26 @@ void QPdfBookmarkModel::setDocument(QPdfDocument *document) d->rebuild(); } +/*! + \reimp +*/ int QPdfBookmarkModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent); return 1; } +/*! + \reimp +*/ QHash QPdfBookmarkModel::roleNames() const { return m_roleNames; } +/*! + \reimp +*/ QVariant QPdfBookmarkModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) @@ -328,6 +367,9 @@ QVariant QPdfBookmarkModel::data(const QModelIndex &index, int role) const return QVariant(); } +/*! + \reimp +*/ QModelIndex QPdfBookmarkModel::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) @@ -347,6 +389,9 @@ QModelIndex QPdfBookmarkModel::index(int row, int column, const QModelIndex &par return QModelIndex(); } +/*! + \reimp +*/ QModelIndex QPdfBookmarkModel::parent(const QModelIndex &index) const { if (!index.isValid()) @@ -361,6 +406,9 @@ QModelIndex QPdfBookmarkModel::parent(const QModelIndex &index) const return createIndex(parentNode->row(), 0, parentNode); } +/*! + \reimp +*/ int QPdfBookmarkModel::rowCount(const QModelIndex &parent) const { if (parent.column() > 0) diff --git a/src/pdf/qpdflinkmodel.cpp b/src/pdf/qpdflinkmodel.cpp index 62d10eaf6..7dbdf71ba 100644 --- a/src/pdf/qpdflinkmodel.cpp +++ b/src/pdf/qpdflinkmodel.cpp @@ -52,6 +52,33 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcLink, "qt.pdf.links") +/*! + \class QPdfLinkModel + \since 5.15 + \inmodule QtPdf + \inherits QAbstractListModel + + \brief The QPdfLinkModel class holds the geometry and the destination for + each link that the specified \l page contains. + + This is used in PDF viewers to implement the hyperlink mechanism. +*/ + +/*! + \enum QPdfLinkModel::Role + + \value Link A QPdfLink object. + \value Rectangle Bounding rectangle around the link. + \value Url If the link is a web link, the URL for that; otherwise an empty URL. + \value Page If the link is an internal link, the page number to which the link should jump; otherwise \c {-1}. + \value Location If the link is an internal link, the location on the page to which the link should jump. + \value Zoom If the link is an internal link, the suggested zoom level on the destination page. + \omitvalue _Count +*/ + +/*! + Constructs a new link model with parent object \a parent. +*/ QPdfLinkModel::QPdfLinkModel(QObject *parent) : QAbstractListModel(*(new QPdfLinkModelPrivate()), parent) { @@ -60,6 +87,9 @@ QPdfLinkModel::QPdfLinkModel(QObject *parent) m_roleNames.insert(r, QByteArray(rolesMetaEnum.valueToKey(r)).toLower()); } +/*! + Destroys the model. +*/ QPdfLinkModel::~QPdfLinkModel() {} QHash QPdfLinkModel::roleNames() const @@ -67,6 +97,9 @@ QHash QPdfLinkModel::roleNames() const return m_roleNames; } +/*! + \reimp +*/ int QPdfLinkModel::rowCount(const QModelIndex &parent) const { Q_D(const QPdfLinkModel); @@ -74,6 +107,9 @@ int QPdfLinkModel::rowCount(const QModelIndex &parent) const return d->links.count(); } +/*! + \reimp +*/ QVariant QPdfLinkModel::data(const QModelIndex &index, int role) const { Q_D(const QPdfLinkModel); @@ -99,6 +135,10 @@ QVariant QPdfLinkModel::data(const QModelIndex &index, int role) const return QVariant(); } +/*! + \property QPdfLinkModel::document + \brief the document to load links from +*/ QPdfDocument *QPdfLinkModel::document() const { Q_D(const QPdfLinkModel); @@ -121,6 +161,10 @@ void QPdfLinkModel::setDocument(QPdfDocument *document) d->update(); } +/*! + \property QPdfLinkModel::page + \brief the page to load links from +*/ int QPdfLinkModel::page() const { Q_D(const QPdfLinkModel); -- cgit v1.2.3