##// END OF EJS Templates
Adding metatype declarations in qml plugin for Qt5...
Jani Honkonen -
r2257:b97c592cff78
parent child
Show More
@@ -1,153 +1,213
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchart.h"
21 #include "qchart.h"
22 #include "qabstractaxis.h"
22 #include "qabstractaxis.h"
23 #include "qvalueaxis.h"
23 #include "qvalueaxis.h"
24 #include "declarativecategoryaxis.h"
24 #include "declarativecategoryaxis.h"
25 #include "qbarcategoryaxis.h"
25 #include "qbarcategoryaxis.h"
26 #include "declarativechart.h"
26 #include "declarativechart.h"
27 #include "declarativexypoint.h"
27 #include "declarativexypoint.h"
28 #include "declarativelineseries.h"
28 #include "declarativelineseries.h"
29 #include "declarativesplineseries.h"
29 #include "declarativesplineseries.h"
30 #include "declarativeareaseries.h"
30 #include "declarativeareaseries.h"
31 #include "declarativescatterseries.h"
31 #include "declarativescatterseries.h"
32 #include "declarativebarseries.h"
32 #include "declarativebarseries.h"
33 #include "declarativepieseries.h"
33 #include "declarativepieseries.h"
34 #include "qvxymodelmapper.h"
34 #include "qvxymodelmapper.h"
35 #include "qhxymodelmapper.h"
35 #include "qhxymodelmapper.h"
36 #include "qhpiemodelmapper.h"
36 #include "qhpiemodelmapper.h"
37 #include "qvpiemodelmapper.h"
37 #include "qvpiemodelmapper.h"
38 #include "qhbarmodelmapper.h"
38 #include "qhbarmodelmapper.h"
39 #include "qvbarmodelmapper.h"
39 #include "qvbarmodelmapper.h"
40 #include "declarativemargins.h"
40 #include "declarativemargins.h"
41 #include "qarealegendmarker.h"
42 #include "qbarlegendmarker.h"
43 #include "qpielegendmarker.h"
44 #include "qxylegendmarker.h"
41 #ifndef QT_ON_ARM
45 #ifndef QT_ON_ARM
42 #include "qdatetimeaxis.h"
46 #include "qdatetimeaxis.h"
43 #endif
47 #endif
44 #include <QAbstractItemModel>
48 #include <QAbstractItemModel>
45 #include <QtDeclarative/qdeclarativeextensionplugin.h>
49 #include <QtDeclarative/qdeclarativeextensionplugin.h>
46 #include <QtDeclarative/qdeclarative.h>
50 #include <QtDeclarative/qdeclarative.h>
47
51
48 QTCOMMERCIALCHART_USE_NAMESPACE
52 QTCOMMERCIALCHART_USE_NAMESPACE
49
53
50 Q_DECLARE_METATYPE(QList<QPieSlice *>)
54 Q_DECLARE_METATYPE(QList<QPieSlice *>)
51 Q_DECLARE_METATYPE(QList<QBarSet *>)
55 Q_DECLARE_METATYPE(QList<QBarSet *>)
56
57 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
58
59 // NOTE: Hackish fixes for Qt5 (beta2).
60 // These should not be needed or at least they are not needed in Qt4.
61
62 Q_DECLARE_METATYPE(DeclarativeChart::SeriesType)
63 Q_DECLARE_METATYPE(DeclarativeMargins *)
64 Q_DECLARE_METATYPE(DeclarativeAreaSeries *)
65 Q_DECLARE_METATYPE(DeclarativeBarSeries *)
66 Q_DECLARE_METATYPE(DeclarativeLineSeries *)
67 Q_DECLARE_METATYPE(DeclarativePieSeries *)
68 Q_DECLARE_METATYPE(DeclarativeScatterSeries *)
69 Q_DECLARE_METATYPE(DeclarativeSplineSeries *)
70
71 Q_DECLARE_METATYPE(QAbstractAxis *)
72 Q_DECLARE_METATYPE(QValueAxis *)
73 Q_DECLARE_METATYPE(QBarCategoryAxis *)
74 Q_DECLARE_METATYPE(QCategoryAxis *)
75 Q_DECLARE_METATYPE(QDateTimeAxis *)
76
77 Q_DECLARE_METATYPE(QLegend *)
78 Q_DECLARE_METATYPE(QLegendMarker *)
79 Q_DECLARE_METATYPE(QAreaLegendMarker *)
80 Q_DECLARE_METATYPE(QBarLegendMarker *)
81 Q_DECLARE_METATYPE(QPieLegendMarker *)
82
83 Q_DECLARE_METATYPE(QHPieModelMapper *)
84 Q_DECLARE_METATYPE(QHXYModelMapper *)
85 Q_DECLARE_METATYPE(QPieModelMapper *)
86 Q_DECLARE_METATYPE(QHBarModelMapper *)
87 Q_DECLARE_METATYPE(QBarModelMapper *)
88 Q_DECLARE_METATYPE(QVBarModelMapper *)
89 Q_DECLARE_METATYPE(QVPieModelMapper *)
90 Q_DECLARE_METATYPE(QVXYModelMapper *)
91 Q_DECLARE_METATYPE(QXYLegendMarker *)
92 Q_DECLARE_METATYPE(QXYModelMapper *)
93
52 Q_DECLARE_METATYPE(QAbstractSeries *)
94 Q_DECLARE_METATYPE(QAbstractSeries *)
95 Q_DECLARE_METATYPE(QXYSeries *)
96 Q_DECLARE_METATYPE(QAbstractBarSeries *)
97 Q_DECLARE_METATYPE(QBarSeries *)
98 Q_DECLARE_METATYPE(QBarSet *)
99 Q_DECLARE_METATYPE(QAreaSeries *)
100 Q_DECLARE_METATYPE(QHorizontalBarSeries *)
101 Q_DECLARE_METATYPE(QHorizontalPercentBarSeries *)
102 Q_DECLARE_METATYPE(QHorizontalStackedBarSeries *)
103 Q_DECLARE_METATYPE(QLineSeries *)
104 Q_DECLARE_METATYPE(QPercentBarSeries *)
105 Q_DECLARE_METATYPE(QPieSeries *)
106 Q_DECLARE_METATYPE(QPieSlice *)
107 Q_DECLARE_METATYPE(QScatterSeries *)
108 Q_DECLARE_METATYPE(QSplineSeries *)
109 Q_DECLARE_METATYPE(QStackedBarSeries *)
110
111 #endif
53
112
54 QTCOMMERCIALCHART_BEGIN_NAMESPACE
113 QTCOMMERCIALCHART_BEGIN_NAMESPACE
55
114
56 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
115 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
57 {
116 {
58 Q_OBJECT
117 Q_OBJECT
59
118
60 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
119 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
61 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
120 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface")
62 #endif
121 #endif
63
122
64 public:
123 public:
65 virtual void registerTypes(const char *uri)
124 virtual void registerTypes(const char *uri)
66 {
125 {
67 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
126 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
68
127
69 qRegisterMetaType<QList<QPieSlice *> >();
128 qRegisterMetaType<QList<QPieSlice *> >();
70 qRegisterMetaType<QList<QBarSet *> >();
129 qRegisterMetaType<QList<QBarSet *> >();
130 qRegisterMetaType<DeclarativeChart::SeriesType>();
71
131
72 // QtCommercial.Chart 1.0
132 // QtCommercial.Chart 1.0
73 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
133 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
74 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
134 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
75 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
135 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
76 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
136 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
77 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
137 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
78 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
138 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
79 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
139 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
80 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
140 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
81 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
141 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
82 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
142 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
83 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
143 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
84 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
144 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
85 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
145 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
86 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
146 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
87 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
147 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
88 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
148 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
89 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
149 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
90 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
150 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
91 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
151 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
92 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
152 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
93 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
153 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
94 QLatin1String("Trying to create uncreatable: Legend."));
154 QLatin1String("Trying to create uncreatable: Legend."));
95 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
155 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
96 QLatin1String("Trying to create uncreatable: XYSeries."));
156 QLatin1String("Trying to create uncreatable: XYSeries."));
97 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
157 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
98 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
158 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
99 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
159 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
100 QLatin1String("Trying to create uncreatable: XYModelMapper."));
160 QLatin1String("Trying to create uncreatable: XYModelMapper."));
101 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
161 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
102 QLatin1String("Trying to create uncreatable: PieModelMapper."));
162 QLatin1String("Trying to create uncreatable: PieModelMapper."));
103 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
163 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
104 QLatin1String("Trying to create uncreatable: BarModelMapper."));
164 QLatin1String("Trying to create uncreatable: BarModelMapper."));
105 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
165 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
106 QLatin1String("Trying to create uncreatable: AbstractSeries."));
166 QLatin1String("Trying to create uncreatable: AbstractSeries."));
107 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
167 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
108 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
168 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
109 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
169 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
110 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
170 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
111 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
171 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
112 QLatin1String("Trying to create uncreatable: BarsetBase."));
172 QLatin1String("Trying to create uncreatable: BarsetBase."));
113 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
173 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
114 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
174 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
115
175
116 // QtCommercial.Chart 1.1
176 // QtCommercial.Chart 1.1
117 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
177 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
118 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
178 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
119 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
179 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
120 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
180 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
121 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
181 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
122 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
182 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
123 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
183 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
124 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
184 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
125 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
185 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
126 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
186 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
127 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
187 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
128 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
188 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
129 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
189 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
130 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
190 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
131 #ifndef QT_ON_ARM
191 #ifndef QT_ON_ARM
132 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
192 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
133 #endif
193 #endif
134 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
194 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
135 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
195 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
136 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
196 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
137 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
197 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
138 QLatin1String("Trying to create uncreatable: Margins."));
198 QLatin1String("Trying to create uncreatable: Margins."));
139
199
140 // QtCommercial.Chart 1.2
200 // QtCommercial.Chart 1.2
141 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
201 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
142 }
202 }
143 };
203 };
144
204
145 #include "plugin.moc"
205 #include "plugin.moc"
146
206
147 QTCOMMERCIALCHART_END_NAMESPACE
207 QTCOMMERCIALCHART_END_NAMESPACE
148
208
149 QTCOMMERCIALCHART_USE_NAMESPACE
209 QTCOMMERCIALCHART_USE_NAMESPACE
150
210
151 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
211 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
152 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
212 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
153 #endif
213 #endif
General Comments 0
You need to be logged in to leave comments. Login now