##// END OF EJS Templates
Added new model mappers for pie to QML api
Tero Ahola -
r1249:94a47eb3a2ef
parent child
Show More
@@ -31,7 +31,6 Rectangle {
31 legend: ChartView.LegendBottom
31 legend: ChartView.LegendBottom
32 // TODO: labels defined by x-axis, not by bar series
32 // TODO: labels defined by x-axis, not by bar series
33 axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"]
33 axisXLabels: ["0", "2008", "1", "2009", "2", "2010", "3", "2012"]
34 axisX.max: 10
35
34
36 GroupedBarSeries {
35 GroupedBarSeries {
37 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
36 barCategories: [ "2008", "2009", "2010", "2011", "2012" ]
@@ -43,10 +43,6 Rectangle {
43
43
44 LineSeries {
44 LineSeries {
45 name: "line"
45 name: "line"
46 // TODO: the current mapper api
47 model: chartModel
48 modelMapper.mapX: 3
49 modelMapper.mapY: 3
50
46
51 // TODO: the new mapper api
47 // TODO: the new mapper api
52 // XYModelMapperVertical {
48 // XYModelMapperVertical {
@@ -63,20 +59,12 Rectangle {
63 horizontalPosition: 0.2
59 horizontalPosition: 0.2
64 verticalPosition: 0.3
60 verticalPosition: 0.3
65
61
66 // model: chartModel
62 VPieModelMapper {
67 // // TODO: the current mapper api
63 series: pieSeries // TODO
68 // modelMapper.mapLabels: 1
64 model: chartModel
69 // modelMapper.mapValues: 2
65 labelsColumn: 1
70 // modelMapper.first: 0
66 valuesColumn: 2
71 // modelMapper.count: -1 // "Undefined" = -1 by default
67 }
72 // modelMapper.orientation: PieModelMapper.Vertical
73
74 // TODO: the new mapper api
75 // PieModelMapperVertical {
76 // model: chartModel
77 // labelsColumn: 0
78 // valuesColumn: 1
79 // }
80 }
68 }
81
69
82 // TODO: the new mapper api
70 // TODO: the new mapper api
@@ -90,14 +78,14 Rectangle {
90 AreaSeries {
78 AreaSeries {
91 name: "area"
79 name: "area"
92 upperSeries: LineSeries {
80 upperSeries: LineSeries {
93 model: chartModel
81 // model: chartModel
94 modelMapper.mapX: 2
82 // modelMapper.mapX: 2
95 modelMapper.mapY: 2
83 // modelMapper.mapY: 2
96 }
84 }
97 lowerSeries: LineSeries {
85 lowerSeries: LineSeries {
98 model: chartModel
86 // model: chartModel
99 modelMapper.mapX: 2
87 // modelMapper.mapX: 2
100 modelMapper.mapY: 0
88 // modelMapper.mapY: 0
101 }
89 }
102 }
90 }
103
91
@@ -33,6 +33,9
33
33
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
35
36 // TODO: move model into demo app,
37 // the ChartModel API will not be implemented by charts declarative plugin
38
36 class DeclarativeTableModelElement : public QObject
39 class DeclarativeTableModelElement : public QObject
37 {
40 {
38 Q_OBJECT
41 Q_OBJECT
@@ -31,7 +31,8
31 #include "declarativebarseries.h"
31 #include "declarativebarseries.h"
32 #include "declarativepieseries.h"
32 #include "declarativepieseries.h"
33 #include "declarativemodel.h"
33 #include "declarativemodel.h"
34 #include <QPieModelMapper>
34 #include <QHPieModelMapper>
35 #include <QVPieModelMapper>
35 #include <QXYModelMapper>
36 #include <QXYModelMapper>
36
37
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
@@ -58,6 +59,12 public:
58 qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement");
59 qmlRegisterType<DeclarativeTableModelElement>(uri, 1, 0, "ChartModelElement");
59 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
60 qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet");
60
61
62 qmlRegisterUncreatableType<QAbstractItemModel>(uri, 1, 0, "AbstractItemModel",
63 QLatin1String("Trying to create uncreatable: AbstractItemModel."));
64 qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper",
65 QLatin1String("Trying to create uncreatable: PieModelMapper."));
66 qmlRegisterType<QHPieModelMapper>(uri, 1, 0, "HPieModelMapper");
67 qmlRegisterType<QVPieModelMapper>(uri, 1, 0, "VPieModelMapper");
61
68
62 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
69 qmlRegisterUncreatableType<QAbstractSeries>(uri, 1, 0, "AbstractSeries",
63 QLatin1String("Trying to create uncreatable: AbstractSeries."));
70 QLatin1String("Trying to create uncreatable: AbstractSeries."));
@@ -140,17 +140,17 void QPieModelMapper::reset()
140 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
140 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
141
141
142 QPieModelMapperPrivate::QPieModelMapperPrivate(QPieModelMapper *q) :
142 QPieModelMapperPrivate::QPieModelMapperPrivate(QPieModelMapper *q) :
143 m_series(0),
144 m_model(0),
145 m_first(0),
146 m_count(-1),
147 m_orientation(Qt::Vertical),
148 m_valuesIndex(-1),
149 m_labelsIndex(-1),
150 m_seriesSignalsBlock(false),
151 m_modelSignalsBlock(false),
143 q_ptr(q)
152 q_ptr(q)
144 {
153 {
145 m_series = 0;
146 m_model = 0;
147 m_first = 0;
148 m_count = -1;
149 m_orientation = Qt::Vertical;
150 m_valuesIndex = -1;
151 m_labelsIndex = -1;
152 m_seriesSignalsBlock = false;
153 m_modelSignalsBlock = false;
154 }
154 }
155
155
156 void QPieModelMapperPrivate::blockModelSignals(bool block)
156 void QPieModelMapperPrivate::blockModelSignals(bool block)
@@ -34,6 +34,8 class QPieSeries;
34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
34 class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 Q_PROPERTY(QPieSeries *series READ series WRITE setSeries)
38 Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel)
37 Q_PROPERTY(int first READ first WRITE setFirst)
39 Q_PROPERTY(int first READ first WRITE setFirst)
38 Q_PROPERTY(int count READ count WRITE setCount)
40 Q_PROPERTY(int count READ count WRITE setCount)
39 Q_ENUMS(Qt::Orientation)
41 Q_ENUMS(Qt::Orientation)
@@ -47,8 +47,6 private:
47 void blockSeriesSignals(bool block = true);
47 void blockSeriesSignals(bool block = true);
48
48
49 private:
49 private:
50 bool m_seriesSignalsBlock;
51 bool m_modelSignalsBlock;
52 QPieSeries *m_series;
50 QPieSeries *m_series;
53 QList<QPieSlice*> m_slices;
51 QList<QPieSlice*> m_slices;
54 QAbstractItemModel *m_model;
52 QAbstractItemModel *m_model;
@@ -57,6 +55,8 private:
57 Qt::Orientation m_orientation;
55 Qt::Orientation m_orientation;
58 int m_valuesIndex;
56 int m_valuesIndex;
59 int m_labelsIndex;
57 int m_labelsIndex;
58 bool m_seriesSignalsBlock;
59 bool m_modelSignalsBlock;
60
60
61 private:
61 private:
62
62
General Comments 0
You need to be logged in to leave comments. Login now