1/****************************************************************************
2**
3** Copyright (C) 2015 Jolla Ltd.
4** Contact: Aaron McCarthy <aaron.mccarthy@jollamobile.com>
5** Copyright (C) 2015 The Qt Company Ltd.
6** Contact: http://www.qt.io/licensing/
7**
8** This file is part of the QtLocation module of the Qt Toolkit.
9**
10** $QT_BEGIN_LICENSE:LGPL3$
11** Commercial License Usage
12** Licensees holding valid commercial Qt licenses may use this file in
13** accordance with the commercial license agreement provided with the
14** Software or, alternatively, in accordance with the terms contained in
15** a written agreement between you and The Qt Company. For licensing terms
16** and conditions see http://www.qt.io/terms-conditions. For further
17** information use the contact form at http://www.qt.io/contact-us.
18**
19** GNU Lesser General Public License Usage
20** Alternatively, this file may be used under the terms of the GNU Lesser
21** General Public License version 3 as published by the Free Software
22** Foundation and appearing in the file LICENSE.LGPLv3 included in the
23** packaging of this file. Please review the following information to
24** ensure the GNU Lesser General Public License version 3 requirements
25** will be met: https://www.gnu.org/licenses/lgpl.html.
26**
27** GNU General Public License Usage
28** Alternatively, this file may be used under the terms of the GNU
29** General Public License version 2.0 or later as published by the Free
30** Software Foundation and appearing in the file LICENSE.GPL included in
31** the packaging of this file. Please review the following information to
32** ensure the GNU General Public License version 2.0 requirements will be
33** met: http://www.gnu.org/licenses/gpl-2.0.html.
34**
35** $QT_END_LICENSE$
36**
37****************************************************************************/
38
39#ifndef QDECLARATIVEGEOMAPITEMVIEW_H
40#define QDECLARATIVEGEOMAPITEMVIEW_H
41
42//
43// W A R N I N G
44// -------------
45//
46// This file is not part of the Qt API. It exists purely as an
47// implementation detail. This header file may change from version to
48// version without notice, or even be removed.
49//
50// We mean it.
51//
52
53#include <QtLocation/private/qlocationglobal_p.h>
54#include <map>
55#include <QtCore/QModelIndex>
56#include <QtQml/QQmlParserStatus>
57#include <QtQml/QQmlIncubator>
58#include <QtQml/qqml.h>
59#include <private/qqmldelegatemodel_p.h>
60#include <QtQuick/private/qquicktransition_p.h>
61#include <QtLocation/private/qdeclarativegeomapitemgroup_p.h>
62
63QT_BEGIN_NAMESPACE
64
65class QAbstractItemModel;
66class QQmlComponent;
67class QQuickItem;
68class QDeclarativeGeoMap;
69class QDeclarativeGeoMapItemBase;
70class QQmlOpenMetaObject;
71class QQmlOpenMetaObjectType;
72class MapItemViewDelegateIncubator;
73class QDeclarativeGeoMapItemViewItemData;
74class QDeclarativeGeoMapItemView;
75class QDeclarativeGeoMapItemGroup;
76
77class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemView : public QDeclarativeGeoMapItemGroup
78{
79 Q_OBJECT
80
81 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
82 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
83 Q_PROPERTY(bool autoFitViewport READ autoFitViewport WRITE setAutoFitViewport NOTIFY autoFitViewportChanged)
84 Q_PROPERTY(QQuickTransition *add MEMBER m_enter REVISION 12)
85 Q_PROPERTY(QQuickTransition *remove MEMBER m_exit REVISION 12)
86 Q_PROPERTY(QList<QQuickItem *> mapItems READ mapItems REVISION 12)
87 Q_PROPERTY(bool incubateDelegates READ incubateDelegates WRITE setIncubateDelegates NOTIFY incubateDelegatesChanged REVISION 12)
88
89public:
90 explicit QDeclarativeGeoMapItemView(QQuickItem *parent = 0);
91 ~QDeclarativeGeoMapItemView();
92
93 QVariant model() const;
94 void setModel(const QVariant &);
95
96 QQmlComponent *delegate() const;
97 void setDelegate(QQmlComponent *);
98
99 bool autoFitViewport() const;
100 void setAutoFitViewport(const bool &fit);
101
102 void setMap(QDeclarativeGeoMap *);
103 void removeInstantiatedItems(bool transition = true);
104 void instantiateAllItems();
105
106 void setIncubateDelegates(bool useIncubators);
107 bool incubateDelegates() const;
108
109 QList<QQuickItem *> mapItems();
110
111 // From QQmlParserStatus
112 void componentComplete() override;
113 void classBegin() override;
114
115Q_SIGNALS:
116 void modelChanged();
117 void delegateChanged();
118 void autoFitViewportChanged();
119 void incubateDelegatesChanged();
120
121private Q_SLOTS:
122 void destroyingItem(QObject *object);
123 void initItem(int index, QObject *object);
124 void createdItem(int index, QObject *object);
125 void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
126 void exitTransitionFinished();
127
128private:
129 void fitViewport();
130 void removeDelegateFromMap(int index, bool transition = true);
131 void removeDelegateFromMap(QQuickItem *o);
132 void transitionItemOut(QQuickItem *o);
133 void terminateExitTransition(QQuickItem *o);
134 QQmlInstanceModel::ReleaseFlags disposeDelegate(QQuickItem *item);
135
136 void insertInstantiatedItem(int index, QQuickItem *o, bool createdItem);
137 void addItemToMap(QDeclarativeGeoMapItemBase *item, int index, bool createdItem);
138 void addItemViewToMap(QDeclarativeGeoMapItemView *item, int index, bool createdItem);
139 void addItemGroupToMap(QDeclarativeGeoMapItemGroup *item, int index, bool createdItem);
140 void addDelegateToMap(QQuickItem *object, int index, bool createdItem = false);
141
142 bool m_componentCompleted;
143 QQmlIncubator::IncubationMode m_incubationMode = QQmlIncubator::Asynchronous;
144 QQmlComponent *m_delegate;
145 QVariant m_itemModel;
146 QDeclarativeGeoMap *m_map;
147 QList<QQuickItem *> m_instantiatedItems;
148 bool m_fitViewport;
149 bool m_creatingObject = false;
150 QQmlDelegateModel *m_delegateModel;
151 QQuickTransition *m_enter = nullptr;
152 QQuickTransition *m_exit = nullptr;
153
154 friend class QDeclarativeGeoMap;
155 friend class QDeclarativeGeoMapItemBase;
156 friend class QDeclarativeGeoMapItemTransitionManager;
157};
158
159QT_END_NAMESPACE
160
161QML_DECLARE_TYPE(QDeclarativeGeoMapItemView)
162
163#endif
164

source code of qtlocation/src/location/declarativemaps/qdeclarativegeomapitemview_p.h