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