Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
13QT_BEGIN_NAMESPACE
14
15class QPdfSearchModelPrivate;
16
17class Q_PDF_EXPORT QPdfSearchModel : public QAbstractListModel
18{
19 Q_OBJECT
20 Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
21 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
22 Q_PROPERTY(int count READ count NOTIFY countChanged REVISION(6, 8) FINAL)
23 Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION(6, 12) FINAL)
24
25public:
26 enum class Role : int {
27 Page = Qt::UserRole,
28 IndexOnPage,
29 Location,
30 ContextBefore,
31 ContextAfter,
32 NRoles
33 };
34 Q_ENUM(Role)
35
36 enum class Status {
37 Null,
38 Searching,
39 Finished
40 };
41 Q_ENUM(Status)
42
43 QPdfSearchModel() : QPdfSearchModel(nullptr) {}
44 explicit QPdfSearchModel(QObject *parent);
45 ~QPdfSearchModel() override;
46
47 QList<QPdfLink> resultsOnPage(int page) const;
48 QPdfLink resultAtIndex(int index) const;
49
50 QPdfDocument *document() const;
51 QString searchString() const;
52
53 QHash<int, QByteArray> roleNames() const override;
54 int rowCount(const QModelIndex &parent) const override;
55 QVariant data(const QModelIndex &index, int role) const override;
56
57 int count() const;
58
59 Status status() const;
60
61public Q_SLOTS:
62 void setSearchString(const QString &searchString);
63 void setDocument(QPdfDocument *document);
64
65Q_SIGNALS:
66 void documentChanged();
67 void searchStringChanged();
68 Q_REVISION(6, 8) void countChanged();
69 Q_REVISION(6, 12) void statusChanged(QPdfSearchModel::Status status);
70
71protected:
72 void updatePage(int page);
73 void timerEvent(QTimerEvent *event) override;
74
75private:
76 QHash<int, QByteArray> m_roleNames;
77 Q_DECLARE_PRIVATE(QPdfSearchModel)
78};
79
80QT_END_NAMESPACE
81
82#endif // QPDFSEARCHMODEL_H
void setStatus(QPdfSearchModel::Status s)
PageAndIndex pageAndIndexForResult(int resultIndex)
The QPdfSearchModel class searches for a string in a PDF document and holds the results.
Combined button and popup list for selecting options.
static const int ContextChars
#define Q_PDF_LOGGING_CATEGORY(name,...)