Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qpdfsearchmodel.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPDFSEARCHMODEL_H
5#define QPDFSEARCHMODEL_H
6
7#include <QtPdf/qtpdfglobal.h>
8
9#include <QtCore/qabstractitemmodel.h>
10#include <QtPdf/qpdfdocument.h>
11#include <QtPdf/qpdflink.h>
12
14
16
18{
20 Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
21 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
22
23public:
24 enum class Role : int {
26 IndexOnPage,
27 Location,
28 ContextBefore,
29 ContextAfter,
30 NRoles
31 };
32 Q_ENUM(Role)
35 ~QPdfSearchModel() override;
36
37 QList<QPdfLink> resultsOnPage(int page) const;
38 QPdfLink resultAtIndex(int index) const;
39
40 QPdfDocument *document() const;
41 QString searchString() const;
42
43 QHash<int, QByteArray> roleNames() const override;
44 int rowCount(const QModelIndex &parent) const override;
45 QVariant data(const QModelIndex &index, int role) const override;
46
47public Q_SLOTS:
48 void setSearchString(const QString &searchString);
49 void setDocument(QPdfDocument *document);
50
54
55protected:
56 void updatePage(int page);
57 void timerEvent(QTimerEvent *event) override;
58 void onDocumentPageCountChanged(int count);
59
60private:
61 QHash<int, QByteArray> m_roleNames;
62 Q_DECLARE_PRIVATE(QPdfSearchModel)
63};
64
66
67#endif // QPDFSEARCHMODEL_H
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
virtual QHash< int, QByteArray > roleNames() const
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:90
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1433
The QPdfDocument class loads a PDF document and renders pages from it.
The QPdfSearchModel class searches for a string in a PDF document and holds the results.
void documentChanged()
void searchStringChanged()
Role
\value Page The page number where the search result is found (int).
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qcoreevent.h:359
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
@ UserRole
GLuint index
[2]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
struct _cl_event * event
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
#define Q_PDF_EXPORT
Definition qtpdfglobal.h:16
QByteArray page
[45]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent