##// END OF EJS Templates
Replaced NOTE: with Note: in modelmapper classes and qdatetimeaxis to remove it from QtCreator TODO entries
Marek Rosa -
r2396:240c05f01c11
parent child
Show More
@@ -1,373 +1,373
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 "qdatetimeaxis.h"
22 22 #include "qdatetimeaxis_p.h"
23 23 #include "chartdatetimeaxisx_p.h"
24 24 #include "chartdatetimeaxisy_p.h"
25 25 #include "abstractdomain_p.h"
26 26 #include "qchart.h"
27 27 #include <float.h>
28 28 #include <cmath>
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31 /*!
32 32 \class QDateTimeAxis
33 33 \brief The QDateTimeAxis class is used for manipulating chart's axis.
34 34 \mainclass
35 35
36 36 The labels can be configured by setting an appropriate DateTime format.
37 37 QDateTimeAxis works correctly with dates from 4714 BCE to 287396 CE
38 38 There are also other limitiation related to QDateTime . Please refer to QDateTime documentation.
39 39 QDateTimeAxis can be setup to show axis line with tick marks, grid lines and shades.
40 40
41 NOTE: QDateTimeAxis is disabled on ARM architecture.
41 Note: QDateTimeAxis is disabled on ARM architecture.
42 42
43 43 \image api_datatime_axis.png
44 44
45 45 QDateTimeAxis can be used with QLineSeries, QSplineSeries or QScatterSeries.
46 46 To add a data point to the series QDateTime::toMSecsSinceEpoch() is used.
47 47 \code
48 48 QLineSeries *series = new QLineSeries;
49 49
50 50 QDateTime xValue;
51 51 xValue.setDate(QDate(2012, 1 , 18));
52 52 xValue.setTime(QTime(9, 34));
53 53 qreal yValue = 12;
54 54 series->append(xValue.toMSecsSinceEpoch(), yValue);
55 55
56 56 xValue.setDate(QDate(2013, 5 , 11));
57 57 xValue.setTime(QTime(11, 14));
58 58 qreal yValue = 22;
59 59 series->append(xValue.toMSecsSinceEpoch(), yValue);
60 60 \endcode
61 61
62 62 Adding the series to the chart and setting up the QDateTimeAxis.
63 63 \code
64 64 QChartView *chartView = new QChartView;
65 65 chartView->chart()->addSeries(series);
66 66
67 67 // ...
68 68 QDateTimeAxis *axisX = new QDateTimeAxis;
69 69 axisX->setFormat("dd-MM-yyyy h:mm");
70 70 chartView->chart()->setAxisX(axisX, series);
71 71 \endcode
72 72 */
73 73
74 74 /*!
75 75 \qmlclass DateTimeAxis QDateTimeAxis
76 76 \brief The DateTimeAxis element is used for manipulating chart's axes
77 77 \inherits AbstractAxis
78 78
79 79 The labels can be configured by setting an appropriate DateTime format.
80 80 Note that any date before 4714 BCE or after about 1.4 million CE may not be accurately stored.
81 81 DateTimeAxis can be setup to show axis line with tick marks, grid lines and shades.
82 82 */
83 83
84 84 /*!
85 85 \property QDateTimeAxis::min
86 86 Defines the minimum value on the axis.
87 87 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
88 88 */
89 89 /*!
90 90 \qmlproperty real ValuesAxis::min
91 91 Defines the minimum value on the axis.
92 92 When setting this property the max is adjusted if necessary, to ensure that the range remains valid.
93 93 */
94 94
95 95 /*!
96 96 \property QDateTimeAxis::max
97 97 Defines the maximum value on the axis.
98 98 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
99 99 */
100 100 /*!
101 101 \qmlproperty real ValuesAxis::max
102 102 Defines the maximum value on the axis.
103 103 When setting this property the min is adjusted if necessary, to ensure that the range remains valid.
104 104 */
105 105
106 106 /*!
107 107 \fn void QDateTimeAxis::minChanged(QDateTime min)
108 108 Axis emits signal when \a min of axis has changed.
109 109 */
110 110 /*!
111 111 \qmlsignal ValuesAxis::onMinChanged(QDateTime min)
112 112 Axis emits signal when \a min of axis has changed.
113 113 */
114 114
115 115 /*!
116 116 \fn void QDateTimeAxis::maxChanged(QDateTime max)
117 117 Axis emits signal when \a max of axis has changed.
118 118 */
119 119 /*!
120 120 \qmlsignal ValuesAxis::onMaxChanged(QDateTime max)
121 121 Axis emits signal when \a max of axis has changed.
122 122 */
123 123
124 124 /*!
125 125 \fn void QDateTimeAxis::rangeChanged(QDateTime min, QDateTime max)
126 126 Axis emits signal when \a min or \a max of axis has changed.
127 127 */
128 128
129 129 /*!
130 130 \property QDateTimeAxis::tickCount
131 131 The number of tick marks for the axis.
132 132 */
133 133
134 134 /*!
135 135 \qmlproperty int DateTimeAxis::tickCount
136 136 The number of tick marks for the axis.
137 137 */
138 138
139 139 /*!
140 140 \property QDateTimeAxis::format
141 141 The format string that is used when creating label for the axis out of a QDateTime object.
142 142 Check QDateTime documentation for information on how the string should be defined.
143 143 */
144 144 /*!
145 145 \qmlproperty string DateTimeAxis::format
146 146 The format string that is used when creating label for the axis out of a QDateTime object.
147 147 Check QDateTime documentation for information on how the string should be defined.
148 148 */
149 149
150 150 /*!
151 151 \fn void QDateTimeAxis::tickCountChanged(int tickCount)
152 152 Axis emits signal when \a tickCount number on axis have changed.
153 153 */
154 154 /*!
155 155 \qmlsignal DateTimeAxis::tickCountChanged(int tickCount)
156 156 Axis emits signal when \a tickCount number on axis have changed.
157 157 */
158 158
159 159 /*!
160 160 \fn void QDateTimeAxis::formatChanged(QString format)
161 161 Axis emits signal when \a format of the axis has changed.
162 162 */
163 163 /*!
164 164 \qmlsignal DateTimeAxis::onFormatChanged(string format)
165 165 Axis emits signal when \a format of the axis has changed.
166 166 */
167 167
168 168 /*!
169 169 Constructs an axis object which is a child of \a parent.
170 170 */
171 171 QDateTimeAxis::QDateTimeAxis(QObject *parent) :
172 172 QAbstractAxis(*new QDateTimeAxisPrivate(this), parent)
173 173 {
174 174
175 175 }
176 176
177 177 /*!
178 178 \internal
179 179 */
180 180 QDateTimeAxis::QDateTimeAxis(QDateTimeAxisPrivate &d, QObject *parent) : QAbstractAxis(d, parent)
181 181 {
182 182
183 183 }
184 184
185 185 /*!
186 186 Destroys the object
187 187 */
188 188 QDateTimeAxis::~QDateTimeAxis()
189 189 {
190 190 Q_D(QDateTimeAxis);
191 191 if (d->m_chart)
192 192 d->m_chart->removeAxis(this);
193 193 }
194 194
195 195 void QDateTimeAxis::setMin(QDateTime min)
196 196 {
197 197 Q_D(QDateTimeAxis);
198 198 if (min.isValid())
199 199 d->setRange(min.toMSecsSinceEpoch(), qMax(d->m_max, qreal(min.toMSecsSinceEpoch())));
200 200 }
201 201
202 202 QDateTime QDateTimeAxis::min() const
203 203 {
204 204 Q_D(const QDateTimeAxis);
205 205 return QDateTime::fromMSecsSinceEpoch(d->m_min);
206 206 }
207 207
208 208 void QDateTimeAxis::setMax(QDateTime max)
209 209 {
210 210 Q_D(QDateTimeAxis);
211 211 if (max.isValid())
212 212 d->setRange(qMin(d->m_min, qreal(max.toMSecsSinceEpoch())), max.toMSecsSinceEpoch());
213 213 }
214 214
215 215 QDateTime QDateTimeAxis::max() const
216 216 {
217 217 Q_D(const QDateTimeAxis);
218 218 return QDateTime::fromMSecsSinceEpoch(d->m_max);
219 219 }
220 220
221 221 /*!
222 222 Sets range from \a min to \a max on the axis.
223 223 If min is greater than max then this function returns without making any changes.
224 224 */
225 225 void QDateTimeAxis::setRange(QDateTime min, QDateTime max)
226 226 {
227 227 Q_D(QDateTimeAxis);
228 228 if (!min.isValid() || !max.isValid() || min > max)
229 229 return;
230 230
231 231 d->setRange(min.toMSecsSinceEpoch(),max.toMSecsSinceEpoch());
232 232 }
233 233
234 234 void QDateTimeAxis::setFormat(QString format)
235 235 {
236 236 Q_D(QDateTimeAxis);
237 237 if (d->m_format != format) {
238 238 d->m_format = format;
239 239 emit formatChanged(format);
240 240 }
241 241 }
242 242
243 243 QString QDateTimeAxis::format() const
244 244 {
245 245 Q_D(const QDateTimeAxis);
246 246 return d->m_format;
247 247 }
248 248
249 249 /*!
250 250 Sets \a count for ticks on the axis.
251 251 */
252 252 void QDateTimeAxis::setTickCount(int count)
253 253 {
254 254 Q_D(QDateTimeAxis);
255 255 if (d->m_tickCount != count && count >= 2) {
256 256 d->m_tickCount = count;
257 257 emit tickCountChanged(count);
258 258 }
259 259 }
260 260
261 261 /*!
262 262 \fn int QDateTimeAxis::tickCount() const
263 263 Return number of ticks on the axis
264 264 */
265 265 int QDateTimeAxis::tickCount() const
266 266 {
267 267 Q_D(const QDateTimeAxis);
268 268 return d->m_tickCount;
269 269 }
270 270
271 271 /*!
272 272 Returns the type of the axis
273 273 */
274 274 QAbstractAxis::AxisType QDateTimeAxis::type() const
275 275 {
276 276 return AxisTypeDateTime;
277 277 }
278 278
279 279 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
280 280
281 281 QDateTimeAxisPrivate::QDateTimeAxisPrivate(QDateTimeAxis *q)
282 282 : QAbstractAxisPrivate(q),
283 283 m_min(0),
284 284 m_max(0),
285 285 m_tickCount(5)
286 286 {
287 287 m_format = "dd-MM-yyyy\nh:mm";
288 288 }
289 289
290 290 QDateTimeAxisPrivate::~QDateTimeAxisPrivate()
291 291 {
292 292
293 293 }
294 294
295 295 void QDateTimeAxisPrivate::setRange(qreal min,qreal max)
296 296 {
297 297 Q_Q(QDateTimeAxis);
298 298
299 299 bool changed = false;
300 300
301 301 if (m_min != min) {
302 302 m_min = min;
303 303 changed = true;
304 304 emit q->minChanged(QDateTime::fromMSecsSinceEpoch(min));
305 305 }
306 306
307 307 if (m_max != max) {
308 308 m_max = max;
309 309 changed = true;
310 310 emit q->maxChanged(QDateTime::fromMSecsSinceEpoch(max));
311 311 }
312 312
313 313 if (changed) {
314 314 emit q->rangeChanged(QDateTime::fromMSecsSinceEpoch(min), QDateTime::fromMSecsSinceEpoch(max));
315 315 emit rangeChanged(m_min,m_max);
316 316 }
317 317 }
318 318
319 319
320 320 void QDateTimeAxisPrivate::setMin(const QVariant &min)
321 321 {
322 322 Q_Q(QDateTimeAxis);
323 323 if (min.canConvert(QVariant::DateTime))
324 324 q->setMin(min.toDateTime());
325 325 }
326 326
327 327 void QDateTimeAxisPrivate::setMax(const QVariant &max)
328 328 {
329 329
330 330 Q_Q(QDateTimeAxis);
331 331 if (max.canConvert(QVariant::DateTime))
332 332 q->setMax(max.toDateTime());
333 333 }
334 334
335 335 void QDateTimeAxisPrivate::setRange(const QVariant &min, const QVariant &max)
336 336 {
337 337 Q_Q(QDateTimeAxis);
338 338 if (min.canConvert(QVariant::DateTime) && max.canConvert(QVariant::DateTime))
339 339 q->setRange(min.toDateTime(), max.toDateTime());
340 340 }
341 341
342 342 void QDateTimeAxisPrivate::initializeGraphics(QGraphicsItem* parent)
343 343 {
344 344 Q_Q(QDateTimeAxis);
345 345 ChartAxis* axis(0);
346 346 if (orientation() == Qt::Vertical)
347 347 axis = new ChartDateTimeAxisY(q,parent);
348 348 if (orientation() == Qt::Horizontal)
349 349 axis = new ChartDateTimeAxisX(q,parent);
350 350
351 351 m_item.reset(axis);
352 352 QAbstractAxisPrivate::initializeGraphics(parent);
353 353 }
354 354
355 355 void QDateTimeAxisPrivate::initializeDomain(AbstractDomain *domain)
356 356 {
357 357 if (m_max == m_min) {
358 358 if (orientation() == Qt::Vertical)
359 359 setRange(domain->minY(), domain->maxY());
360 360 else
361 361 setRange(domain->minX(), domain->maxX());
362 362 } else {
363 363 if (orientation() == Qt::Vertical)
364 364 domain->setRangeY(m_min, m_max);
365 365 else
366 366 domain->setRangeX(m_min, m_max);
367 367 }
368 368 }
369 369
370 370 #include "moc_qdatetimeaxis.cpp"
371 371 #include "moc_qdatetimeaxis_p.cpp"
372 372
373 373 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,248 +1,248
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
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 QPieSeries 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 78 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
79 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
79 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
80 80 and modifying 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 Default value is: -1 (invalid mapping)
87 87 */
88 88 /*!
89 89 \qmlproperty int VBarModelMapper::firstBarSetColumn
90 90 Defines which column of the model is used as the data source for the first bar set. Default value
91 91 is: -1 (invalid mapping).
92 92 */
93 93
94 94 /*!
95 95 \property QVBarModelMapper::lastBarSetColumn
96 96 \brief Defines which column of the model is used as the data source for the last bar set
97 97 Default value is: -1 (invalid mapping)
98 98 */
99 99 /*!
100 100 \qmlproperty int VBarModelMapper::lastBarSetColumn
101 101 Defines which column of the model is used as the data source for the last bar set. Default
102 102 value is: -1 (invalid mapping).
103 103 */
104 104
105 105 /*!
106 106 \property QVBarModelMapper::firstRow
107 107 \brief Defines which row of the model contains the first values of the QBarSets in the series.
108 108 Minimal and default value is: 0
109 109 */
110 110 /*!
111 111 \qmlproperty int VBarModelMapper::firstRow
112 112 Defines which row of the model contains the first values of the QBarSets in the series.
113 113 The default value is 0.
114 114 */
115 115
116 116 /*!
117 117 \property QVBarModelMapper::rowCount
118 118 \brief Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries
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 VBarModelMapper::rowCount
123 123 Defines the number of rows of the model that are mapped as the data for QAbstractBarSeries. 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 QVBarModelMapper::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 QVBarModelMapper::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 QVBarModelMapper::firstBarSetColumnChanged()
141 141 Emitted when the firstBarSetColumn has changed.
142 142 */
143 143
144 144 /*!
145 145 \fn void QVBarModelMapper::lastBarSetColumnChanged()
146 146 Emitted when the lastBarSetColumn has changed.
147 147 */
148 148
149 149 /*!
150 150 \fn void QVBarModelMapper::firstRowChanged()
151 151 Emitted when the firstRow has changed.
152 152 */
153 153
154 154 /*!
155 155 \fn void QVBarModelMapper::rowCountChanged()
156 156 Emitted when the rowCount has changed.
157 157 */
158 158
159 159 /*!
160 160 Constructs a mapper object which is a child of \a parent.
161 161 */
162 162 QVBarModelMapper::QVBarModelMapper(QObject *parent) :
163 163 QBarModelMapper(parent)
164 164 {
165 165 QBarModelMapper::setOrientation(Qt::Vertical);
166 166 }
167 167
168 168 QAbstractItemModel *QVBarModelMapper::model() const
169 169 {
170 170 return QBarModelMapper::model();
171 171 }
172 172
173 173 void QVBarModelMapper::setModel(QAbstractItemModel *model)
174 174 {
175 175 if (model != QBarModelMapper::model()) {
176 176 QBarModelMapper::setModel(model);
177 177 emit modelReplaced();
178 178 }
179 179 }
180 180
181 181 QAbstractBarSeries *QVBarModelMapper::series() const
182 182 {
183 183 return QBarModelMapper::series();
184 184 }
185 185
186 186 void QVBarModelMapper::setSeries(QAbstractBarSeries *series)
187 187 {
188 188 if (series != QBarModelMapper::series()) {
189 189 QBarModelMapper::setSeries(series);
190 190 emit seriesReplaced();
191 191 }
192 192 }
193 193
194 194 int QVBarModelMapper::firstBarSetColumn() const
195 195 {
196 196 return QBarModelMapper::firstBarSetSection();
197 197 }
198 198
199 199 void QVBarModelMapper::setFirstBarSetColumn(int firstBarSetColumn)
200 200 {
201 201 if (firstBarSetColumn != firstBarSetSection()) {
202 202 QBarModelMapper::setFirstBarSetSection(firstBarSetColumn);
203 203 emit firstBarSetColumnChanged();
204 204 }
205 205 }
206 206
207 207 int QVBarModelMapper::lastBarSetColumn() const
208 208 {
209 209 return QBarModelMapper::lastBarSetSection();
210 210 }
211 211
212 212 void QVBarModelMapper::setLastBarSetColumn(int lastBarSetColumn)
213 213 {
214 214 if (lastBarSetColumn != lastBarSetSection()) {
215 215 QBarModelMapper::setLastBarSetSection(lastBarSetColumn);
216 216 emit lastBarSetColumnChanged();
217 217 }
218 218 }
219 219
220 220 int QVBarModelMapper::firstRow() const
221 221 {
222 222 return QBarModelMapper::first();
223 223 }
224 224
225 225 void QVBarModelMapper::setFirstRow(int firstRow)
226 226 {
227 227 if (firstRow != first()) {
228 228 QBarModelMapper::setFirst(firstRow);
229 229 emit firstRowChanged();
230 230 }
231 231 }
232 232
233 233 int QVBarModelMapper::rowCount() const
234 234 {
235 235 return QBarModelMapper::count();
236 236 }
237 237
238 238 void QVBarModelMapper::setRowCount(int rowCount)
239 239 {
240 240 if (rowCount != count()) {
241 241 QBarModelMapper::setCount(rowCount);
242 242 emit rowCountChanged();
243 243 }
244 244 }
245 245
246 246 #include "moc_qvbarmodelmapper.cpp"
247 247
248 248 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,257 +1,257
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
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 75 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
76 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
76 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
77 77 and modifying 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 Default value is: -1 (invalid mapping)
84 84 */
85 85 /*!
86 86 \qmlproperty int HPieModelMapper::valuesRow
87 87 Defines which row 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 QHPieModelMapper::labelsRow
93 93 \brief Defines which row of the model is kept in sync with the labels of the pie's slices
94 94 Default value is: -1 (invalid mapping)
95 95 */
96 96 /*!
97 97 \qmlproperty int HPieModelMapper::labelsRow
98 98 Defines which row of the model is kept in sync with the labels of the pie's slices
99 99 Default value is: -1 (invalid mapping)
100 100 */
101 101
102 102 /*!
103 103 \property QHPieModelMapper::firstColumn
104 104 \brief Defines which column of the model contains the first slice value.
105 105 Minimal and default value is: 0
106 106 */
107 107 /*!
108 108 \qmlproperty int HPieModelMapper::firstColumn
109 109 Defines which column of the model contains the first slice value.
110 110 The default value is 0.
111 111 */
112 112
113 113 /*!
114 114 \property QHPieModelMapper::columnCount
115 115 \brief Defines the number of columns of the model that are mapped as the data for QPieSeries
116 116 Minimal and default value is: -1 (count limited by the number of columns in the model)
117 117 */
118 118 /*!
119 119 \qmlproperty int HPieModelMapper::columnCount
120 120 Defines the number of columns of the model that are mapped as the data for QPieSeries. The default value is
121 121 -1 (count limited by the number of columns in the model)
122 122 */
123 123
124 124 /*!
125 125 \fn void QHPieModelMapper::seriesReplaced()
126 126 Emitted when the series to which mapper is connected to has changed.
127 127 */
128 128
129 129 /*!
130 130 \fn void QHPieModelMapper::modelReplaced()
131 131 Emitted when the model to which mapper is connected to has changed.
132 132 */
133 133
134 134 /*!
135 135 \fn void QHPieModelMapper::valuesRowChanged()
136 136 Emitted when the valuesRow has changed.
137 137 */
138 138
139 139 /*!
140 140 \fn void QHPieModelMapper::labelsRowChanged()
141 141 Emitted when the labelsRow has changed.
142 142 */
143 143
144 144 /*!
145 145 \fn void QHPieModelMapper::firstColumnChanged()
146 146 Emitted when the firstColumn has changed.
147 147 */
148 148
149 149 /*!
150 150 \fn void QHPieModelMapper::columnCountChanged()
151 151 Emitted when the columnCount has changed.
152 152 */
153 153
154 154 /*!
155 155 Constructs a mapper object which is a child of \a parent.
156 156 */
157 157 QHPieModelMapper::QHPieModelMapper(QObject *parent) :
158 158 QPieModelMapper(parent)
159 159 {
160 160 setOrientation(Qt::Horizontal);
161 161 }
162 162
163 163 QAbstractItemModel *QHPieModelMapper::model() const
164 164 {
165 165 return QPieModelMapper::model();
166 166 }
167 167
168 168 void QHPieModelMapper::setModel(QAbstractItemModel *model)
169 169 {
170 170 if (model != QPieModelMapper::model()) {
171 171 QPieModelMapper::setModel(model);
172 172 emit modelReplaced();
173 173 }
174 174 }
175 175
176 176 QPieSeries *QHPieModelMapper::series() const
177 177 {
178 178 return QPieModelMapper::series();
179 179 }
180 180
181 181 void QHPieModelMapper::setSeries(QPieSeries *series)
182 182 {
183 183 if (series != QPieModelMapper::series()) {
184 184 QPieModelMapper::setSeries(series);
185 185 emit seriesReplaced();
186 186 }
187 187 }
188 188
189 189 /*!
190 190 Returns which row of the model is kept in sync with the values of the pie's slices
191 191 */
192 192 int QHPieModelMapper::valuesRow() const
193 193 {
194 194 return valuesSection();
195 195 }
196 196
197 197 /*!
198 198 Sets the model row that is kept in sync with the pie slices values.
199 199 Parameter \a valuesRow specifies the row of the model.
200 200 */
201 201 void QHPieModelMapper::setValuesRow(int valuesRow)
202 202 {
203 203 if (valuesRow != valuesSection()) {
204 204 setValuesSection(valuesRow);
205 205 emit valuesRowChanged();
206 206 }
207 207 }
208 208
209 209 /*!
210 210 Returns which row of the model is kept in sync with the labels of the pie's slices
211 211 */
212 212 int QHPieModelMapper::labelsRow() const
213 213 {
214 214 return labelsSection();
215 215 }
216 216
217 217 /*!
218 218 Sets the model row that is kept in sync with the pie's slices labels.
219 219 Parameter \a labelsRow specifies the row of the model.
220 220 */
221 221 void QHPieModelMapper::setLabelsRow(int labelsRow)
222 222 {
223 223 if (labelsRow != labelsSection()) {
224 224 setLabelsSection(labelsRow);
225 225 emit labelsRowChanged();
226 226 }
227 227 }
228 228
229 229 int QHPieModelMapper::firstColumn() const
230 230 {
231 231 return first();
232 232 }
233 233
234 234 void QHPieModelMapper::setFirstColumn(int firstColumn)
235 235 {
236 236 if (firstColumn != first()) {
237 237 setFirst(firstColumn);
238 238 emit firstColumnChanged();
239 239 }
240 240 }
241 241
242 242 int QHPieModelMapper::columnCount() const
243 243 {
244 244 return count();
245 245 }
246 246
247 247 void QHPieModelMapper::setColumnCount(int columnCount)
248 248 {
249 249 if (columnCount != count()) {
250 250 setCount(columnCount);
251 251 emit columnCountChanged();
252 252 }
253 253 }
254 254
255 255 #include "moc_qhpiemodelmapper.cpp"
256 256
257 257 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,260 +1,260
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
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 74 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
75 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
75 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
76 76 and modifying 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 Default value is: -1 (invalid mapping)
83 83 */
84 84 /*!
85 85 \qmlproperty int VPieModelMapper::valuesColumn
86 86 Defines which column of the model is kept in sync with the values of the pie's slices. Default value is -1 (invalid
87 87 mapping).
88 88 */
89 89
90 90 /*!
91 91 \property QVPieModelMapper::labelsColumn
92 92 \brief Defines which column of the model is kept in sync with the labels of the pie's slices
93 93 Default value is: -1 (invalid mapping)
94 94 */
95 95 /*!
96 96 \qmlproperty int VPieModelMapper::labelsColumn
97 97 Defines which column of the model is kept in sync with the labels of the pie's slices. Default value is -1 (invalid
98 98 mapping).
99 99 */
100 100
101 101 /*!
102 102 \property QVPieModelMapper::firstRow
103 103 \brief Defines which row of the model contains the first slice value.
104 104 Minimal and default value is: 0
105 105 */
106 106 /*!
107 107 \qmlproperty int VPieModelMapper::firstRow
108 108 Defines which row of the model contains the first slice value.
109 109 The default value is 0.
110 110 */
111 111
112 112 /*!
113 113 \property QVPieModelMapper::rowCount
114 114 \brief Defines the number of rows of the model that are mapped as the data for QPieSeries
115 115 Minimal and default value is: -1 (count limited by the number of rows in the model)
116 116 */
117 117 /*!
118 118 \qmlproperty int VPieModelMapper::columnCount
119 119 Defines the number of rows of the model that are mapped as the data for QPieSeries. The default value is
120 120 -1 (count limited by the number of rows in the model)
121 121 */
122 122
123 123 /*!
124 124 \fn void QVPieModelMapper::seriesReplaced()
125 125
126 126 Emitted when the series to which mapper is connected to has changed.
127 127 */
128 128
129 129 /*!
130 130 \fn void QVPieModelMapper::modelReplaced()
131 131
132 132 Emitted when the model to which mapper is connected to has changed.
133 133 */
134 134
135 135 /*!
136 136 \fn void QVPieModelMapper::valuesColumnChanged()
137 137
138 138 Emitted when the valuesColumn has changed.
139 139 */
140 140
141 141 /*!
142 142 \fn void QVPieModelMapper::labelsColumnChanged()
143 143
144 144 Emitted when the labelsColumn has changed.
145 145 */
146 146
147 147 /*!
148 148 \fn void QVPieModelMapper::firstRowChanged()
149 149 Emitted when the firstRow has changed.
150 150 */
151 151
152 152 /*!
153 153 \fn void QVPieModelMapper::rowCountChanged()
154 154 Emitted when the rowCount has changed.
155 155 */
156 156
157 157 /*!
158 158 Constructs a mapper object which is a child of \a parent.
159 159 */
160 160 QVPieModelMapper::QVPieModelMapper(QObject *parent) :
161 161 QPieModelMapper(parent)
162 162 {
163 163 QPieModelMapper::setOrientation(Qt::Vertical);
164 164 }
165 165
166 166 QAbstractItemModel *QVPieModelMapper::model() const
167 167 {
168 168 return QPieModelMapper::model();
169 169 }
170 170
171 171 void QVPieModelMapper::setModel(QAbstractItemModel *model)
172 172 {
173 173 if (model != QPieModelMapper::model()) {
174 174 QPieModelMapper::setModel(model);
175 175 emit modelReplaced();
176 176 }
177 177 }
178 178
179 179 QPieSeries *QVPieModelMapper::series() const
180 180 {
181 181 return QPieModelMapper::series();
182 182 }
183 183
184 184 void QVPieModelMapper::setSeries(QPieSeries *series)
185 185 {
186 186 if (series != QPieModelMapper::series()) {
187 187 QPieModelMapper::setSeries(series);
188 188 emit seriesReplaced();
189 189 }
190 190 }
191 191
192 192 /*!
193 193 Returns which column of the model is kept in sync with the values of the pie's slices
194 194 */
195 195 int QVPieModelMapper::valuesColumn() const
196 196 {
197 197 return QPieModelMapper::valuesSection();
198 198 }
199 199
200 200 /*!
201 201 Sets the model column that is kept in sync with the pie slices values.
202 202 Parameter \a valuesColumn specifies the row of the model.
203 203 */
204 204 void QVPieModelMapper::setValuesColumn(int valuesColumn)
205 205 {
206 206 if (valuesColumn != valuesSection()) {
207 207 QPieModelMapper::setValuesSection(valuesColumn);
208 208 emit valuesColumnChanged();
209 209 }
210 210 }
211 211
212 212 /*!
213 213 Returns which column of the model is kept in sync with the labels of the pie's slices
214 214 */
215 215 int QVPieModelMapper::labelsColumn() const
216 216 {
217 217 return QPieModelMapper::labelsSection();
218 218 }
219 219
220 220 /*!
221 221 Sets the model column that is kept in sync with the pie's slices labels.
222 222 Parameter \a labelsColumn specifies the row of the model.
223 223 */
224 224 void QVPieModelMapper::setLabelsColumn(int labelsColumn)
225 225 {
226 226 if (labelsColumn != labelsSection()) {
227 227 QPieModelMapper::setLabelsSection(labelsColumn);
228 228 emit labelsColumnChanged();
229 229 }
230 230 }
231 231
232 232 int QVPieModelMapper::firstRow() const
233 233 {
234 234 return first();
235 235 }
236 236
237 237 void QVPieModelMapper::setFirstRow(int firstRow)
238 238 {
239 239 if (firstRow != first()) {
240 240 setFirst(firstRow);
241 241 emit firstRowChanged();
242 242 }
243 243 }
244 244
245 245 int QVPieModelMapper::rowCount() const
246 246 {
247 247 return count();
248 248 }
249 249
250 250 void QVPieModelMapper::setRowCount(int rowCount)
251 251 {
252 252 if (rowCount != count()) {
253 253 setCount(rowCount);
254 254 emit rowCountChanged();
255 255 }
256 256 }
257 257
258 258 #include "moc_qvpiemodelmapper.cpp"
259 259
260 260 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,232 +1,232
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
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 All the data in the series is discarded when it is set to the mapper.
46 46 When new series is specified the old series is disconnected (it preserves its data)
47 47 */
48 48 /*!
49 49 \qmlproperty XYSeries HXYModelMapper::series
50 50 Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to
51 51 the mapper. When new series is specified the old series is disconnected (it preserves its data).
52 52 */
53 53
54 54 /*!
55 55 \property QHXYModelMapper::model
56 56 \brief Defines the model that is used by the mapper.
57 57 */
58 58 /*!
59 59 \qmlproperty SomeModel HXYModelMapper::model
60 60 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
61 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
61 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
62 62 and modifying the data of the cells.
63 63 */
64 64
65 65 /*!
66 66 \property QHXYModelMapper::xRow
67 67 \brief Defines which row of the model is kept in sync with the x values of the QXYSeries
68 68 Default value is: -1 (invalid mapping)
69 69 */
70 70 /*!
71 71 \qmlproperty int HXYModelMapper::xRow
72 72 Defines which row of the model is kept in sync with the x values of the series. Default value is -1 (invalid
73 73 mapping).
74 74 */
75 75
76 76 /*!
77 77 \property QHXYModelMapper::yRow
78 78 \brief Defines which row of the model is kept in sync with the y values of the QXYSeries
79 79 Default value is: -1 (invalid mapping)
80 80 */
81 81 /*!
82 82 \qmlproperty int HXYModelMapper::yRow
83 83 Defines which row of the model is kept in sync with the y values of the series. Default value is -1
84 84 (invalid mapping).
85 85 */
86 86
87 87 /*!
88 88 \property QHXYModelMapper::firstColumn
89 89 \brief Defines which column of the model contains the data for the first point of the series.
90 90 Minimal and default value is: 0
91 91 */
92 92 /*!
93 93 \qmlproperty int HXYModelMapper::firstColumn
94 94 Defines which column of the model contains the data for the first point of the series.
95 95 The default value is 0.
96 96 */
97 97
98 98 /*!
99 99 \property QHXYModelMapper::columnCount
100 100 \brief Defines the number of columns of the model that are mapped as the data for series
101 101 Minimal and default value is: -1 (count limited by the number of columns in the model)
102 102 */
103 103 /*!
104 104 \qmlproperty int HXYModelMapper::columnCount
105 105 Defines the number of columns of the model that are mapped as the data for series. The default value is
106 106 -1 (count limited by the number of columns in the model)
107 107 */
108 108
109 109 /*!
110 110 \fn void QHXYModelMapper::seriesReplaced()
111 111
112 112 Emitted when the series to which mapper is connected to has changed.
113 113 */
114 114
115 115 /*!
116 116 \fn void QHXYModelMapper::modelReplaced()
117 117
118 118 Emitted when the model to which mapper is connected to has changed.
119 119 */
120 120
121 121 /*!
122 122 \fn void QHXYModelMapper::xRowChanged()
123 123
124 124 Emitted when the xRow has changed.
125 125 */
126 126
127 127 /*!
128 128 \fn void QHXYModelMapper::yRowChanged()
129 129
130 130 Emitted when the yRow has changed.
131 131 */
132 132
133 133 /*!
134 134 \fn void QHXYModelMapper::firstColumnChanged()
135 135 Emitted when the firstColumn has changed.
136 136 */
137 137
138 138 /*!
139 139 \fn void QHXYModelMapper::columnCountChanged()
140 140 Emitted when the columnCount has changed.
141 141 */
142 142
143 143 /*!
144 144 Constructs a mapper object which is a child of \a parent.
145 145 */
146 146 QHXYModelMapper::QHXYModelMapper(QObject *parent) :
147 147 QXYModelMapper(parent)
148 148 {
149 149 QXYModelMapper::setOrientation(Qt::Horizontal);
150 150 }
151 151
152 152 QAbstractItemModel *QHXYModelMapper::model() const
153 153 {
154 154 return QXYModelMapper::model();
155 155 }
156 156
157 157 void QHXYModelMapper::setModel(QAbstractItemModel *model)
158 158 {
159 159 if (model != QXYModelMapper::model()) {
160 160 QXYModelMapper::setModel(model);
161 161 emit modelReplaced();
162 162 }
163 163 }
164 164
165 165 QXYSeries *QHXYModelMapper::series() const
166 166 {
167 167 return QXYModelMapper::series();
168 168 }
169 169
170 170 void QHXYModelMapper::setSeries(QXYSeries *series)
171 171 {
172 172 if (series != QXYModelMapper::series()) {
173 173 QXYModelMapper::setSeries(series);
174 174 emit seriesReplaced();
175 175 }
176 176 }
177 177
178 178 int QHXYModelMapper::xRow() const
179 179 {
180 180 return QXYModelMapper::xSection();
181 181 }
182 182
183 183 void QHXYModelMapper::setXRow(int xRow)
184 184 {
185 185 if (xRow != xSection()) {
186 186 QXYModelMapper::setXSection(xRow);
187 187 emit xRowChanged();
188 188 }
189 189 }
190 190
191 191 int QHXYModelMapper::yRow() const
192 192 {
193 193 return QXYModelMapper::ySection();
194 194 }
195 195
196 196 void QHXYModelMapper::setYRow(int yRow)
197 197 {
198 198 if (yRow != ySection()) {
199 199 QXYModelMapper::setYSection(yRow);
200 200 emit yRowChanged();
201 201 }
202 202 }
203 203
204 204 int QHXYModelMapper::firstColumn() const
205 205 {
206 206 return first();
207 207 }
208 208
209 209 void QHXYModelMapper::setFirstColumn(int firstColumn)
210 210 {
211 211 if (firstColumn != first()) {
212 212 setFirst(firstColumn);
213 213 emit firstColumnChanged();
214 214 }
215 215 }
216 216
217 217 int QHXYModelMapper::columnCount() const
218 218 {
219 219 return count();
220 220 }
221 221
222 222 void QHXYModelMapper::setColumnCount(int columnCount)
223 223 {
224 224 if (columnCount != count()) {
225 225 setCount(columnCount);
226 226 emit columnCountChanged();
227 227 }
228 228 }
229 229
230 230 #include "moc_qhxymodelmapper.cpp"
231 231
232 232 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,232 +1,232
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 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 Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial 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 NOTE: used model has to support adding/removing rows/columns and modifying the data of the cells.
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 All the data in the series is discarded when it is set to the mapper.
46 46 When new series is specified the old series is disconnected (it preserves its data)
47 47 */
48 48 /*!
49 49 \qmlproperty XYSeries VXYModelMapper::series
50 50 Defines the XYSeries object that is used by the mapper. All the data in the series is discarded when it is set to
51 51 the mapper. When new series is specified the old series is disconnected (it preserves its data).
52 52 */
53 53
54 54 /*!
55 55 \property QVXYModelMapper::model
56 56 \brief Defines the model that is used by the mapper.
57 57 */
58 58 /*!
59 59 \qmlproperty SomeModel VXYModelMapper::model
60 60 The QAbstractItemModel based model that is used by the mapper. You need to implement the model and expose it to
61 QML as shown in \l {QML Custom Model} demo application. NOTE: the model has to support adding/removing rows/columns
61 QML as shown in \l {QML Custom Model} demo application. Note: the model has to support adding/removing rows/columns
62 62 and modifying the data of the cells.
63 63 */
64 64
65 65 /*!
66 66 \property QVXYModelMapper::xColumn
67 67 \brief Defines which column of the model is kept in sync with the x values of QXYSeries
68 68 Default value is: -1 (invalid mapping)
69 69 */
70 70 /*!
71 71 \qmlproperty int VXYModelMapper::xColumn
72 72 Defines which column of the model is kept in sync with the x values of the series. Default value is -1 (invalid
73 73 mapping).
74 74 */
75 75
76 76 /*!
77 77 \property QVXYModelMapper::yColumn
78 78 \brief Defines which column of the model is kept in sync with the y values of QXYSeries
79 79 Default value is: -1 (invalid mapping)
80 80 */
81 81 /*!
82 82 \qmlproperty int VXYModelMapper::yColumn
83 83 Defines which column of the model is kept in sync with the y values of the series. Default value is -1 (invalid
84 84 mapping).
85 85 */
86 86
87 87 /*!
88 88 \property QVXYModelMapper::firstRow
89 89 \brief Defines which row of the model contains the data for the first point of the series.
90 90 Minimal and default value is: 0
91 91 */
92 92 /*!
93 93 \qmlproperty int VXYModelMapper::firstRow
94 94 Defines which row of the model contains the data for the first point of the series.
95 95 The default value is 0.
96 96 */
97 97
98 98 /*!
99 99 \property QVXYModelMapper::rowCount
100 100 \brief Defines the number of rows of the model that are mapped as the data for series
101 101 Minimal and default value is: -1 (count limited by the number of rows in the model)
102 102 */
103 103 /*!
104 104 \qmlproperty int VXYModelMapper::columnCount
105 105 Defines the number of rows of the model that are mapped as the data for series. The default value is
106 106 -1 (count limited by the number of rows in the model).
107 107 */
108 108
109 109 /*!
110 110 \fn void QVXYModelMapper::seriesReplaced()
111 111
112 112 Emitted when the series to which mapper is connected to has changed.
113 113 */
114 114
115 115 /*!
116 116 \fn void QVXYModelMapper::modelReplaced()
117 117
118 118 Emitted when the model to which mapper is connected to has changed.
119 119 */
120 120
121 121 /*!
122 122 \fn void QVXYModelMapper::xColumnChanged()
123 123
124 124 Emitted when the xColumn has changed.
125 125 */
126 126
127 127 /*!
128 128 \fn void QVXYModelMapper::yColumnChanged()
129 129
130 130 Emitted when the yColumn has changed.
131 131 */
132 132
133 133 /*!
134 134 \fn void QVXYModelMapper::firstRowChanged()
135 135 Emitted when the firstRow has changed.
136 136 */
137 137
138 138 /*!
139 139 \fn void QVXYModelMapper::rowCountChanged()
140 140 Emitted when the rowCount has changed.
141 141 */
142 142
143 143 /*!
144 144 Constructs a mapper object which is a child of \a parent.
145 145 */
146 146 QVXYModelMapper::QVXYModelMapper(QObject *parent) :
147 147 QXYModelMapper(parent)
148 148 {
149 149 QXYModelMapper::setOrientation(Qt::Vertical);
150 150 }
151 151
152 152 QAbstractItemModel *QVXYModelMapper::model() const
153 153 {
154 154 return QXYModelMapper::model();
155 155 }
156 156
157 157 void QVXYModelMapper::setModel(QAbstractItemModel *model)
158 158 {
159 159 if (model != QXYModelMapper::model()) {
160 160 QXYModelMapper::setModel(model);
161 161 emit modelReplaced();
162 162 }
163 163 }
164 164
165 165 QXYSeries *QVXYModelMapper::series() const
166 166 {
167 167 return QXYModelMapper::series();
168 168 }
169 169
170 170 void QVXYModelMapper::setSeries(QXYSeries *series)
171 171 {
172 172 if (series != QXYModelMapper::series()) {
173 173 QXYModelMapper::setSeries(series);
174 174 emit seriesReplaced();
175 175 }
176 176 }
177 177
178 178 int QVXYModelMapper::xColumn() const
179 179 {
180 180 return QXYModelMapper::xSection();
181 181 }
182 182
183 183 void QVXYModelMapper::setXColumn(int xColumn)
184 184 {
185 185 if (xColumn != xSection()) {
186 186 QXYModelMapper::setXSection(xColumn);
187 187 emit xColumnChanged();
188 188 }
189 189 }
190 190
191 191 int QVXYModelMapper::yColumn() const
192 192 {
193 193 return QXYModelMapper::ySection();
194 194 }
195 195
196 196 void QVXYModelMapper::setYColumn(int yColumn)
197 197 {
198 198 if (yColumn != ySection()) {
199 199 QXYModelMapper::setYSection(yColumn);
200 200 emit yColumnChanged();
201 201 }
202 202 }
203 203
204 204 int QVXYModelMapper::firstRow() const
205 205 {
206 206 return first();
207 207 }
208 208
209 209 void QVXYModelMapper::setFirstRow(int firstRow)
210 210 {
211 211 if (firstRow != first()) {
212 212 setFirst(firstRow);
213 213 emit firstRowChanged();
214 214 }
215 215 }
216 216
217 217 int QVXYModelMapper::rowCount() const
218 218 {
219 219 return count();
220 220 }
221 221
222 222 void QVXYModelMapper::setRowCount(int rowCount)
223 223 {
224 224 if (rowCount != count()) {
225 225 setCount(rowCount);
226 226 emit rowCountChanged();
227 227 }
228 228 }
229 229
230 230 #include "moc_qvxymodelmapper.cpp"
231 231
232 232 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now