##// END OF EJS Templates
Adds pimpl for qchartaxis and qchartaxiscategories
Michal Klocek -
r963:1ec42cbed063
parent child
Show More
@@ -0,0 +1,85
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef QCHARTAXIS_P_H_
31 #define QCHARTAXIS_P_H_
32
33 #include "qchartaxis.h"
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
37 class QChartAxisPrivate : public QObject
38 {
39 Q_OBJECT
40 public:
41 QChartAxisPrivate(QChartAxis *q);
42 ~QChartAxisPrivate();
43
44 Q_SIGNALS:
45 void updated();
46 void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
47
48 public Q_SLOTS:
49 void handleAxisRangeChanged(qreal min, qreal max,int count);
50
51 private:
52 QChartAxis *q_ptr;
53
54 bool m_axisVisible;
55 QPen m_axisPen;
56 QBrush m_axisBrush;
57
58 bool m_gridLineVisible;
59 QPen m_gridLinePen;
60
61 bool m_labelsVisible;
62 QPen m_labelsPen;
63 QBrush m_labelsBrush;
64 QFont m_labelsFont;
65 int m_labelsAngle;
66
67 bool m_shadesVisible;
68 QPen m_shadesPen;
69 QBrush m_shadesBrush;
70 qreal m_shadesOpacity;
71
72 qreal m_min;
73 qreal m_max;
74
75 int m_ticksCount;
76 QChartAxisCategories m_category;
77
78 bool m_niceNumbers;
79
80 friend class QChartAxis;
81 };
82
83 QTCOMMERCIALCHART_END_NAMESPACE
84
85 #endif
@@ -0,0 +1,56
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
27 //
28 // We mean it.
29
30 #ifndef QCHARTAXISCATEGORIES_P_H_
31 #define QCHARTAXISCATEGORIES_P_H_
32
33 #include "qchartaxiscategories.h"
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
37 class QChartAxisCategoriesPrivate : public QObject
38 {
39 Q_OBJECT
40 public:
41 QChartAxisCategoriesPrivate(QChartAxisCategories *q);
42 ~QChartAxisCategoriesPrivate();
43
44 Q_SIGNALS:
45 void updated();
46
47 private:
48 QChartAxisCategories *q_ptr;
49 QMap<qreal,QString> m_map;
50 friend class QChartAxisCategories;
51
52 };
53
54 QTCOMMERCIALCHART_END_NAMESPACE
55
56 #endif
@@ -20,6 +20,8
20
20
21 #include "axis_p.h"
21 #include "axis_p.h"
22 #include "qchartaxis.h"
22 #include "qchartaxis.h"
23 #include "qchartaxis_p.h"
24 #include "qchartaxiscategories_p.h"
23 #include "chartpresenter_p.h"
25 #include "chartpresenter_p.h"
24 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
25 #include <QPainter>
27 #include <QPainter>
@@ -48,8 +50,8 Axis::Axis(QChartAxis *axis,ChartPresenter *presenter,AxisType type) : Chart(pre
48 m_shades->setZValue(ChartPresenter::ShadesZValue);
50 m_shades->setZValue(ChartPresenter::ShadesZValue);
49 m_grid->setZValue(ChartPresenter::GridZValue);
51 m_grid->setZValue(ChartPresenter::GridZValue);
50
52
51 connect(m_chartAxis,SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
53 QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated()));
52 connect(m_chartAxis->categories(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated()));
54 QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated()));
53
55
54 handleAxisUpdated();
56 handleAxisUpdated();
55 }
57 }
@@ -455,10 +457,9 void Axis::handleGeometryChanged(const QRectF &rect)
455
457
456 void Axis::axisSelected()
458 void Axis::axisSelected()
457 {
459 {
458 qDebug()<<"TODO axis clicked";
460 qDebug()<<"TODO: axis clicked";
459 }
461 }
460
462
461 //TODO "nice numbers algorithm"
462 #include "moc_axis_p.cpp"
463 #include "moc_axis_p.cpp"
463
464
464 QTCOMMERCIALCHART_END_NAMESPACE
465 QTCOMMERCIALCHART_END_NAMESPACE
@@ -7,7 +7,9 SOURCES += \
7 $$PWD/qchartaxiscategories.cpp
7 $$PWD/qchartaxiscategories.cpp
8
8
9 PRIVATE_HEADERS += \
9 PRIVATE_HEADERS += \
10 $$PWD/axis_p.h
10 $$PWD/axis_p.h \
11 $$PWD/qchartaxis_p.h \
12 $$PWD/qchartaxiscategories_p.h
11
13
12 PUBLIC_HEADERS += \
14 PUBLIC_HEADERS += \
13 $$PWD/qchartaxis.h \
15 $$PWD/qchartaxis.h \
@@ -19,6 +19,7
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchartaxis.h"
21 #include "qchartaxis.h"
22 #include "qchartaxis_p.h"
22
23
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
25
@@ -178,16 +179,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
178 */
179 */
179
180
180 QChartAxis::QChartAxis(QObject *parent) : QObject(parent),
181 QChartAxis::QChartAxis(QObject *parent) : QObject(parent),
181 m_axisVisible(true),
182 d_ptr(new QChartAxisPrivate(this))
182 m_gridLineVisible(true),
183 m_labelsVisible(true),
184 m_labelsAngle(0),
185 m_shadesVisible(false),
186 m_shadesOpacity(1.0),
187 m_min(0),
188 m_max(0),
189 m_ticksCount(5),
190 m_niceNumbers(false)
191 {
183 {
192
184
193 }
185 }
@@ -205,150 +197,218 QChartAxis::~QChartAxis()
205 */
197 */
206 void QChartAxis::setAxisPen(const QPen &pen)
198 void QChartAxis::setAxisPen(const QPen &pen)
207 {
199 {
208 if (pen != m_axisPen) {
200 if (d_ptr->m_axisPen!=pen) {
209 m_axisPen = pen;
201 d_ptr->m_axisPen = pen;
210 emit updated();
202 emit d_ptr->updated();
211 }
203 }
212 }
204 }
213
205
206 QPen QChartAxis::axisPen() const
207 {
208 return d_ptr->m_axisPen;
209 }
210
214 /*!
211 /*!
215 Sets if axis and ticks are \a visible.
212 Sets if axis and ticks are \a visible.
216 */
213 */
217 void QChartAxis::setAxisVisible(bool visible)
214 void QChartAxis::setAxisVisible(bool visible)
218 {
215 {
219 if (m_axisVisible != visible) {
216 if (d_ptr->m_axisVisible != visible) {
220 m_axisVisible = visible;
217 d_ptr->m_axisVisible = visible;
221 emit updated();
218 emit d_ptr->updated();
222 }
219 }
223 }
220 }
224
221
222 bool QChartAxis::isAxisVisible() const
223 {
224 return d_ptr->m_axisVisible;
225 }
226
225 /*!
227 /*!
226 Sets if grid line is \a visible.
228 Sets if grid line is \a visible.
227 */
229 */
228 void QChartAxis::setGridLineVisible(bool visible)
230 void QChartAxis::setGridLineVisible(bool visible)
229 {
231 {
230 if (m_gridLineVisible != visible) {
232 if (d_ptr->m_gridLineVisible != visible) {
231 m_gridLineVisible = visible;
233 d_ptr->m_gridLineVisible = visible;
232 emit updated();
234 emit d_ptr->updated();
233 }
235 }
234 }
236 }
235
237
238 bool QChartAxis::isGridLineVisible() const
239 {
240 return d_ptr->m_gridLineVisible;
241 }
236 /*!
242 /*!
237 Sets \a pen used to draw grid line.
243 Sets \a pen used to draw grid line.
238 */
244 */
239 void QChartAxis::setGridLinePen(const QPen &pen)
245 void QChartAxis::setGridLinePen(const QPen &pen)
240 {
246 {
241 if (m_gridLinePen != pen) {
247 if (d_ptr->m_gridLinePen != pen) {
242 m_gridLinePen = pen;
248 d_ptr->m_gridLinePen = pen;
243 emit updated();
249 emit d_ptr->updated();
244 }
250 }
245 }
251 }
246
252
253 QPen QChartAxis::gridLinePen() const
254 {
255 return d_ptr->m_gridLinePen;
256 }
257
247 /*!
258 /*!
248 Sets if axis' labels are \a visible.
259 Sets if axis' labels are \a visible.
249 */
260 */
250 void QChartAxis::setLabelsVisible(bool visible)
261 void QChartAxis::setLabelsVisible(bool visible)
251 {
262 {
252 if (m_labelsVisible != visible) {
263 if (d_ptr->m_labelsVisible != visible) {
253 m_labelsVisible = visible;
264 d_ptr->m_labelsVisible = visible;
254 emit updated();
265 emit d_ptr->updated();
255 }
266 }
256 }
267 }
257
268
269 bool QChartAxis::labelsVisible() const
270 {
271 return d_ptr->m_labelsVisible;
272 }
258 /*!
273 /*!
259 Sets \a pen used to draw labels.
274 Sets \a pen used to draw labels.
260 */
275 */
261 void QChartAxis::setLabelsPen(const QPen &pen)
276 void QChartAxis::setLabelsPen(const QPen &pen)
262 {
277 {
263 if (m_labelsPen != pen) {
278 if (d_ptr->m_labelsPen != pen) {
264 m_labelsPen = pen;
279 d_ptr->m_labelsPen = pen;
265 emit updated();
280 emit d_ptr->updated();
266 }
281 }
267 }
282 }
268
283
284 QPen QChartAxis::labelsPen() const
285 {
286 return d_ptr->m_labelsPen;
287 }
288
269 /*!
289 /*!
270 Sets \a brush used to draw labels.
290 Sets \a brush used to draw labels.
271 */
291 */
272 void QChartAxis::setLabelsBrush(const QBrush &brush)
292 void QChartAxis::setLabelsBrush(const QBrush &brush)
273 {
293 {
274 if (m_labelsBrush != brush) {
294 if (d_ptr->m_labelsBrush != brush) {
275 m_labelsBrush = brush;
295 d_ptr->m_labelsBrush = brush;
276 emit updated();
296 emit d_ptr->updated();
277 }
297 }
278 }
298 }
279
299
300 QBrush QChartAxis::labelsBrush() const
301 {
302 return d_ptr->m_labelsBrush;
303 }
304
280 /*!
305 /*!
281 Sets \a font used to draw labels.
306 Sets \a font used to draw labels.
282 */
307 */
283 void QChartAxis::setLabelsFont(const QFont &font)
308 void QChartAxis::setLabelsFont(const QFont &font)
284 {
309 {
285 if (m_labelsFont != font) {
310 if (d_ptr->m_labelsFont != font) {
286 m_labelsFont = font;
311 d_ptr->m_labelsFont = font;
287 emit updated();
312 emit d_ptr->updated();
288 }
313 }
289 }
314 }
290
315
316 QFont QChartAxis::labelsFont() const
317 {
318 return d_ptr->m_labelsFont;
319 }
320
291 /*!
321 /*!
292 Sets \a angle for all the labels on given axis.
322 Sets \a angle for all the labels on given axis.
293 */
323 */
294 void QChartAxis::setLabelsAngle(int angle)
324 void QChartAxis::setLabelsAngle(int angle)
295 {
325 {
296 if (m_labelsAngle != angle) {
326 if (d_ptr->m_labelsAngle != angle) {
297 m_labelsAngle = angle;
327 d_ptr->m_labelsAngle = angle;
298 emit updated();
328 emit d_ptr->updated();
299 }
329 }
300 }
330 }
301
331
332 int QChartAxis::labelsAngle() const
333 {
334 return d_ptr->m_labelsAngle;
335 }
336
302 /*!
337 /*!
303 Sets if shades are \a visible.
338 Sets if shades are \a visible.
304 */
339 */
305 void QChartAxis::setShadesVisible(bool visible)
340 void QChartAxis::setShadesVisible(bool visible)
306 {
341 {
307 if (m_shadesVisible != visible) {
342 if (d_ptr->m_shadesVisible != visible) {
308 m_shadesVisible = visible;
343 d_ptr->m_shadesVisible = visible;
309 emit updated();
344 emit d_ptr->updated();
310 }
345 }
311 }
346 }
312
347
348 bool QChartAxis::shadesVisible() const
349 {
350 return d_ptr->m_shadesVisible;
351 }
352
313 /*!
353 /*!
314 Sets \a pen used to draw shades.
354 Sets \a pen used to draw shades.
315 */
355 */
316 void QChartAxis::setShadesPen(const QPen &pen)
356 void QChartAxis::setShadesPen(const QPen &pen)
317 {
357 {
318 if (m_shadesPen != pen) {
358 if (d_ptr->m_shadesPen != pen) {
319 m_shadesPen = pen;
359 d_ptr->m_shadesPen = pen;
320 emit updated();
360 emit d_ptr->updated();
321 }
361 }
322 }
362 }
323
363
364 QPen QChartAxis::shadesPen() const
365 {
366 return d_ptr->m_shadesPen;
367 }
368
324 /*!
369 /*!
325 Sets \a brush used to draw shades.
370 Sets \a brush used to draw shades.
326 */
371 */
327 void QChartAxis::setShadesBrush(const QBrush &brush)
372 void QChartAxis::setShadesBrush(const QBrush &brush)
328 {
373 {
329 if (m_shadesBrush != brush) {
374 if (d_ptr->m_shadesBrush != brush) {
330 m_shadesBrush = brush;
375 d_ptr->m_shadesBrush = brush;
331 emit updated();
376 emit d_ptr->updated();
332 }
377 }
333 }
378 }
334
379
380 QBrush QChartAxis::shadesBrush() const
381 {
382 return d_ptr->m_shadesBrush;
383 }
384
335 /*!
385 /*!
336 Sets \a opacity of the shades.
386 Sets \a opacity of the shades.
337 */
387 */
338 void QChartAxis::setShadesOpacity(qreal opacity)
388 void QChartAxis::setShadesOpacity(qreal opacity)
339 {
389 {
340 if (m_shadesOpacity != opacity) {
390 if (d_ptr->m_shadesOpacity != opacity) {
341 m_shadesOpacity=opacity;
391 d_ptr->m_shadesOpacity=opacity;
342 emit updated();
392 emit d_ptr->updated();
343 }
393 }
344 }
394 }
345
395
396 qreal QChartAxis::shadesOpacity() const
397 {
398 return d_ptr->m_shadesOpacity;
399 }
400
346 /*!
401 /*!
347 Sets \a min value on the axis.
402 Sets \a min value on the axis.
348 */
403 */
349 void QChartAxis::setMin(qreal min)
404 void QChartAxis::setMin(qreal min)
350 {
405 {
351 setRange(min,m_max);
406 setRange(min,d_ptr->m_max);
407 }
408
409 qreal QChartAxis::min() const
410 {
411 return d_ptr->m_min;
352 }
412 }
353
413
354 /*!
414 /*!
@@ -356,7 +416,12 void QChartAxis::setMin(qreal min)
356 */
416 */
357 void QChartAxis::setMax(qreal max)
417 void QChartAxis::setMax(qreal max)
358 {
418 {
359 setRange(m_min,max);
419 setRange(d_ptr->m_min,max);
420 }
421
422 qreal QChartAxis::max() const
423 {
424 return d_ptr->m_max;
360 }
425 }
361
426
362 /*!
427 /*!
@@ -365,21 +430,21 void QChartAxis::setMax(qreal max)
365 void QChartAxis::setRange(qreal min, qreal max)
430 void QChartAxis::setRange(qreal min, qreal max)
366 {
431 {
367 bool changed = false;
432 bool changed = false;
368 if (!qFuzzyIsNull(m_min - min)) {
433 if (!qFuzzyIsNull(d_ptr->m_min - min)) {
369 m_min = min;
434 d_ptr->m_min = min;
370 changed = true;
435 changed = true;
371 emit minChanged(min);
436 emit minChanged(min);
372 }
437 }
373
438
374 if (!qFuzzyIsNull(m_max - max)) {
439 if (!qFuzzyIsNull(d_ptr->m_max - max)) {
375 m_max = max;
440 d_ptr->m_max = max;
376 changed = true;
441 changed = true;
377 emit maxChanged(max);
442 emit maxChanged(max);
378 }
443 }
379
444
380 if (changed) {
445 if (changed) {
381 emit rangeChanged(m_min,m_max);
446 emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
382 emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers);
447 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
383 }
448 }
384 }
449 }
385
450
@@ -388,23 +453,28 void QChartAxis::setRange(qreal min, qreal max)
388 */
453 */
389 void QChartAxis::setTicksCount(int count)
454 void QChartAxis::setTicksCount(int count)
390 {
455 {
391 if (m_ticksCount != count) {
456 if (d_ptr->m_ticksCount != count) {
392 m_ticksCount = count;
457 d_ptr->m_ticksCount = count;
393 emit ticksCountChanged(count);
458 emit ticksCountChanged(count);
394 emit changed(m_min, m_max, m_ticksCount, m_niceNumbers);
459 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
395 }
460 }
396 }
461 }
397
462
463 int QChartAxis::ticksCount() const
464 {
465 return d_ptr->m_ticksCount;
466 }
467
398 /*!
468 /*!
399 Sets axis, shades, labels and grid lines to be visible.
469 Sets axis, shades, labels and grid lines to be visible.
400 */
470 */
401 void QChartAxis::show()
471 void QChartAxis::show()
402 {
472 {
403 m_axisVisible=true;
473 d_ptr->m_axisVisible=true;
404 m_gridLineVisible=true;
474 d_ptr->m_gridLineVisible=true;
405 m_labelsVisible=true;
475 d_ptr->m_labelsVisible=true;
406 m_shadesVisible=true;
476 d_ptr->m_shadesVisible=true;
407 emit updated();
477 emit d_ptr->updated();
408 }
478 }
409
479
410 /*!
480 /*!
@@ -412,20 +482,11 void QChartAxis::show()
412 */
482 */
413 void QChartAxis::hide()
483 void QChartAxis::hide()
414 {
484 {
415 m_axisVisible = false;
485 d_ptr->m_axisVisible = false;
416 m_gridLineVisible = false;
486 d_ptr->m_gridLineVisible = false;
417 m_labelsVisible = false;
487 d_ptr->m_labelsVisible = false;
418 m_shadesVisible = false;
488 d_ptr->m_shadesVisible = false;
419 emit updated();
489 emit d_ptr->updated();
420 }
421
422 /*!
423 \internal
424 */
425 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count)
426 {
427 setRange(min,max);
428 setTicksCount(count);
429 }
490 }
430
491
431 /*!
492 /*!
@@ -433,12 +494,52 void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count)
433 */
494 */
434 void QChartAxis::setNiceNumbers(bool enable)
495 void QChartAxis::setNiceNumbers(bool enable)
435 {
496 {
436 if (m_niceNumbers != enable){
497 if (d_ptr->m_niceNumbers != enable){
437 m_niceNumbers = enable;
498 d_ptr->m_niceNumbers = enable;
438 emit changed(m_min, m_max, m_ticksCount, m_niceNumbers);
499 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
439 }
500 }
440 }
501 }
441
502
503 bool QChartAxis::niceNumbers() const
504 {
505 return d_ptr->m_niceNumbers;
506 }
507
508 QChartAxisCategories* QChartAxis::categories()
509 {
510 return &d_ptr->m_category;
511 }
512
513 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
514
515 QChartAxisPrivate::QChartAxisPrivate(QChartAxis* q):
516 q_ptr(q),
517 m_axisVisible(true),
518 m_gridLineVisible(true),
519 m_labelsVisible(true),
520 m_labelsAngle(0),
521 m_shadesVisible(false),
522 m_shadesOpacity(1.0),
523 m_min(0),
524 m_max(0),
525 m_ticksCount(5),
526 m_niceNumbers(false)
527 {
528
529 }
530
531 QChartAxisPrivate::~QChartAxisPrivate()
532 {
533
534 }
535
536 void QChartAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
537 {
538 q_ptr->setRange(min,max);
539 q_ptr->setTicksCount(count);
540 }
541
442 #include "moc_qchartaxis.cpp"
542 #include "moc_qchartaxis.cpp"
543 #include "moc_qchartaxis_p.cpp"
443
544
444 QTCOMMERCIALCHART_END_NAMESPACE
545 QTCOMMERCIALCHART_END_NAMESPACE
@@ -28,6 +28,8
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QChartAxisPrivate;
32
31 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
32 {
34 {
33 Q_OBJECT
35 Q_OBJECT
@@ -37,54 +39,54 public:
37 ~QChartAxis();
39 ~QChartAxis();
38
40
39 //axis handling
41 //axis handling
40 bool isAxisVisible() const { return m_axisVisible; }
42 bool isAxisVisible() const;
41 void setAxisVisible(bool visible);
43 void setAxisVisible(bool visible);
42 void setAxisPen(const QPen &pen);
44 void setAxisPen(const QPen &pen);
43 QPen axisPen() const { return m_axisPen; }
45 QPen axisPen() const;
44
46
45 //grid handling
47 //grid handling
46 bool isGridLineVisible() const { return m_gridLineVisible; }
48 bool isGridLineVisible() const;
47 void setGridLineVisible(bool visible);
49 void setGridLineVisible(bool visible);
48 void setGridLinePen(const QPen &pen);
50 void setGridLinePen(const QPen &pen);
49 QPen gridLinePen() const { return m_gridLinePen; }
51 QPen gridLinePen() const;
50
52
51 //labels handling
53 //labels handling
52 bool labelsVisible() const { return m_labelsVisible; }
54 bool labelsVisible() const;
53 void setLabelsVisible(bool visible);
55 void setLabelsVisible(bool visible);
54 void setLabelsPen(const QPen &pen);
56 void setLabelsPen(const QPen &pen);
55 QPen labelsPen() const { return m_labelsPen;}
57 QPen labelsPen() const;
56 void setLabelsBrush(const QBrush &brush);
58 void setLabelsBrush(const QBrush &brush);
57 QBrush labelsBrush() const { return m_labelsBrush; }
59 QBrush labelsBrush() const;
58 void setLabelsFont(const QFont &font);
60 void setLabelsFont(const QFont &font);
59 QFont labelsFont() const { return m_labelsFont; }
61 QFont labelsFont() const;
60 void setLabelsAngle(int angle);
62 void setLabelsAngle(int angle);
61 int labelsAngle() const { return m_labelsAngle; }
63 int labelsAngle() const;
62
64
63 //shades handling
65 //shades handling
64 bool shadesVisible() const { return m_shadesVisible; }
66 bool shadesVisible() const;
65 void setShadesVisible(bool visible);
67 void setShadesVisible(bool visible);
66 void setShadesPen(const QPen &pen);
68 void setShadesPen(const QPen &pen);
67 QPen shadesPen() const { return m_shadesPen; }
69 QPen shadesPen() const;
68 void setShadesBrush(const QBrush &brush);
70 void setShadesBrush(const QBrush &brush);
69 QBrush shadesBrush() const { return m_shadesBrush; }
71 QBrush shadesBrush() const;
70 void setShadesOpacity(qreal opacity);
72 void setShadesOpacity(qreal opacity);
71 qreal shadesOpacity() const { return m_shadesOpacity; }
73 qreal shadesOpacity() const;
72
74
73 //range handling
75 //range handling
74 void setMin(qreal min);
76 void setMin(qreal min);
75 qreal min() const { return m_min; }
77 qreal min() const;
76 void setMax(qreal max);
78 void setMax(qreal max);
77 qreal max() const { return m_max; }
79 qreal max() const;
78 void setRange(qreal min, qreal max);
80 void setRange(qreal min, qreal max);
79
81
80 //ticks handling
82 //ticks handling
81 void setTicksCount(int count);
83 void setTicksCount(int count);
82 int ticksCount() const { return m_ticksCount;}
84 int ticksCount() const;
83
85
84 void setNiceNumbers(bool enable);
86 void setNiceNumbers(bool enable);
85 bool niceNumbers() const { return m_niceNumbers;}
87 bool niceNumbers() const;
86
88
87 QChartAxisCategories* categories() { return &m_category; }
89 QChartAxisCategories* categories();
88
90
89 void show();
91 void show();
90 void hide();
92 void hide();
@@ -95,39 +97,11 Q_SIGNALS:
95 void rangeChanged(qreal min, qreal max);
97 void rangeChanged(qreal min, qreal max);
96 void ticksCountChanged(int count);
98 void ticksCountChanged(int count);
97
99
98 //interal signal
99 void updated();
100 void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
101 //internal slot
102 public Q_SLOTS:
103 void handleAxisRangeChanged(qreal min, qreal max,int count);
104
105 private:
100 private:
106 bool m_axisVisible;
101 QScopedPointer<QChartAxisPrivate> d_ptr;
107 QPen m_axisPen;
102 Q_DISABLE_COPY(QChartAxis);
108 QBrush m_axisBrush;
103 friend class ChartDataSet;
109
104 friend class Axis;
110 bool m_gridLineVisible;
111 QPen m_gridLinePen;
112
113 bool m_labelsVisible;
114 QPen m_labelsPen;
115 QBrush m_labelsBrush;
116 QFont m_labelsFont;
117 int m_labelsAngle;
118
119 bool m_shadesVisible;
120 QPen m_shadesPen;
121 QBrush m_shadesBrush;
122 qreal m_shadesOpacity;
123
124 qreal m_min;
125 qreal m_max;
126
127 int m_ticksCount;
128 QChartAxisCategories m_category;
129
130 bool m_niceNumbers;
131 };
105 };
132
106
133 QTCOMMERCIALCHART_END_NAMESPACE
107 QTCOMMERCIALCHART_END_NAMESPACE
@@ -19,63 +19,78
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchartaxiscategories.h"
21 #include "qchartaxiscategories.h"
22 #include "qchartaxiscategories_p.h"
22
23
23 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24
25
25 QChartAxisCategories::QChartAxisCategories()
26 QChartAxisCategories::QChartAxisCategories():
27 d_ptr(new QChartAxisCategoriesPrivate(this))
26 {
28 {
27 // TODO Auto-generated constructor stub
28
29
29 }
30 }
30
31
31 QChartAxisCategories::~QChartAxisCategories()
32 QChartAxisCategories::~QChartAxisCategories()
32 {
33 {
33 // TODO Auto-generated destructor stub
34
34 }
35 }
35
36
36 void QChartAxisCategories::insert(const QBarCategories &categories)
37 void QChartAxisCategories::insert(const QBarCategories &categories)
37 {
38 {
38 int i=1;
39 int i=1;
39 foreach (QString string , categories) {
40 foreach (QString string , categories) {
40 m_map.insert(i,string);
41 d_ptr->m_map.insert(i,string);
41 i++;
42 i++;
42 }
43 }
43 emit updated();
44 emit d_ptr->updated();
44 }
45 }
45
46
46 void QChartAxisCategories::insert(qreal value,QString label)
47 void QChartAxisCategories::insert(qreal value,QString label)
47 {
48 {
48 m_map.insert(value,label);
49 d_ptr->m_map.insert(value,label);
49 emit updated();
50 emit d_ptr->updated();
50 }
51 }
51
52
52 void QChartAxisCategories::remove(qreal value)
53 void QChartAxisCategories::remove(qreal value)
53 {
54 {
54 m_map.remove(value);
55 d_ptr->m_map.remove(value);
55 emit updated();
56 emit d_ptr->updated();
56 }
57 }
57
58
58 void QChartAxisCategories::clear()
59 void QChartAxisCategories::clear()
59 {
60 {
60 m_map.clear();
61 d_ptr->m_map.clear();
61 emit updated();
62 emit d_ptr->updated();
62 }
63 }
63
64
64 int QChartAxisCategories::count()
65 int QChartAxisCategories::count()
65 {
66 {
66 return m_map.count();
67 return d_ptr->m_map.count();
67 }
68 }
68
69
69 QList<qreal> QChartAxisCategories::values() const
70 QList<qreal> QChartAxisCategories::values() const
70 {
71 {
71 return m_map.keys();
72 return d_ptr->m_map.keys();
72 }
73 }
73
74
74 QString QChartAxisCategories::label(qreal value) const
75 QString QChartAxisCategories::label(qreal value) const
75 {
76 {
76 return m_map.value(value);
77 return d_ptr->m_map.value(value);
78 }
79
80 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
81
82 QChartAxisCategoriesPrivate::QChartAxisCategoriesPrivate(QChartAxisCategories *q):
83 q_ptr(q)
84 {
85
86 }
87
88 QChartAxisCategoriesPrivate::~QChartAxisCategoriesPrivate()
89 {
90
77 }
91 }
78
92
79 #include "moc_qchartaxiscategories.cpp"
93 #include "moc_qchartaxiscategories.cpp"
94 #include "moc_qchartaxiscategories_p.cpp"
80
95
81 QTCOMMERCIALCHART_END_NAMESPACE
96 QTCOMMERCIALCHART_END_NAMESPACE
@@ -26,6 +26,8
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class QChartAxisCategoriesPrivate;
30
29 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
31 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
30 {
32 {
31 Q_OBJECT
33 Q_OBJECT
@@ -42,14 +44,10 public:
42 void clear();
44 void clear();
43 int count();
45 int count();
44
46
45 //internal signal
46 Q_SIGNALS:
47 void updated();
48
49 private:
47 private:
50 QMap<qreal,QString> m_map;
48 QScopedPointer<QChartAxisCategoriesPrivate> d_ptr;
51
49 friend class QChartAxisPrivate;
52 friend class QChartAxis;
50 friend class Axis;
53 };
51 };
54
52
55
53
@@ -20,16 +20,12
20
20
21 #include "chartdataset_p.h"
21 #include "chartdataset_p.h"
22 #include "qchartaxis.h"
22 #include "qchartaxis.h"
23 //series
23 #include "qchartaxis_p.h"
24 #include "qseries_p.h"
24 #include "qseries_p.h"
25 #include "qlineseries.h"
26 #include "qareaseries.h"
27 #include "qbarseries.h"
25 #include "qbarseries.h"
28 #include "qstackedbarseries.h"
26 #include "qstackedbarseries.h"
29 #include "qpercentbarseries.h"
27 #include "qpercentbarseries.h"
30 #include "qpieseries.h"
28 #include "qpieseries.h"
31 #include "qscatterseries.h"
32 #include "qsplineseries.h"
33
29
34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35
31
@@ -68,10 +64,10 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY)
68
64
69 if(!domain) {
65 if(!domain) {
70 domain = new Domain(axisY);
66 domain = new Domain(axisY);
71 QObject::connect(axisY,SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool)));
67 QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool)));
72 QObject::connect(axisX(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool)));
68 QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool)));
73 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal,int)));
69 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
74 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
70 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX()->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int)));
75 //initialize
71 //initialize
76 m_axisDomainMap.insert(axisY,domain);
72 m_axisDomainMap.insert(axisY,domain);
77 emit axisAdded(axisY,domain);
73 emit axisAdded(axisY,domain);
General Comments 0
You need to be logged in to leave comments. Login now