@@ -1,84 +1,78 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page demos.html |
|
3 | 3 | \title Qt Charts Demos |
|
4 | 4 | \keyword Demos |
|
5 | 5 | |
|
6 | 6 | \raw HTML |
|
7 | 7 | <div class="qchart"> |
|
8 | 8 | |
|
9 | 9 | <table> |
|
10 | 10 | <tr> |
|
11 | 11 | <td><a href="demos-audio.html">Audio</a></td> |
|
12 | 12 | <td><a href="demos-callout.html">Callout</a></td> |
|
13 | 13 | </tr> |
|
14 | 14 | <tr> |
|
15 | 15 | <td><a href="demos-audio.html"><img src="images/demos_audio.png" width="300" alt="Audio" /></a></td> |
|
16 | 16 | <td><a href="demos-callout.html"><img src="images/demos_callout.png" width="300" alt="Callout" /></a></td> |
|
17 | 17 | </tr> |
|
18 | 18 | <tr> |
|
19 | 19 | <td><a href="demos-chartthemes.html">Chart Themes</a></td> |
|
20 | 20 | <td><a href="demos-dynamicspline.html">Dynamic Spline Chart</a></td> |
|
21 | 21 | </tr> |
|
22 | 22 | <tr> |
|
23 | 23 | <td><a href="demos-chartthemes.html"><img src="images/demo_chartthemes_blue_cerulean.png" width="300" alt="Chart Themes" /></a></td> |
|
24 | 24 | <td><a href="demos-dynamicspline.html"><img src="images/demos_dynamicspline2.png" width="300" alt="Dynamic Spline" /></a></td> |
|
25 | 25 | </tr> |
|
26 | 26 | <tr> |
|
27 | 27 | <td><a href="demos-nesteddonuts.html">Nested Donuts Chart</a></td> |
|
28 | 28 | <td><a href="demos-piechartcustomization.html">Pie Chart Customization</a></td> |
|
29 | 29 | </tr> |
|
30 | 30 | <tr> |
|
31 | 31 | <td><a href="demos-nesteddonuts.html"><img src="images/demos_nesteddonuts.png" width="300" alt="Nested Donuts Chart" /></a></td> |
|
32 | 32 | <td><a href="demos-piechartcustomization.html"><img src="images/piechart_customization.png" width="300" alt="Pie Chart Customization" /></a></td> |
|
33 | 33 | </tr> |
|
34 | 34 | <tr> |
|
35 | 35 | <td><a href="demos-qmlchart.html">Qml Basic Charts</a></td> |
|
36 | 36 | <td><a href="demos-qmlaxes.html">Qml Axes</a></td> |
|
37 | 37 | </tr> |
|
38 | 38 | <tr> |
|
39 | 39 | <td><a href="demos-qmlchart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qml Basic Charts" /></a></td> |
|
40 | 40 | <td><a href="demos-qmlaxes.html"><img src="images/demos_qmlaxes1.png" width="300" alt="Qml Axes" /></a></td> |
|
41 | 41 | </tr> |
|
42 | 42 | <tr> |
|
43 | 43 | <td><a href="demos-qmlcustomizations.html">Qml Customizations</a></td> |
|
44 |
<td><a href="demos-qmlcustom |
|
|
44 | <td><a href="demos-qmlcustomlegend.html">Qml Custom Legend</a></td> | |
|
45 | 45 | </tr> |
|
46 | 46 | <tr> |
|
47 | 47 | <td><a href="demos-qmlcustomizations.html"><img src="images/demos_qmlcustomizations.png" width="300" alt="Qml Customizations" /></a></td> |
|
48 |
<td><a href="demos-qmlcustom |
|
|
48 | <td><a href="demos-qmlcustomlegend.html"><img src="images/demos-qmlcustomlegend1.png" width="300" alt="Qml Custom Legend" /></a></td> | |
|
49 | 49 | </tr> |
|
50 | 50 | <tr> |
|
51 | 51 | <td><a href="demos-qmlf1legends.html">Qml F1 Legends</a></td> |
|
52 | 52 | <td><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></td> |
|
53 | 53 | </tr> |
|
54 | 54 | <tr> |
|
55 | 55 | <td><a href="demos-qmlf1legends.html"><img src="images/demos_qmlf1legends.png" width="300" alt="Qml F1 Legends" /></a></td> |
|
56 | 56 | <td><a href="demos-qmloscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qml Oscilloscope" /></a></td> |
|
57 | 57 | </tr> |
|
58 | 58 | <tr> |
|
59 | 59 | <td><a href="demos-qmlweather.html">Qml Weather</a></td> |
|
60 | <td><a href="demos-qmlcustomlegend.html">Qml Custom Legend</a></td> | |
|
61 | </tr> | |
|
62 | <tr> | |
|
63 | <td><a href="demos-qmlweather.html"><img src="images/demos_qmlweather.png" width="300" alt="Qml Weather" /></a></td> | |
|
64 | <td><a href="demos-qmlcustomlegend.html"><img src="images/demos-qmlcustomlegend1.png" width="300" alt="Qml Custom Legend" /></a></td> | |
|
65 | </tr> | |
|
66 | <tr> | |
|
67 | 60 | <td><a href="demos-qmlpolarchart.html">Qml Polar Chart</a></td> |
|
68 | <td><a href="demos-quick2chart.html">Qt Quick 2 Basic Charts</a></td> | |
|
69 | 61 | </tr> |
|
70 | 62 | <tr> |
|
63 | <td><a href="demos-qmlweather.html"><img src="images/demos_qmlweather.png" width="300" alt="Qml Weather" /></a></td> | |
|
71 | 64 | <td><a href="demos-qmlpolarchart.html"><img src="images/demos_qmlpolarchart1.png" width="300" alt="Qml Polar Chart" /></a></td> |
|
72 | <td><a href="demos-quick2chart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qt Quick 2 Basic Charts" /></a></td> | |
|
73 | 65 | </tr> |
|
74 | 66 | <tr> |
|
67 | <td><a href="demos-quick2chart.html">Qt Quick 2 Basic Charts</a></td> | |
|
75 | 68 | <td><a href="demos-quick2oscilloscope.html">Qt Quick 2 Oscilloscope</a></td> |
|
76 | 69 | </tr> |
|
77 | 70 | <tr> |
|
71 | <td><a href="demos-quick2chart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qt Quick 2 Basic Charts" /></a></td> | |
|
78 | 72 | <td><a href="demos-quick2oscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qt Quick 2 Oscilloscope" /></a></td> |
|
79 | 73 | </tr> |
|
80 | 74 | </table> |
|
81 | 75 | </div> |
|
82 | 76 | \endraw |
|
83 | 77 | |
|
84 | 78 | */ |
@@ -1,253 +1,253 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qhbarmodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QHBarModelMapper |
|
27 | 27 | \brief Horizontal model mapper for bar series. |
|
28 | 28 | \mainclass |
|
29 | 29 | |
|
30 | 30 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
31 | 31 | Horizontal model mapper is used to create a connection between QAbstractBarSeries and QAbstractItemModel derived model object. |
|
32 | 32 | Model mapper maintains equal size of all the BarSets. |
|
33 | 33 | Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series. |
|
34 | 34 | \note Used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
35 | 35 | */ |
|
36 | 36 | /*! |
|
37 | 37 | \qmlclass HBarModelMapper QHBarModelMapper |
|
38 | 38 | |
|
39 | 39 | HBarModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source |
|
40 | 40 | for any bar series. It is possible to use both QAbstractItemModel and bar series data API to manipulate data. |
|
41 | 41 | HBarModelMapper keeps the series and the model in sync. |
|
42 | 42 | |
|
43 | 43 | The following QML example would create a bar series with three bar sets (assuming the model has |
|
44 | 44 | at least four rows). Each bar set would contain data starting from column 1. The name of a set would be defined by |
|
45 | 45 | the vertical header (of the row). |
|
46 | 46 | \code |
|
47 | 47 | BarSeries { |
|
48 | 48 | HBarModelMapper { |
|
49 | 49 | model: myCustomModel // QAbstractItemModel derived implementation |
|
50 | 50 | firstBarSetRow: 1 |
|
51 | 51 | lastBarSetRow: 3 |
|
52 | 52 | firstColumn: 1 |
|
53 | 53 | } |
|
54 | 54 | } |
|
55 | 55 | \endcode |
|
56 | 56 | */ |
|
57 | 57 | |
|
58 | 58 | /*! |
|
59 | 59 | \property QHBarModelMapper::series |
|
60 | 60 | \brief Defines the QPieSeries object that is used by the mapper. |
|
61 | 61 | |
|
62 | 62 | All the data in the series is discarded when it is set to the mapper. |
|
63 | 63 | When new series is specified the old series is disconnected (it preserves its data) |
|
64 | 64 | */ |
|
65 | 65 | /*! |
|
66 | 66 | \qmlproperty AbstractBarSeries HBarModelMapper::series |
|
67 | 67 | Defines the AbstractBarSeries based object that is used by the mapper. All the data in the series is discarded when it is |
|
68 | 68 | set to the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
69 | 69 | */ |
|
70 | 70 | |
|
71 | 71 | /*! |
|
72 | 72 | \property QHBarModelMapper::model |
|
73 | 73 | \brief Defines the model that is used by the mapper. |
|
74 | 74 | */ |
|
75 | 75 | /*! |
|
76 | 76 | \qmlproperty SomeModel HBarModelMapper::model |
|
77 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
78 |
|
|
|
79 |
|
|
|
77 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
78 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
79 | the data of the cells. | |
|
80 | 80 | */ |
|
81 | 81 | |
|
82 | 82 | /*! |
|
83 | 83 | \property QHBarModelMapper::firstBarSetRow |
|
84 | 84 | \brief Defines which column of the model is used as the data source for the first bar set. |
|
85 | 85 | |
|
86 | 86 | Default value is: -1 (invalid mapping) |
|
87 | 87 | */ |
|
88 | 88 | /*! |
|
89 | 89 | \qmlproperty int HBarModelMapper::firstBarSetRow |
|
90 | 90 | Defines which column of the model is used as the data source for the first bar set. The default value is -1 |
|
91 | 91 | (invalid mapping). |
|
92 | 92 | */ |
|
93 | 93 | |
|
94 | 94 | /*! |
|
95 | 95 | \property QHBarModelMapper::lastBarSetRow |
|
96 | 96 | \brief Defines which column of the model is used as the data source for the last bar set. |
|
97 | 97 | |
|
98 | 98 | Default value is: -1 (invalid mapping) |
|
99 | 99 | */ |
|
100 | 100 | /*! |
|
101 | 101 | \qmlproperty int HBarModelMapper::lastBarSetRow |
|
102 | 102 | Defines which column of the model is used as the data source for the last bar set. The default value is -1 |
|
103 | 103 | (invalid mapping). |
|
104 | 104 | */ |
|
105 | 105 | |
|
106 | 106 | /*! |
|
107 | 107 | \property QHBarModelMapper::firstColumn |
|
108 | 108 | \brief Defines which column of the model contains the first values of the QBarSets in the series. |
|
109 | 109 | |
|
110 | 110 | Minimal and default value is: 0 |
|
111 | 111 | */ |
|
112 | 112 | /*! |
|
113 | 113 | \qmlproperty int HBarModelMapper::firstColumn |
|
114 | 114 | Defines which column of the model contains the first values of the QBarSets in the series. |
|
115 | 115 | The default value is 0. |
|
116 | 116 | */ |
|
117 | 117 | |
|
118 | 118 | /*! |
|
119 | 119 | \property QHBarModelMapper::columnCount |
|
120 | 120 | \brief Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. |
|
121 | 121 | |
|
122 | 122 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
123 | 123 | */ |
|
124 | 124 | /*! |
|
125 | 125 | \qmlproperty int HBarModelMapper::columnCount |
|
126 | 126 | Defines the number of columns of the model that are mapped as the data for QAbstractBarSeries. The default value is |
|
127 | 127 | -1 (count limited by the number of columns in the model) |
|
128 | 128 | */ |
|
129 | 129 | |
|
130 | 130 | /*! |
|
131 | 131 | \fn void QHBarModelMapper::seriesReplaced() |
|
132 | 132 | |
|
133 | 133 | Emitted when the series to which mapper is connected to has changed. |
|
134 | 134 | */ |
|
135 | 135 | |
|
136 | 136 | /*! |
|
137 | 137 | \fn void QHBarModelMapper::modelReplaced() |
|
138 | 138 | |
|
139 | 139 | Emitted when the model to which mapper is connected to has changed. |
|
140 | 140 | */ |
|
141 | 141 | |
|
142 | 142 | /*! |
|
143 | 143 | \fn void QHBarModelMapper::firstBarSetRowChanged() |
|
144 | 144 | |
|
145 | 145 | Emitted when the firstBarSetRow has changed. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | \fn void QHBarModelMapper::lastBarSetRowChanged() |
|
150 | 150 | |
|
151 | 151 | Emitted when the lastBarSetRow has changed. |
|
152 | 152 | */ |
|
153 | 153 | |
|
154 | 154 | /*! |
|
155 | 155 | \fn void QHBarModelMapper::firstColumnChanged() |
|
156 | 156 | Emitted when the firstColumn has changed. |
|
157 | 157 | */ |
|
158 | 158 | |
|
159 | 159 | /*! |
|
160 | 160 | \fn void QHBarModelMapper::columnCountChanged() |
|
161 | 161 | Emitted when the columnCount has changed. |
|
162 | 162 | */ |
|
163 | 163 | |
|
164 | 164 | /*! |
|
165 | 165 | Constructs a mapper object which is a child of \a parent. |
|
166 | 166 | */ |
|
167 | 167 | QHBarModelMapper::QHBarModelMapper(QObject *parent) : |
|
168 | 168 | QBarModelMapper(parent) |
|
169 | 169 | { |
|
170 | 170 | QBarModelMapper::setOrientation(Qt::Horizontal); |
|
171 | 171 | } |
|
172 | 172 | |
|
173 | 173 | QAbstractItemModel *QHBarModelMapper::model() const |
|
174 | 174 | { |
|
175 | 175 | return QBarModelMapper::model(); |
|
176 | 176 | } |
|
177 | 177 | |
|
178 | 178 | void QHBarModelMapper::setModel(QAbstractItemModel *model) |
|
179 | 179 | { |
|
180 | 180 | if (model != QBarModelMapper::model()) { |
|
181 | 181 | QBarModelMapper::setModel(model); |
|
182 | 182 | emit modelReplaced(); |
|
183 | 183 | } |
|
184 | 184 | } |
|
185 | 185 | |
|
186 | 186 | QAbstractBarSeries *QHBarModelMapper::series() const |
|
187 | 187 | { |
|
188 | 188 | return QBarModelMapper::series(); |
|
189 | 189 | } |
|
190 | 190 | |
|
191 | 191 | void QHBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
192 | 192 | { |
|
193 | 193 | if (series != QBarModelMapper::series()) { |
|
194 | 194 | QBarModelMapper::setSeries(series); |
|
195 | 195 | emit seriesReplaced(); |
|
196 | 196 | } |
|
197 | 197 | } |
|
198 | 198 | |
|
199 | 199 | int QHBarModelMapper::firstBarSetRow() const |
|
200 | 200 | { |
|
201 | 201 | return QBarModelMapper::firstBarSetSection(); |
|
202 | 202 | } |
|
203 | 203 | |
|
204 | 204 | void QHBarModelMapper::setFirstBarSetRow(int firstBarSetRow) |
|
205 | 205 | { |
|
206 | 206 | if (firstBarSetRow != firstBarSetSection()) { |
|
207 | 207 | QBarModelMapper::setFirstBarSetSection(firstBarSetRow); |
|
208 | 208 | emit firstBarSetRowChanged(); |
|
209 | 209 | } |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | int QHBarModelMapper::lastBarSetRow() const |
|
213 | 213 | { |
|
214 | 214 | return QBarModelMapper::lastBarSetSection(); |
|
215 | 215 | } |
|
216 | 216 | |
|
217 | 217 | void QHBarModelMapper::setLastBarSetRow(int lastBarSetRow) |
|
218 | 218 | { |
|
219 | 219 | if (lastBarSetRow != lastBarSetSection()) { |
|
220 | 220 | QBarModelMapper::setLastBarSetSection(lastBarSetRow); |
|
221 | 221 | emit lastBarSetRowChanged(); |
|
222 | 222 | } |
|
223 | 223 | } |
|
224 | 224 | |
|
225 | 225 | int QHBarModelMapper::firstColumn() const |
|
226 | 226 | { |
|
227 | 227 | return QBarModelMapper::first(); |
|
228 | 228 | } |
|
229 | 229 | |
|
230 | 230 | void QHBarModelMapper::setFirstColumn(int firstColumn) |
|
231 | 231 | { |
|
232 | 232 | if (firstColumn != first()) { |
|
233 | 233 | QBarModelMapper::setFirst(firstColumn); |
|
234 | 234 | emit firstColumnChanged(); |
|
235 | 235 | } |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | int QHBarModelMapper::columnCount() const |
|
239 | 239 | { |
|
240 | 240 | return QBarModelMapper::count(); |
|
241 | 241 | } |
|
242 | 242 | |
|
243 | 243 | void QHBarModelMapper::setColumnCount(int columnCount) |
|
244 | 244 | { |
|
245 | 245 | if (columnCount != count()) { |
|
246 | 246 | QBarModelMapper::setCount(columnCount); |
|
247 | 247 | emit columnCountChanged(); |
|
248 | 248 | } |
|
249 | 249 | } |
|
250 | 250 | |
|
251 | 251 | #include "moc_qhbarmodelmapper.cpp" |
|
252 | 252 | |
|
253 | 253 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,252 +1,252 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qvbarmodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QVBarModelMapper |
|
27 | 27 | \brief Vertical model mapper for bar series. |
|
28 | 28 | \mainclass |
|
29 | 29 | |
|
30 | 30 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
31 | 31 | Vertical model mapper is used to create a connection between QAbstractBarSeries and QAbstractItemModel derived model object. |
|
32 | 32 | Model mapper maintains equal size of all the BarSets. |
|
33 | 33 | Adding/removing value from the BarSet causes the the same change in the rest of the BarSets added to the same series. |
|
34 | 34 | \note Used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
35 | 35 | */ |
|
36 | 36 | /*! |
|
37 | 37 | \qmlclass VBarModelMapper |
|
38 | 38 | \mainclass |
|
39 | 39 | |
|
40 | 40 | VBarModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source |
|
41 | 41 | for any bar series. It is possible to use both QAbstractItemModel and bar series data API to manipulate data. |
|
42 | 42 | VBarModelMapper keeps the series and the model in sync. |
|
43 | 43 | |
|
44 | 44 | The following QML example would create a bar series with three bar sets (assuming the |
|
45 | 45 | model has at least four columns). Each bar set would contain data starting from row 1. The name of a set would be |
|
46 | 46 | defined by the horizontal header (of the column). |
|
47 | 47 | \code |
|
48 | 48 | BarSeries { |
|
49 | 49 | VBarModelMapper { |
|
50 | 50 | model: myCustomModel // QAbstractItemModel derived implementation |
|
51 | 51 | firstBarSetColumn: 1 |
|
52 | 52 | lastBarSetColumn: 3 |
|
53 | 53 | firstRow: 1 |
|
54 | 54 | } |
|
55 | 55 | } |
|
56 | 56 | \endcode |
|
57 | 57 | */ |
|
58 | 58 | |
|
59 | 59 | /*! |
|
60 | 60 | \property QVBarModelMapper::series |
|
61 | 61 | \brief Defines the QBarSeries object that is used by the mapper. |
|
62 | 62 | |
|
63 | 63 | All the data in the series is discarded when it is set to the mapper. |
|
64 | 64 | When new series is specified the old series is disconnected (it preserves its data) |
|
65 | 65 | */ |
|
66 | 66 | /*! |
|
67 | 67 | \qmlproperty AbstractBarSeries VBarModelMapper::series |
|
68 | 68 | Defines the AbstractBarSeries based object that is used by the mapper. All the data in the series is discarded when it is |
|
69 | 69 | set to the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
70 | 70 | */ |
|
71 | 71 | |
|
72 | 72 | /*! |
|
73 | 73 | \property QVBarModelMapper::model |
|
74 | 74 | \brief Defines the model that is used by the mapper. |
|
75 | 75 | */ |
|
76 | 76 | /*! |
|
77 | 77 | \qmlproperty SomeModel VBarModelMapper::model |
|
78 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
79 |
|
|
|
80 |
|
|
|
78 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
79 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
80 | the data of the cells. | |
|
81 | 81 | */ |
|
82 | 82 | |
|
83 | 83 | /*! |
|
84 | 84 | \property QVBarModelMapper::firstBarSetColumn |
|
85 | 85 | \brief Defines which column of the model is used as the data source for the first bar set. |
|
86 | 86 | |
|
87 | 87 | Default value is: -1 (invalid mapping) |
|
88 | 88 | */ |
|
89 | 89 | /*! |
|
90 | 90 | \qmlproperty int VBarModelMapper::firstBarSetColumn |
|
91 | 91 | Defines which column of the model is used as the data source for the first bar set. Default value |
|
92 | 92 | is: -1 (invalid mapping). |
|
93 | 93 | */ |
|
94 | 94 | |
|
95 | 95 | /*! |
|
96 | 96 | \property QVBarModelMapper::lastBarSetColumn |
|
97 | 97 | \brief Defines which column of the model is used as the data source for the last bar set. |
|
98 | 98 | |
|
99 | 99 | Default value is: -1 (invalid mapping) |
|
100 | 100 | */ |
|
101 | 101 | /*! |
|
102 | 102 | \qmlproperty int VBarModelMapper::lastBarSetColumn |
|
103 | 103 | Defines which column of the model is used as the data source for the last bar set. Default |
|
104 | 104 | value is: -1 (invalid mapping). |
|
105 | 105 | */ |
|
106 | 106 | |
|
107 | 107 | /*! |
|
108 | 108 | \property QVBarModelMapper::firstRow |
|
109 | 109 | \brief Defines which row of the model contains the first values of the QBarSets in the series. |
|
110 | 110 | |
|
111 | 111 | Minimal and default value is: 0 |
|
112 | 112 | */ |
|
113 | 113 | /*! |
|
114 | 114 | \qmlproperty int VBarModelMapper::firstRow |
|
115 | 115 | Defines which row of the model contains the first values of the QBarSets in the series. |
|
116 | 116 | The default value is 0. |
|
117 | 117 | */ |
|
118 | 118 | |
|
119 | 119 | /*! |
|
120 | 120 | \property QVBarModelMapper::rowCount |
|
121 | 121 | \brief Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. |
|
122 | 122 | |
|
123 | 123 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
124 | 124 | */ |
|
125 | 125 | /*! |
|
126 | 126 | \qmlproperty int VBarModelMapper::rowCount |
|
127 | 127 | Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. The default value is |
|
128 | 128 | -1 (count limited by the number of rows in the model) |
|
129 | 129 | */ |
|
130 | 130 | |
|
131 | 131 | /*! |
|
132 | 132 | \fn void QVBarModelMapper::seriesReplaced() |
|
133 | 133 | |
|
134 | 134 | Emitted when the series to which mapper is connected to has changed. |
|
135 | 135 | */ |
|
136 | 136 | |
|
137 | 137 | /*! |
|
138 | 138 | \fn void QVBarModelMapper::modelReplaced() |
|
139 | 139 | |
|
140 | 140 | Emitted when the model to which mapper is connected to has changed. |
|
141 | 141 | */ |
|
142 | 142 | |
|
143 | 143 | /*! |
|
144 | 144 | \fn void QVBarModelMapper::firstBarSetColumnChanged() |
|
145 | 145 | Emitted when the firstBarSetColumn has changed. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | \fn void QVBarModelMapper::lastBarSetColumnChanged() |
|
150 | 150 | Emitted when the lastBarSetColumn has changed. |
|
151 | 151 | */ |
|
152 | 152 | |
|
153 | 153 | /*! |
|
154 | 154 | \fn void QVBarModelMapper::firstRowChanged() |
|
155 | 155 | Emitted when the firstRow has changed. |
|
156 | 156 | */ |
|
157 | 157 | |
|
158 | 158 | /*! |
|
159 | 159 | \fn void QVBarModelMapper::rowCountChanged() |
|
160 | 160 | Emitted when the rowCount has changed. |
|
161 | 161 | */ |
|
162 | 162 | |
|
163 | 163 | /*! |
|
164 | 164 | Constructs a mapper object which is a child of \a parent. |
|
165 | 165 | */ |
|
166 | 166 | QVBarModelMapper::QVBarModelMapper(QObject *parent) : |
|
167 | 167 | QBarModelMapper(parent) |
|
168 | 168 | { |
|
169 | 169 | QBarModelMapper::setOrientation(Qt::Vertical); |
|
170 | 170 | } |
|
171 | 171 | |
|
172 | 172 | QAbstractItemModel *QVBarModelMapper::model() const |
|
173 | 173 | { |
|
174 | 174 | return QBarModelMapper::model(); |
|
175 | 175 | } |
|
176 | 176 | |
|
177 | 177 | void QVBarModelMapper::setModel(QAbstractItemModel *model) |
|
178 | 178 | { |
|
179 | 179 | if (model != QBarModelMapper::model()) { |
|
180 | 180 | QBarModelMapper::setModel(model); |
|
181 | 181 | emit modelReplaced(); |
|
182 | 182 | } |
|
183 | 183 | } |
|
184 | 184 | |
|
185 | 185 | QAbstractBarSeries *QVBarModelMapper::series() const |
|
186 | 186 | { |
|
187 | 187 | return QBarModelMapper::series(); |
|
188 | 188 | } |
|
189 | 189 | |
|
190 | 190 | void QVBarModelMapper::setSeries(QAbstractBarSeries *series) |
|
191 | 191 | { |
|
192 | 192 | if (series != QBarModelMapper::series()) { |
|
193 | 193 | QBarModelMapper::setSeries(series); |
|
194 | 194 | emit seriesReplaced(); |
|
195 | 195 | } |
|
196 | 196 | } |
|
197 | 197 | |
|
198 | 198 | int QVBarModelMapper::firstBarSetColumn() const |
|
199 | 199 | { |
|
200 | 200 | return QBarModelMapper::firstBarSetSection(); |
|
201 | 201 | } |
|
202 | 202 | |
|
203 | 203 | void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn) |
|
204 | 204 | { |
|
205 | 205 | if (firstBarSetColumn != firstBarSetSection()) { |
|
206 | 206 | QBarModelMapper::setFirstBarSetSection(firstBarSetColumn); |
|
207 | 207 | emit firstBarSetColumnChanged(); |
|
208 | 208 | } |
|
209 | 209 | } |
|
210 | 210 | |
|
211 | 211 | int QVBarModelMapper::lastBarSetColumn() const |
|
212 | 212 | { |
|
213 | 213 | return QBarModelMapper::lastBarSetSection(); |
|
214 | 214 | } |
|
215 | 215 | |
|
216 | 216 | void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn) |
|
217 | 217 | { |
|
218 | 218 | if (lastBarSetColumn != lastBarSetSection()) { |
|
219 | 219 | QBarModelMapper::setLastBarSetSection(lastBarSetColumn); |
|
220 | 220 | emit lastBarSetColumnChanged(); |
|
221 | 221 | } |
|
222 | 222 | } |
|
223 | 223 | |
|
224 | 224 | int QVBarModelMapper::firstRow() const |
|
225 | 225 | { |
|
226 | 226 | return QBarModelMapper::first(); |
|
227 | 227 | } |
|
228 | 228 | |
|
229 | 229 | void QVBarModelMapper::setFirstRow(int firstRow) |
|
230 | 230 | { |
|
231 | 231 | if (firstRow != first()) { |
|
232 | 232 | QBarModelMapper::setFirst(firstRow); |
|
233 | 233 | emit firstRowChanged(); |
|
234 | 234 | } |
|
235 | 235 | } |
|
236 | 236 | |
|
237 | 237 | int QVBarModelMapper::rowCount() const |
|
238 | 238 | { |
|
239 | 239 | return QBarModelMapper::count(); |
|
240 | 240 | } |
|
241 | 241 | |
|
242 | 242 | void QVBarModelMapper::setRowCount(int rowCount) |
|
243 | 243 | { |
|
244 | 244 | if (rowCount != count()) { |
|
245 | 245 | QBarModelMapper::setCount(rowCount); |
|
246 | 246 | emit rowCountChanged(); |
|
247 | 247 | } |
|
248 | 248 | } |
|
249 | 249 | |
|
250 | 250 | #include "moc_qvbarmodelmapper.cpp" |
|
251 | 251 | |
|
252 | 252 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,261 +1,261 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qhpiemodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QHPieModelMapper |
|
27 | 27 | \mainclass |
|
28 | 28 | |
|
29 | 29 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
30 | 30 | Horizontal model mapper is used to create a connection between QPieSeries and QAbstractItemModel derived model object that keeps the consecutive pie slices data in rows. |
|
31 | 31 | It is possible to use both QAbstractItemModel and QPieSeries model API. QHPieModelMapper makes sure that Pie and the model are kept in sync. |
|
32 | 32 | \note Used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
33 | 33 | */ |
|
34 | 34 | /*! |
|
35 | 35 | \qmlclass HPieModelMapper QHPieModelMapper |
|
36 | 36 | |
|
37 | 37 | HPieModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source |
|
38 | 38 | for a pie series. It is possible to use both QAbstractItemModel and PieSeries data API to manipulate data. |
|
39 | 39 | HPieModelMapper keeps the Pie and the model in sync. |
|
40 | 40 | |
|
41 | 41 | The following QML example would create a pie series with four slices (assuming the model has |
|
42 | 42 | at least five columns). Each slice would contain a label from row 1 and a value from row 2. |
|
43 | 43 | \code |
|
44 | 44 | HPieModelMapper { |
|
45 | 45 | series: pieSeries |
|
46 | 46 | model: customModel |
|
47 | 47 | labelsRow: 1 |
|
48 | 48 | valuesRow: 2 |
|
49 | 49 | firstColumn: 1 |
|
50 | 50 | columnCount: 4 |
|
51 | 51 | } |
|
52 | 52 | \endcode |
|
53 | 53 | */ |
|
54 | 54 | |
|
55 | 55 | /*! |
|
56 | 56 | \property QHPieModelMapper::series |
|
57 | 57 | \brief Defines the QPieSeries object that is used by the mapper. |
|
58 | 58 | |
|
59 | 59 | All the data in the series is discarded when it is set to the mapper. |
|
60 | 60 | When new series is specified the old series is disconnected (it preserves its data) |
|
61 | 61 | */ |
|
62 | 62 | /*! |
|
63 | 63 | \qmlproperty PieSeries HPieModelMapper::series |
|
64 | 64 | Defines the PieSeries object that is used by the mapper. If you define the mapper element as a child for a |
|
65 | 65 | PieSeries, leave this property undefined. All the data in the series is discarded when it is set to the mapper. |
|
66 | 66 | When new series is specified the old series is disconnected (it preserves its data). |
|
67 | 67 | */ |
|
68 | 68 | |
|
69 | 69 | /*! |
|
70 | 70 | \property QHPieModelMapper::model |
|
71 | 71 | \brief Defines the model that is used by the mapper. |
|
72 | 72 | */ |
|
73 | 73 | /*! |
|
74 | 74 | \qmlproperty SomeModel HPieModelMapper::model |
|
75 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
76 |
|
|
|
77 |
|
|
|
75 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
76 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
77 | the data of the cells. | |
|
78 | 78 | */ |
|
79 | 79 | |
|
80 | 80 | /*! |
|
81 | 81 | \property QHPieModelMapper::valuesRow |
|
82 | 82 | \brief Defines which row of the model is kept in sync with the values of the pie's slices. |
|
83 | 83 | |
|
84 | 84 | Default value is: -1 (invalid mapping) |
|
85 | 85 | */ |
|
86 | 86 | /*! |
|
87 | 87 | \qmlproperty int HPieModelMapper::valuesRow |
|
88 | 88 | Defines which row of the model is kept in sync with the values of the pie's slices. Default value is: -1 (invalid |
|
89 | 89 | mapping). |
|
90 | 90 | */ |
|
91 | 91 | |
|
92 | 92 | /*! |
|
93 | 93 | \property QHPieModelMapper::labelsRow |
|
94 | 94 | \brief Defines which row of the model is kept in sync with the labels of the pie's slices. |
|
95 | 95 | |
|
96 | 96 | Default value is: -1 (invalid mapping) |
|
97 | 97 | */ |
|
98 | 98 | /*! |
|
99 | 99 | \qmlproperty int HPieModelMapper::labelsRow |
|
100 | 100 | Defines which row of the model is kept in sync with the labels of the pie's slices |
|
101 | 101 | Default value is: -1 (invalid mapping) |
|
102 | 102 | */ |
|
103 | 103 | |
|
104 | 104 | /*! |
|
105 | 105 | \property QHPieModelMapper::firstColumn |
|
106 | 106 | \brief Defines which column of the model contains the first slice value. |
|
107 | 107 | |
|
108 | 108 | Minimal and default value is: 0 |
|
109 | 109 | */ |
|
110 | 110 | /*! |
|
111 | 111 | \qmlproperty int HPieModelMapper::firstColumn |
|
112 | 112 | Defines which column of the model contains the first slice value. |
|
113 | 113 | The default value is 0. |
|
114 | 114 | */ |
|
115 | 115 | |
|
116 | 116 | /*! |
|
117 | 117 | \property QHPieModelMapper::columnCount |
|
118 | 118 | \brief Defines the number of columns of the model that are mapped as the data for QPieSeries. |
|
119 | 119 | |
|
120 | 120 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
121 | 121 | */ |
|
122 | 122 | /*! |
|
123 | 123 | \qmlproperty int HPieModelMapper::columnCount |
|
124 | 124 | Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is |
|
125 | 125 | -1 (count limited by the number of columns in the model) |
|
126 | 126 | */ |
|
127 | 127 | |
|
128 | 128 | /*! |
|
129 | 129 | \fn void QHPieModelMapper::seriesReplaced() |
|
130 | 130 | Emitted when the series to which mapper is connected to has changed. |
|
131 | 131 | */ |
|
132 | 132 | |
|
133 | 133 | /*! |
|
134 | 134 | \fn void QHPieModelMapper::modelReplaced() |
|
135 | 135 | Emitted when the model to which mapper is connected to has changed. |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \fn void QHPieModelMapper::valuesRowChanged() |
|
140 | 140 | Emitted when the valuesRow has changed. |
|
141 | 141 | */ |
|
142 | 142 | |
|
143 | 143 | /*! |
|
144 | 144 | \fn void QHPieModelMapper::labelsRowChanged() |
|
145 | 145 | Emitted when the labelsRow has changed. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | \fn void QHPieModelMapper::firstColumnChanged() |
|
150 | 150 | Emitted when the firstColumn has changed. |
|
151 | 151 | */ |
|
152 | 152 | |
|
153 | 153 | /*! |
|
154 | 154 | \fn void QHPieModelMapper::columnCountChanged() |
|
155 | 155 | Emitted when the columnCount has changed. |
|
156 | 156 | */ |
|
157 | 157 | |
|
158 | 158 | /*! |
|
159 | 159 | Constructs a mapper object which is a child of \a parent. |
|
160 | 160 | */ |
|
161 | 161 | QHPieModelMapper::QHPieModelMapper(QObject *parent) : |
|
162 | 162 | QPieModelMapper(parent) |
|
163 | 163 | { |
|
164 | 164 | setOrientation(Qt::Horizontal); |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | QAbstractItemModel *QHPieModelMapper::model() const |
|
168 | 168 | { |
|
169 | 169 | return QPieModelMapper::model(); |
|
170 | 170 | } |
|
171 | 171 | |
|
172 | 172 | void QHPieModelMapper::setModel(QAbstractItemModel *model) |
|
173 | 173 | { |
|
174 | 174 | if (model != QPieModelMapper::model()) { |
|
175 | 175 | QPieModelMapper::setModel(model); |
|
176 | 176 | emit modelReplaced(); |
|
177 | 177 | } |
|
178 | 178 | } |
|
179 | 179 | |
|
180 | 180 | QPieSeries *QHPieModelMapper::series() const |
|
181 | 181 | { |
|
182 | 182 | return QPieModelMapper::series(); |
|
183 | 183 | } |
|
184 | 184 | |
|
185 | 185 | void QHPieModelMapper::setSeries(QPieSeries *series) |
|
186 | 186 | { |
|
187 | 187 | if (series != QPieModelMapper::series()) { |
|
188 | 188 | QPieModelMapper::setSeries(series); |
|
189 | 189 | emit seriesReplaced(); |
|
190 | 190 | } |
|
191 | 191 | } |
|
192 | 192 | |
|
193 | 193 | /*! |
|
194 | 194 | Returns which row of the model is kept in sync with the values of the pie's slices |
|
195 | 195 | */ |
|
196 | 196 | int QHPieModelMapper::valuesRow() const |
|
197 | 197 | { |
|
198 | 198 | return valuesSection(); |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | /*! |
|
202 | 202 | Sets the model row that is kept in sync with the pie slices values. |
|
203 | 203 | Parameter \a valuesRow specifies the row of the model. |
|
204 | 204 | */ |
|
205 | 205 | void QHPieModelMapper::setValuesRow(int valuesRow) |
|
206 | 206 | { |
|
207 | 207 | if (valuesRow != valuesSection()) { |
|
208 | 208 | setValuesSection(valuesRow); |
|
209 | 209 | emit valuesRowChanged(); |
|
210 | 210 | } |
|
211 | 211 | } |
|
212 | 212 | |
|
213 | 213 | /*! |
|
214 | 214 | Returns which row of the model is kept in sync with the labels of the pie's slices |
|
215 | 215 | */ |
|
216 | 216 | int QHPieModelMapper::labelsRow() const |
|
217 | 217 | { |
|
218 | 218 | return labelsSection(); |
|
219 | 219 | } |
|
220 | 220 | |
|
221 | 221 | /*! |
|
222 | 222 | Sets the model row that is kept in sync with the pie's slices labels. |
|
223 | 223 | Parameter \a labelsRow specifies the row of the model. |
|
224 | 224 | */ |
|
225 | 225 | void QHPieModelMapper::setLabelsRow(int labelsRow) |
|
226 | 226 | { |
|
227 | 227 | if (labelsRow != labelsSection()) { |
|
228 | 228 | setLabelsSection(labelsRow); |
|
229 | 229 | emit labelsRowChanged(); |
|
230 | 230 | } |
|
231 | 231 | } |
|
232 | 232 | |
|
233 | 233 | int QHPieModelMapper::firstColumn() const |
|
234 | 234 | { |
|
235 | 235 | return first(); |
|
236 | 236 | } |
|
237 | 237 | |
|
238 | 238 | void QHPieModelMapper::setFirstColumn(int firstColumn) |
|
239 | 239 | { |
|
240 | 240 | if (firstColumn != first()) { |
|
241 | 241 | setFirst(firstColumn); |
|
242 | 242 | emit firstColumnChanged(); |
|
243 | 243 | } |
|
244 | 244 | } |
|
245 | 245 | |
|
246 | 246 | int QHPieModelMapper::columnCount() const |
|
247 | 247 | { |
|
248 | 248 | return count(); |
|
249 | 249 | } |
|
250 | 250 | |
|
251 | 251 | void QHPieModelMapper::setColumnCount(int columnCount) |
|
252 | 252 | { |
|
253 | 253 | if (columnCount != count()) { |
|
254 | 254 | setCount(columnCount); |
|
255 | 255 | emit columnCountChanged(); |
|
256 | 256 | } |
|
257 | 257 | } |
|
258 | 258 | |
|
259 | 259 | #include "moc_qhpiemodelmapper.cpp" |
|
260 | 260 | |
|
261 | 261 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,264 +1,264 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qvpiemodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QVPieModelMapper |
|
27 | 27 | \mainclass |
|
28 | 28 | |
|
29 | 29 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
30 | 30 | Vertical model mapper is used to create a connection between QPieSeries and QAbstractItemModel derived model object that keeps the consecutive pie slices data in columns. |
|
31 | 31 | It is possible to use both QAbstractItemModel and QPieSeries model API. QVPieModelMapper makes sure that Pie and the model are kept in sync. |
|
32 | 32 | \note Used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
33 | 33 | */ |
|
34 | 34 | /*! |
|
35 | 35 | \qmlclass VPieModelMapper QVPieModelMapper |
|
36 | 36 | |
|
37 | 37 | VPieModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source |
|
38 | 38 | for a pie series. It is possible to use both QAbstractItemModel and PieSeries data API to manipulate data. |
|
39 | 39 | VPieModelMapper keeps the Pie and the model in sync. |
|
40 | 40 | |
|
41 | 41 | The following QML example would create a pie series with four slices (assuming the model has at least five rows). |
|
42 | 42 | Each slice would contain a label from column 1 and a value from column 2. |
|
43 | 43 | \code |
|
44 | 44 | VPieModelMapper { |
|
45 | 45 | series: pieSeries |
|
46 | 46 | model: customModel |
|
47 | 47 | labelsColumn: 1 |
|
48 | 48 | valuesColumn: 2 |
|
49 | 49 | firstRow: 1 |
|
50 | 50 | rowCount: 4 |
|
51 | 51 | } |
|
52 | 52 | \endcode |
|
53 | 53 | */ |
|
54 | 54 | |
|
55 | 55 | /*! |
|
56 | 56 | \property QVPieModelMapper::series |
|
57 | 57 | \brief Defines the QPieSeries object that is used by the mapper. |
|
58 | 58 | All the data in the series is discarded when it is set to the mapper. |
|
59 | 59 | When new series is specified the old series is disconnected (it preserves its data) |
|
60 | 60 | */ |
|
61 | 61 | /*! |
|
62 | 62 | \qmlproperty PieSeries VPieModelMapper::series |
|
63 | 63 | Defines the PieSeries object that is used by the mapper. If you define the mapper element as a child for a |
|
64 | 64 | PieSeries, leave this property undefined. All the data in the series is discarded when it is set to the mapper. |
|
65 | 65 | When new series is specified the old series is disconnected (it preserves its data). |
|
66 | 66 | */ |
|
67 | 67 | |
|
68 | 68 | /*! |
|
69 | 69 | \property QVPieModelMapper::model |
|
70 | 70 | \brief Defines the model that is used by the mapper. |
|
71 | 71 | */ |
|
72 | 72 | /*! |
|
73 | 73 | \qmlproperty SomeModel VPieModelMapper::model |
|
74 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
75 |
|
|
|
76 |
|
|
|
74 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
75 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
76 | the data of the cells. | |
|
77 | 77 | */ |
|
78 | 78 | |
|
79 | 79 | /*! |
|
80 | 80 | \property QVPieModelMapper::valuesColumn |
|
81 | 81 | \brief Defines which column of the model is kept in sync with the values of the pie's slices. |
|
82 | 82 | |
|
83 | 83 | Default value is: -1 (invalid mapping) |
|
84 | 84 | */ |
|
85 | 85 | /*! |
|
86 | 86 | \qmlproperty int VPieModelMapper::valuesColumn |
|
87 | 87 | Defines which column of the model is kept in sync with the values of the pie's slices. Default value is -1 (invalid |
|
88 | 88 | mapping). |
|
89 | 89 | */ |
|
90 | 90 | |
|
91 | 91 | /*! |
|
92 | 92 | \property QVPieModelMapper::labelsColumn |
|
93 | 93 | \brief Defines which column of the model is kept in sync with the labels of the pie's slices. |
|
94 | 94 | |
|
95 | 95 | Default value is: -1 (invalid mapping) |
|
96 | 96 | */ |
|
97 | 97 | /*! |
|
98 | 98 | \qmlproperty int VPieModelMapper::labelsColumn |
|
99 | 99 | Defines which column of the model is kept in sync with the labels of the pie's slices. Default value is -1 (invalid |
|
100 | 100 | mapping). |
|
101 | 101 | */ |
|
102 | 102 | |
|
103 | 103 | /*! |
|
104 | 104 | \property QVPieModelMapper::firstRow |
|
105 | 105 | \brief Defines which row of the model contains the first slice value. |
|
106 | 106 | |
|
107 | 107 | Minimal and default value is: 0 |
|
108 | 108 | */ |
|
109 | 109 | /*! |
|
110 | 110 | \qmlproperty int VPieModelMapper::firstRow |
|
111 | 111 | Defines which row of the model contains the first slice value. |
|
112 | 112 | The default value is 0. |
|
113 | 113 | */ |
|
114 | 114 | |
|
115 | 115 | /*! |
|
116 | 116 | \property QVPieModelMapper::rowCount |
|
117 | 117 | \brief Defines the number of rows of the model that are mapped as the data for QPieSeries. |
|
118 | 118 | |
|
119 | 119 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
120 | 120 | */ |
|
121 | 121 | /*! |
|
122 | 122 | \qmlproperty int VPieModelMapper::columnCount |
|
123 | 123 | Defines the number of rows of the model that are mapped as the data for QPieSeries. The default value is |
|
124 | 124 | -1 (count limited by the number of rows in the model) |
|
125 | 125 | */ |
|
126 | 126 | |
|
127 | 127 | /*! |
|
128 | 128 | \fn void QVPieModelMapper::seriesReplaced() |
|
129 | 129 | |
|
130 | 130 | Emitted when the series to which mapper is connected to has changed. |
|
131 | 131 | */ |
|
132 | 132 | |
|
133 | 133 | /*! |
|
134 | 134 | \fn void QVPieModelMapper::modelReplaced() |
|
135 | 135 | |
|
136 | 136 | Emitted when the model to which mapper is connected to has changed. |
|
137 | 137 | */ |
|
138 | 138 | |
|
139 | 139 | /*! |
|
140 | 140 | \fn void QVPieModelMapper::valuesColumnChanged() |
|
141 | 141 | |
|
142 | 142 | Emitted when the valuesColumn has changed. |
|
143 | 143 | */ |
|
144 | 144 | |
|
145 | 145 | /*! |
|
146 | 146 | \fn void QVPieModelMapper::labelsColumnChanged() |
|
147 | 147 | |
|
148 | 148 | Emitted when the labelsColumn has changed. |
|
149 | 149 | */ |
|
150 | 150 | |
|
151 | 151 | /*! |
|
152 | 152 | \fn void QVPieModelMapper::firstRowChanged() |
|
153 | 153 | Emitted when the firstRow has changed. |
|
154 | 154 | */ |
|
155 | 155 | |
|
156 | 156 | /*! |
|
157 | 157 | \fn void QVPieModelMapper::rowCountChanged() |
|
158 | 158 | Emitted when the rowCount has changed. |
|
159 | 159 | */ |
|
160 | 160 | |
|
161 | 161 | /*! |
|
162 | 162 | Constructs a mapper object which is a child of \a parent. |
|
163 | 163 | */ |
|
164 | 164 | QVPieModelMapper::QVPieModelMapper(QObject *parent) : |
|
165 | 165 | QPieModelMapper(parent) |
|
166 | 166 | { |
|
167 | 167 | QPieModelMapper::setOrientation(Qt::Vertical); |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | QAbstractItemModel *QVPieModelMapper::model() const |
|
171 | 171 | { |
|
172 | 172 | return QPieModelMapper::model(); |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void QVPieModelMapper::setModel(QAbstractItemModel *model) |
|
176 | 176 | { |
|
177 | 177 | if (model != QPieModelMapper::model()) { |
|
178 | 178 | QPieModelMapper::setModel(model); |
|
179 | 179 | emit modelReplaced(); |
|
180 | 180 | } |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | QPieSeries *QVPieModelMapper::series() const |
|
184 | 184 | { |
|
185 | 185 | return QPieModelMapper::series(); |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | void QVPieModelMapper::setSeries(QPieSeries *series) |
|
189 | 189 | { |
|
190 | 190 | if (series != QPieModelMapper::series()) { |
|
191 | 191 | QPieModelMapper::setSeries(series); |
|
192 | 192 | emit seriesReplaced(); |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | /*! |
|
197 | 197 | Returns which column of the model is kept in sync with the values of the pie's slices |
|
198 | 198 | */ |
|
199 | 199 | int QVPieModelMapper::valuesColumn() const |
|
200 | 200 | { |
|
201 | 201 | return QPieModelMapper::valuesSection(); |
|
202 | 202 | } |
|
203 | 203 | |
|
204 | 204 | /*! |
|
205 | 205 | Sets the model column that is kept in sync with the pie slices values. |
|
206 | 206 | Parameter \a valuesColumn specifies the row of the model. |
|
207 | 207 | */ |
|
208 | 208 | void QVPieModelMapper::setValuesColumn(int valuesColumn) |
|
209 | 209 | { |
|
210 | 210 | if (valuesColumn != valuesSection()) { |
|
211 | 211 | QPieModelMapper::setValuesSection(valuesColumn); |
|
212 | 212 | emit valuesColumnChanged(); |
|
213 | 213 | } |
|
214 | 214 | } |
|
215 | 215 | |
|
216 | 216 | /*! |
|
217 | 217 | Returns which column of the model is kept in sync with the labels of the pie's slices |
|
218 | 218 | */ |
|
219 | 219 | int QVPieModelMapper::labelsColumn() const |
|
220 | 220 | { |
|
221 | 221 | return QPieModelMapper::labelsSection(); |
|
222 | 222 | } |
|
223 | 223 | |
|
224 | 224 | /*! |
|
225 | 225 | Sets the model column that is kept in sync with the pie's slices labels. |
|
226 | 226 | Parameter \a labelsColumn specifies the row of the model. |
|
227 | 227 | */ |
|
228 | 228 | void QVPieModelMapper::setLabelsColumn(int labelsColumn) |
|
229 | 229 | { |
|
230 | 230 | if (labelsColumn != labelsSection()) { |
|
231 | 231 | QPieModelMapper::setLabelsSection(labelsColumn); |
|
232 | 232 | emit labelsColumnChanged(); |
|
233 | 233 | } |
|
234 | 234 | } |
|
235 | 235 | |
|
236 | 236 | int QVPieModelMapper::firstRow() const |
|
237 | 237 | { |
|
238 | 238 | return first(); |
|
239 | 239 | } |
|
240 | 240 | |
|
241 | 241 | void QVPieModelMapper::setFirstRow(int firstRow) |
|
242 | 242 | { |
|
243 | 243 | if (firstRow != first()) { |
|
244 | 244 | setFirst(firstRow); |
|
245 | 245 | emit firstRowChanged(); |
|
246 | 246 | } |
|
247 | 247 | } |
|
248 | 248 | |
|
249 | 249 | int QVPieModelMapper::rowCount() const |
|
250 | 250 | { |
|
251 | 251 | return count(); |
|
252 | 252 | } |
|
253 | 253 | |
|
254 | 254 | void QVPieModelMapper::setRowCount(int rowCount) |
|
255 | 255 | { |
|
256 | 256 | if (rowCount != count()) { |
|
257 | 257 | setCount(rowCount); |
|
258 | 258 | emit rowCountChanged(); |
|
259 | 259 | } |
|
260 | 260 | } |
|
261 | 261 | |
|
262 | 262 | #include "moc_qvpiemodelmapper.cpp" |
|
263 | 263 | |
|
264 | 264 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,237 +1,237 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qhxymodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QHXYModelMapper |
|
27 | 27 | \mainclass |
|
28 | 28 | |
|
29 | 29 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
30 | 30 | Horizontal model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object. |
|
31 | 31 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. |
|
32 | 32 | Note: used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
33 | 33 | */ |
|
34 | 34 | /*! |
|
35 | 35 | \qmlclass HXYModelMapper QHXYModelMapper |
|
36 | 36 | |
|
37 | 37 | HXYModelMapper allows you to use your own QAbstractItemModel derived model with data in rows as a data source |
|
38 | 38 | for XYSeries based series. It is possible to use both QAbstractItemModel and XYSeries data API to manipulate data. |
|
39 | 39 | HXYModelMapper keeps the series and the model in sync. |
|
40 | 40 | */ |
|
41 | 41 | |
|
42 | 42 | /*! |
|
43 | 43 | \property QHXYModelMapper::series |
|
44 | 44 | \brief Defines the QXYSeries object that is used by the mapper. |
|
45 | 45 | |
|
46 | 46 | All the data in the series is discarded when it is set to the mapper. |
|
47 | 47 | When new series is specified the old series is disconnected (it preserves its data) |
|
48 | 48 | */ |
|
49 | 49 | /*! |
|
50 | 50 | \qmlproperty XYSeries HXYModelMapper::series |
|
51 | 51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to |
|
52 | 52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
53 | 53 | */ |
|
54 | 54 | |
|
55 | 55 | /*! |
|
56 | 56 | \property QHXYModelMapper::model |
|
57 | 57 | \brief Defines the model that is used by the mapper. |
|
58 | 58 | */ |
|
59 | 59 | /*! |
|
60 | 60 | \qmlproperty SomeModel HXYModelMapper::model |
|
61 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
62 |
|
|
|
63 |
|
|
|
61 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
62 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
63 | the data of the cells. | |
|
64 | 64 | */ |
|
65 | 65 | |
|
66 | 66 | /*! |
|
67 | 67 | \property QHXYModelMapper::xRow |
|
68 | 68 | \brief Defines which row of the model is kept in sync with the x values of the QXYSeries. |
|
69 | 69 | |
|
70 | 70 | Default value is: -1 (invalid mapping) |
|
71 | 71 | */ |
|
72 | 72 | /*! |
|
73 | 73 | \qmlproperty int HXYModelMapper::xRow |
|
74 | 74 | Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid |
|
75 | 75 | mapping). |
|
76 | 76 | */ |
|
77 | 77 | |
|
78 | 78 | /*! |
|
79 | 79 | \property QHXYModelMapper::yRow |
|
80 | 80 | \brief Defines which row of the model is kept in sync with the y values of the QXYSeries. |
|
81 | 81 | |
|
82 | 82 | Default value is: -1 (invalid mapping) |
|
83 | 83 | */ |
|
84 | 84 | /*! |
|
85 | 85 | \qmlproperty int HXYModelMapper::yRow |
|
86 | 86 | Defines which row of the model is kept in sync with the y values of the series. Default value is -1 |
|
87 | 87 | (invalid mapping). |
|
88 | 88 | */ |
|
89 | 89 | |
|
90 | 90 | /*! |
|
91 | 91 | \property QHXYModelMapper::firstColumn |
|
92 | 92 | \brief Defines which column of the model contains the data for the first point of the series. |
|
93 | 93 | |
|
94 | 94 | Minimal and default value is: 0 |
|
95 | 95 | */ |
|
96 | 96 | /*! |
|
97 | 97 | \qmlproperty int HXYModelMapper::firstColumn |
|
98 | 98 | Defines which column of the model contains the data for the first point of the series. |
|
99 | 99 | The default value is 0. |
|
100 | 100 | */ |
|
101 | 101 | |
|
102 | 102 | /*! |
|
103 | 103 | \property QHXYModelMapper::columnCount |
|
104 | 104 | \brief Defines the number of columns of the model that are mapped as the data for series. |
|
105 | 105 | |
|
106 | 106 | Minimal and default value is: -1 (count limited by the number of columns in the model) |
|
107 | 107 | */ |
|
108 | 108 | /*! |
|
109 | 109 | \qmlproperty int HXYModelMapper::columnCount |
|
110 | 110 | Defines the number of columns of the model that are mapped as the data for series. The default value is |
|
111 | 111 | -1 (count limited by the number of columns in the model) |
|
112 | 112 | */ |
|
113 | 113 | |
|
114 | 114 | /*! |
|
115 | 115 | \fn void QHXYModelMapper::seriesReplaced() |
|
116 | 116 | |
|
117 | 117 | Emitted when the series to which mapper is connected to has changed. |
|
118 | 118 | */ |
|
119 | 119 | |
|
120 | 120 | /*! |
|
121 | 121 | \fn void QHXYModelMapper::modelReplaced() |
|
122 | 122 | |
|
123 | 123 | Emitted when the model to which mapper is connected to has changed. |
|
124 | 124 | */ |
|
125 | 125 | |
|
126 | 126 | /*! |
|
127 | 127 | \fn void QHXYModelMapper::xRowChanged() |
|
128 | 128 | |
|
129 | 129 | Emitted when the xRow has changed. |
|
130 | 130 | */ |
|
131 | 131 | |
|
132 | 132 | /*! |
|
133 | 133 | \fn void QHXYModelMapper::yRowChanged() |
|
134 | 134 | |
|
135 | 135 | Emitted when the yRow has changed. |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \fn void QHXYModelMapper::firstColumnChanged() |
|
140 | 140 | Emitted when the firstColumn has changed. |
|
141 | 141 | */ |
|
142 | 142 | |
|
143 | 143 | /*! |
|
144 | 144 | \fn void QHXYModelMapper::columnCountChanged() |
|
145 | 145 | Emitted when the columnCount has changed. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | Constructs a mapper object which is a child of \a parent. |
|
150 | 150 | */ |
|
151 | 151 | QHXYModelMapper::QHXYModelMapper(QObject *parent) : |
|
152 | 152 | QXYModelMapper(parent) |
|
153 | 153 | { |
|
154 | 154 | QXYModelMapper::setOrientation(Qt::Horizontal); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | QAbstractItemModel *QHXYModelMapper::model() const |
|
158 | 158 | { |
|
159 | 159 | return QXYModelMapper::model(); |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | void QHXYModelMapper::setModel(QAbstractItemModel *model) |
|
163 | 163 | { |
|
164 | 164 | if (model != QXYModelMapper::model()) { |
|
165 | 165 | QXYModelMapper::setModel(model); |
|
166 | 166 | emit modelReplaced(); |
|
167 | 167 | } |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | QXYSeries *QHXYModelMapper::series() const |
|
171 | 171 | { |
|
172 | 172 | return QXYModelMapper::series(); |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void QHXYModelMapper::setSeries(QXYSeries *series) |
|
176 | 176 | { |
|
177 | 177 | if (series != QXYModelMapper::series()) { |
|
178 | 178 | QXYModelMapper::setSeries(series); |
|
179 | 179 | emit seriesReplaced(); |
|
180 | 180 | } |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | int QHXYModelMapper::xRow() const |
|
184 | 184 | { |
|
185 | 185 | return QXYModelMapper::xSection(); |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | void QHXYModelMapper::setXRow(int xRow) |
|
189 | 189 | { |
|
190 | 190 | if (xRow != xSection()) { |
|
191 | 191 | QXYModelMapper::setXSection(xRow); |
|
192 | 192 | emit xRowChanged(); |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | int QHXYModelMapper::yRow() const |
|
197 | 197 | { |
|
198 | 198 | return QXYModelMapper::ySection(); |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | void QHXYModelMapper::setYRow(int yRow) |
|
202 | 202 | { |
|
203 | 203 | if (yRow != ySection()) { |
|
204 | 204 | QXYModelMapper::setYSection(yRow); |
|
205 | 205 | emit yRowChanged(); |
|
206 | 206 | } |
|
207 | 207 | } |
|
208 | 208 | |
|
209 | 209 | int QHXYModelMapper::firstColumn() const |
|
210 | 210 | { |
|
211 | 211 | return first(); |
|
212 | 212 | } |
|
213 | 213 | |
|
214 | 214 | void QHXYModelMapper::setFirstColumn(int firstColumn) |
|
215 | 215 | { |
|
216 | 216 | if (firstColumn != first()) { |
|
217 | 217 | setFirst(firstColumn); |
|
218 | 218 | emit firstColumnChanged(); |
|
219 | 219 | } |
|
220 | 220 | } |
|
221 | 221 | |
|
222 | 222 | int QHXYModelMapper::columnCount() const |
|
223 | 223 | { |
|
224 | 224 | return count(); |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | void QHXYModelMapper::setColumnCount(int columnCount) |
|
228 | 228 | { |
|
229 | 229 | if (columnCount != count()) { |
|
230 | 230 | setCount(columnCount); |
|
231 | 231 | emit columnCountChanged(); |
|
232 | 232 | } |
|
233 | 233 | } |
|
234 | 234 | |
|
235 | 235 | #include "moc_qhxymodelmapper.cpp" |
|
236 | 236 | |
|
237 | 237 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,237 +1,237 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qvxymodelmapper.h" |
|
22 | 22 | |
|
23 | 23 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 24 | |
|
25 | 25 | /*! |
|
26 | 26 | \class QVXYModelMapper |
|
27 | 27 | \mainclass |
|
28 | 28 | |
|
29 | 29 | Model mappers allow you to use QAbstractItemModel derived models as a data source for a chart series. |
|
30 | 30 | Vertical model mapper is used to create a connection between QXYSeries and QAbstractItemModel derived model object. |
|
31 | 31 | It is possible to use both QAbstractItemModel and QXYSeries model API. QXYModelMapper makes sure that QXYSeries and the model are kept in sync. |
|
32 | 32 | Note: used model has to support adding/removing rows/columns and modifying the data of the cells. |
|
33 | 33 | */ |
|
34 | 34 | /*! |
|
35 | 35 | \qmlclass VXYModelMapper QHXYModelMapper |
|
36 | 36 | |
|
37 | 37 | VXYModelMapper allows you to use your own QAbstractItemModel derived model with data in columns as a data source |
|
38 | 38 | for XYSeries based series. It is possible to use both QAbstractItemModel and XYSeries data API to manipulate data. |
|
39 | 39 | VYModelMapper keeps the series and the model in sync. |
|
40 | 40 | */ |
|
41 | 41 | |
|
42 | 42 | /*! |
|
43 | 43 | \property QVXYModelMapper::series |
|
44 | 44 | \brief Defines the QXYSeries object that is used by the mapper. |
|
45 | 45 | |
|
46 | 46 | All the data in the series is discarded when it is set to the mapper. |
|
47 | 47 | When new series is specified the old series is disconnected (it preserves its data) |
|
48 | 48 | */ |
|
49 | 49 | /*! |
|
50 | 50 | \qmlproperty XYSeries VXYModelMapper::series |
|
51 | 51 | Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to |
|
52 | 52 | the mapper. When new series is specified the old series is disconnected (it preserves its data). |
|
53 | 53 | */ |
|
54 | 54 | |
|
55 | 55 | /*! |
|
56 | 56 | \property QVXYModelMapper::model |
|
57 | 57 | \brief Defines the model that is used by the mapper. |
|
58 | 58 | */ |
|
59 | 59 | /*! |
|
60 | 60 | \qmlproperty SomeModel VXYModelMapper::model |
|
61 |
The QAbstractItemModel based model that is used by the mapper. You need to implement the model |
|
|
62 |
|
|
|
63 |
|
|
|
61 | The QAbstractItemModel based model that is used by the mapper. You need to implement the model | |
|
62 | and expose it to QML. Note: the model has to support adding/removing rows/columns and modifying | |
|
63 | the data of the cells. | |
|
64 | 64 | */ |
|
65 | 65 | |
|
66 | 66 | /*! |
|
67 | 67 | \property QVXYModelMapper::xColumn |
|
68 | 68 | \brief Defines which column of the model is kept in sync with the x values of QXYSeries. |
|
69 | 69 | |
|
70 | 70 | Default value is: -1 (invalid mapping) |
|
71 | 71 | */ |
|
72 | 72 | /*! |
|
73 | 73 | \qmlproperty int VXYModelMapper::xColumn |
|
74 | 74 | Defines which column of the model is kept in sync with the x values of the series. Default value is -1 (invalid |
|
75 | 75 | mapping). |
|
76 | 76 | */ |
|
77 | 77 | |
|
78 | 78 | /*! |
|
79 | 79 | \property QVXYModelMapper::yColumn |
|
80 | 80 | \brief Defines which column of the model is kept in sync with the y values of QXYSeries. |
|
81 | 81 | |
|
82 | 82 | Default value is: -1 (invalid mapping) |
|
83 | 83 | */ |
|
84 | 84 | /*! |
|
85 | 85 | \qmlproperty int VXYModelMapper::yColumn |
|
86 | 86 | Defines which column of the model is kept in sync with the y values of the series. Default value is -1 (invalid |
|
87 | 87 | mapping). |
|
88 | 88 | */ |
|
89 | 89 | |
|
90 | 90 | /*! |
|
91 | 91 | \property QVXYModelMapper::firstRow |
|
92 | 92 | \brief Defines which row of the model contains the data for the first point of the series. |
|
93 | 93 | |
|
94 | 94 | Minimal and default value is: 0 |
|
95 | 95 | */ |
|
96 | 96 | /*! |
|
97 | 97 | \qmlproperty int VXYModelMapper::firstRow |
|
98 | 98 | Defines which row of the model contains the data for the first point of the series. |
|
99 | 99 | The default value is 0. |
|
100 | 100 | */ |
|
101 | 101 | |
|
102 | 102 | /*! |
|
103 | 103 | \property QVXYModelMapper::rowCount |
|
104 | 104 | \brief Defines the number of rows of the model that are mapped as the data for series. |
|
105 | 105 | |
|
106 | 106 | Minimal and default value is: -1 (count limited by the number of rows in the model) |
|
107 | 107 | */ |
|
108 | 108 | /*! |
|
109 | 109 | \qmlproperty int VXYModelMapper::columnCount |
|
110 | 110 | Defines the number of rows of the model that are mapped as the data for series. The default value is |
|
111 | 111 | -1 (count limited by the number of rows in the model). |
|
112 | 112 | */ |
|
113 | 113 | |
|
114 | 114 | /*! |
|
115 | 115 | \fn void QVXYModelMapper::seriesReplaced() |
|
116 | 116 | |
|
117 | 117 | Emitted when the series to which mapper is connected to has changed. |
|
118 | 118 | */ |
|
119 | 119 | |
|
120 | 120 | /*! |
|
121 | 121 | \fn void QVXYModelMapper::modelReplaced() |
|
122 | 122 | |
|
123 | 123 | Emitted when the model to which mapper is connected to has changed. |
|
124 | 124 | */ |
|
125 | 125 | |
|
126 | 126 | /*! |
|
127 | 127 | \fn void QVXYModelMapper::xColumnChanged() |
|
128 | 128 | |
|
129 | 129 | Emitted when the xColumn has changed. |
|
130 | 130 | */ |
|
131 | 131 | |
|
132 | 132 | /*! |
|
133 | 133 | \fn void QVXYModelMapper::yColumnChanged() |
|
134 | 134 | |
|
135 | 135 | Emitted when the yColumn has changed. |
|
136 | 136 | */ |
|
137 | 137 | |
|
138 | 138 | /*! |
|
139 | 139 | \fn void QVXYModelMapper::firstRowChanged() |
|
140 | 140 | Emitted when the firstRow has changed. |
|
141 | 141 | */ |
|
142 | 142 | |
|
143 | 143 | /*! |
|
144 | 144 | \fn void QVXYModelMapper::rowCountChanged() |
|
145 | 145 | Emitted when the rowCount has changed. |
|
146 | 146 | */ |
|
147 | 147 | |
|
148 | 148 | /*! |
|
149 | 149 | Constructs a mapper object which is a child of \a parent. |
|
150 | 150 | */ |
|
151 | 151 | QVXYModelMapper::QVXYModelMapper(QObject *parent) : |
|
152 | 152 | QXYModelMapper(parent) |
|
153 | 153 | { |
|
154 | 154 | QXYModelMapper::setOrientation(Qt::Vertical); |
|
155 | 155 | } |
|
156 | 156 | |
|
157 | 157 | QAbstractItemModel *QVXYModelMapper::model() const |
|
158 | 158 | { |
|
159 | 159 | return QXYModelMapper::model(); |
|
160 | 160 | } |
|
161 | 161 | |
|
162 | 162 | void QVXYModelMapper::setModel(QAbstractItemModel *model) |
|
163 | 163 | { |
|
164 | 164 | if (model != QXYModelMapper::model()) { |
|
165 | 165 | QXYModelMapper::setModel(model); |
|
166 | 166 | emit modelReplaced(); |
|
167 | 167 | } |
|
168 | 168 | } |
|
169 | 169 | |
|
170 | 170 | QXYSeries *QVXYModelMapper::series() const |
|
171 | 171 | { |
|
172 | 172 | return QXYModelMapper::series(); |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void QVXYModelMapper::setSeries(QXYSeries *series) |
|
176 | 176 | { |
|
177 | 177 | if (series != QXYModelMapper::series()) { |
|
178 | 178 | QXYModelMapper::setSeries(series); |
|
179 | 179 | emit seriesReplaced(); |
|
180 | 180 | } |
|
181 | 181 | } |
|
182 | 182 | |
|
183 | 183 | int QVXYModelMapper::xColumn() const |
|
184 | 184 | { |
|
185 | 185 | return QXYModelMapper::xSection(); |
|
186 | 186 | } |
|
187 | 187 | |
|
188 | 188 | void QVXYModelMapper::setXColumn(int xColumn) |
|
189 | 189 | { |
|
190 | 190 | if (xColumn != xSection()) { |
|
191 | 191 | QXYModelMapper::setXSection(xColumn); |
|
192 | 192 | emit xColumnChanged(); |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | int QVXYModelMapper::yColumn() const |
|
197 | 197 | { |
|
198 | 198 | return QXYModelMapper::ySection(); |
|
199 | 199 | } |
|
200 | 200 | |
|
201 | 201 | void QVXYModelMapper::setYColumn(int yColumn) |
|
202 | 202 | { |
|
203 | 203 | if (yColumn != ySection()) { |
|
204 | 204 | QXYModelMapper::setYSection(yColumn); |
|
205 | 205 | emit yColumnChanged(); |
|
206 | 206 | } |
|
207 | 207 | } |
|
208 | 208 | |
|
209 | 209 | int QVXYModelMapper::firstRow() const |
|
210 | 210 | { |
|
211 | 211 | return first(); |
|
212 | 212 | } |
|
213 | 213 | |
|
214 | 214 | void QVXYModelMapper::setFirstRow(int firstRow) |
|
215 | 215 | { |
|
216 | 216 | if (firstRow != first()) { |
|
217 | 217 | setFirst(firstRow); |
|
218 | 218 | emit firstRowChanged(); |
|
219 | 219 | } |
|
220 | 220 | } |
|
221 | 221 | |
|
222 | 222 | int QVXYModelMapper::rowCount() const |
|
223 | 223 | { |
|
224 | 224 | return count(); |
|
225 | 225 | } |
|
226 | 226 | |
|
227 | 227 | void QVXYModelMapper::setRowCount(int rowCount) |
|
228 | 228 | { |
|
229 | 229 | if (rowCount != count()) { |
|
230 | 230 | setCount(rowCount); |
|
231 | 231 | emit rowCountChanged(); |
|
232 | 232 | } |
|
233 | 233 | } |
|
234 | 234 | |
|
235 | 235 | #include "moc_qvxymodelmapper.cpp" |
|
236 | 236 | |
|
237 | 237 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now