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
qdeclarativesearchmodelbase_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QDECLARATIVESEARCHMODELBASE_H
5#define QDECLARATIVESEARCHMODELBASE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtLocation/private/qlocationglobal_p.h>
19#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
20#include <QtCore/QAbstractListModel>
21#include <QtQml/QQmlParserStatus>
22#include <QtLocation/QPlaceSearchRequest>
23#include <QtLocation/QPlaceSearchResult>
24#include <QtLocation/QPlaceReply>
25
26QT_BEGIN_NAMESPACE
27
28class QPlaceManager;
29class QPlaceSearchRequest;
30class QPlaceSearchReply;
31class QDeclarativePlace;
32
33class Q_LOCATION_EXPORT QDeclarativeSearchModelBase : public QAbstractListModel, public QQmlParserStatus
34{
35 Q_OBJECT
36
37 Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
38 Q_PROPERTY(QVariant searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged)
39 Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
40 Q_PROPERTY(bool previousPagesAvailable READ previousPagesAvailable NOTIFY previousPagesAvailableChanged)
41 Q_PROPERTY(bool nextPagesAvailable READ nextPagesAvailable NOTIFY nextPagesAvailableChanged)
42 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
43
44 Q_ENUMS(Status)
45
46 Q_INTERFACES(QQmlParserStatus)
47
48public:
49 enum Status {
50 Null,
51 Ready,
52 Loading,
53 Error
54 };
55
56 explicit QDeclarativeSearchModelBase(QObject *parent = nullptr);
57 ~QDeclarativeSearchModelBase();
58
59 QDeclarativeGeoServiceProvider *plugin() const;
60 void setPlugin(QDeclarativeGeoServiceProvider *plugin);
61
62 QVariant searchArea() const;
63 void setSearchArea(const QVariant &searchArea);
64
65 int limit() const;
66 void setLimit(int limit);
67
68 bool previousPagesAvailable() const;
69 bool nextPagesAvailable() const;
70
71 Status status() const;
72 void setStatus(Status status, const QString &errorString = QString());
73
74 Q_INVOKABLE void update();
75
76 Q_INVOKABLE void cancel();
77 Q_INVOKABLE void reset();
78
79 Q_INVOKABLE QString errorString() const;
80
81 Q_INVOKABLE void previousPage();
82 Q_INVOKABLE void nextPage();
83
84 virtual void clearData(bool suppressSignal = false);
85
86 // From QQmlParserStatus
87 void classBegin() override;
88 void componentComplete() override;
89
90Q_SIGNALS:
91 void pluginChanged();
92 void searchAreaChanged();
93 void limitChanged();
94 void previousPagesAvailableChanged();
95 void nextPagesAvailableChanged();
96 void statusChanged();
97
98protected:
99 virtual void initializePlugin(QDeclarativeGeoServiceProvider *plugin);
100
101protected Q_SLOTS:
102 virtual void queryFinished() = 0;
103 virtual void onContentUpdated();
104
105private Q_SLOTS:
106 void pluginNameChanged();
107
108protected:
109 virtual QPlaceReply *sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) = 0;
110 void setPreviousPageRequest(const QPlaceSearchRequest &previous);
111 void setNextPageRequest(const QPlaceSearchRequest &next);
112
113 QPlaceSearchRequest m_request;
114 QDeclarativeGeoServiceProvider *m_plugin = nullptr;
115 QPlaceReply *m_reply = nullptr;
116
117private:
118 bool m_complete = false;
119 Status m_status = Null;
120 QString m_errorString;
121 QPlaceSearchRequest m_previousPageRequest;
122 QPlaceSearchRequest m_nextPageRequest;
123};
124
125QT_END_NAMESPACE
126
127#endif // QDECLARATIVESEARCHMODELBASE_H