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