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
qdeclarativegeomapitemview_p.h
Go to the documentation of this file.
1// Copyright (C) 2015 Jolla Ltd.
2// Copyright (C) 2022 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QDECLARATIVEGEOMAPITEMVIEW_H
6#define QDECLARATIVEGEOMAPITEMVIEW_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 <map>
21#include <QtCore/QModelIndex>
22#include <QtQml/QQmlParserStatus>
23#include <QtQml/QQmlIncubator>
24#include <QtQml/qqml.h>
25#include <private/qqmldelegatemodel_p.h>
26#include <QtQuick/private/qquicktransition_p.h>
27#include <QtLocation/private/qdeclarativegeomapitemgroup_p.h>
28
29QT_BEGIN_NAMESPACE
30
31class QAbstractItemModel;
32class QQmlComponent;
33class QQuickItem;
34class QDeclarativeGeoMap;
35class QDeclarativeGeoMapItemBase;
36class QQmlOpenMetaObject;
37class QQmlOpenMetaObjectType;
38class MapItemViewDelegateIncubator;
39class QDeclarativeGeoMapItemViewItemData;
40class QDeclarativeGeoMapItemView;
41class QDeclarativeGeoMapItemGroup;
42
43class Q_LOCATION_EXPORT QDeclarativeGeoMapItemView : public QDeclarativeGeoMapItemGroup
44{
45 Q_OBJECT
46 QML_NAMED_ELEMENT(MapItemView)
47 QML_ADDED_IN_VERSION(5, 0)
48 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
49 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
50 Q_PROPERTY(bool autoFitViewport READ autoFitViewport WRITE setAutoFitViewport NOTIFY autoFitViewportChanged)
51 Q_PROPERTY(QQuickTransition *add MEMBER m_enter REVISION(5, 12))
52 Q_PROPERTY(QQuickTransition *remove MEMBER m_exit REVISION(5, 12))
53 Q_PROPERTY(QList<QQuickItem *> mapItems READ mapItems REVISION(5, 12))
54 Q_PROPERTY(bool incubateDelegates READ incubateDelegates WRITE setIncubateDelegates NOTIFY incubateDelegatesChanged REVISION(5, 12))
55 Q_PROPERTY(QQmlDelegateModel::DelegateModelAccess delegateModelAccess READ delegateModelAccess
56 WRITE setDelegateModelAccess NOTIFY delegateModelAccessChanged REVISION(6, 10) FINAL)
57
58
59public:
60 explicit QDeclarativeGeoMapItemView(QQuickItem *parent = nullptr);
61 ~QDeclarativeGeoMapItemView();
62
63 QVariant model() const;
64 void setModel(const QVariant &);
65
66 QQmlComponent *delegate() const;
67 void setDelegate(QQmlComponent *);
68
69 bool autoFitViewport() const;
70 void setAutoFitViewport(const bool &fit);
71
72 void setMap(QDeclarativeGeoMap *);
73 void removeInstantiatedItems(bool transition = true);
74 void instantiateAllItems();
75
76 void setIncubateDelegates(bool useIncubators);
77 bool incubateDelegates() const;
78
79 QQmlDelegateModel::DelegateModelAccess delegateModelAccess() const;
80 void setDelegateModelAccess(QQmlDelegateModel::DelegateModelAccess delegateModelAccess);
81
82 QList<QQuickItem *> mapItems();
83
84 // From QQmlParserStatus
85 void componentComplete() override;
86 void classBegin() override;
87
88Q_SIGNALS:
89 void modelChanged();
90 void delegateChanged();
91 void autoFitViewportChanged();
92 void incubateDelegatesChanged();
93 Q_REVISION(6, 10) void delegateModelAccessChanged();
94
95private Q_SLOTS:
96 void destroyingItem(QObject *object);
97 void initItem(int index, QObject *object);
98 void createdItem(int index, QObject *object);
99 void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
100 void exitTransitionFinished();
101
102private:
103 void fitViewport();
104 void removeDelegateFromMap(int index, bool transition = true);
105 void removeDelegateFromMap(QQuickItem *o);
106 void transitionItemOut(QQuickItem *o);
107 void terminateExitTransition(QQuickItem *o);
108 QQmlInstanceModel::ReleaseFlags disposeDelegate(QQuickItem *item);
109
110 void insertInstantiatedItem(int index, QQuickItem *o, bool createdItem);
111 void addItemToMap(QDeclarativeGeoMapItemBase *item, int index, bool createdItem);
112 void addItemViewToMap(QDeclarativeGeoMapItemView *item, int index, bool createdItem);
113 void addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index, bool createdItem);
114 void addDelegateToMap(QQuickItem *object, int index, bool createdItem = false);
115
116 QQmlIncubator::IncubationMode m_incubationMode = QQmlIncubator::Asynchronous;
117 QQmlComponent *m_delegate = nullptr;
118 QVariant m_itemModel;
119 QDeclarativeGeoMap *m_map = nullptr;
120 QList<QQuickItem *> m_instantiatedItems;
121 QQmlDelegateModel *m_delegateModel = nullptr;
122 QQuickTransition *m_enter = nullptr;
123 QQuickTransition *m_exit = nullptr;
124
125 QQmlDelegateModel::DelegateModelAccess m_delegateModelAccess
126 = QQmlDelegateModel::Qt5ReadWrite;
127
128 bool m_componentCompleted = false;
129 bool m_fitViewport = false;
130 bool m_creatingObject = false;
131
132 friend class QDeclarativeGeoMap;
133 friend class QDeclarativeGeoMapItemBase;
134 friend class QDeclarativeGeoMapItemTransitionManager;
135};
136
137QT_END_NAMESPACE
138
139QML_DECLARE_TYPE(QDeclarativeGeoMapItemView)
140
141#endif