diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-21 11:38:27 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-21 11:40:49 +0100 |
commit | d9349a299f66fb154ad24f410451872a7ca253fb (patch) | |
tree | 2e8258ef3679707a2a9245c85bc8490251b3e256 /src/pdf/api/qpdfsearchmodel.h | |
parent | 50bc8b124705c33c5e27f035b1eab756e14247ba (diff) | |
parent | c0aa9d794378846e4cc0b6fe94f2765bc31cefdd (diff) |
Merge remote-tracking branch 'origin/wip/qtpdf' into 5.15v5.15.0-beta1
The feature set is mostly in place (except for some known shortcomings)
and we need the merge to build it on iOS.
Task-number: QTBUG-69519
Change-Id: Ib1ac82a9a7e0830d98d1c4327a1b15d4d7f4d4c1
Diffstat (limited to 'src/pdf/api/qpdfsearchmodel.h')
-rw-r--r-- | src/pdf/api/qpdfsearchmodel.h | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/pdf/api/qpdfsearchmodel.h b/src/pdf/api/qpdfsearchmodel.h index 02d2a20d5..cc91e214a 100644 --- a/src/pdf/api/qpdfsearchmodel.h +++ b/src/pdf/api/qpdfsearchmodel.h @@ -39,34 +39,57 @@ #include "qtpdfglobal.h" #include "qpdfdocument.h" +#include "qpdfsearchresult.h" -#include <QObject> +#include <QtCore/qabstractitemmodel.h> QT_BEGIN_NAMESPACE class QPdfSearchModelPrivate; -class Q_PDF_EXPORT QPdfSearchModel : public QObject // TODO QAIM? +class Q_PDF_EXPORT QPdfSearchModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(QPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged) + Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged) public: + enum class Role : int { + Page = Qt::UserRole, + IndexOnPage, + Location, + Context, + _Count + }; + Q_ENUM(Role) explicit QPdfSearchModel(QObject *parent = nullptr); ~QPdfSearchModel(); - QVector<QRectF> matches(int page, const QString &searchString); + QVector<QPdfSearchResult> resultsOnPage(int page) const; + QPdfSearchResult resultAtIndex(int index) const; QPdfDocument *document() const; + QString searchString() const; + + QHash<int, QByteArray> roleNames() const override; + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; public Q_SLOTS: + void setSearchString(QString searchString); void setDocument(QPdfDocument *document); Q_SIGNALS: void documentChanged(); + void searchStringChanged(); + +protected: + void updatePage(int page); + void timerEvent(QTimerEvent *event) override; private: - QScopedPointer<QPdfSearchModelPrivate> d; + QHash<int, QByteArray> m_roleNames; + Q_DECLARE_PRIVATE(QPdfSearchModel) }; QT_END_NAMESPACE |