##// END OF EJS Templates
Simplified QML type registrations
Tero Ahola -
r2245:9bd84dc87648
parent child
Show More
@@ -1,189 +1,158
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 #ifdef QT5_QUICK_1
21 #ifdef QT5_QUICK_1
22 #include <QtQuick1/qdeclarativeextensionplugin.h>
22 #include <QtQuick1/qdeclarativeextensionplugin.h>
23 #include <QtQuick1/qdeclarative.h>
23 #include <QtQuick1/qdeclarative.h>
24 #else
24 #else
25 #include <QtDeclarative/qdeclarativeextensionplugin.h>
25 #include <QtDeclarative/qdeclarativeextensionplugin.h>
26 #include <QtDeclarative/qdeclarative.h>
26 #include <QtDeclarative/qdeclarative.h>
27 #endif
27 #endif
28 #include "qchart.h"
28 #include "qchart.h"
29 #include "qabstractaxis.h"
29 #include "qabstractaxis.h"
30 #include "qvalueaxis.h"
30 #include "qvalueaxis.h"
31 #include "declarativecategoryaxis.h"
31 #include "declarativecategoryaxis.h"
32 #include "qbarcategoryaxis.h"
32 #include "qbarcategoryaxis.h"
33 #include "declarativechart.h"
33 #include "declarativechart.h"
34 #include "declarativexypoint.h"
34 #include "declarativexypoint.h"
35 #include "declarativelineseries.h"
35 #include "declarativelineseries.h"
36 #include "declarativesplineseries.h"
36 #include "declarativesplineseries.h"
37 #include "declarativeareaseries.h"
37 #include "declarativeareaseries.h"
38 #include "declarativescatterseries.h"
38 #include "declarativescatterseries.h"
39 #include "declarativebarseries.h"
39 #include "declarativebarseries.h"
40 #include "declarativepieseries.h"
40 #include "declarativepieseries.h"
41 #include "qvxymodelmapper.h"
41 #include "qvxymodelmapper.h"
42 #include "qhxymodelmapper.h"
42 #include "qhxymodelmapper.h"
43 #include "qhpiemodelmapper.h"
43 #include "qhpiemodelmapper.h"
44 #include "qvpiemodelmapper.h"
44 #include "qvpiemodelmapper.h"
45 #include "qhbarmodelmapper.h"
45 #include "qhbarmodelmapper.h"
46 #include "qvbarmodelmapper.h"
46 #include "qvbarmodelmapper.h"
47 #include "declarativemargins.h"
47 #include "declarativemargins.h"
48 #include <QAbstractItemModel>
48 #include <QAbstractItemModel>
49
49
50 #ifndef QT_ON_ARM
50 #ifndef QT_ON_ARM
51 #include "qdatetimeaxis.h"
51 #include "qdatetimeaxis.h"
52 #endif
52 #endif
53
53
54 QTCOMMERCIALCHART_USE_NAMESPACE
54 QTCOMMERCIALCHART_USE_NAMESPACE
55
55
56 Q_DECLARE_METATYPE(QList<QPieSlice *>)
56 Q_DECLARE_METATYPE(QList<QPieSlice *>)
57 Q_DECLARE_METATYPE(QList<QBarSet *>)
57 Q_DECLARE_METATYPE(QList<QBarSet *>)
58
58
59 QTCOMMERCIALCHART_BEGIN_NAMESPACE
59 QTCOMMERCIALCHART_BEGIN_NAMESPACE
60
60
61 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
61 class ChartQmlPlugin : public QDeclarativeExtensionPlugin
62 {
62 {
63 Q_OBJECT
63 Q_OBJECT
64
64
65 #ifdef QT5_QUICK_1
65 #ifdef QT5_QUICK_1
66 // TODO: fix the metadata
66 // TODO: fix the metadata
67 Q_PLUGIN_METADATA(IID "org.qt-project.foo")
67 Q_PLUGIN_METADATA(IID "org.qt-project.foo")
68 #endif
68 #endif
69
69
70 public:
70 public:
71 virtual void registerTypes(const char *uri)
71 virtual void registerTypes(const char *uri)
72 {
72 {
73 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
73 Q_ASSERT(QLatin1String(uri) == QLatin1String("QtCommercial.Chart"));
74
74
75 qRegisterMetaType<QList<QPieSlice *> >();
75 qRegisterMetaType<QList<QPieSlice *> >();
76 qRegisterMetaType<QList<QBarSet *> >();
76 qRegisterMetaType<QList<QBarSet *> >();
77
77
78 // QtCommercial.Chart 1.0
78 // QtCommercial.Chart 1.0
79 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
79 qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView");
80 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
80 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 0, "XYPoint");
81 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
81 qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries");
82 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
82 qmlRegisterType<DeclarativeLineSeries>(uri, 1, 0, "LineSeries");
83 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
83 qmlRegisterType<DeclarativeSplineSeries>(uri, 1, 0, "SplineSeries");
84 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
84 qmlRegisterType<DeclarativeAreaSeries>(uri, 1, 0, "AreaSeries");
85 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
85 qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries");
86 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
86 qmlRegisterType<DeclarativeStackedBarSeries>(uri, 1, 0, "StackedBarSeries");
87 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
87 qmlRegisterType<DeclarativePercentBarSeries>(uri, 1, 0, "PercentBarSeries");
88 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
88 qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries");
89 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
89 qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice");
90 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
90 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
91 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
91 qmlRegisterType<QHXYModelMapper>(uri, 1, 0, "HXYModelMapper");
92 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
92 qmlRegisterType<QVXYModelMapper>(uri, 1, 0, "VXYModelMapper");
93 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
93 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
94 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
94 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
95 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
95 qmlRegisterType<QHBarModelMapper>(uri, 1, 0, "HBarModelMapper");
96 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
96 qmlRegisterType<QVBarModelMapper>(uri, 1, 0, "VBarModelMapper");
97 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
97 qmlRegisterType<QValueAxis>(uri, 1, 0, "ValuesAxis");
98 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
98 qmlRegisterType<QBarCategoryAxis>(uri, 1, 0, "BarCategoriesAxis");
99 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
99 qmlRegisterUncreatableType<QLegend>(uri, 1, 0, "Legend",
100 QLatin1String("Trying to create uncreatable: Legend."));
100 QLatin1String("Trying to create uncreatable: Legend."));
101 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
101 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 0, "XYSeries",
102 QLatin1String("Trying to create uncreatable: XYSeries."));
102 QLatin1String("Trying to create uncreatable: XYSeries."));
103 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
103 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
104 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
104 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
105 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
105 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper",
106 QLatin1String("Trying to create uncreatable: XYModelMapper."));
106 QLatin1String("Trying to create uncreatable: XYModelMapper."));
107 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
107 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
108 QLatin1String("Trying to create uncreatable: PieModelMapper."));
108 QLatin1String("Trying to create uncreatable: PieModelMapper."));
109 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
109 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 0, "BarModelMapper",
110 QLatin1String("Trying to create uncreatable: BarModelMapper."));
110 QLatin1String("Trying to create uncreatable: BarModelMapper."));
111 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
111 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
112 QLatin1String("Trying to create uncreatable: AbstractSeries."));
112 QLatin1String("Trying to create uncreatable: AbstractSeries."));
113 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
113 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 0, "AbstractBarSeries",
114 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
114 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
115 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
115 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 0, "AbstractAxis",
116 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
116 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
117 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
117 qmlRegisterUncreatableType<QBarSet>(uri, 1, 0, "BarSetBase",
118 QLatin1String("Trying to create uncreatable: BarsetBase."));
118 QLatin1String("Trying to create uncreatable: BarsetBase."));
119 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
119 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 0, "QPieSeries",
120 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
120 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
121
121
122 // QtCommercial.Chart 1.1
122 // QtCommercial.Chart 1.1
123 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
123 qmlRegisterType<DeclarativeChart, 1>(uri, 1, 1, "ChartView");
124 qmlRegisterType<DeclarativeXYPoint>(uri, 1, 1, "XYPoint");
125 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
124 qmlRegisterType<DeclarativeScatterSeries, 1>(uri, 1, 1, "ScatterSeries");
126 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
125 qmlRegisterType<DeclarativeLineSeries, 1>(uri, 1, 1, "LineSeries");
127 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
126 qmlRegisterType<DeclarativeSplineSeries, 1>(uri, 1, 1, "SplineSeries");
128 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
127 qmlRegisterType<DeclarativeAreaSeries, 1>(uri, 1, 1, "AreaSeries");
129 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
128 qmlRegisterType<DeclarativeBarSeries, 1>(uri, 1, 1, "BarSeries");
130 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
129 qmlRegisterType<DeclarativeStackedBarSeries, 1>(uri, 1, 1, "StackedBarSeries");
131 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
130 qmlRegisterType<DeclarativePercentBarSeries, 1>(uri, 1, 1, "PercentBarSeries");
132 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
131 qmlRegisterType<DeclarativeHorizontalBarSeries, 1>(uri, 1, 1, "HorizontalBarSeries");
133 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
132 qmlRegisterType<DeclarativeHorizontalStackedBarSeries, 1>(uri, 1, 1, "HorizontalStackedBarSeries");
134 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
133 qmlRegisterType<DeclarativeHorizontalPercentBarSeries, 1>(uri, 1, 1, "HorizontalPercentBarSeries");
135 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
134 qmlRegisterType<DeclarativePieSeries>(uri, 1, 1, "PieSeries");
136 qmlRegisterType<QPieSlice>(uri, 1, 1, "PieSlice");
137 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
135 qmlRegisterType<DeclarativeBarSet>(uri, 1, 1, "BarSet");
138 qmlRegisterType<QHXYModelMapper>(uri, 1, 1, "HXYModelMapper");
139 qmlRegisterType<QVXYModelMapper>(uri, 1, 1, "VXYModelMapper");
140 qmlRegisterType<QHPieModelMapper>(uri, 1, 1, "HPieModelMapper");
141 qmlRegisterType<QVPieModelMapper>(uri, 1, 1, "VPieModelMapper");
142 qmlRegisterType<QHBarModelMapper>(uri, 1, 1, "HBarModelMapper");
143 qmlRegisterType<QVBarModelMapper>(uri, 1, 1, "VBarModelMapper");
144 qmlRegisterType<QValueAxis>(uri, 1, 1, "ValueAxis");
145 #ifndef QT_ON_ARM
136 #ifndef QT_ON_ARM
146 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
137 qmlRegisterType<QDateTimeAxis>(uri, 1, 1, "DateTimeAxis");
147 #endif
138 #endif
148 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
139 qmlRegisterType<DeclarativeCategoryAxis>(uri, 1, 1, "CategoryAxis");
149 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
140 qmlRegisterType<DeclarativeCategoryRange>(uri, 1, 1, "CategoryRange");
150 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
141 qmlRegisterType<QBarCategoryAxis>(uri, 1, 1, "BarCategoryAxis");
151 qmlRegisterUncreatableType<QLegend>(uri, 1, 1, "Legend",
152 QLatin1String("Trying to create uncreatable: Legend."));
153 qmlRegisterUncreatableType<QXYSeries>(uri, 1, 1, "XYSeries",
154 QLatin1String("Trying to create uncreatable: XYSeries."));
155 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 1, "AbstractItemModel",
156 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
157 qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 1, "XYModelMapper",
158 QLatin1String("Trying to create uncreatable: XYModelMapper."));
159 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 1, "PieModelMapper",
160 QLatin1String("Trying to create uncreatable: PieModelMapper."));
161 qmlRegisterUncreatableType<QBarModelMapper>(uri, 1, 1, "BarModelMapper",
162 QLatin1String("Trying to create uncreatable: BarModelMapper."));
163 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 1, "AbstractSeries",
164 QLatin1String("Trying to create uncreatable: AbstractSeries."));
165 qmlRegisterUncreatableType<QAbstractBarSeries>(uri, 1, 1, "AbstractBarSeries",
166 QLatin1String("Trying to create uncreatable: AbstractBarSeries."));
167 qmlRegisterUncreatableType<QAbstractAxis>(uri, 1, 1, "AbstractAxis",
168 QLatin1String("Trying to create uncreatable: AbstractAxis. Use specific types of axis instead."));
169 qmlRegisterUncreatableType<QBarSet>(uri, 1, 1, "BarSetBase",
170 QLatin1String("Trying to create uncreatable: BarsetBase."));
171 qmlRegisterUncreatableType<QPieSeries>(uri, 1, 1, "QPieSeries",
172 QLatin1String("Trying to create uncreatable: QPieSeries. Use PieSeries instead."));
173 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
142 qmlRegisterUncreatableType<DeclarativeMargins>(uri, 1, 1, "Margins",
174 QLatin1String("Trying to create uncreatable: Margins."));
143 QLatin1String("Trying to create uncreatable: Margins."));
175
144
176 // QtCommercial.Chart 1.2
145 // QtCommercial.Chart 1.2
177 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
146 qmlRegisterType<DeclarativeChart, 2>(uri, 1, 2, "ChartView");
178 }
147 }
179 };
148 };
180
149
181 #include "plugin.moc"
150 #include "plugin.moc"
182
151
183 QTCOMMERCIALCHART_END_NAMESPACE
152 QTCOMMERCIALCHART_END_NAMESPACE
184
153
185 QTCOMMERCIALCHART_USE_NAMESPACE
154 QTCOMMERCIALCHART_USE_NAMESPACE
186
155
187 #ifndef QT5_QUICK_1
156 #ifndef QT5_QUICK_1
188 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
157 Q_EXPORT_PLUGIN2(qtcommercialchartqml, QT_PREPEND_NAMESPACE(ChartQmlPlugin))
189 #endif
158 #endif
General Comments 0
You need to be logged in to leave comments. Login now