@@ -25,6 +25,15 Rectangle { | |||
|
25 | 25 | anchors.fill: parent |
|
26 | 26 | property int __explodedIndex: -1 |
|
27 | 27 | |
|
28 | ChartModel { | |
|
29 | id: chartModel | |
|
30 | ChartModelRow { values: ["Volkswagen", 13.5] } | |
|
31 | ChartModelRow { values: ["Toyota", 10.9] } | |
|
32 | ChartModelRow { values: ["Ford", 8.6] } | |
|
33 | ChartModelRow { values: ["Skoda", 8.2] } | |
|
34 | ChartModelRow { values: ["Volvo", 6.8] } | |
|
35 | } | |
|
36 | ||
|
28 | 37 | ChartView { |
|
29 | 38 | id: chart |
|
30 | 39 | title: "Top-5 car brand shares in Finland" |
@@ -38,33 +47,34 Rectangle { | |||
|
38 | 47 | |
|
39 | 48 | PieSeries { |
|
40 | 49 | id: pieSeries |
|
41 |
model: |
|
|
42 | id: pieModel | |
|
43 | // TODO: initializing properties does not work at the moment, see DeclarativePieModel::append | |
|
44 | // TODO: explode range, color, border color, border thickness, font, .. | |
|
45 | PieSlice { exploded: true; label: "Volkswagen"; value: 13.5 } | |
|
46 | PieSlice { label: "Toyota"; value: 10.9 } | |
|
47 | PieSlice { label: "Ford"; value: 8.6 } | |
|
48 | PieSlice { label: "Skoda"; value: 8.2 } | |
|
49 |
|
|
|
50 | } | |
|
50 | model: chartModel | |
|
51 | modelMapper.mapLabels: 0 | |
|
52 | modelMapper.mapValues: 1 | |
|
53 | modelMapper.first: 0 | |
|
54 | modelMapper.count: -1 // "Undefined" = -1 by default | |
|
55 | modelMapper.orientation: PieModelMapper.Vertical | |
|
56 | ||
|
57 | // TODO: PieSlice to append the data directly into the mapped columns | |
|
58 | //PieSlice { label: "Toyota"; value: 10.9 } | |
|
51 | 59 | } |
|
52 | 60 | } |
|
53 | 61 | |
|
62 | Component.onCompleted: { | |
|
63 | chartModel.append(["Others", 52.0]); | |
|
64 | } | |
|
65 | ||
|
54 | 66 | Timer { |
|
55 | 67 | repeat: true |
|
56 | 68 | interval: 2000 |
|
57 | 69 | running: true |
|
58 | 70 | onTriggered: { |
|
59 | changeSliceExploded(__explodedIndex); | |
|
60 | __explodedIndex = (__explodedIndex + 1) % pieModel.count; | |
|
61 | changeSliceExploded(__explodedIndex); | |
|
62 | } | |
|
63 | } | |
|
71 | // Set all slices as not exploded | |
|
72 | for (var i = 0; i < pieSeries.count; i++) | |
|
73 | pieSeries.slice(i).exploded = false; | |
|
64 | 74 | |
|
65 | function changeSliceExploded(index) { | |
|
66 | if (index >= 0 && index < pieModel.count) { | |
|
67 |
pieSeries.slice( |
|
|
75 | // Explode one of the slices | |
|
76 | __explodedIndex = (__explodedIndex + 1) % pieSeries.count; | |
|
77 | pieSeries.slice(__explodedIndex).exploded = true; | |
|
68 | 78 | } |
|
69 | 79 | } |
|
70 | 80 | |
@@ -80,46 +90,24 Rectangle { | |||
|
80 | 90 | Text { |
|
81 | 91 | id: buttonText |
|
82 | 92 | anchors.centerIn: parent |
|
83 |
text: |
|
|
93 | text: "Hide others" | |
|
84 | 94 | } |
|
85 | 95 | MouseArea { |
|
86 | 96 | anchors.fill: parent |
|
87 | 97 | onClicked: { |
|
88 |
if (button. |
|
|
89 | // The share of "others" was enabled -> append the data into the model | |
|
90 | // TODO: this should also be doable by redefining the range inside the model | |
|
91 | button.state = "show"; | |
|
92 | pieModel.append(["Others", 52.0]); | |
|
98 | if (buttonText.text == "Show others") { | |
|
99 | pieSeries.modelMapper.count = -1; | |
|
100 | buttonText.text = "Hide others"; | |
|
93 | 101 | } else { |
|
94 | // The share of "others" was disabled -> remove the data from the model | |
|
95 | // TODO: this should also be doable by redefining the range inside the model | |
|
96 | button.state = ""; | |
|
97 | pieModel.removeRow(pieModel.count - 1); | |
|
102 | pieSeries.modelMapper.count = 5; | |
|
103 | buttonText.text = "Show others"; | |
|
104 | //pieModel.removeRow(pieModel.count - 1); | |
|
98 | 105 | // TODO: removeAll("label") ? |
|
99 | 106 | } |
|
100 | 107 | } |
|
101 | 108 | } |
|
102 | 109 | } |
|
103 | 110 | |
|
104 | ||
|
105 | // TODO: Optional syntax for defining models for different series. Is this really needed? | |
|
106 | // ChartModel { | |
|
107 | // id: chartModel | |
|
108 | // ChartElement { column1: "Volkswagen"; column2: 13.5; column3: 1.2 } | |
|
109 | // ChartElement { column1: "Toyota"; column2: 10.9; column3: 2.5 } | |
|
110 | // } | |
|
111 | // // column3 not used by pie series | |
|
112 | // PieSeries { | |
|
113 | // model: chartModel | |
|
114 | // modelMapping: PieMapping { | |
|
115 | // labels: 0 // undefined by default | |
|
116 | // values: 1 // undefined by default | |
|
117 | // first: 0 // 0 by default | |
|
118 | // count: 10 // "Undefined" by default | |
|
119 | // orientation: PieMapping.Vertical // Vertical by default | |
|
120 | // } | |
|
121 | // } | |
|
122 | ||
|
123 | 111 | // TODO: show how to use data from a list model in a chart view |
|
124 | 112 | // i.e. copy the data into a chart model |
|
125 | 113 | // ListModel { |
@@ -32,27 +32,31 Rectangle { | |||
|
32 | 32 | |
|
33 | 33 | LineSeries { |
|
34 | 34 | name: "Line" |
|
35 |
model: |
|
|
36 | XyPoint { x: 0.0; y: 0.0 } | |
|
37 | XyPoint { x: 1.1; y: 2.1 } | |
|
38 | XyPoint { x: 1.9; y: 3.3 } | |
|
39 | XyPoint { x: 2.9; y: 4.9 } | |
|
40 | XyPoint { x: 3.2; y: 3.0 } | |
|
41 | XyPoint { x: 4.0; y: 3.3 } | |
|
42 | } | |
|
35 | model: chartModel | |
|
36 | modelMapper.mapX: 0 | |
|
37 | modelMapper.mapY: 1 | |
|
38 | modelMapper.first: 0 | |
|
39 | modelMapper.count: -1 | |
|
40 | modelMapper.orientation: XYModelMapper.Vertical | |
|
43 | 41 | } |
|
44 | 42 | |
|
45 | 43 | SplineSeries { |
|
46 | 44 | name: "Spline" |
|
47 |
model: |
|
|
48 | XyPoint { x: 0.0; y: 0.3 } | |
|
49 | XyPoint { x: 1.1; y: 3.2 } | |
|
50 | XyPoint { x: 1.7; y: 2.4 } | |
|
51 | XyPoint { x: 2.1; y: 2.1 } | |
|
52 | XyPoint { x: 2.9; y: 2.6 } | |
|
53 | XyPoint { x: 3.4; y: 2.3 } | |
|
54 | XyPoint { x: 4.1; y: 3.1 } | |
|
55 | } | |
|
45 | model: chartModel | |
|
46 | modelMapper.mapX: 0 | |
|
47 | modelMapper.mapY: 2 | |
|
56 | 48 | } |
|
57 | 49 | } |
|
50 | ||
|
51 | ChartModel { | |
|
52 | id: chartModel | |
|
53 | ChartModelRow { values: [0.0, 0.0, 0.3] } | |
|
54 | ChartModelRow { values: [1.1, 2.1, 3.2] } | |
|
55 | ChartModelRow { values: [1.9, 3.3, 2.4] } | |
|
56 | ChartModelRow { values: [2.1, 2.1, 2.1] } | |
|
57 | ChartModelRow { values: [2.9, 4.9, 2.6] } | |
|
58 | ChartModelRow { values: [3.4, 3.0, 2.3] } | |
|
59 | ChartModelRow { values: [4.1, 3.3, 3.1] } | |
|
60 | } | |
|
61 | ||
|
58 | 62 | } |
@@ -34,95 +34,46 Rectangle { | |||
|
34 | 34 | |
|
35 | 35 | AreaSeries { |
|
36 | 36 | name: "Russian" |
|
37 |
upperModel: |
|
|
38 |
|
|
|
37 | upperModel: chartModel | |
|
38 | upperModelMapper.mapX: 0 | |
|
39 | upperModelMapper.mapY: 2 | |
|
40 | lowerModel: chartModel | |
|
41 | lowerModelMapper.mapX: 0 | |
|
42 | lowerModelMapper.mapY: 1 | |
|
39 | 43 | } |
|
40 | 44 | AreaSeries { |
|
41 | 45 | name: "Swedish" |
|
42 |
upperModel: |
|
|
43 |
|
|
|
46 | upperModel: chartModel | |
|
47 | upperModelMapper.mapX: 0 | |
|
48 | upperModelMapper.mapY: 3 | |
|
49 | lowerModel: chartModel | |
|
50 | lowerModelMapper.mapX: 0 | |
|
51 | lowerModelMapper.mapY: 1 | |
|
44 | 52 | } |
|
45 | 53 | AreaSeries { |
|
46 | 54 | name: "Finnish" |
|
47 |
upperModel: |
|
|
48 |
|
|
|
55 | upperModel: chartModel | |
|
56 | upperModelMapper.mapX: 0 | |
|
57 | upperModelMapper.mapY: 4 | |
|
58 | lowerModel: chartModel | |
|
59 | lowerModelMapper.mapX: 0 | |
|
60 | lowerModelMapper.mapY: 1 | |
|
49 | 61 | } |
|
50 | 62 | } |
|
51 | 63 | |
|
52 | // TODO: optional implementation with generic ChartModel | |
|
53 | // AreaSeries { | |
|
54 | // model: chartModel | |
|
55 | // modelMapping: XyMapping { | |
|
56 | // xValues: 0 // undefined by default | |
|
57 | // yValues: 1 // undefined by default | |
|
58 | // first: 0 // 0 by default | |
|
59 | // count: 10 // "Undefined" by default | |
|
60 | // orientation: XyMapping.Vertical // Vertical by default | |
|
61 | // } | |
|
62 | // } | |
|
63 | ||
|
64 | ||
|
65 | XYModel { | |
|
66 | id: zerosModel | |
|
67 | XyPoint { x: 0; y: 0 } | |
|
68 | XyPoint { x: 1; y: 0 } | |
|
69 | XyPoint { x: 2; y: 0 } | |
|
70 | XyPoint { x: 3; y: 0 } | |
|
71 | XyPoint { x: 4; y: 0 } | |
|
72 | XyPoint { x: 5; y: 0 } | |
|
73 | XyPoint { x: 6; y: 0 } | |
|
74 | XyPoint { x: 7; y: 0 } | |
|
75 | XyPoint { x: 8; y: 0 } | |
|
76 | XyPoint { x: 9; y: 0 } | |
|
77 | XyPoint { x: 10; y: 0 } | |
|
78 | XyPoint { x: 11; y: 0 } | |
|
79 | } | |
|
80 | ||
|
81 | XYModel { | |
|
82 | id: russianModel | |
|
83 | XyPoint { x: 0; y: 1 } | |
|
84 | XyPoint { x: 1; y: 1 } | |
|
85 | XyPoint { x: 2; y: 1 } | |
|
86 | XyPoint { x: 3; y: 1 } | |
|
87 | XyPoint { x: 4; y: 1 } | |
|
88 | XyPoint { x: 5; y: 0 } | |
|
89 | XyPoint { x: 6; y: 1 } | |
|
90 | XyPoint { x: 7; y: 1 } | |
|
91 | XyPoint { x: 8; y: 4 } | |
|
92 | XyPoint { x: 9; y: 3 } | |
|
93 | XyPoint { x: 10; y: 2 } | |
|
94 | XyPoint { x: 11; y: 1 } | |
|
95 | } | |
|
96 | ||
|
97 | XYModel { | |
|
98 | id: swedishModel | |
|
99 | XyPoint { x: 0; y: 1 } | |
|
100 | XyPoint { x: 1; y: 1 } | |
|
101 | XyPoint { x: 2; y: 3 } | |
|
102 | XyPoint { x: 3; y: 3 } | |
|
103 | XyPoint { x: 4; y: 2 } | |
|
104 | XyPoint { x: 5; y: 0 } | |
|
105 | XyPoint { x: 6; y: 2 } | |
|
106 | XyPoint { x: 7; y: 1 } | |
|
107 | XyPoint { x: 8; y: 2 } | |
|
108 | XyPoint { x: 9; y: 1 } | |
|
109 | XyPoint { x: 10; y: 3 } | |
|
110 | XyPoint { x: 11; y: 3 } | |
|
111 | } | |
|
112 | ||
|
113 | XYModel { | |
|
114 | id: finnishModel | |
|
115 | XyPoint { x: 0; y: 0 } | |
|
116 | XyPoint { x: 1; y: 0 } | |
|
117 | XyPoint { x: 2; y: 0 } | |
|
118 | XyPoint { x: 3; y: 0 } | |
|
119 | XyPoint { x: 4; y: 0 } | |
|
120 | XyPoint { x: 5; y: 0 } | |
|
121 | XyPoint { x: 6; y: 1 } | |
|
122 | XyPoint { x: 7; y: 0 } | |
|
123 | XyPoint { x: 8; y: 0 } | |
|
124 | XyPoint { x: 9; y: 0 } | |
|
125 | XyPoint { x: 10; y: 0 } | |
|
126 | XyPoint { x: 11; y: 1 } | |
|
64 | ChartModel { | |
|
65 | id: chartModel | |
|
66 | ChartModelRow { values: [0, 0, 1, 1, 0] } | |
|
67 | ChartModelRow { values: [1, 0, 1, 1, 0] } | |
|
68 | ChartModelRow { values: [2, 0, 1, 3, 0] } | |
|
69 | ChartModelRow { values: [3, 0, 1, 3, 0] } | |
|
70 | ChartModelRow { values: [4, 0, 1, 2, 0] } | |
|
71 | ChartModelRow { values: [5, 0, 0, 0, 0] } | |
|
72 | ChartModelRow { values: [6, 0, 1, 2, 1] } | |
|
73 | ChartModelRow { values: [7, 0, 1, 1, 0] } | |
|
74 | ChartModelRow { values: [8, 0, 4, 2, 0] } | |
|
75 | ChartModelRow { values: [9, 0, 3, 1, 0] } | |
|
76 | ChartModelRow { values: [10, 0, 2, 3, 0] } | |
|
77 | ChartModelRow { values: [11, 0, 1, 3, 1] } | |
|
127 | 78 | } |
|
128 | 79 | } |
@@ -32,7 +32,7 Rectangle { | |||
|
32 | 32 | ScatterSeries { |
|
33 | 33 | id: scatter1 |
|
34 | 34 | name: "Scatter1" |
|
35 |
model: |
|
|
35 | model: ChartModel { | |
|
36 | 36 | XyPoint { x: 1.5; y: 1.5 } |
|
37 | 37 | XyPoint { x: 1.5; y: 1.6 } |
|
38 | 38 | XyPoint { x: 1.57; y: 1.55 } |
@@ -44,7 +44,7 Rectangle { | |||
|
44 | 44 | } |
|
45 | 45 | ScatterSeries { |
|
46 | 46 | name: "Scatter2" |
|
47 |
model: |
|
|
47 | model: ChartModel { | |
|
48 | 48 | XyPoint { x: 2.0; y: 2.0 } |
|
49 | 49 | XyPoint { x: 2.0; y: 2.1 } |
|
50 | 50 | XyPoint { x: 2.07; y: 2.05 } |
@@ -69,11 +69,11 Rectangle { | |||
|
69 | 69 | // id: chartModel |
|
70 | 70 | // } |
|
71 | 71 | |
|
72 |
|
|
|
72 | ChartModel { | |
|
73 | 73 | id: maxModel |
|
74 | 74 | } |
|
75 | 75 | |
|
76 |
|
|
|
76 | ChartModel { | |
|
77 | 77 | id: minModel |
|
78 | 78 | } |
|
79 | 79 |
@@ -28,48 +28,65 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
28 | 28 | DeclarativeAreaSeries::DeclarativeAreaSeries(QObject *parent) : |
|
29 | 29 | QAreaSeries(new QLineSeries(parent), new QLineSeries(parent)) |
|
30 | 30 | { |
|
31 | QXYModelMapper *upperMapper = new QXYModelMapper(upperSeries()); | |
|
32 | upperMapper->setMapX(0); | |
|
33 | upperMapper->setMapY(1); | |
|
34 | upperMapper->setFirst(0); | |
|
35 | upperMapper->setCount(-1); | |
|
36 | upperMapper->setOrientation(Qt::Vertical); | |
|
37 | upperSeries()->setModelMapper(upperMapper); | |
|
38 | ||
|
39 | QXYModelMapper *lowerMapper = new QXYModelMapper(lowerSeries()); | |
|
40 | lowerMapper->setMapX(2); | |
|
41 | lowerMapper->setMapY(3); | |
|
42 | lowerMapper->setFirst(0); | |
|
43 | lowerMapper->setCount(-1); | |
|
44 | lowerMapper->setOrientation(Qt::Vertical); | |
|
45 | lowerSeries()->setModelMapper(lowerMapper); | |
|
31 | 46 | } |
|
32 | 47 | |
|
33 |
bool DeclarativeAreaSeries::setDeclarativeUpperModel(Declarative |
|
|
48 | bool DeclarativeAreaSeries::setDeclarativeUpperModel(DeclarativeTableModel *model) | |
|
34 | 49 | { |
|
35 | 50 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
36 | 51 | bool value(false); |
|
37 | 52 | if (m) { |
|
38 | 53 | upperSeries()->setModel(m); |
|
39 | QXYModelMapper *mapper = new QXYModelMapper; | |
|
40 | mapper->setMapX(0); | |
|
41 | mapper->setMapY(1); | |
|
42 | upperSeries()->setModelMapper(mapper); | |
|
43 | 54 | } else { |
|
44 | 55 | qWarning("DeclarativeAreaSeries: Illegal model"); |
|
45 | 56 | } |
|
46 | 57 | return value; |
|
47 | 58 | } |
|
48 | 59 | |
|
49 |
Declarative |
|
|
60 | DeclarativeTableModel *DeclarativeAreaSeries::declarativeUpperModel() | |
|
50 | 61 | { |
|
51 |
return qobject_cast<Declarative |
|
|
62 | return qobject_cast<DeclarativeTableModel *>(upperSeries()->model()); | |
|
52 | 63 | } |
|
53 | 64 | |
|
54 |
bool DeclarativeAreaSeries::setDeclarativeLowerModel(Declarative |
|
|
65 | bool DeclarativeAreaSeries::setDeclarativeLowerModel(DeclarativeTableModel *model) | |
|
55 | 66 | { |
|
56 | 67 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
57 | 68 | bool value(false); |
|
58 | 69 | if (m) { |
|
59 | 70 | lowerSeries()->setModel(m); |
|
60 | QXYModelMapper *mapper = new QXYModelMapper; | |
|
61 | mapper->setMapX(0); | |
|
62 | mapper->setMapY(1); | |
|
63 | lowerSeries()->setModelMapper(mapper); | |
|
64 | 71 | } else { |
|
65 | 72 | qWarning("DeclarativeAreaSeries: Illegal model"); |
|
66 | 73 | } |
|
67 | 74 | return value; |
|
68 | 75 | } |
|
69 | 76 | |
|
70 |
Declarative |
|
|
77 | DeclarativeTableModel *DeclarativeAreaSeries::declarativeLowerModel() | |
|
78 | { | |
|
79 | return qobject_cast<DeclarativeTableModel *>(lowerSeries()->model()); | |
|
80 | } | |
|
81 | ||
|
82 | QXYModelMapper* DeclarativeAreaSeries::upperModelMapper() const | |
|
83 | { | |
|
84 | return upperSeries()->modelMapper(); | |
|
85 | } | |
|
86 | ||
|
87 | QXYModelMapper* DeclarativeAreaSeries::lowerModelMapper() const | |
|
71 | 88 | { |
|
72 |
return |
|
|
89 | return lowerSeries()->modelMapper(); | |
|
73 | 90 | } |
|
74 | 91 | |
|
75 | 92 | #include "moc_declarativeareaseries.cpp" |
@@ -24,24 +24,27 | |||
|
24 | 24 | #include "qchartglobal.h" |
|
25 | 25 | #include "qareaseries.h" |
|
26 | 26 | #include "declarativelineseries.h" |
|
27 | #include "declarativexyseries.h" | |
|
28 | 27 | |
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
|
31 |
class DeclarativeAreaSeries : public QAreaSeries |
|
|
30 | class DeclarativeAreaSeries : public QAreaSeries | |
|
32 | 31 | { |
|
33 | 32 | Q_OBJECT |
|
34 |
Q_PROPERTY(Declarative |
|
|
35 |
Q_PROPERTY(Declarative |
|
|
33 | Q_PROPERTY(DeclarativeTableModel *upperModel READ declarativeUpperModel WRITE setDeclarativeUpperModel) | |
|
34 | Q_PROPERTY(DeclarativeTableModel *lowerModel READ declarativeLowerModel WRITE setDeclarativeLowerModel) | |
|
35 | Q_PROPERTY(QXYModelMapper *upperModelMapper READ upperModelMapper) | |
|
36 | Q_PROPERTY(QXYModelMapper *lowerModelMapper READ lowerModelMapper) | |
|
36 | 37 | |
|
37 | 38 | public: |
|
38 | 39 | explicit DeclarativeAreaSeries(QObject *parent = 0); |
|
39 | 40 | |
|
40 | 41 | public: |
|
41 |
bool setDeclarativeUpperModel(Declarative |
|
|
42 |
Declarative |
|
|
43 |
bool setDeclarativeLowerModel(Declarative |
|
|
44 |
Declarative |
|
|
42 | bool setDeclarativeUpperModel(DeclarativeTableModel *model); | |
|
43 | DeclarativeTableModel *declarativeUpperModel(); | |
|
44 | bool setDeclarativeLowerModel(DeclarativeTableModel *model); | |
|
45 | DeclarativeTableModel *declarativeLowerModel(); | |
|
46 | QXYModelMapper* upperModelMapper() const; | |
|
47 | QXYModelMapper* lowerModelMapper() const; | |
|
45 | 48 | }; |
|
46 | 49 | |
|
47 | 50 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,7 +31,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | class DeclarativeLineSeries : public QLineSeries, public DeclarativeXySeries |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 |
Q_PROPERTY(Declarative |
|
|
34 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |
|
35 | 35 | |
|
36 | 36 | public: |
|
37 | 37 | explicit DeclarativeLineSeries(QObject *parent = 0); |
@@ -24,7 +24,25 | |||
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 | |
|
27 | ////////////// Table model (base) /////////////////// | |
|
27 | ||
|
28 | ////////////// Table model row /////////////////// | |
|
29 | ||
|
30 | DeclarativeTableModelRow::DeclarativeTableModelRow(QObject *parent) | |
|
31 | : QObject(parent) | |
|
32 | { | |
|
33 | } | |
|
34 | ||
|
35 | QVariantList DeclarativeTableModelRow::values() | |
|
36 | { | |
|
37 | return m_values; | |
|
38 | } | |
|
39 | ||
|
40 | void DeclarativeTableModelRow::setValues(QVariantList values) | |
|
41 | { | |
|
42 | m_values = values; | |
|
43 | } | |
|
44 | ||
|
45 | ////////////// Table model /////////////////// | |
|
28 | 46 | |
|
29 | 47 | DeclarativeTableModel::DeclarativeTableModel(QObject *parent) : |
|
30 | 48 | ChartTableModel(parent) |
@@ -54,39 +72,45 void DeclarativeTableModel::appendModelChild(QDeclarativeListProperty<QObject> * | |||
|
54 | 72 | Q_UNUSED(child) |
|
55 | 73 | } |
|
56 | 74 | |
|
57 |
void DeclarativeTableModel::append |
|
|
75 | void DeclarativeTableModel::append(QVariantList values) | |
|
58 | 76 | { |
|
59 | if (qobject_cast<DeclarativeBarModel *>(this)) { | |
|
60 | DeclarativeBarModel *model = qobject_cast<DeclarativeBarModel *>(this); | |
|
61 | model->append(qobject_cast<QBarSet *>(object)); | |
|
62 | } else if (qobject_cast<DeclarativePieModel *>(this)) { | |
|
63 | DeclarativePieModel *model = qobject_cast<DeclarativePieModel *>(this); | |
|
64 | model->append(qobject_cast<QPieSlice *>(object)); | |
|
65 | } else if (qobject_cast<DeclarativeXyModel *>(this)) { | |
|
66 | DeclarativeXyModel *model = qobject_cast<DeclarativeXyModel *>(this); | |
|
67 | model->append(qobject_cast<DeclarativeXyPoint *>(object)); | |
|
68 | } | |
|
69 | } | |
|
77 | // qDebug() << "DeclarativeTableModel::append:" << values; | |
|
70 | 78 | |
|
71 | ////////////// XY model /////////////////////// | |
|
79 | while (columnCount() < values.count()) | |
|
80 | insertColumn(columnCount()); | |
|
72 | 81 | |
|
73 | DeclarativeXyModel::DeclarativeXyModel(QObject *parent) : | |
|
74 | DeclarativeTableModel(parent) | |
|
75 | { | |
|
82 | insertRow(rowCount()); | |
|
83 | ||
|
84 | QModelIndex beginIndex = QModelIndex(); | |
|
85 | QModelIndex endIndex = QModelIndex(); | |
|
86 | for (int i(0); i < values.count(); i++) { | |
|
87 | QModelIndex modelIndex = createIndex(rowCount() - 1, i); | |
|
88 | if (i == 0) | |
|
89 | beginIndex = modelIndex; | |
|
90 | if (i == (values.count() - 1)) | |
|
91 | endIndex = modelIndex; | |
|
92 | setData(modelIndex, values.at(i)); | |
|
93 | } | |
|
94 | dataChanged(beginIndex, endIndex); | |
|
76 | 95 | } |
|
77 | 96 | |
|
78 |
void Declarative |
|
|
97 | void DeclarativeTableModel::appendToModel(QObject *object) | |
|
79 | 98 | { |
|
80 | // qDebug() << "DeclarativeXyModel::append:" << point->x() << " " << point->y(); | |
|
81 | insertRow(rowCount()); | |
|
82 | QModelIndex xModelIndex = createIndex(rowCount() - 1, 0); | |
|
83 | QModelIndex yModelIndex = createIndex(rowCount() - 1, 1); | |
|
84 | setData(xModelIndex, point->x()); | |
|
85 | setData(yModelIndex, point->y()); | |
|
86 | dataChanged(xModelIndex, yModelIndex); | |
|
99 | if (qobject_cast<QBarSet *>(object)) { | |
|
100 | DeclarativeBarModel *model = qobject_cast<DeclarativeBarModel *>(this); | |
|
101 | Q_ASSERT(model); | |
|
102 | model->append(qobject_cast<QBarSet *>(object)); | |
|
103 | } else if (qobject_cast<QPieSlice *>(object)) { | |
|
104 | // TODO | |
|
105 | } else if (qobject_cast<DeclarativeXyPoint *>(object)) { | |
|
106 | // TODO | |
|
107 | appendPoint(qobject_cast<DeclarativeXyPoint *>(object)); | |
|
108 | } else if (qobject_cast<DeclarativeTableModel *>(this)) { | |
|
109 | append(qobject_cast<DeclarativeTableModelRow *>(object)->values()); | |
|
110 | } | |
|
87 | 111 | } |
|
88 | 112 | |
|
89 |
void Declarative |
|
|
113 | void DeclarativeTableModel::appendPoints(QVariantList points) | |
|
90 | 114 | { |
|
91 | 115 | qreal x = 0.0; |
|
92 | 116 | for (int i(0); i < points.count(); i++) { |
@@ -97,7 +121,7 void DeclarativeXyModel::append(QVariantList points) | |||
|
97 | 121 | DeclarativeXyPoint *point= new DeclarativeXyPoint(); |
|
98 | 122 | point->setX(x); |
|
99 | 123 | point->setY(y); |
|
100 | append(point); | |
|
124 | appendPoint(point); | |
|
101 | 125 | } else { |
|
102 | 126 | qWarning() << "Illegal y value"; |
|
103 | 127 | } |
@@ -111,44 +135,15 void DeclarativeXyModel::append(QVariantList points) | |||
|
111 | 135 | } |
|
112 | 136 | } |
|
113 | 137 | |
|
114 | ////////////// Pie model /////////////////////// | |
|
115 | ||
|
116 | DeclarativePieModel::DeclarativePieModel(QObject *parent) : | |
|
117 | DeclarativeTableModel(parent) | |
|
138 | void DeclarativeTableModel::appendPoint(DeclarativeXyPoint* point) | |
|
118 | 139 | { |
|
119 | } | |
|
120 | ||
|
121 | void DeclarativePieModel::append(QPieSlice* slice) | |
|
122 | { | |
|
123 | // qDebug() << "DeclarativePieModel::append:" << slice->label() << " " << slice->value(); | |
|
140 | // qDebug() << "DeclarativeTableModel::append:" << point->x() << " " << point->y(); | |
|
124 | 141 | insertRow(rowCount()); |
|
125 | ||
|
126 | setData(createIndex(rowCount() - 1, 0), slice->value()); | |
|
127 | setData(createIndex(rowCount() - 1, 1), slice->label()); | |
|
128 | } | |
|
129 | ||
|
130 | void DeclarativePieModel::append(QVariantList slices) | |
|
131 | { | |
|
132 | // qDebug() << "append:" << slices; | |
|
133 | QString label = ""; | |
|
134 | for (int i(0); i < slices.count(); i++) { | |
|
135 | if (i % 2) { | |
|
136 | bool ok(false); | |
|
137 | qreal value = slices.at(i).toReal(&ok); | |
|
138 | if (ok) { | |
|
139 | QPieSlice *slice = new QPieSlice(value, label); | |
|
140 | append(slice); | |
|
141 | // TODO: how to copy the properties to the newly added slice? | |
|
142 | // (DeclarativePieModel::append only copies the label and value to the model) | |
|
143 | // QPieSlice *addedSlice = append(slice); | |
|
144 | // addedSlice->setExploded(slice->isExploded()); | |
|
145 | } else { | |
|
146 | qWarning() << "Illegal slice item"; | |
|
147 | } | |
|
148 | } else { | |
|
149 | label = slices.at(i).toString(); | |
|
150 | } | |
|
151 | } | |
|
142 | QModelIndex xModelIndex = createIndex(rowCount() - 1, 0); | |
|
143 | QModelIndex yModelIndex = createIndex(rowCount() - 1, 1); | |
|
144 | setData(xModelIndex, point->x()); | |
|
145 | setData(yModelIndex, point->y()); | |
|
146 | dataChanged(xModelIndex, yModelIndex); | |
|
152 | 147 | } |
|
153 | 148 | |
|
154 | 149 | ////////////// Bar model /////////////////////// |
@@ -32,6 +32,19 | |||
|
32 | 32 | |
|
33 | 33 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
34 | 34 | |
|
35 | class DeclarativeTableModelRow : public QObject | |
|
36 | { | |
|
37 | Q_OBJECT | |
|
38 | Q_PROPERTY(QVariantList values READ values WRITE setValues) | |
|
39 | ||
|
40 | public: | |
|
41 | explicit DeclarativeTableModelRow(QObject *parent = 0); | |
|
42 | QVariantList values(); | |
|
43 | void setValues(QVariantList values); | |
|
44 | private: | |
|
45 | QVariantList m_values; | |
|
46 | }; | |
|
47 | ||
|
35 | 48 | class DeclarativeTableModel : public ChartTableModel, public QDeclarativeParserStatus |
|
36 | 49 | { |
|
37 | 50 | Q_OBJECT |
@@ -48,36 +61,15 public: // from QDeclarativeParserStatus | |||
|
48 | 61 | void componentComplete(); |
|
49 | 62 | |
|
50 | 63 | public Q_SLOTS: |
|
64 | void append(QVariantList slices); | |
|
65 | void appendPoints(QVariantList points); | |
|
66 | void appendPoint(DeclarativeXyPoint* point); | |
|
51 | 67 | static void appendModelChild(QDeclarativeListProperty<QObject> *list, |
|
52 | 68 | QObject *element); |
|
53 | 69 | private: |
|
54 | 70 | void appendToModel(QObject *object); |
|
55 | 71 | }; |
|
56 | 72 | |
|
57 | class DeclarativeXyModel : public DeclarativeTableModel | |
|
58 | { | |
|
59 | Q_OBJECT | |
|
60 | ||
|
61 | public: | |
|
62 | explicit DeclarativeXyModel(QObject *parent = 0); | |
|
63 | ||
|
64 | public Q_SLOTS: | |
|
65 | void append(DeclarativeXyPoint* point); | |
|
66 | void append(QVariantList points); | |
|
67 | }; | |
|
68 | ||
|
69 | class DeclarativePieModel : public DeclarativeTableModel | |
|
70 | { | |
|
71 | Q_OBJECT | |
|
72 | ||
|
73 | public: | |
|
74 | explicit DeclarativePieModel(QObject *parent = 0); | |
|
75 | ||
|
76 | public Q_SLOTS: | |
|
77 | void append(QPieSlice* slice); | |
|
78 | void append(QVariantList slices); | |
|
79 | }; | |
|
80 | ||
|
81 | 73 | class DeclarativeBarModel : public DeclarativeTableModel |
|
82 | 74 | { |
|
83 | 75 | Q_OBJECT |
@@ -29,6 +29,17 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
29 | 29 | DeclarativePieSeries::DeclarativePieSeries(QObject *parent) : |
|
30 | 30 | QPieSeries(parent) |
|
31 | 31 | { |
|
32 | // TODO: set default model on init? | |
|
33 | // setModel(new DeclarativeTableModel()); | |
|
34 | ||
|
35 | // Set default mapper parameters to allow easy to use PieSeries api | |
|
36 | QPieModelMapper *mapper = new QPieModelMapper(); | |
|
37 | mapper->setMapLabels(0); | |
|
38 | mapper->setMapValues(1); | |
|
39 | mapper->setOrientation(Qt::Vertical); | |
|
40 | mapper->setFirst(0); | |
|
41 | mapper->setCount(-1); | |
|
42 | setModelMapper(mapper); | |
|
32 | 43 | } |
|
33 | 44 | |
|
34 | 45 | QPieSlice *DeclarativePieSeries::slice(int index) |
@@ -40,24 +51,19 QPieSlice *DeclarativePieSeries::slice(int index) | |||
|
40 | 51 | return 0; |
|
41 | 52 | } |
|
42 | 53 | |
|
43 | ||
|
44 | void DeclarativePieSeries::setPieModel(DeclarativePieModel *model) | |
|
54 | void DeclarativePieSeries::setPieModel(DeclarativeTableModel *model) | |
|
45 | 55 | { |
|
46 | 56 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
47 | 57 | if (m) { |
|
48 | 58 | QPieSeries::setModel(m); |
|
49 | QPieModelMapper *mapper = new QPieModelMapper; | |
|
50 | mapper->setMapValues(0); | |
|
51 | mapper->setMapLabels(1); | |
|
52 | QPieSeries::setModelMapper(mapper); | |
|
53 | 59 | } else { |
|
54 | 60 | qWarning("DeclarativePieSeries: Illegal model"); |
|
55 | 61 | } |
|
56 | 62 | } |
|
57 | 63 | |
|
58 |
Declarative |
|
|
64 | DeclarativeTableModel *DeclarativePieSeries::pieModel() | |
|
59 | 65 | { |
|
60 |
return qobject_cast<Declarative |
|
|
66 | return qobject_cast<DeclarativeTableModel *>(model()); | |
|
61 | 67 | } |
|
62 | 68 | |
|
63 | 69 | #include "moc_declarativepieseries.cpp" |
@@ -36,7 +36,7 class QChart; | |||
|
36 | 36 | class DeclarativePieSeries : public QPieSeries |
|
37 | 37 | { |
|
38 | 38 | Q_OBJECT |
|
39 |
Q_PROPERTY(Declarative |
|
|
39 | Q_PROPERTY(DeclarativeTableModel *model READ pieModel WRITE setPieModel) | |
|
40 | 40 | |
|
41 | 41 | public: |
|
42 | 42 | explicit DeclarativePieSeries(QObject *parent = 0); |
@@ -44,11 +44,9 public: | |||
|
44 | 44 | public: |
|
45 | 45 | Q_INVOKABLE QPieSlice *slice(int index); |
|
46 | 46 | |
|
47 | public Q_SLOTS: | |
|
48 | ||
|
49 | 47 | public: |
|
50 |
void setPieModel(Declarative |
|
|
51 |
Declarative |
|
|
48 | void setPieModel(DeclarativeTableModel *model); | |
|
49 | DeclarativeTableModel *pieModel(); | |
|
52 | 50 | }; |
|
53 | 51 | |
|
54 | 52 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -31,7 +31,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | class DeclarativeScatterSeries : public QScatterSeries, public DeclarativeXySeries |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 |
Q_PROPERTY(Declarative |
|
|
34 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |
|
35 | 35 | |
|
36 | 36 | public: |
|
37 | 37 | explicit DeclarativeScatterSeries(QObject *parent = 0); |
@@ -20,7 +20,7 | |||
|
20 | 20 | |
|
21 | 21 | #include "declarativesplineseries.h" |
|
22 | 22 | #include "declarativechart.h" |
|
23 |
#include |
|
|
23 | #include <QChart> | |
|
24 | 24 | |
|
25 | 25 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | 26 |
@@ -31,7 +31,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
31 | 31 | class DeclarativeSplineSeries : public QSplineSeries, public DeclarativeXySeries |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 |
Q_PROPERTY(Declarative |
|
|
34 | Q_PROPERTY(DeclarativeTableModel *model READ declarativeModel WRITE setDeclarativeModel) | |
|
35 | 35 | |
|
36 | 36 | public: |
|
37 | 37 | explicit DeclarativeSplineSeries(QObject *parent = 0); |
@@ -20,21 +20,30 | |||
|
20 | 20 | |
|
21 | 21 | //#include "DeclarativeXySeries.h" |
|
22 | 22 | #include "declarativexyseries.h" |
|
23 |
#include |
|
|
24 |
#include |
|
|
23 | #include <QXYSeries> | |
|
24 | #include <QXYModelMapper> | |
|
25 | 25 | #include "declarativechart.h" |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | DeclarativeXySeries::DeclarativeXySeries() |
|
30 | 30 | { |
|
31 | // All the inherited objects must be of type QXYSeries, so it is safe to cast | |
|
32 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); | |
|
33 | QXYModelMapper *mapper = new QXYModelMapper(series); | |
|
34 | mapper->setMapX(0); | |
|
35 | mapper->setMapY(1); | |
|
36 | mapper->setFirst(0); | |
|
37 | mapper->setCount(-1); | |
|
38 | mapper->setOrientation(Qt::Vertical); | |
|
39 | series->setModelMapper(mapper); | |
|
31 | 40 | } |
|
32 | 41 | |
|
33 | 42 | DeclarativeXySeries::~DeclarativeXySeries() |
|
34 | 43 | { |
|
35 | 44 | } |
|
36 | 45 | |
|
37 |
bool DeclarativeXySeries::setDeclarativeModel(Declarative |
|
|
46 | bool DeclarativeXySeries::setDeclarativeModel(DeclarativeTableModel *model) | |
|
38 | 47 | { |
|
39 | 48 | QAbstractItemModel *m = qobject_cast<QAbstractItemModel *>(model); |
|
40 | 49 | bool value(false); |
@@ -42,22 +51,21 bool DeclarativeXySeries::setDeclarativeModel(DeclarativeXyModel *model) | |||
|
42 | 51 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
43 | 52 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); |
|
44 | 53 | series->setModel(m); |
|
45 | QXYModelMapper *mapper = new QXYModelMapper; | |
|
46 | mapper->setMapX(0); | |
|
47 | mapper->setMapY(1); | |
|
48 | series->setModelMapper(mapper); | |
|
54 | // QXYModelMapper *mapper = new QXYModelMapper; | |
|
55 | // mapper->setMapX(0); | |
|
56 | // mapper->setMapY(1); | |
|
57 | // series->setModelMapper(mapper); | |
|
49 | 58 | } else { |
|
50 | 59 | qWarning("DeclarativeXySeries: Illegal model"); |
|
51 | 60 | } |
|
52 | 61 | return value; |
|
53 | 62 | } |
|
54 | 63 | |
|
55 |
Declarative |
|
|
64 | DeclarativeTableModel *DeclarativeXySeries::declarativeModel() | |
|
56 | 65 | { |
|
57 | 66 | // All the inherited objects must be of type QXYSeries, so it is safe to cast |
|
58 | 67 | QXYSeries *series = reinterpret_cast<QXYSeries *>(this); |
|
59 | Q_ASSERT(series); | |
|
60 | return qobject_cast<DeclarativeXyModel *>(series->model()); | |
|
68 | return qobject_cast<DeclarativeTableModel *>(series->model()); | |
|
61 | 69 | } |
|
62 | 70 | |
|
63 | 71 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -39,8 +39,8 public: | |||
|
39 | 39 | ~DeclarativeXySeries(); |
|
40 | 40 | |
|
41 | 41 | public: |
|
42 |
bool setDeclarativeModel(Declarative |
|
|
43 |
Declarative |
|
|
42 | bool setDeclarativeModel(DeclarativeTableModel *model); | |
|
43 | DeclarativeTableModel *declarativeModel(); | |
|
44 | 44 | }; |
|
45 | 45 | |
|
46 | 46 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -30,6 +30,9 | |||
|
30 | 30 | #include "declarativescatterseries.h" |
|
31 | 31 | #include "declarativebarseries.h" |
|
32 | 32 | #include "declarativepieseries.h" |
|
33 | #include "declarativemodel.h" | |
|
34 | #include <QPieModelMapper> | |
|
35 | #include <QXYModelMapper> | |
|
33 | 36 | |
|
34 | 37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | 38 | |
@@ -43,7 +46,7 public: | |||
|
43 | 46 | |
|
44 | 47 | qmlRegisterType<DeclarativeChart>(uri, 1, 0, "ChartView"); |
|
45 | 48 | qmlRegisterUncreatableType<QAxis>(uri, 1, 0, "Axis", |
|
46 |
QLatin1String("Trying to create uncreatable |
|
|
49 | QLatin1String("Trying to create uncreatable: Axis.")); | |
|
47 | 50 | //qmlRegisterType<DeclarativeAxisCategory>(uri, 1, 0, "AxisCategory"); |
|
48 | 51 | qmlRegisterType<DeclarativeXyPoint>(uri, 1, 0, "XyPoint"); |
|
49 | 52 | qmlRegisterType<DeclarativeScatterSeries>(uri, 1, 0, "ScatterSeries"); |
@@ -53,8 +56,15 public: | |||
|
53 | 56 | qmlRegisterType<DeclarativeBarSeries>(uri, 1, 0, "BarSeries"); |
|
54 | 57 | qmlRegisterType<DeclarativePieSeries>(uri, 1, 0, "PieSeries"); |
|
55 | 58 | qmlRegisterType<QPieSlice>(uri, 1, 0, "PieSlice"); |
|
56 |
qmlRegisterType<Declarative |
|
|
57 |
qmlRegisterType<Declarative |
|
|
59 | qmlRegisterType<DeclarativeTableModel>(uri, 1, 0, "ChartModel"); | |
|
60 | qmlRegisterType<DeclarativeTableModelRow>(uri, 1, 0, "ChartModelRow"); | |
|
61 | //qmlRegisterType<DeclarativePieMapping>(uri, 1, 0, "PieMapping"); | |
|
62 | //qmlRegisterType<QPieModelMapper>(uri, 1, 0, "PieModelMapper"); | |
|
63 | qmlRegisterUncreatableType<QPieModelMapper>(uri, 1, 0, "PieModelMapper", | |
|
64 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
|
65 | qmlRegisterUncreatableType<QXYModelMapper>(uri, 1, 0, "XYModelMapper", | |
|
66 | QLatin1String("Trying to create uncreatable: PieModelMapper.")); | |
|
67 | ||
|
58 | 68 | qmlRegisterType<DeclarativeBarModel>(uri, 1, 0, "BarModel"); |
|
59 | 69 | qmlRegisterType<DeclarativeBarSet>(uri, 1, 0, "BarSet"); |
|
60 | 70 | } |
@@ -94,11 +94,16 bool ChartTableModel::setData(const QModelIndex &index, const QVariant &value, i | |||
|
94 | 94 | return false; |
|
95 | 95 | } |
|
96 | 96 | |
|
97 |
void ChartTableModel::insert |
|
|
97 | void ChartTableModel::insertColumn(int column, const QModelIndex &parent) | |
|
98 | 98 | { |
|
99 | Q_UNUSED(parent) | |
|
99 | beginInsertColumns(parent, column, column); | |
|
100 | m_columnCount++; | |
|
101 | endInsertColumns(); | |
|
102 | } | |
|
100 | 103 | |
|
101 | beginInsertRows(QModelIndex(), row, row); | |
|
104 | void ChartTableModel::insertRow(int row, const QModelIndex &parent) | |
|
105 | { | |
|
106 | beginInsertRows(parent, row, row); | |
|
102 | 107 | QVector<QVariant>* dataVec = new QVector<QVariant>(m_columnCount); |
|
103 | 108 | m_data.insert(row, dataVec); |
|
104 | 109 | endInsertRows(); |
@@ -42,6 +42,7 public: | |||
|
42 | 42 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
|
43 | 43 | bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ); |
|
44 | 44 | Qt::ItemFlags flags ( const QModelIndex & index ) const; |
|
45 | void insertColumn(int column, const QModelIndex &parent = QModelIndex()); | |
|
45 | 46 | void insertRow(int row, const QModelIndex &parent = QModelIndex()); |
|
46 | 47 | /*Q_INVOKABLE*/ //bool removeRow(int row, const QModelIndex &parent = QModelIndex()); |
|
47 | 48 | Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); |
@@ -9,9 +9,16 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
9 | 9 | class QTCOMMERCIALCHART_EXPORT QPieModelMapper : public QObject |
|
10 | 10 | { |
|
11 | 11 | Q_OBJECT |
|
12 | Q_PROPERTY(int mapValues READ mapValues WRITE setMapValues) | |
|
13 | Q_PROPERTY(int mapLabels READ mapLabels WRITE setMapLabels) | |
|
14 | Q_PROPERTY(int first READ first WRITE setFirst) | |
|
15 | Q_PROPERTY(int count READ count WRITE setCount) | |
|
16 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) | |
|
17 | Q_ENUMS(Qt::Orientation) | |
|
18 | ||
|
12 | 19 | public: |
|
13 | 20 | explicit QPieModelMapper(QObject *parent = 0); |
|
14 | ||
|
21 | ||
|
15 | 22 | int first() const; |
|
16 | 23 | void setFirst(int first); |
|
17 | 24 |
@@ -36,6 +36,8 class QTCOMMERCIALCHART_EXPORT QPieSeries : public QAbstractSeries | |||
|
36 | 36 | Q_PROPERTY(qreal size READ pieSize WRITE setPieSize) |
|
37 | 37 | Q_PROPERTY(qreal startAngle READ pieStartAngle WRITE setPieStartAngle) |
|
38 | 38 | Q_PROPERTY(qreal endAngle READ pieEndAngle WRITE setPieEndAngle) |
|
39 | Q_PROPERTY(int count READ count) | |
|
40 | Q_PROPERTY(QPieModelMapper *modelMapper READ modelMapper) | |
|
39 | 41 | |
|
40 | 42 | public: |
|
41 | 43 | explicit QPieSeries(QObject *parent = 0); |
@@ -3,13 +3,18 | |||
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include <QObject> |
|
6 | #include <Qt> | |
|
7 | 6 | |
|
8 | 7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 8 | |
|
10 | 9 | class QTCOMMERCIALCHART_EXPORT QXYModelMapper : public QObject |
|
11 | 10 | { |
|
12 | 11 | Q_OBJECT |
|
12 | Q_PROPERTY(int mapX READ mapX WRITE setMapX) | |
|
13 | Q_PROPERTY(int mapY READ mapY WRITE setMapY) | |
|
14 | Q_PROPERTY(int first READ first WRITE setFirst) | |
|
15 | Q_PROPERTY(int count READ count WRITE setCount) | |
|
16 | Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) | |
|
17 | Q_ENUMS(Qt::Orientation) | |
|
13 | 18 | |
|
14 | 19 | public: |
|
15 | 20 | explicit QXYModelMapper(QObject *parent = 0); |
General Comments 0
You need to be logged in to leave comments.
Login now