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
13#include <QtCore/qhash.h>
14
15QT_BEGIN_NAMESPACE
16
17class QPdfSearchModelPrivate;
18
19class Q_PDF_EXPORT QPdfSearchModel : public QAbstractListModel
20{
21 Q_OBJECT
22 Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged)
23 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged)
24 Q_PROPERTY(int count READ count NOTIFY countChanged REVISION(6, 8) FINAL)
25 Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION(6, 12))
26
27public:
28 enum class Role : int {
29 Page = Qt::UserRole,
30 IndexOnPage,
31 Location,
32 ContextBefore,
33 ContextAfter,
34 NRoles
35 };
36 Q_ENUM(Role)
37
38 enum class Status : int {
39 Null,
40 Searching,
41 Finished,
42 };
43 Q_ENUM(Status)
44
45 QPdfSearchModel() : QPdfSearchModel(nullptr) {}
46 explicit QPdfSearchModel(QObject *parent);
47 ~QPdfSearchModel() override;
48
49 QList<QPdfLink> resultsOnPage(int page) const;
50 QPdfLink resultAtIndex(int index) const;
51
52 QPdfDocument *document() const;
53 QString searchString() const;
54
55 QHash<int, QByteArray> roleNames() const override;
56 int rowCount(const QModelIndex &parent) const override;
57 QVariant data(const QModelIndex &index, int role) const override;
58
59 int count() const;
60
61 Status status() const;
62
63public Q_SLOTS:
64 void setSearchString(const QString &searchString);
65 void setDocument(QPdfDocument *document);
66
67Q_SIGNALS:
68 void documentChanged();
69 void searchStringChanged();
70 Q_REVISION(6, 8) void countChanged();
71 Q_REVISION(6, 12) void statusChanged(QPdfSearchModel::Status status);
72
73protected:
74 void updatePage(int page);
75 void timerEvent(QTimerEvent *event) override;
76
77private:
78 QHash<int, QByteArray> m_roleNames;
79 Q_DECLARE_PRIVATE(QPdfSearchModel)
80};
81
82QT_END_NAMESPACE
83
84#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,...)