Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdeclarativesupportedcategoriesmodel_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 QDECLARATIVESUPPORTEDCATEGORIESMODEL_H
5#define QDECLARATIVESUPPORTEDCATEGORIESMODEL_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
21#include <QObject>
22#include <QtCore/QStringList>
23#include <QtCore/QSharedPointer>
24#include <QAbstractListModel>
25#include <QQmlListProperty>
26#include <QtQml/QQmlParserStatus>
27
28#include <QtLocation/QPlaceCategory>
29
30#include <QtLocation/private/qdeclarativecategory_p.h>
31
33
35class QPlaceManager;
36class QPlaceReply;
37
39{
41 QML_NAMED_ELEMENT(CategoryModel)
43
45
46 Q_PROPERTY(QDeclarativeGeoServiceProvider *plugin READ plugin WRITE setPlugin NOTIFY pluginChanged)
47 Q_PROPERTY(bool hierarchical READ hierarchical WRITE setHierarchical NOTIFY hierarchicalChanged)
48 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
49
51 Q_ENUMS(Roles) //The Roles enum is for internal usage only.
52
53public:
56
57 // From QQmlParserStatus
58 void classBegin() override {}
59 void componentComplete() override;
60
61 // From QAbstractItemModel
62 int rowCount(const QModelIndex &parent) const override;
63 int columnCount(const QModelIndex &parent) const override;
64
65 QModelIndex index(int row, int column, const QModelIndex &parent) const override;
66 QModelIndex parent(const QModelIndex &child) const override;
67
68 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
69 QHash<int, QByteArray> roleNames() const override;
70
71 enum Roles {
72 CategoryRole = Qt::UserRole,
73 ParentCategoryRole
74 }; //for internal usage only
75
76 enum Status {Null, Ready, Loading, Error};
77
78 void setPlugin(QDeclarativeGeoServiceProvider *plugin);
79 QDeclarativeGeoServiceProvider *plugin() const;
80
81 void setHierarchical(bool hierarchical);
82 bool hierarchical() const;
83
84 Q_INVOKABLE QString errorString() const;
85
86 Status status() const;
87 void setStatus(Status status, const QString &errorString = QString());
88
95
96public Q_SLOTS:
97 void update();
98
99private Q_SLOTS:
100 void replyFinished();
101 void addedCategory(const QPlaceCategory &category, const QString &parentId);
102 void updatedCategory(const QPlaceCategory &category, const QString &parentId);
103 void removedCategory(const QString &categoryId, const QString &parentId);
104 void connectNotificationSignals();
105
106private:
107 struct PlaceCategoryNode
108 {
109 QString parentId;
110 QStringList childIds;
111 QSharedPointer<QDeclarativeCategory> declCategory;
112 };
113
114 QStringList populateCategories(QPlaceManager *, const QPlaceCategory &parent);
115 QModelIndex index(const QString &categoryId) const;
116 int rowToAddChild(PlaceCategoryNode *, const QPlaceCategory &category);
117 void updateLayout();
118 void emitDataChanged() { Q_EMIT dataChanged(); }
119
120 QPlaceReply *m_response = nullptr;
121
122 QDeclarativeGeoServiceProvider *m_plugin = nullptr;
123 bool m_hierarchical = true;
124 bool m_complete = false;
125 Status m_status = Null;
126 QString m_errorString;
127
128 QHash<QString, PlaceCategoryNode *> m_categoriesTree;
129};
130
132
134
135#endif // QDECLARATIVESUPPORTEDCATEGORIESMODEL_H
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
Roles
\qmltype CategoryModel \instantiates QDeclarativeSupportedCategoriesModel \inqmlmodule QtLocation
\inmodule QtLocation
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtLocation
\inmodule QtLocation
\inmodule QtLocation
Definition qplacereply.h:15
The QQmlParserStatus class provides updates on the QML parser state.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
const QLoggingCategory & category()
[1]
void statusChanged(QQmlComponent::Status status)
[1]
Definition qlogging.cpp:11
Combined button and popup list for selecting options.
@ UserRole
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_INVOKABLE
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_ENUMS(x)
#define Q_SIGNALS
#define explicit
QLayoutItem * child
[0]
void replyFinished(QNetworkReply *reply)
[1]