9#include "third_party/pdfium/public/fpdf_doc.h"
10#include "third_party/pdfium/public/fpdfview.h"
12#include <QLoggingCategory>
15#include <QScopedPointer>
16#include <private/qabstractitemmodel_p.h>
26 : m_parentNode(parentNode)
43 m_childNodes.append(
child);
48 return m_childNodes.at(
row);
53 return m_childNodes.size();
59 return m_parentNode->m_childNodes.indexOf(
const_cast<BookmarkNode*
>(
this));
96 m_pageNumber = pageNumber;
125 int m_pageNumber = 0;
143 if (documentAvailable) {
144 q->beginResetModel();
154 q->beginResetModel();
163 FPDF_BOOKMARK bookmark = FPDFBookmark_GetFirstChild(document, parentBookmark);
168 childBookmarkNode =
new BookmarkNode(parentBookmarkNode);
169 parentBookmarkNode->
appendChild(childBookmarkNode);
172 const int titleLength = int(FPDFBookmark_GetTitle(bookmark,
nullptr, 0));
175 FPDFBookmark_GetTitle(bookmark, titleBuffer.
data(),
quint32(titleBuffer.
size()));
177 const FPDF_DEST dest = FPDFBookmark_GetDest(document, bookmark);
178 const int pageNumber = FPDFDest_GetDestPageIndex(document, dest);
179 double pageHeight = 11.69 * 72;
183 FPDF_PAGE pdfPage = FPDF_LoadPage(document, pageNumber);
185 pageHeight = FPDF_GetPageHeight(pdfPage);
187 qCWarning(qLcBM) <<
"failed to load page" << pageNumber;
190 FPDF_BOOL hasX, hasY, hasZoom;
192 bool ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &
x, &
y, &zoom);
197 childBookmarkNode->
setZoom(zoom);
199 qCWarning(qLcBM) <<
"bookmark with invalid location and/or zoom" <<
x <<
y << zoom;
209 bookmark = FPDFBookmark_GetNextSibling(document, bookmark);
270 return d->m_document;
304 return d->m_roleNames;
312 if (!
index.isValid())
316 switch (
Role(role)) {
318 return node->
title();
320 return node->
level();
331 return node->
title();
346 parentNode = d->m_rootNode.data();
362 if (!
index.isValid())
368 if (parentNode == d->m_rootNode.data())
385 parentNode = d->m_rootNode.data();
394#include "moc_qpdfbookmarkmodel.cpp"
BookmarkNode * child(int row) const
void setTitle(const QString &title)
BookmarkNode(BookmarkNode *parentNode=nullptr)
void setLocation(qreal x, qreal y)
void setPageNumber(int pageNumber)
void appendChild(BookmarkNode *child)
BookmarkNode * parentNode() const
Q_INVOKABLE int const QModelIndex & parent
Returns the parent of the model item with the given index.
Q_INVOKABLE bool hasIndex(int row, int column, const QModelIndex &parent=QModelIndex()) const
Returns {true} if the model returns a valid QModelIndex for row and column with parent,...
virtual QHash< int, QByteArray > roleNames() const
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
QByteArray toLower() const &
qsizetype size() const noexcept
constexpr int column() const noexcept
Returns the column this model index refers to.
void * internalPointer() const noexcept
Returns a {void} {*} pointer used by the model to associate the index with the internal data structur...
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QPdfBookmarkModel class holds a tree of of links (anchors) within a PDF document,...
void documentChanged(QPdfDocument *document)
~QPdfBookmarkModel() override
Destroys the model.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
void setDocument(QPdfDocument *document)
Role
\value Title The name of the bookmark for display.
QVariant data(const QModelIndex &index, int role) const override
\reimp
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
QHash< int, QByteArray > roleNames() const override
\reimp
The QPdfDocument class loads a PDF document and renders pages from it.
Status status
This property holds the current status of the document.
Status
This enum describes the current status of the document.
\inmodule QtCore\reentrant
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf16(const char16_t *, qsizetype size=-1)
void statusChanged(QDeclarativeComponent::Status status)
[1]
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLint level
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
obj metaObject() -> className()
myObject disconnect()
[26]
void _q_documentStatusChanged()
void appendChildNode(BookmarkNode *parentBookmarkNode, FPDF_BOOKMARK parentBookmark, int level, FPDF_DOCUMENT document)
QScopedPointer< BookmarkNode > m_rootNode
QHash< int, QByteArray > m_roleNames
QPdfBookmarkModelPrivate()
QPointer< QPdfDocument > m_document
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent