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