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_INTERFACES(QQmlParserStatus)
45
46public:
47 enum Status {
48 Null,
49 Ready,
50 Loading,
51 Error
52 };
53 Q_ENUM(Status)
54
55 explicit QDeclarativeSearchModelBase(QObject *parent = nullptr);
56 ~QDeclarativeSearchModelBase();
57
58 QDeclarativeGeoServiceProvider *plugin() const;
59 void setPlugin(QDeclarativeGeoServiceProvider *plugin);
60
61 QVariant searchArea() const;
62 void setSearchArea(const QVariant &searchArea);
63
64 int limit() const;
65 void setLimit(int limit);
66
67 bool previousPagesAvailable() const;
68 bool nextPagesAvailable() const;
69
70 Status status() const;
71 void setStatus(Status status, const QString &errorString = QString());
72
73 Q_INVOKABLE void update();
74
75 Q_INVOKABLE void cancel();
76 Q_INVOKABLE void reset();
77
78 Q_INVOKABLE QString errorString() const;
79
80 Q_INVOKABLE void previousPage();
81 Q_INVOKABLE void nextPage();
82
83 virtual void clearData(bool suppressSignal = false);
84
85 // From QQmlParserStatus
86 void classBegin() override;
87 void componentComplete() override;
88
89Q_SIGNALS:
90 void pluginChanged();
91 void searchAreaChanged();
92 void limitChanged();
93 void previousPagesAvailableChanged();
94 void nextPagesAvailableChanged();
95 void statusChanged();
96
97protected:
98 virtual void initializePlugin(QDeclarativeGeoServiceProvider *plugin);
99
100protected Q_SLOTS:
101 virtual void queryFinished() = 0;
102 virtual void onContentUpdated();
103
104private Q_SLOTS:
105 void pluginNameChanged();
106
107protected:
108 virtual QPlaceReply *sendQuery(QPlaceManager *manager, const QPlaceSearchRequest &request) = 0;
109 void setPreviousPageRequest(const QPlaceSearchRequest &previous);
110 void setNextPageRequest(const QPlaceSearchRequest &next);
111
112 QPlaceSearchRequest m_request;
113 QDeclarativeGeoServiceProvider *m_plugin = nullptr;
114 QPlaceReply *m_reply = nullptr;
115
116private:
117 bool m_complete = false;
118 Status m_status = Null;
119 QString m_errorString;
120 QPlaceSearchRequest m_previousPageRequest;
121 QPlaceSearchRequest m_nextPageRequest;
122};
123
124QT_END_NAMESPACE
125
126#endif // QDECLARATIVESEARCHMODELBASE_H
Combined button and popup list for selecting options.