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// Qt-Security score:significant reason:default
4
5#ifndef QDECLARATIVESEARCHMODELBASE_H
6#define QDECLARATIVESEARCHMODELBASE_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtLocation/private/qlocationglobal_p.h>
20#include <QtLocation/private/qdeclarativegeoserviceprovider_p.h>
21#include <QtCore/QAbstractListModel>
22#include <QtQml/QQmlParserStatus>
23#include <QtLocation/QPlaceSearchRequest>
24#include <QtLocation/QPlaceSearchResult>
25#include <QtLocation/QPlaceReply>
26
27QT_BEGIN_NAMESPACE
28
29class QPlaceManager;
30class QPlaceSearchRequest;
31class QPlaceSearchReply;
32class QDeclarativePlace;
33
34class Q_LOCATION_EXPORT QDeclarativeSearchModelBase : public QAbstractListModel, public QQmlParserStatus
35{
36 Q_OBJECT
37
38 Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
39 Q_PROPERTY(QVariant searchArea READ searchArea WRITE setSearchArea NOTIFY searchAreaChanged)
40 Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged)
41 Q_PROPERTY(bool previousPagesAvailable READ previousPagesAvailable NOTIFY previousPagesAvailableChanged)
42 Q_PROPERTY(bool nextPagesAvailable READ nextPagesAvailable NOTIFY nextPagesAvailableChanged)
43 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
44
45 Q_INTERFACES(QQmlParserStatus)
46
47public:
48 enum Status {
49 Null,
50 Ready,
51 Loading,
52 Error
53 };
54 Q_ENUM(Status)
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
Combined button and popup list for selecting options.