##// END OF EJS Templates
BC fix: change gridLineVisibleChanged() back to gridVisibleChanged()
Jani Honkonen -
r2282:b5e4768d3a3a
parent child
Show More
@@ -1,497 +1,497
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "chartaxis_p.h"
22 22 #include "qabstractaxis.h"
23 23 #include "qabstractaxis_p.h"
24 24 #include "chartpresenter_p.h"
25 25 #include "chartlayout_p.h"
26 26 #include "abstractdomain_p.h"
27 27 #include <qmath.h>
28 28 #include <QDateTime>
29 29 #include <QValueAxis>
30 30 #include <QLogValueAxis>
31 31 #include <QGraphicsLayout>
32 32 #include <QFontMetrics>
33 33
34 34 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 35
36 36 ChartAxis::ChartAxis(QAbstractAxis *axis, QGraphicsItem* item , bool intervalAxis)
37 37 : ChartElement(item),
38 38 m_axis(axis),
39 39 m_labelsAngle(0),
40 40 m_grid(new QGraphicsItemGroup(item)),
41 41 m_arrow(new QGraphicsItemGroup(item)),
42 42 m_shades(new QGraphicsItemGroup(item)),
43 43 m_labels(new QGraphicsItemGroup(item)),
44 44 m_title(new QGraphicsSimpleTextItem(item)),
45 45 m_animation(0),
46 46 m_labelPadding(5),
47 47 m_intervalAxis(intervalAxis)
48 48 {
49 49 Q_ASSERT(item);
50 50 //initial initialization
51 51 m_arrow->setHandlesChildEvents(false);
52 52 m_arrow->setZValue(ChartPresenter::AxisZValue);
53 53 m_arrow->setVisible(m_axis->isLineVisible());
54 54 m_labels->setZValue(ChartPresenter::AxisZValue);
55 55 m_labels->setVisible(m_axis->labelsVisible());
56 56 m_shades->setZValue(ChartPresenter::ShadesZValue);
57 57 m_shades->setVisible(m_axis->shadesVisible());
58 58 m_grid->setZValue(ChartPresenter::GridZValue);
59 59 m_grid->setVisible(m_axis->isGridLineVisible());
60 60 m_title->setZValue(ChartPresenter::GridZValue);
61 61 connectSlots();
62 62
63 63 setFlag(QGraphicsItem::ItemHasNoContents,true);
64 64 }
65 65
66 66 void ChartAxis::connectSlots()
67 67 {
68 68 QObject::connect(m_axis,SIGNAL(visibleChanged(bool)),this,SLOT(handleVisibleChanged(bool)));
69 69 QObject::connect(m_axis,SIGNAL(lineVisibleChanged(bool)),this,SLOT(handleArrowVisibleChanged(bool)));
70 QObject::connect(m_axis,SIGNAL(gridLineVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool)));
70 QObject::connect(m_axis,SIGNAL(gridVisibleChanged(bool)),this,SLOT(handleGridVisibleChanged(bool)));
71 71 QObject::connect(m_axis,SIGNAL(labelsVisibleChanged(bool)),this,SLOT(handleLabelsVisibleChanged(bool)));
72 72 QObject::connect(m_axis,SIGNAL(shadesVisibleChanged(bool)),this,SLOT(handleShadesVisibleChanged(bool)));
73 73 QObject::connect(m_axis,SIGNAL(labelsAngleChanged(int)),this,SLOT(handleLabelsAngleChanged(int)));
74 74 QObject::connect(m_axis,SIGNAL(linePenChanged(const QPen&)),this,SLOT(handleArrowPenChanged(const QPen&)));
75 75 QObject::connect(m_axis,SIGNAL(labelsPenChanged(const QPen&)),this,SLOT(handleLabelsPenChanged(const QPen&)));
76 76 QObject::connect(m_axis,SIGNAL(labelsBrushChanged(const QBrush&)),this,SLOT(handleLabelsBrushChanged(const QBrush&)));
77 77 QObject::connect(m_axis,SIGNAL(labelsFontChanged(const QFont&)),this,SLOT(handleLabelsFontChanged(const QFont&)));
78 78 QObject::connect(m_axis,SIGNAL(gridLinePenChanged(const QPen&)),this,SLOT(handleGridPenChanged(const QPen&)));
79 79 QObject::connect(m_axis,SIGNAL(shadesPenChanged(const QPen&)),this,SLOT(handleShadesPenChanged(const QPen&)));
80 80 QObject::connect(m_axis,SIGNAL(shadesBrushChanged(const QBrush&)),this,SLOT(handleShadesBrushChanged(const QBrush&)));
81 81 QObject::connect(m_axis,SIGNAL(titleTextChanged(const QString&)),this,SLOT(handleTitleTextChanged(const QString&)));
82 82 QObject::connect(m_axis,SIGNAL(titleFontChanged(const QFont&)),this,SLOT(handleTitleFontChanged(const QFont&)));
83 83 QObject::connect(m_axis,SIGNAL(titlePenChanged(const QPen&)),this,SLOT(handleTitlePenChanged(const QPen&)));
84 84 QObject::connect(m_axis,SIGNAL(titleBrushChanged(const QBrush&)),this,SLOT(handleTitleBrushChanged(const QBrush&)));
85 85 QObject::connect(m_axis->d_ptr.data(),SIGNAL(rangeChanged(qreal,qreal)),this,SLOT(handleRangeChanged(qreal,qreal)));
86 86 }
87 87
88 88 ChartAxis::~ChartAxis()
89 89 {
90 90 }
91 91
92 92 void ChartAxis::setAnimation(AxisAnimation *animation)
93 93 {
94 94 m_animation = animation;
95 95 }
96 96
97 97 void ChartAxis::setLayout(QVector<qreal> &layout)
98 98 {
99 99 m_layoutVector = layout;
100 100 }
101 101
102 102 void ChartAxis::createItems(int count)
103 103 {
104 104 if (m_arrow->childItems().size() == 0){
105 105 QGraphicsLineItem* arrow = new ArrowItem(this, this);
106 106 arrow->setPen(m_axis->linePen());
107 107 m_arrow->addToGroup(arrow);
108 108 }
109 109
110 110 if (m_intervalAxis && m_grid->childItems().size() == 0) {
111 111 for (int i = 0 ; i < 2 ; i ++){
112 112 QGraphicsLineItem* item = new QGraphicsLineItem(this);
113 113 item->setPen(m_axis->gridLinePen());
114 114 m_grid->addToGroup(item);
115 115 }
116 116 }
117 117
118 118 for (int i = 0; i < count; ++i) {
119 119 QGraphicsLineItem* arrow = new QGraphicsLineItem(this);
120 120 arrow->setPen(m_axis->linePen());
121 121 QGraphicsLineItem* grid = new QGraphicsLineItem(this);
122 122 grid->setPen(m_axis->gridLinePen());
123 123 QGraphicsSimpleTextItem* label = new QGraphicsSimpleTextItem(this);
124 124 label->setFont(m_axis->labelsFont());
125 125 label->setPen(m_axis->labelsPen());
126 126 label->setBrush(m_axis->labelsBrush());
127 127 m_arrow->addToGroup(arrow);
128 128 m_grid->addToGroup(grid);
129 129 m_labels->addToGroup(label);
130 130
131 131 if ((m_grid->childItems().size()) % 2 && m_grid->childItems().size() > 2){
132 132 QGraphicsRectItem* shades = new QGraphicsRectItem(this);
133 133 shades->setPen(m_axis->shadesPen());
134 134 shades->setBrush(m_axis->shadesBrush());
135 135 m_shades->addToGroup(shades);
136 136 }
137 137 }
138 138
139 139 }
140 140
141 141 void ChartAxis::deleteItems(int count)
142 142 {
143 143 QList<QGraphicsItem *> lines = m_grid->childItems();
144 144 QList<QGraphicsItem *> labels = m_labels->childItems();
145 145 QList<QGraphicsItem *> shades = m_shades->childItems();
146 146 QList<QGraphicsItem *> axis = m_arrow->childItems();
147 147
148 148 for (int i = 0; i < count; ++i) {
149 149 if (lines.size() % 2 && lines.size() > 1)
150 150 delete(shades.takeLast());
151 151 delete(lines.takeLast());
152 152 delete(labels.takeLast());
153 153 delete(axis.takeLast());
154 154 }
155 155 }
156 156
157 157 void ChartAxis::updateLayout(QVector<qreal> &layout)
158 158 {
159 159 int diff = m_layoutVector.size() - layout.size();
160 160
161 161 if (diff > 0)
162 162 deleteItems(diff);
163 163 else if (diff < 0)
164 164 createItems(-diff);
165 165
166 166 if (m_animation) {
167 167 switch (presenter()->state()) {
168 168 case ChartPresenter::ZoomInState:
169 169 m_animation->setAnimationType(AxisAnimation::ZoomInAnimation);
170 170 m_animation->setAnimationPoint(presenter()->statePoint());
171 171 break;
172 172 case ChartPresenter::ZoomOutState:
173 173 m_animation->setAnimationType(AxisAnimation::ZoomOutAnimation);
174 174 m_animation->setAnimationPoint(presenter()->statePoint());
175 175 break;
176 176 case ChartPresenter::ScrollUpState:
177 177 case ChartPresenter::ScrollLeftState:
178 178 m_animation->setAnimationType(AxisAnimation::MoveBackwordAnimation);
179 179 break;
180 180 case ChartPresenter::ScrollDownState:
181 181 case ChartPresenter::ScrollRightState:
182 182 m_animation->setAnimationType(AxisAnimation::MoveForwardAnimation);
183 183 break;
184 184 case ChartPresenter::ShowState:
185 185 m_animation->setAnimationType(AxisAnimation::DefaultAnimation);
186 186 break;
187 187 }
188 188 m_animation->setValues(m_layoutVector, layout);
189 189 presenter()->startAnimation(m_animation);
190 190 } else {
191 191 setLayout(layout);
192 192 updateGeometry();
193 193 }
194 194 }
195 195
196 196 void ChartAxis::setLabelPadding(int padding)
197 197 {
198 198 m_labelPadding = padding;
199 199 }
200 200
201 201 bool ChartAxis::isEmpty()
202 202 {
203 203 return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(min(),max());
204 204 }
205 205
206 206 void ChartAxis::setGeometry(const QRectF &axis, const QRectF &grid)
207 207 {
208 208 m_gridRect = grid;
209 209 m_axisRect = axis;
210 210
211 211 if (isEmpty())
212 212 return;
213 213
214 214 QVector<qreal> layout = calculateLayout();
215 215 updateLayout(layout);
216 216 }
217 217
218 218 qreal ChartAxis::min() const
219 219 {
220 220 return m_axis->d_ptr->min();
221 221 }
222 222
223 223 qreal ChartAxis::max() const
224 224 {
225 225 return m_axis->d_ptr->max();
226 226 }
227 227
228 228 QFont ChartAxis::font() const
229 229 {
230 230 return m_axis->labelsFont();
231 231 }
232 232
233 233 QFont ChartAxis::titleFont() const
234 234 {
235 235 return m_axis->titleFont();
236 236 }
237 237
238 238 QString ChartAxis::titleText() const
239 239 {
240 240 return m_axis->titleText();
241 241 }
242 242
243 243 void ChartAxis::axisSelected()
244 244 {
245 245 emit clicked();
246 246 }
247 247
248 248 Qt::Orientation ChartAxis::orientation() const
249 249 {
250 250 return m_axis->orientation();
251 251 }
252 252
253 253 Qt::Alignment ChartAxis::alignment() const
254 254 {
255 255 return m_axis->alignment();
256 256 }
257 257
258 258 void ChartAxis::setLabels(const QStringList &labels)
259 259 {
260 260 m_labelsList = labels;
261 261 }
262 262
263 263 QSizeF ChartAxis::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
264 264 {
265 265 Q_UNUSED(which);
266 266 Q_UNUSED(constraint);
267 267 return QSizeF();
268 268 }
269 269
270 270 //handlers
271 271
272 272 void ChartAxis::handleArrowVisibleChanged(bool visible)
273 273 {
274 274 m_arrow->setVisible(visible);
275 275 }
276 276
277 277 void ChartAxis::handleGridVisibleChanged(bool visible)
278 278 {
279 279 m_grid->setVisible(visible);
280 280 }
281 281
282 282 void ChartAxis::handleLabelsVisibleChanged(bool visible)
283 283 {
284 284 m_labels->setVisible(visible);
285 285 }
286 286
287 287 void ChartAxis::handleShadesVisibleChanged(bool visible)
288 288 {
289 289 m_shades->setVisible(visible);
290 290 }
291 291
292 292 void ChartAxis::handleLabelsAngleChanged(int angle)
293 293 {
294 294 foreach (QGraphicsItem *item, m_labels->childItems())
295 295 item->setRotation(angle);
296 296
297 297 m_labelsAngle = angle;
298 298 }
299 299
300 300 void ChartAxis::handleLabelsPenChanged(const QPen &pen)
301 301 {
302 302 foreach (QGraphicsItem *item , m_labels->childItems())
303 303 static_cast<QGraphicsSimpleTextItem *>(item)->setPen(pen);
304 304 }
305 305
306 306 void ChartAxis::handleLabelsBrushChanged(const QBrush &brush)
307 307 {
308 308 foreach (QGraphicsItem *item , m_labels->childItems())
309 309 static_cast<QGraphicsSimpleTextItem *>(item)->setBrush(brush);
310 310 }
311 311
312 312 void ChartAxis::handleLabelsFontChanged(const QFont &font)
313 313 {
314 314 foreach (QGraphicsItem *item , m_labels->childItems())
315 315 static_cast<QGraphicsSimpleTextItem *>(item)->setFont(font);
316 316 QGraphicsLayoutItem::updateGeometry();
317 317 presenter()->layout()->invalidate();
318 318 }
319 319
320 320 void ChartAxis::handleShadesBrushChanged(const QBrush &brush)
321 321 {
322 322 foreach (QGraphicsItem *item , m_shades->childItems())
323 323 static_cast<QGraphicsRectItem *>(item)->setBrush(brush);
324 324 }
325 325
326 326 void ChartAxis::handleShadesPenChanged(const QPen &pen)
327 327 {
328 328 foreach (QGraphicsItem *item , m_shades->childItems())
329 329 static_cast<QGraphicsRectItem *>(item)->setPen(pen);
330 330 }
331 331
332 332 void ChartAxis::handleArrowPenChanged(const QPen &pen)
333 333 {
334 334 foreach (QGraphicsItem *item , m_arrow->childItems())
335 335 static_cast<QGraphicsLineItem *>(item)->setPen(pen);
336 336 }
337 337
338 338 void ChartAxis::handleGridPenChanged(const QPen &pen)
339 339 {
340 340 foreach (QGraphicsItem *item , m_grid->childItems())
341 341 static_cast<QGraphicsLineItem *>(item)->setPen(pen);
342 342 }
343 343
344 344 void ChartAxis::handleTitleTextChanged(const QString &title)
345 345 {
346 346 Q_UNUSED(title)
347 347 QGraphicsLayoutItem::updateGeometry();
348 348 presenter()->layout()->invalidate();
349 349 }
350 350
351 351
352 352 void ChartAxis::handleTitlePenChanged(const QPen &pen)
353 353 {
354 354 m_title->setPen(pen);
355 355 }
356 356
357 357 void ChartAxis::handleTitleBrushChanged(const QBrush &brush)
358 358 {
359 359 m_title->setBrush(brush);
360 360 }
361 361
362 362 void ChartAxis::handleTitleFontChanged(const QFont &font)
363 363 {
364 364 if(m_title->font() != font){
365 365 m_title->setFont(font);
366 366 QGraphicsLayoutItem::updateGeometry();
367 367 presenter()->layout()->invalidate();
368 368 }
369 369 }
370 370
371 371 void ChartAxis::handleVisibleChanged(bool visible)
372 372 {
373 373 setVisible(visible);
374 374 }
375 375
376 376 void ChartAxis::handleRangeChanged(qreal min, qreal max)
377 377 {
378 378 Q_UNUSED(min);
379 379 Q_UNUSED(max);
380 380
381 381 if (!isEmpty()) {
382 382
383 383 QVector<qreal> layout = calculateLayout();
384 384 updateLayout(layout);
385 385 QSizeF before = effectiveSizeHint(Qt::PreferredSize);
386 386 QSizeF after = sizeHint(Qt::PreferredSize);
387 387
388 388 if (before != after) {
389 389 QGraphicsLayoutItem::updateGeometry();
390 390 //we don't want to call invalidate on layout, since it will change minimum size of component,
391 391 //which we would like to avoid since it causes nasty flips when scrolling or zooming,
392 392 //instead recalculate layout and use plotArea for extra space.
393 393 presenter()->layout()->setGeometry(presenter()->layout()->geometry());
394 394 }
395 395 }
396 396
397 397 }
398 398
399 399 //helpers
400 400
401 401 QStringList ChartAxis::createValueLabels(qreal min, qreal max, int ticks,const QString& format)
402 402 {
403 403 //TODO: Q_ASSERT(m_max > m_min);
404 404 //TODO: Q_ASSERT(ticks > 1);
405 405
406 406 QStringList labels;
407 407
408 408 if(max <= min || ticks < 1){
409 409 return labels;
410 410 }
411 411
412 412 int n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
413 413 n++;
414 414
415 415 if (format.isNull()) {
416 416 for (int i = 0; i < ticks; i++) {
417 417 qreal value = min + (i * (max - min) / (ticks - 1));
418 418 labels << QString::number(value, 'f', n);
419 419 }
420 420 } else {
421 421 QByteArray array = format.toLatin1();
422 422 for (int i = 0; i < ticks; i++) {
423 423 qreal value = min + (i * (max - min) / (ticks - 1));
424 424 if (format.contains("d")
425 425 || format.contains("i")
426 426 || format.contains("c"))
427 427 labels << QString().sprintf(array, (qint64)value);
428 428 else if (format.contains("u")
429 429 || format.contains("o")
430 430 || format.contains("x", Qt::CaseInsensitive))
431 431 labels << QString().sprintf(array, (quint64)value);
432 432 else if (format.contains("f", Qt::CaseInsensitive)
433 433 || format.contains("e", Qt::CaseInsensitive)
434 434 || format.contains("g", Qt::CaseInsensitive))
435 435 labels << QString().sprintf(array, value);
436 436 }
437 437 }
438 438
439 439 return labels;
440 440 }
441 441
442 442 QStringList ChartAxis::createLogValueLabels(qreal min, qreal max, qreal base, int ticks, const QString& format)
443 443 {
444 444 // Q_ASSERT(m_max > m_min);
445 445 // Q_ASSERT(ticks > 1);
446 446
447 447 QStringList labels;
448 448
449 449 int n = 0;
450 450 if (ticks > 1)
451 451 n = qMax(int(-qFloor(log10((max - min) / (ticks - 1)))), 0);
452 452 n++;
453 453
454 454 int firstTick;
455 455 if (base > 1)
456 456 firstTick = ceil(log10(min) / log10(base));
457 457 else
458 458 firstTick = ceil(log10(max) / log10(base));
459 459
460 460 if (format.isNull()) {
461 461 for (int i = firstTick; i < ticks + firstTick; i++) {
462 462 qreal value = qPow(base, i);
463 463 labels << QString::number(value, 'f', n);
464 464 }
465 465 } else {
466 466 QByteArray array = format.toLatin1();
467 467 for (int i = firstTick; i < ticks + firstTick; i++) {
468 468 qreal value = qPow(base, i);
469 469 labels << QString().sprintf(array, value);
470 470 }
471 471 }
472 472
473 473 return labels;
474 474 }
475 475
476 476 QStringList ChartAxis::createDateTimeLabels(qreal min, qreal max,int ticks,const QString& format)
477 477 {
478 478 //TODO: Q_ASSERT(m_max > m_min);
479 479 //TODO: Q_ASSERT(ticks > 1);
480 480 QStringList labels;
481 481
482 482 if(max <= min || ticks < 1) {
483 483 return labels;
484 484 }
485 485
486 486 int n = qMax(int(-floor(log10((max - min) / (ticks - 1)))), 0);
487 487 n++;
488 488 for (int i = 0; i < ticks; i++) {
489 489 qreal value = min + (i * (max - min) / (ticks - 1));
490 490 labels << QDateTime::fromMSecsSinceEpoch(value).toString(format);
491 491 }
492 492 return labels;
493 493 }
494 494
495 495 #include "moc_chartaxis_p.cpp"
496 496
497 497 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,868 +1,868
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qabstractaxis.h"
22 22 #include "qabstractaxis_p.h"
23 23 #include "chartdataset_p.h"
24 24 #include "charttheme_p.h"
25 25
26 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 27
28 28 /*!
29 29 \class QAbstractAxis
30 30 \brief The QAbstractAxis class is used for manipulating chart's axis.
31 31 \mainclass
32 32
33 33 There is only one x Axis visible at the time, however there can be multiple y axes.
34 34 Each chart series can be bound to exactly one Y axis and the shared common X axis.
35 35 Axis can be setup to show axis line with tick marks, grid lines and shades.
36 36 */
37 37
38 38 /*!
39 39 \qmlclass AbstractAxis QAbstractAxis
40 40 \brief The Axis element is used for manipulating chart's axes
41 41
42 42 There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView.
43 43 Each chart series can be bound to exactly one Y axis and the shared common X axis.
44 44 Axis can be setup to show axis line with tick marks, grid lines and shades.
45 45
46 46 To access Axes you can use ChartView API. For example:
47 47 \code
48 48 ChartView {
49 49 axisX.min: 0
50 50 axisX.max: 3
51 51 axisX.ticksCount: 4
52 52 axisY.min: 0
53 53 axisY.max: 4
54 54 // Add a few series...
55 55 }
56 56 \endcode
57 57 */
58 58
59 59 /*!
60 60 \enum QAbstractAxis::AxisType
61 61
62 62 The type of the series object.
63 63
64 64 \value AxisTypeNoAxis
65 65 \value AxisTypeValue
66 66 \value AxisTypeBarCategory
67 67 \value AxisTypeCategory
68 68 \value AxisTypeDateTime
69 69 */
70 70
71 71 /*!
72 72 *\fn void QAbstractAxis::type() const
73 73 Returns the type of the axis
74 74 */
75 75
76 76 /*!
77 77 \property QAbstractAxis::lineVisible
78 78 The visibility of the axis line
79 79 */
80 80 /*!
81 81 \qmlproperty bool AbstractAxis::lineVisible
82 82 The visibility of the axis line
83 83 */
84 84
85 85 /*!
86 86 \property QAbstractAxis::labelsVisible
87 87 Defines if axis labels are visible.
88 88 */
89 89 /*!
90 90 \qmlproperty bool AbstractAxis::labelsVisible
91 91 Defines if axis labels are visible.
92 92 */
93 93
94 94 /*!
95 95 \property QAbstractAxis::visible
96 96 The visibility of the axis.
97 97 */
98 98 /*!
99 99 \qmlproperty bool AbstractAxis::visible
100 100 The visibility of the axis.
101 101 */
102 102
103 103 /*!
104 104 \property QAbstractAxis::gridVisible
105 105 The visibility of the grid lines.
106 106 */
107 107 /*!
108 108 \qmlproperty bool AbstractAxis::gridVisible
109 109 The visibility of the grid lines.
110 110 */
111 111
112 112 /*!
113 113 \property QAbstractAxis::color
114 114 The color of the axis and ticks.
115 115 */
116 116 /*!
117 117 \qmlproperty color AbstractAxis::color
118 118 The color of the axis and ticks.
119 119 */
120 120
121 121 /*!
122 122 \property QAbstractAxis::labelsFont
123 123 The font of the axis labels.
124 124 */
125 125
126 126 /*!
127 127 \qmlproperty Font AbstractAxis::labelsFont
128 128 The font of the axis labels.
129 129
130 130 See the \l {Font} {QML Font Element} for detailed documentation.
131 131 */
132 132
133 133 /*!
134 134 \property QAbstractAxis::labelsColor
135 135 The color of the axis labels.
136 136 */
137 137 /*!
138 138 \qmlproperty color AbstractAxis::labelsColor
139 139 The color of the axis labels.
140 140 */
141 141
142 142 /*!
143 143 \property QAbstractAxis::labelsAngle
144 144 The angle of the axis labels in degrees.
145 145 */
146 146 /*!
147 147 \qmlproperty int AbstractAxis::labelsAngle
148 148 The angle of the axis labels in degrees.
149 149 */
150 150
151 151 /*!
152 152 \property QAbstractAxis::shadesVisible
153 153 The visibility of the axis shades.
154 154 */
155 155 /*!
156 156 \qmlproperty bool AbstractAxis::shadesVisible
157 157 The visibility of the axis shades.
158 158 */
159 159
160 160 /*!
161 161 \property QAbstractAxis::shadesColor
162 162 The fill (brush) color of the axis shades.
163 163 */
164 164 /*!
165 165 \qmlproperty color AbstractAxis::shadesColor
166 166 The fill (brush) color of the axis shades.
167 167 */
168 168
169 169 /*!
170 170 \property QAbstractAxis::shadesBorderColor
171 171 The border (pen) color of the axis shades.
172 172 */
173 173 /*!
174 174 \qmlproperty color AbstractAxis::shadesBorderColor
175 175 The border (pen) color of the axis shades.
176 176 */
177 177
178 178 /*!
179 179 \property QAbstractAxis::titleVisible
180 180 The visibility of the axis title. By default the value is true.
181 181 */
182 182 /*!
183 183 \qmlproperty bool AbstractAxis::titleVisible
184 184 The visibility of the axis title. By default the value is true.
185 185 */
186 186
187 187 /*!
188 188 \property QAbstractAxis::titleFont
189 189 The font of the title of the axis.
190 190 */
191 191 /*!
192 192 \qmlproperty Font AbstractAxis::title
193 193 The font of the title of the axis.
194 194 */
195 195
196 196 /*!
197 197 \property QAbstractAxis::title
198 198 The title of the axis. Empty by default.
199 199 */
200 200 /*!
201 201 \qmlproperty string AbstractAxis::title
202 202 The title of the axis. Empty string by default.
203 203 */
204 204
205 205 /*!
206 206 \property QAbstractAxis::alignment
207 207 The alignment of the axis. Either Qt::AlignLeft or Qt::AlignBottom.
208 208 */
209 209 /*!
210 210 \qmlproperty alignment AbstractAxis::alignment
211 211 The alignment of the axis. Either Qt.AlignLeft or Qt.AlignBottom.
212 212 */
213 213
214 214 /*!
215 215 \fn void QAbstractAxis::visibleChanged(bool visible)
216 216 Visibility of the axis has changed to \a visible.
217 217 */
218 218 /*!
219 219 \qmlsignal AbstractAxis::onVisibleChanged(bool visible)
220 220 Visibility of the axis has changed to \a visible.
221 221 */
222 222
223 223 /*!
224 224 \fn void QAbstractAxis::lineVisibleChanged(bool visible)
225 225 Visibility of the axis line has changed to \a visible.
226 226 */
227 227 /*!
228 228 \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible)
229 229 Visibility of the axis line has changed to \a visible.
230 230 */
231 231
232 232 /*!
233 233 \fn void QAbstractAxis::labelsVisibleChanged(bool visible)
234 234 Visibility of the labels of the axis has changed to \a visible.
235 235 */
236 236 /*!
237 237 \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible)
238 238 Visibility of the labels of the axis has changed to \a visible.
239 239 */
240 240
241 241 /*!
242 242 \fn void QAbstractAxis::gridVisibleChanged(bool visible)
243 243 Visibility of the grid lines of the axis has changed to \a visible.
244 244 */
245 245 /*!
246 246 \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible)
247 247 Visibility of the grid lines of the axis has changed to \a visible.
248 248 */
249 249
250 250 /*!
251 251 \fn void QAbstractAxis::colorChanged(QColor color)
252 252 Emitted if the \a color of the axis is changed.
253 253 */
254 254 /*!
255 255 \qmlsignal AbstractAxis::onColorChanged(QColor color)
256 256 Emitted if the \a color of the axis is changed.
257 257 */
258 258
259 259 /*!
260 260 \fn void QAbstractAxis::labelsColorChanged(QColor color)
261 261 Emitted if the \a color of the axis labels is changed.
262 262 */
263 263 /*!
264 264 \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color)
265 265 Emitted if the \a color of the axis labels is changed.
266 266 */
267 267
268 268 /*!
269 269 \fn void QAbstractAxis::shadesVisibleChanged(bool)
270 270 Emitted if the visibility of the axis shades is changed to \a visible.
271 271 */
272 272 /*!
273 273 \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible)
274 274 Emitted if the visibility of the axis shades is changed to \a visible.
275 275 */
276 276
277 277 /*!
278 278 \fn void QAbstractAxis::shadesColorChanged(QColor color)
279 279 Emitted if the \a color of the axis shades is changed.
280 280 */
281 281 /*!
282 282 \qmlsignal AbstractAxis::onShadesColorChanged(QColor color)
283 283 Emitted if the \a color of the axis shades is changed.
284 284 */
285 285
286 286 /*!
287 287 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
288 288 Emitted if the border \a color of the axis shades is changed.
289 289 */
290 290 /*!
291 291 \qmlsignal AbstractAxis::onBorderColorChanged(QColor color)
292 292 Emitted if the border \a color of the axis shades is changed.
293 293 */
294 294
295 295 /*!
296 296 \internal
297 297 Constructs new axis object which is a child of \a parent. Ownership is taken by
298 298 QChart when axis added.
299 299 */
300 300
301 301 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent)
302 302 : QObject(parent),
303 303 d_ptr(&d)
304 304 {
305 305 }
306 306
307 307 /*!
308 308 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
309 309 */
310 310
311 311 QAbstractAxis::~QAbstractAxis()
312 312 {
313 313 if (d_ptr->m_chart)
314 314 qFatal("Still binded axis detected !");
315 315 }
316 316
317 317 /*!
318 318 Sets \a pen used to draw axis line and ticks.
319 319 */
320 320 void QAbstractAxis::setLinePen(const QPen &pen)
321 321 {
322 322 if (d_ptr->m_axisPen != pen) {
323 323 d_ptr->m_axisPen = pen;
324 324 emit linePenChanged(pen);
325 325 }
326 326 }
327 327
328 328 /*!
329 329 Returns pen used to draw axis and ticks.
330 330 */
331 331 QPen QAbstractAxis::linePen() const
332 332 {
333 333 return d_ptr->m_axisPen;
334 334 }
335 335
336 336 //TODO: remove me
337 337 void QAbstractAxis::setLinePenColor(QColor color)
338 338 {
339 339 QPen p = d_ptr->m_axisPen;
340 340 if (p.color() != color) {
341 341 p.setColor(color);
342 342 setLinePen(p);
343 343 emit colorChanged(color);
344 344 }
345 345 }
346 346
347 347 QColor QAbstractAxis::linePenColor() const
348 348 {
349 349 return d_ptr->m_axisPen.color();
350 350 }
351 351
352 352 /*!
353 353 Sets if axis and ticks are \a visible.
354 354 */
355 355 void QAbstractAxis::setLineVisible(bool visible)
356 356 {
357 357 if (d_ptr->m_arrowVisible != visible) {
358 358 d_ptr->m_arrowVisible = visible;
359 359 emit lineVisibleChanged(visible);
360 360 }
361 361 }
362 362
363 363 bool QAbstractAxis::isLineVisible() const
364 364 {
365 365 return d_ptr->m_arrowVisible;
366 366 }
367 367
368 368 void QAbstractAxis::setGridLineVisible(bool visible)
369 369 {
370 370 if (d_ptr->m_gridLineVisible != visible) {
371 371 d_ptr->m_gridLineVisible = visible;
372 emit gridLineVisibleChanged(visible);
372 emit gridVisibleChanged(visible);
373 373 }
374 374 }
375 375
376 376 bool QAbstractAxis::isGridLineVisible() const
377 377 {
378 378 return d_ptr->m_gridLineVisible;
379 379 }
380 380
381 381 /*!
382 382 Sets \a pen used to draw grid line.
383 383 */
384 384 void QAbstractAxis::setGridLinePen(const QPen &pen)
385 385 {
386 386 if (d_ptr->m_gridLinePen != pen) {
387 387 d_ptr->m_gridLinePen = pen;
388 388 emit gridLinePenChanged(pen);
389 389 }
390 390 }
391 391
392 392 /*!
393 393 Returns pen used to draw grid.
394 394 */
395 395 QPen QAbstractAxis::gridLinePen() const
396 396 {
397 397 return d_ptr->m_gridLinePen;
398 398 }
399 399
400 400 void QAbstractAxis::setLabelsVisible(bool visible)
401 401 {
402 402 if (d_ptr->m_labelsVisible != visible) {
403 403 d_ptr->m_labelsVisible = visible;
404 404 emit labelsVisibleChanged(visible);
405 405 }
406 406 }
407 407
408 408 bool QAbstractAxis::labelsVisible() const
409 409 {
410 410 return d_ptr->m_labelsVisible;
411 411 }
412 412
413 413 /*!
414 414 Sets \a pen used to draw labels.
415 415 */
416 416 void QAbstractAxis::setLabelsPen(const QPen &pen)
417 417 {
418 418 if (d_ptr->m_labelsPen != pen) {
419 419 d_ptr->m_labelsPen = pen;
420 420 emit labelsPenChanged(pen);
421 421 }
422 422 }
423 423
424 424 /*!
425 425 Returns the pen used to labels.
426 426 */
427 427 QPen QAbstractAxis::labelsPen() const
428 428 {
429 429 return d_ptr->m_labelsPen;
430 430 }
431 431
432 432 /*!
433 433 Sets \a brush used to draw labels.
434 434 */
435 435 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
436 436 {
437 437 if (d_ptr->m_labelsBrush != brush) {
438 438 d_ptr->m_labelsBrush = brush;
439 439 emit labelsBrushChanged(brush);
440 440 }
441 441 }
442 442
443 443 /*!
444 444 Returns brush used to draw labels.
445 445 */
446 446 QBrush QAbstractAxis::labelsBrush() const
447 447 {
448 448 return d_ptr->m_labelsBrush;
449 449 }
450 450
451 451 /*!
452 452 Sets \a font used to draw labels.
453 453 */
454 454 void QAbstractAxis::setLabelsFont(const QFont &font)
455 455 {
456 456 if (d_ptr->m_labelsFont != font) {
457 457 d_ptr->m_labelsFont = font;
458 458 emit labelsFontChanged(font);
459 459 }
460 460 }
461 461
462 462 /*!
463 463 Returns font used to draw labels.
464 464 */
465 465 QFont QAbstractAxis::labelsFont() const
466 466 {
467 467 return d_ptr->m_labelsFont;
468 468 }
469 469
470 470 void QAbstractAxis::setLabelsAngle(int angle)
471 471 {
472 472 if (d_ptr->m_labelsAngle != angle) {
473 473 d_ptr->m_labelsAngle = angle;
474 474 emit labelsAngleChanged(angle);
475 475 }
476 476 }
477 477
478 478 int QAbstractAxis::labelsAngle() const
479 479 {
480 480 return d_ptr->m_labelsAngle;
481 481 }
482 482 //TODO: remove me
483 483 void QAbstractAxis::setLabelsColor(QColor color)
484 484 {
485 485 QBrush b = d_ptr->m_labelsBrush;
486 486 if (b.color() != color) {
487 487 b.setColor(color);
488 488 setLabelsBrush(b);
489 489 emit labelsColorChanged(color);
490 490 }
491 491 }
492 492
493 493 QColor QAbstractAxis::labelsColor() const
494 494 {
495 495 return d_ptr->m_labelsBrush.color();
496 496 }
497 497
498 498 void QAbstractAxis::setTitleVisible(bool visible)
499 499 {
500 500 if (d_ptr->m_titleVisible != visible) {
501 501 d_ptr->m_titleVisible = visible;
502 502 emit labelsVisibleChanged(visible);
503 503 }
504 504 }
505 505
506 506 bool QAbstractAxis::titleVisible() const
507 507 {
508 508 return d_ptr->m_titleVisible;
509 509 }
510 510
511 511 /*!
512 512 Sets \a pen used to draw title.
513 513 */
514 514 void QAbstractAxis::setTitlePen(const QPen &pen)
515 515 {
516 516 if (d_ptr->m_titlePen != pen) {
517 517 d_ptr->m_titlePen = pen;
518 518 emit titlePenChanged(pen);
519 519 }
520 520 }
521 521
522 522 /*!
523 523 Returns the pen used to title.
524 524 */
525 525 QPen QAbstractAxis::titlePen() const
526 526 {
527 527 return d_ptr->m_titlePen;
528 528 }
529 529
530 530 /*!
531 531 Sets \a brush used to draw title.
532 532 */
533 533 void QAbstractAxis::setTitleBrush(const QBrush &brush)
534 534 {
535 535 if (d_ptr->m_titleBrush != brush) {
536 536 d_ptr->m_titleBrush = brush;
537 537 emit titleBrushChanged(brush);
538 538 }
539 539 }
540 540
541 541 /*!
542 542 Returns brush used to draw title.
543 543 */
544 544 QBrush QAbstractAxis::titleBrush() const
545 545 {
546 546 return d_ptr->m_titleBrush;
547 547 }
548 548
549 549 /*!
550 550 Sets \a font used to draw title.
551 551 */
552 552 void QAbstractAxis::setTitleFont(const QFont &font)
553 553 {
554 554 if (d_ptr->m_titleFont != font) {
555 555 d_ptr->m_titleFont = font;
556 556 emit titleFontChanged(font);
557 557 }
558 558 }
559 559
560 560 /*!
561 561 Returns font used to draw title.
562 562 */
563 563 QFont QAbstractAxis::titleFont() const
564 564 {
565 565 return d_ptr->m_titleFont;
566 566 }
567 567
568 568 void QAbstractAxis::setTitleText(const QString &title)
569 569 {
570 570 if (d_ptr->m_title != title) {
571 571 d_ptr->m_title = title;
572 572 emit titleTextChanged(title);
573 573 }
574 574 }
575 575
576 576 QString QAbstractAxis::titleText() const
577 577 {
578 578 return d_ptr->m_title;
579 579 }
580 580
581 581
582 582 void QAbstractAxis::setShadesVisible(bool visible)
583 583 {
584 584 if (d_ptr->m_shadesVisible != visible) {
585 585 d_ptr->m_shadesVisible = visible;
586 586 emit shadesVisibleChanged(visible);
587 587 }
588 588 }
589 589
590 590 bool QAbstractAxis::shadesVisible() const
591 591 {
592 592 return d_ptr->m_shadesVisible;
593 593 }
594 594
595 595 /*!
596 596 Sets \a pen used to draw shades.
597 597 */
598 598 void QAbstractAxis::setShadesPen(const QPen &pen)
599 599 {
600 600 if (d_ptr->m_shadesPen != pen) {
601 601 d_ptr->m_shadesPen = pen;
602 602 emit shadesPenChanged(pen);
603 603 }
604 604 }
605 605
606 606 /*!
607 607 Returns pen used to draw shades.
608 608 */
609 609 QPen QAbstractAxis::shadesPen() const
610 610 {
611 611 return d_ptr->m_shadesPen;
612 612 }
613 613
614 614 /*!
615 615 Sets \a brush used to draw shades.
616 616 */
617 617 void QAbstractAxis::setShadesBrush(const QBrush &brush)
618 618 {
619 619 if (d_ptr->m_shadesBrush != brush) {
620 620 d_ptr->m_shadesBrush = brush;
621 621 emit shadesBrushChanged(brush);
622 622 }
623 623 }
624 624
625 625 /*!
626 626 Returns brush used to draw shades.
627 627 */
628 628 QBrush QAbstractAxis::shadesBrush() const
629 629 {
630 630 return d_ptr->m_shadesBrush;
631 631 }
632 632
633 633 void QAbstractAxis::setShadesColor(QColor color)
634 634 {
635 635 QBrush b = d_ptr->m_shadesBrush;
636 636 if (b.color() != color) {
637 637 b.setColor(color);
638 638 setShadesBrush(b);
639 639 emit shadesColorChanged(color);
640 640 }
641 641 }
642 642
643 643 QColor QAbstractAxis::shadesColor() const
644 644 {
645 645 return d_ptr->m_shadesBrush.color();
646 646 }
647 647
648 648 void QAbstractAxis::setShadesBorderColor(QColor color)
649 649 {
650 650 QPen p = d_ptr->m_shadesPen;
651 651 if (p.color() != color) {
652 652 p.setColor(color);
653 653 setShadesPen(p);
654 654 emit shadesColorChanged(color);
655 655 }
656 656 }
657 657
658 658 QColor QAbstractAxis::shadesBorderColor() const
659 659 {
660 660 return d_ptr->m_shadesPen.color();
661 661 }
662 662
663 663
664 664 bool QAbstractAxis::isVisible() const
665 665 {
666 666 return d_ptr->m_visible;
667 667 }
668 668
669 669 /*!
670 670 Sets axis, shades, labels and grid lines to be visible.
671 671 */
672 672 void QAbstractAxis::setVisible(bool visible)
673 673 {
674 674 if (d_ptr->m_visible != visible) {
675 675 d_ptr->m_visible = visible;
676 676 emit visibleChanged(visible);
677 677 }
678 678 }
679 679
680 680
681 681 /*!
682 682 Sets axis, shades, labels and grid lines to be visible.
683 683 */
684 684 void QAbstractAxis::show()
685 685 {
686 686 setVisible(true);
687 687 }
688 688
689 689 /*!
690 690 Sets axis, shades, labels and grid lines to not be visible.
691 691 */
692 692 void QAbstractAxis::hide()
693 693 {
694 694 setVisible(false);
695 695 }
696 696
697 697 /*!
698 698 Sets the minimum value shown on the axis.
699 699 Depending on the actual axis type the \a min parameter is converted to appropriate type.
700 700 If the conversion is impossible then the function call does nothing
701 701 */
702 702 void QAbstractAxis::setMin(const QVariant &min)
703 703 {
704 704 d_ptr->setMin(min);
705 705 }
706 706
707 707 /*!
708 708 Sets the maximum value shown on the axis.
709 709 Depending on the actual axis type the \a max parameter is converted to appropriate type.
710 710 If the conversion is impossible then the function call does nothing
711 711 */
712 712 void QAbstractAxis::setMax(const QVariant &max)
713 713 {
714 714 d_ptr->setMax(max);
715 715 }
716 716
717 717 /*!
718 718 Sets the range shown on the axis.
719 719 Depending on the actual axis type the \a min and \a max parameters are converted to appropriate types.
720 720 If the conversion is impossible then the function call does nothing.
721 721 */
722 722 void QAbstractAxis::setRange(const QVariant &min, const QVariant &max)
723 723 {
724 724 d_ptr->setRange(min, max);
725 725 }
726 726
727 727
728 728 /*!
729 729 Returns the orientation in which the axis is being used (Vertical or Horizontal)
730 730 */
731 731 // NOTE: should have const but it breaks BC:
732 732 // http://techbase.kde.org/Policies/Binary_Compatibility_Examples#Change_the_CV-qualifiers_of_a_member_function
733 733 Qt::Orientation QAbstractAxis::orientation()
734 734 {
735 735 return d_ptr->orientation();
736 736 }
737 737
738 738 Qt::Alignment QAbstractAxis::alignment() const
739 739 {
740 740 return d_ptr->alignment();
741 741 }
742 742
743 743 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
744 744
745 745 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis *q)
746 746 : q_ptr(q),
747 747 m_chart(0),
748 748 m_orientation(Qt::Orientation(0)),
749 749 m_alignment(0),
750 750 m_visible(true),
751 751 m_arrowVisible(true),
752 752 m_gridLineVisible(true),
753 753 m_labelsVisible(true),
754 754 m_labelsAngle(0),
755 755 m_shadesVisible(false),
756 756 m_shadesBrush(Qt::SolidPattern),
757 757 m_shadesOpacity(1.0),
758 758 m_dirty(false)
759 759 {
760 760
761 761 }
762 762
763 763 QAbstractAxisPrivate::~QAbstractAxisPrivate()
764 764 {
765 765 }
766 766
767 767 void QAbstractAxisPrivate::setAlignment( Qt::Alignment alignment)
768 768 {
769 769 switch(alignment) {
770 770 case Qt::AlignTop:
771 771 case Qt::AlignBottom:
772 772 m_orientation = Qt::Horizontal;
773 773 break;
774 774 case Qt::AlignLeft:
775 775 case Qt::AlignRight:
776 776 m_orientation = Qt::Vertical;
777 777 break;
778 778 default:
779 779 qWarning()<<"No alignment specified !";
780 780 break;
781 781 };
782 782 m_alignment=alignment;
783 783 }
784 784
785 785 void QAbstractAxisPrivate::initializeTheme(ChartTheme* theme, bool forced)
786 786 {
787 787 QPen pen;
788 788 QBrush brush;
789 789 QFont font;
790 790
791 791 bool axisX = m_orientation == Qt::Horizontal;
792 792
793 793 if (m_arrowVisible) {
794 794
795 795 if (forced || brush == m_labelsBrush){
796 796 q_ptr->setLabelsBrush(theme->labelBrush());
797 797 }
798 798 //TODO: introduce axis brush
799 799 if (forced || brush == m_titleBrush){
800 800 q_ptr->setTitleBrush(theme->labelBrush());
801 801 }
802 802 if (forced || pen == m_labelsPen){
803 803 q_ptr->setLabelsPen(Qt::NoPen);// NoPen for performance reasons
804 804 }
805 805 if (forced || pen == m_titlePen){
806 806 q_ptr->setTitlePen(Qt::NoPen);// Noen for performance reasons
807 807 }
808 808 if (forced || m_shadesVisible) {
809 809
810 810 if (forced || brush == m_shadesBrush){
811 811 q_ptr->setShadesBrush(theme->backgroundShadesBrush());
812 812 }
813 813 if (forced || pen == m_shadesPen){
814 814 q_ptr->setShadesPen(theme->backgroundShadesPen());
815 815 }
816 816 if (forced && (theme->backgroundShades() == ChartTheme::BackgroundShadesBoth
817 817 || (theme->backgroundShades() == ChartTheme::BackgroundShadesVertical && axisX)
818 818 || (theme->backgroundShades() == ChartTheme::BackgroundShadesHorizontal && !axisX))) {
819 819 q_ptr->setShadesVisible(true);
820 820 }
821 821 }
822 822
823 823 if (forced || pen == m_axisPen) {
824 824 q_ptr->setLinePen(theme->axisLinePen());
825 825 }
826 826
827 827 if (forced || pen == m_gridLinePen) {
828 828 q_ptr->setGridLinePen(theme->girdLinePen());
829 829 }
830 830
831 831 if (forced || font == m_labelsFont){
832 832 q_ptr->setLabelsFont(theme->labelFont());
833 833 }
834 834 //TODO: discuss with Tero
835 835 if (forced || font == m_titleFont){
836 836 QFont font(m_labelsFont);
837 837 font.setBold(true);
838 838 q_ptr->setTitleFont(font);
839 839 }
840 840 }
841 841 }
842 842
843 843 void QAbstractAxisPrivate::handleRangeChanged(qreal min, qreal max)
844 844 {
845 845 setRange(min,max);
846 846 }
847 847
848 848 void QAbstractAxisPrivate::initializeGraphics(QGraphicsItem* parent)
849 849 {
850 850 Q_UNUSED(parent);
851 851 }
852 852
853 853 void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options)
854 854 {
855 855 ChartAxis* axis = m_item.data();
856 856 Q_ASSERT(axis);
857 857 if(options.testFlag(QChart::GridAxisAnimations)) {
858 858 axis->setAnimation(new AxisAnimation(axis));
859 859 }else{
860 860 axis->setAnimation(0);
861 861 }
862 862 }
863 863
864 864
865 865 #include "moc_qabstractaxis.cpp"
866 866 #include "moc_qabstractaxis_p.cpp"
867 867
868 868 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,196 +1,196
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef QABSTRACTAXIS_H
22 22 #define QABSTRACTAXIS_H
23 23
24 24 #include <qchartglobal.h>
25 25 #include <QPen>
26 26 #include <QFont>
27 27 #include <QVariant>
28 28
29 29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 30
31 31 class QAbstractAxisPrivate;
32 32
33 33 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
34 34 {
35 35 Q_OBJECT
36 36 //visibility
37 37 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
38 38 //arrow
39 39 Q_PROPERTY(bool lineVisible READ isLineVisible WRITE setLineVisible NOTIFY lineVisibleChanged)
40 40 Q_PROPERTY(QPen linePen READ linePen WRITE setLinePen NOTIFY linePenChanged)
41 41 //TODO: make wrapping of color for qml
42 42 Q_PROPERTY(QColor color READ linePenColor WRITE setLinePenColor NOTIFY colorChanged)
43 43 //labels
44 44 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
45 45 Q_PROPERTY(QPen lablesPen READ labelsPen WRITE setLabelsPen NOTIFY labelsPenChanged)
46 46 Q_PROPERTY(QBrush lablesBrush READ labelsBrush WRITE setLabelsBrush NOTIFY labelsBrushChanged)
47 47 //TODO: fix labels angles to work with layout
48 48 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle NOTIFY labelsAngleChanged)
49 49 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont NOTIFY labelsFontChanged)
50 50 //TODO: make wrapping of color for qml
51 51 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
52 52 //grid
53 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridLineVisibleChanged)
53 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
54 54 Q_PROPERTY(QPen girdLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged)
55 55 //shades
56 56 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
57 57 //TODO: make wrapping of color for qml
58 58 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
59 59 //TODO: make wrapping of border for qml
60 60 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
61 61 Q_PROPERTY(QPen shadesPen READ shadesPen WRITE setShadesPen NOTIFY shadesPenChanged)
62 62 Q_PROPERTY(QBrush shadesBrush READ shadesBrush WRITE setShadesBrush NOTIFY shadesBrushChanged)
63 63 //title
64 64 Q_PROPERTY(QString titleText READ titleText WRITE setTitleText NOTIFY titleTextChanged)
65 65 Q_PROPERTY(QPen titlePen READ titlePen WRITE setTitlePen NOTIFY titlePenChanged)
66 66 Q_PROPERTY(QBrush titleBrush READ titleBrush WRITE setTitleBrush NOTIFY titleBrushChanged)
67 67 Q_PROPERTY(bool titleVisible READ titleVisible WRITE setTitleVisible)
68 68 Q_PROPERTY(QFont titleFont READ titleFont WRITE setTitleFont)
69 69 //orientation
70 70 Q_PROPERTY(Qt::Orientation orinetation READ orientation)
71 71 //aligment
72 72 Q_PROPERTY(Qt::Alignment alignment READ alignment)
73 73
74 74 public:
75 75
76 76 enum AxisType {
77 77 AxisTypeNoAxis = 0x0,
78 78 AxisTypeValue = 0x1,
79 79 AxisTypeBarCategory = 0x2,
80 80 AxisTypeCategory = 0x3,
81 81 AxisTypeDateTime = 0x4,
82 82 AxisTypeLogValue = 0x5
83 83 };
84 84
85 85 Q_DECLARE_FLAGS(AxisTypes, AxisType)
86 86
87 87 protected:
88 88 explicit QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent = 0);
89 89
90 90 public:
91 91 ~QAbstractAxis();
92 92
93 93 virtual AxisType type() const = 0;
94 94
95 95 //visibility handling
96 96 bool isVisible() const;
97 97 void setVisible(bool visible = true);
98 98 void show();
99 99 void hide();
100 100
101 101 //arrow handling
102 102 bool isLineVisible() const;
103 103 void setLineVisible(bool visible = true);
104 104 void setLinePen(const QPen &pen);
105 105 QPen linePen() const;
106 106 void setLinePenColor(QColor color);
107 107 QColor linePenColor() const;
108 108
109 109 //grid handling
110 110 bool isGridLineVisible() const;
111 111 void setGridLineVisible(bool visible = true);
112 112 void setGridLinePen(const QPen &pen);
113 113 QPen gridLinePen() const;
114 114
115 115 //labels handling
116 116 bool labelsVisible() const;
117 117 void setLabelsVisible(bool visible = true);
118 118 void setLabelsPen(const QPen &pen);
119 119 QPen labelsPen() const;
120 120 void setLabelsBrush(const QBrush &brush);
121 121 QBrush labelsBrush() const;
122 122 void setLabelsFont(const QFont &font);
123 123 QFont labelsFont() const;
124 124 void setLabelsAngle(int angle);
125 125 int labelsAngle() const;
126 126 void setLabelsColor(QColor color);
127 127 QColor labelsColor() const;
128 128
129 129 //title handling
130 130 bool titleVisible() const;
131 131 void setTitleVisible(bool visible = true);
132 132 void setTitlePen(const QPen &pen);
133 133 QPen titlePen() const;
134 134 void setTitleBrush(const QBrush &brush);
135 135 QBrush titleBrush() const;
136 136 void setTitleFont(const QFont &font);
137 137 QFont titleFont() const;
138 138 void setTitleText(const QString &title);
139 139 QString titleText() const;
140 140
141 141 //shades handling
142 142 bool shadesVisible() const;
143 143 void setShadesVisible(bool visible = true);
144 144 void setShadesPen(const QPen &pen);
145 145 QPen shadesPen() const;
146 146 void setShadesBrush(const QBrush &brush);
147 147 QBrush shadesBrush() const;
148 148 void setShadesColor(QColor color);
149 149 QColor shadesColor() const;
150 150 void setShadesBorderColor(QColor color);
151 151 QColor shadesBorderColor() const;
152 152
153 153 Qt::Orientation orientation(); //TODO: missing const <- BC
154 154 Qt::Alignment alignment() const;
155 155
156 156 //range handling
157 157 void setMin(const QVariant &min);
158 158 void setMax(const QVariant &max);
159 159 void setRange(const QVariant &min, const QVariant &max);
160 160
161 161 Q_SIGNALS:
162 162 void visibleChanged(bool visible);
163 163 void linePenChanged(const QPen& pen);
164 164 void lineVisibleChanged(bool visible);
165 165 void labelsVisibleChanged(bool visible);
166 166 void labelsPenChanged(const QPen& pen);
167 167 void labelsBrushChanged(const QBrush& brush);
168 168 void labelsFontChanged(const QFont& pen);
169 169 void labelsAngleChanged(int angle);
170 170 void gridLinePenChanged(const QPen& pen);
171 void gridLineVisibleChanged(bool visible);
171 void gridVisibleChanged(bool visible);
172 172 void colorChanged(QColor color);
173 173 void labelsColorChanged(QColor color);
174 174 void titleTextChanged(const QString& title);
175 175 void titlePenChanged(const QPen& pen);
176 176 void titleBrushChanged(const QBrush brush);
177 177 void titleVisibleChanged(bool visible);
178 178 void titleFontChanged(const QFont& font);
179 179 void shadesVisibleChanged(bool visible);
180 180 void shadesColorChanged(QColor color);
181 181 void shadesBorderColorChanged(QColor color);
182 182 void shadesPenChanged(const QPen& pen);
183 183 void shadesBrushChanged(const QBrush brush);
184 184
185 185 protected:
186 186 QScopedPointer<QAbstractAxisPrivate> d_ptr;
187 187 Q_DISABLE_COPY(QAbstractAxis)
188 188 friend class ChartDataSet;
189 189 friend class ChartAxis;
190 190 friend class ChartPresenter;
191 191 friend class ChartThemeManager;
192 192 };
193 193
194 194 QTCOMMERCIALCHART_END_NAMESPACE
195 195
196 196 #endif // QABSTRACTAXIS_H
@@ -1,847 +1,847
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "tst_qabstractaxis.h"
22 22
23 23 Q_DECLARE_METATYPE(QPen)
24 24 Q_DECLARE_METATYPE(Qt::Orientation)
25 25
26 26 void tst_QAbstractAxis::initTestCase()
27 27 {
28 28 }
29 29
30 30 void tst_QAbstractAxis::cleanupTestCase()
31 31 {
32 32 }
33 33
34 34 void tst_QAbstractAxis::init(QAbstractAxis* axis, QAbstractSeries* series)
35 35 {
36 36 m_axis = axis;
37 37 m_series = series;
38 38 m_view = new QChartView(new QChart());
39 39 m_chart = m_view->chart();
40 40 }
41 41
42 42 void tst_QAbstractAxis::cleanup()
43 43 {
44 44 delete m_view;
45 45 m_view = 0;
46 46 m_chart = 0;
47 47 m_axis = 0;
48 48 }
49 49
50 50 void tst_QAbstractAxis::qabstractaxis()
51 51 {
52 52 QCOMPARE(m_axis->linePen(), QPen());
53 53 //TODO QCOMPARE(m_axis->axisPenColor(), QColor());
54 54 QCOMPARE(m_axis->gridLinePen(), QPen());
55 55 QCOMPARE(m_axis->isLineVisible(), true);
56 56 QCOMPARE(m_axis->isGridLineVisible(), true);
57 57 QCOMPARE(m_axis->isVisible(), true);
58 58 QCOMPARE(m_axis->labelsAngle(), 0);
59 59 QCOMPARE(m_axis->labelsBrush(), QBrush());
60 60 //TODO QCOMPARE(m_axis->labelsColor(), QColor());
61 61 QCOMPARE(m_axis->labelsFont(), QFont());
62 62 QCOMPARE(m_axis->labelsPen(), QPen());
63 63 QCOMPARE(m_axis->labelsVisible(), true);
64 64 QCOMPARE(m_axis->orientation(), Qt::Orientation(0));
65 65 m_axis->setLineVisible(false);
66 66 m_axis->setLinePen(QPen());
67 67 m_axis->setLinePenColor(QColor());
68 68 m_axis->setGridLinePen(QPen());
69 69 m_axis->setGridLineVisible(false);
70 70 m_axis->setLabelsAngle(-1);
71 71 m_axis->setLabelsBrush(QBrush());
72 72 m_axis->setLabelsColor(QColor());
73 73 m_axis->setLabelsFont(QFont());
74 74 m_axis->setLabelsPen(QPen());
75 75 m_axis->setLabelsVisible(false);
76 76 m_axis->setMax(QVariant());
77 77 m_axis->setMin(QVariant());
78 78 m_axis->setRange(QVariant(), QVariant());
79 79 m_axis->setShadesBorderColor(QColor());
80 80 m_axis->setShadesBrush(QBrush());
81 81 m_axis->setShadesColor(QColor());
82 82 m_axis->setShadesPen(QPen());
83 83 m_axis->setShadesVisible(false);
84 84 m_axis->setVisible(false);
85 85 //TODO QCOMPARE(m_axis->shadesBorderColor(), QColor());
86 86 //TODO QCOMPARE(m_axis->shadesBrush(), QBrush());
87 87 //TODO QCOMPARE(m_axis->shadesColor(), QColor());
88 88 QCOMPARE(m_axis->shadesPen(), QPen());
89 89 QCOMPARE(m_axis->shadesVisible(), false);
90 90 m_axis->show();
91 91 m_axis->hide();
92 92 }
93 93
94 94 void tst_QAbstractAxis::axisPen_data()
95 95 {
96 96 QTest::addColumn<QPen>("axisPen");
97 97 QTest::newRow("null") << QPen();
98 98 QTest::newRow("blue") << QPen(Qt::blue);
99 99 QTest::newRow("black") << QPen(Qt::black);
100 100 QTest::newRow("red") << QPen(Qt::red);
101 101 }
102 102
103 103 void tst_QAbstractAxis::axisPen()
104 104 {
105 105 QFETCH(QPen, axisPen);
106 106
107 107 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
108 108 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
109 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
110 110 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
111 111 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
112 112 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
113 113 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
114 114 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
115 115 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
116 116
117 117 m_axis->setLinePen(axisPen);
118 118 QCOMPARE(m_axis->linePen(), axisPen);
119 119
120 120 QCOMPARE(spy0.count(), 0);
121 121 QCOMPARE(spy1.count(), 0);
122 122 QCOMPARE(spy2.count(), 0);
123 123 QCOMPARE(spy3.count(), 0);
124 124 QCOMPARE(spy4.count(), 0);
125 125 QCOMPARE(spy5.count(), 0);
126 126 QCOMPARE(spy6.count(), 0);
127 127 QCOMPARE(spy7.count(), 0);
128 128 QCOMPARE(spy8.count(), 0);
129 129
130 130 m_chart->setAxisX(m_axis, m_series);
131 131 m_view->show();
132 132 QTest::qWaitForWindowShown(m_view);
133 133 //TODO QCOMPARE(m_axis->axisPen(), axisPen);
134 134 }
135 135
136 136 void tst_QAbstractAxis::axisPenColor_data()
137 137 {
138 138 }
139 139
140 140 void tst_QAbstractAxis::axisPenColor()
141 141 {
142 142 QSKIP("Test is not implemented. This is deprecated function", SkipAll);
143 143 }
144 144
145 145 void tst_QAbstractAxis::gridLinePen_data()
146 146 {
147 147
148 148 QTest::addColumn<QPen>("gridLinePen");
149 149 QTest::newRow("null") << QPen();
150 150 QTest::newRow("blue") << QPen(Qt::blue);
151 151 QTest::newRow("black") << QPen(Qt::black);
152 152 QTest::newRow("red") << QPen(Qt::red);
153 153
154 154 }
155 155
156 156 void tst_QAbstractAxis::gridLinePen()
157 157 {
158 158 QFETCH(QPen, gridLinePen);
159 159
160 160 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
161 161 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
162 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
162 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
163 163 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
164 164 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
165 165 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
166 166 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
167 167 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
168 168 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
169 169
170 170 m_axis->setGridLinePen(gridLinePen);
171 171 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
172 172
173 173 QCOMPARE(spy0.count(), 0);
174 174 QCOMPARE(spy1.count(), 0);
175 175 QCOMPARE(spy2.count(), 0);
176 176 QCOMPARE(spy3.count(), 0);
177 177 QCOMPARE(spy4.count(), 0);
178 178 QCOMPARE(spy5.count(), 0);
179 179 QCOMPARE(spy6.count(), 0);
180 180 QCOMPARE(spy7.count(), 0);
181 181 QCOMPARE(spy8.count(), 0);
182 182
183 183 m_chart->setAxisX(m_axis, m_series);
184 184 m_view->show();
185 185 QTest::qWaitForWindowShown(m_view);
186 186 //TODO QCOMPARE(m_axis->gridLinePen(), gridLinePen);
187 187 }
188 188
189 189 void tst_QAbstractAxis::lineVisible_data()
190 190 {
191 191 QTest::addColumn<bool>("lineVisible");
192 192 QTest::newRow("true") << true;
193 193 QTest::newRow("false") << false;
194 194 }
195 195
196 196 void tst_QAbstractAxis::lineVisible()
197 197 {
198 198 QFETCH(bool, lineVisible);
199 199
200 200 m_axis->setLineVisible(!lineVisible);
201 201
202 202 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
203 203 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
204 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
204 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
205 205 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
206 206 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
207 207 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
208 208 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
209 209 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
210 210 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
211 211
212 212 m_axis->setLineVisible(lineVisible);
213 213 QCOMPARE(m_axis->isLineVisible(), lineVisible);
214 214
215 215 QCOMPARE(spy0.count(), 1);
216 216 QCOMPARE(spy1.count(), 0);
217 217 QCOMPARE(spy2.count(), 0);
218 218 QCOMPARE(spy3.count(), 0);
219 219 QCOMPARE(spy4.count(), 0);
220 220 QCOMPARE(spy5.count(), 0);
221 221 QCOMPARE(spy6.count(), 0);
222 222 QCOMPARE(spy7.count(), 0);
223 223 QCOMPARE(spy8.count(), 0);
224 224
225 225 m_chart->setAxisX(m_axis, m_series);
226 226 m_view->show();
227 227 QTest::qWaitForWindowShown(m_view);
228 228 QCOMPARE(m_axis->isLineVisible(), lineVisible);
229 229 }
230 230
231 231 void tst_QAbstractAxis::gridLineVisible_data()
232 232 {
233 233 QTest::addColumn<bool>("gridLineVisible");
234 234 QTest::newRow("true") << true;
235 235 QTest::newRow("false") << false;
236 236 }
237 237
238 238 void tst_QAbstractAxis::gridLineVisible()
239 239 {
240 240 QFETCH(bool, gridLineVisible);
241 241
242 242 m_axis->setGridLineVisible(!gridLineVisible);
243 243
244 244 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
245 245 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
246 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
246 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
247 247 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
248 248 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
249 249 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
250 250 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
251 251 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
252 252 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
253 253
254 254 m_axis->setGridLineVisible(gridLineVisible);
255 255 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
256 256
257 257 QCOMPARE(spy0.count(), 0);
258 258 QCOMPARE(spy1.count(), 0);
259 259 QCOMPARE(spy2.count(), 1);
260 260 QCOMPARE(spy3.count(), 0);
261 261 QCOMPARE(spy4.count(), 0);
262 262 QCOMPARE(spy5.count(), 0);
263 263 QCOMPARE(spy6.count(), 0);
264 264 QCOMPARE(spy7.count(), 0);
265 265 QCOMPARE(spy8.count(), 0);
266 266
267 267 m_chart->setAxisX(m_axis, m_series);
268 268 m_view->show();
269 269 QTest::qWaitForWindowShown(m_view);
270 270 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
271 271
272 272 }
273 273
274 274 void tst_QAbstractAxis::visible_data()
275 275 {
276 276 QTest::addColumn<bool>("visible");
277 277 QTest::newRow("true") << true;
278 278 QTest::newRow("false") << false;
279 279 }
280 280
281 281 void tst_QAbstractAxis::visible()
282 282 {
283 283 QFETCH(bool, visible);
284 284
285 285 m_axis->setVisible(!visible);
286 286
287 287 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
288 288 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
289 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
289 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
290 290 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
291 291 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
292 292 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
293 293 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
294 294 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
295 295 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
296 296
297 297 m_axis->setVisible(visible);
298 298 QCOMPARE(m_axis->isVisible(), visible);
299 299
300 300 QCOMPARE(spy0.count(), 0);
301 301 QCOMPARE(spy1.count(), 0);
302 302 QCOMPARE(spy2.count(), 0);
303 303 QCOMPARE(spy3.count(), 0);
304 304 QCOMPARE(spy4.count(), 0);
305 305 QCOMPARE(spy5.count(), 0);
306 306 QCOMPARE(spy6.count(), 0);
307 307 QCOMPARE(spy7.count(), 0);
308 308 QCOMPARE(spy8.count(), 1);
309 309
310 310 m_chart->setAxisX(m_axis, m_series);
311 311 m_view->show();
312 312 QTest::qWaitForWindowShown(m_view);
313 313 QCOMPARE(m_axis->isVisible(), visible);
314 314 }
315 315
316 316 void tst_QAbstractAxis::labelsAngle_data()
317 317 {
318 318 QTest::addColumn<int>("labelsAngle");
319 319 QTest::newRow("0") << 0;
320 320 QTest::newRow("45") << 45;
321 321 QTest::newRow("90") << 90;
322 322 }
323 323
324 324 void tst_QAbstractAxis::labelsAngle()
325 325 {
326 326 QFETCH(int, labelsAngle);
327 327
328 328 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
329 329 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
330 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
330 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
331 331 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
332 332 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
333 333 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
334 334 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
335 335 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
336 336 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
337 337
338 338 m_axis->setLabelsAngle(labelsAngle);
339 339 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
340 340
341 341 QCOMPARE(spy0.count(), 0);
342 342 QCOMPARE(spy1.count(), 0);
343 343 QCOMPARE(spy2.count(), 0);
344 344 QCOMPARE(spy3.count(), 0);
345 345 QCOMPARE(spy4.count(), 0);
346 346 QCOMPARE(spy5.count(), 0);
347 347 QCOMPARE(spy6.count(), 0);
348 348 QCOMPARE(spy7.count(), 0);
349 349 QCOMPARE(spy8.count(), 0);
350 350
351 351 m_chart->setAxisX(m_axis, m_series);
352 352 m_view->show();
353 353 QTest::qWaitForWindowShown(m_view);
354 354 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
355 355 }
356 356
357 357 void tst_QAbstractAxis::labelsBrush_data()
358 358 {
359 359 QTest::addColumn<QBrush>("labelsBrush");
360 360 QTest::newRow("null") << QBrush();
361 361 QTest::newRow("blue") << QBrush(Qt::blue);
362 362 QTest::newRow("black") << QBrush(Qt::black);
363 363
364 364 }
365 365
366 366 void tst_QAbstractAxis::labelsBrush()
367 367 {
368 368
369 369 QFETCH(QBrush, labelsBrush);
370 370
371 371 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
372 372 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
373 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
373 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
374 374 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
375 375 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
376 376 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
377 377 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
378 378 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
379 379 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
380 380
381 381 m_axis->setLabelsBrush(labelsBrush);
382 382 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
383 383
384 384 QCOMPARE(spy0.count(), 0);
385 385 QCOMPARE(spy1.count(), 0);
386 386 QCOMPARE(spy2.count(), 0);
387 387 QCOMPARE(spy3.count(), 0);
388 388 QCOMPARE(spy4.count(), 0);
389 389 QCOMPARE(spy5.count(), 0);
390 390 //TODO QCOMPARE(spy6.count(), 0);
391 391 QCOMPARE(spy7.count(), 0);
392 392 QCOMPARE(spy8.count(), 0);
393 393
394 394 m_view->show();
395 395 QTest::qWaitForWindowShown(m_view);
396 396 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
397 397
398 398 }
399 399
400 400 void tst_QAbstractAxis::labelsColor_data()
401 401 {
402 402
403 403 }
404 404
405 405 void tst_QAbstractAxis::labelsColor()
406 406 {
407 407 QSKIP("Test is not implemented. This is deprecated function", SkipAll);
408 408 }
409 409
410 410 void tst_QAbstractAxis::labelsFont_data()
411 411 {
412 412 QTest::addColumn<QFont>("labelsFont");
413 413 QTest::newRow("null") << QFont();
414 414 QTest::newRow("serif") << QFont("SansSerif");
415 415 }
416 416
417 417 void tst_QAbstractAxis::labelsFont()
418 418 {
419 419
420 420 QFETCH(QFont, labelsFont);
421 421
422 422 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
423 423 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
424 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
424 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
425 425 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
426 426 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
427 427 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
428 428 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
429 429 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
430 430 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
431 431
432 432 m_axis->setLabelsFont(labelsFont);
433 433 QCOMPARE(m_axis->labelsFont(), labelsFont);
434 434
435 435 QCOMPARE(spy0.count(), 0);
436 436 QCOMPARE(spy1.count(), 0);
437 437 QCOMPARE(spy2.count(), 0);
438 438 QCOMPARE(spy3.count(), 0);
439 439 QCOMPARE(spy4.count(), 0);
440 440 QCOMPARE(spy5.count(), 0);
441 441 QCOMPARE(spy6.count(), 0);
442 442 QCOMPARE(spy7.count(), 0);
443 443 QCOMPARE(spy8.count(), 0);
444 444
445 445 m_view->show();
446 446 QTest::qWaitForWindowShown(m_view);
447 447 QCOMPARE(m_axis->labelsFont(), labelsFont);
448 448
449 449 }
450 450
451 451 void tst_QAbstractAxis::labelsPen_data()
452 452 {
453 453 QTest::addColumn<QPen>("labelsPen");
454 454 QTest::newRow("null") << QPen();
455 455 QTest::newRow("blue") << QPen(Qt::blue);
456 456 QTest::newRow("black") << QPen(Qt::black);
457 457 QTest::newRow("red") << QPen(Qt::red);
458 458 }
459 459
460 460 void tst_QAbstractAxis::labelsPen()
461 461 {
462 462 QFETCH(QPen, labelsPen);
463 463
464 464 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
465 465 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
466 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
466 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
467 467 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
468 468 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
469 469 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
470 470 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
471 471 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
472 472 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
473 473
474 474 m_axis->setLabelsPen(labelsPen);
475 475 QCOMPARE(m_axis->labelsPen(), labelsPen);
476 476
477 477 QCOMPARE(spy0.count(), 0);
478 478 QCOMPARE(spy1.count(), 0);
479 479 QCOMPARE(spy2.count(), 0);
480 480 QCOMPARE(spy3.count(), 0);
481 481 QCOMPARE(spy4.count(), 0);
482 482 QCOMPARE(spy5.count(), 0);
483 483 QCOMPARE(spy6.count(), 0);
484 484 QCOMPARE(spy7.count(), 0);
485 485 QCOMPARE(spy8.count(), 0);
486 486
487 487 m_chart->setAxisX(m_axis, m_series);
488 488 m_view->show();
489 489 QTest::qWaitForWindowShown(m_view);
490 490 //TODO QCOMPARE(m_axis->labelsPen(), labelsPen);
491 491 }
492 492
493 493 void tst_QAbstractAxis::labelsVisible_data()
494 494 {
495 495 QTest::addColumn<bool>("labelsVisible");
496 496 QTest::newRow("true") << true;
497 497 QTest::newRow("false") << false;
498 498 }
499 499
500 500 void tst_QAbstractAxis::labelsVisible()
501 501 {
502 502 QFETCH(bool, labelsVisible);
503 503
504 504 m_axis->setLabelsVisible(!labelsVisible);
505 505
506 506 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
507 507 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
508 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
508 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
509 509 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
510 510 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
511 511 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
512 512 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
513 513 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
514 514 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
515 515
516 516 m_axis->setLabelsVisible(labelsVisible);
517 517 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
518 518
519 519 QCOMPARE(spy0.count(), 0);
520 520 QCOMPARE(spy1.count(), 0);
521 521 QCOMPARE(spy2.count(), 0);
522 522 QCOMPARE(spy3.count(), 0);
523 523 QCOMPARE(spy4.count(), 1);
524 524 QCOMPARE(spy5.count(), 0);
525 525 QCOMPARE(spy6.count(), 0);
526 526 QCOMPARE(spy7.count(), 0);
527 527 QCOMPARE(spy8.count(), 0);
528 528
529 529 m_chart->setAxisX(m_axis, m_series);
530 530 m_view->show();
531 531 QTest::qWaitForWindowShown(m_view);
532 532 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
533 533 }
534 534
535 535 void tst_QAbstractAxis::orientation_data()
536 536 {
537 537 QTest::addColumn<Qt::Orientation>("orientation");
538 538 QTest::newRow("Vertical") << Qt::Vertical;
539 539 QTest::newRow("Horizontal") << Qt::Horizontal;
540 540 }
541 541
542 542 void tst_QAbstractAxis::orientation()
543 543 {
544 544 QFETCH(Qt::Orientation, orientation);
545 545
546 546 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
547 547 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
548 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
548 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
549 549 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
550 550 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
551 551 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
552 552 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
553 553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
554 554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
555 555
556 556 if(orientation==Qt::Vertical){
557 557 m_chart->setAxisY(m_axis,m_series);
558 558 }else{
559 559 m_chart->setAxisX(m_axis,m_series);
560 560 }
561 561 QCOMPARE(m_axis->orientation(), orientation);
562 562
563 563 QCOMPARE(spy0.count(), 0);
564 564 QCOMPARE(spy1.count(), 0);
565 565 QCOMPARE(spy2.count(), 0);
566 566 QCOMPARE(spy3.count(), 0);
567 567 QCOMPARE(spy4.count(), 0);
568 568 QCOMPARE(spy5.count(), 0);
569 569 QCOMPARE(spy6.count(), 0);
570 570 QCOMPARE(spy7.count(), 0);
571 571 QCOMPARE(spy8.count(), 1);
572 572
573 573 m_view->show();
574 574 QTest::qWaitForWindowShown(m_view);
575 575 QCOMPARE(m_axis->orientation(), orientation);
576 576 }
577 577
578 578 void tst_QAbstractAxis::setMax_data()
579 579 {
580 580 //just check if it does not crash
581 581 QTest::addColumn<QVariant>("max");
582 582 QTest::newRow("something") << QVariant("something");
583 583 QTest::newRow("1.0") << QVariant(1.0);
584 584 }
585 585
586 586 void tst_QAbstractAxis::setMax()
587 587 {
588 588 QFETCH(QVariant, max);
589 589 m_axis->setMax(max);
590 590 }
591 591
592 592 void tst_QAbstractAxis::setMin_data()
593 593 {
594 594 //just check if it does not crash
595 595 QTest::addColumn<QVariant>("min");
596 596 QTest::newRow("something") << QVariant("something");
597 597 QTest::newRow("1.0") << QVariant(1.0);
598 598 }
599 599
600 600 // public void setMin(QVariant const& min)
601 601 void tst_QAbstractAxis::setMin()
602 602 {
603 603 QFETCH(QVariant, min);
604 604 m_axis->setMin(min);
605 605 }
606 606
607 607 void tst_QAbstractAxis::setRange_data()
608 608 {
609 609 //just check if it does not crash
610 610 QTest::addColumn<QVariant>("min");
611 611 QTest::addColumn<QVariant>("max");
612 612 QTest::newRow("something") << QVariant("something0") << QVariant("something1");
613 613 QTest::newRow("-1 1") << QVariant(-1.0) << QVariant(1.0);
614 614 }
615 615
616 616 // public void setRange(QVariant const& min, QVariant const& max)
617 617 void tst_QAbstractAxis::setRange()
618 618 {
619 619
620 620 QFETCH(QVariant, min);
621 621 QFETCH(QVariant, max);
622 622 m_axis->setRange(min,max);
623 623 }
624 624
625 625 void tst_QAbstractAxis::shadesBorderColor_data()
626 626 {
627 627
628 628 }
629 629
630 630 void tst_QAbstractAxis::shadesBorderColor()
631 631 {
632 632 QSKIP("Test is not implemented. This is deprecated function", SkipAll);
633 633 }
634 634
635 635 void tst_QAbstractAxis::shadesBrush_data()
636 636 {
637 637 QTest::addColumn<QBrush>("shadesBrush");
638 638 QTest::newRow("null") << QBrush();
639 639 QTest::newRow("blue") << QBrush(Qt::blue);
640 640 QTest::newRow("black") << QBrush(Qt::black);
641 641 }
642 642
643 643 void tst_QAbstractAxis::shadesBrush()
644 644 {
645 645 QFETCH(QBrush, shadesBrush);
646 646
647 647 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
648 648 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
649 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
649 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
650 650 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
651 651 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
652 652 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
653 653 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
654 654 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
655 655 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
656 656
657 657 m_axis->setShadesBrush(shadesBrush);
658 658 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
659 659
660 660 QCOMPARE(spy0.count(), 0);
661 661 QCOMPARE(spy1.count(), 0);
662 662 QCOMPARE(spy2.count(), 0);
663 663 QCOMPARE(spy3.count(), 0);
664 664 QCOMPARE(spy4.count(), 0);
665 665 QCOMPARE(spy5.count(), 0);
666 666 //TODO QCOMPARE(spy6.count(), 0);
667 667 QCOMPARE(spy7.count(), 0);
668 668 QCOMPARE(spy8.count(), 0);
669 669
670 670 m_view->show();
671 671 QTest::qWaitForWindowShown(m_view);
672 672 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
673 673 }
674 674
675 675 void tst_QAbstractAxis::shadesColor_data()
676 676 {
677 677 }
678 678
679 679 // public QColor shadesColor() const
680 680 void tst_QAbstractAxis::shadesColor()
681 681 {
682 682 QSKIP("Test is not implemented. This is deprecated function", SkipAll);
683 683 }
684 684
685 685 void tst_QAbstractAxis::shadesPen_data()
686 686 {
687 687 QTest::addColumn<QPen>("shadesPen");
688 688 QTest::newRow("null") << QPen();
689 689 QTest::newRow("blue") << QPen(Qt::blue);
690 690 QTest::newRow("black") << QPen(Qt::black);
691 691 QTest::newRow("red") << QPen(Qt::red);
692 692 }
693 693
694 694 void tst_QAbstractAxis::shadesPen()
695 695 {
696 696 QFETCH(QPen, shadesPen);
697 697
698 698 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
699 699 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
700 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
700 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
701 701 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
702 702 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
703 703 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
704 704 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
705 705 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
706 706 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
707 707
708 708 m_axis->setShadesPen(shadesPen);
709 709 QCOMPARE(m_axis->shadesPen(), shadesPen);
710 710
711 711 QCOMPARE(spy0.count(), 0);
712 712 QCOMPARE(spy1.count(), 0);
713 713 QCOMPARE(spy2.count(), 0);
714 714 QCOMPARE(spy3.count(), 0);
715 715 QCOMPARE(spy4.count(), 0);
716 716 QCOMPARE(spy5.count(), 0);
717 717 QCOMPARE(spy6.count(), 0);
718 718 QCOMPARE(spy7.count(), 0);
719 719 QCOMPARE(spy8.count(), 0);
720 720
721 721 m_chart->setAxisX(m_axis, m_series);
722 722 m_view->show();
723 723 QTest::qWaitForWindowShown(m_view);
724 724 QCOMPARE(m_axis->shadesPen(), shadesPen);
725 725 }
726 726
727 727 void tst_QAbstractAxis::shadesVisible_data()
728 728 {
729 729 QTest::addColumn<bool>("shadesVisible");
730 730 QTest::newRow("true") << true;
731 731 QTest::newRow("false") << false;
732 732 }
733 733
734 734 void tst_QAbstractAxis::shadesVisible()
735 735 {
736 736 QFETCH(bool, shadesVisible);
737 737
738 738 m_axis->setShadesVisible(!shadesVisible);
739 739
740 740 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
741 741 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
742 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
742 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
743 743 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
744 744 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
745 745 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
746 746 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
747 747 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
748 748 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
749 749
750 750 m_axis->setShadesVisible(shadesVisible);
751 751 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
752 752
753 753 QCOMPARE(spy0.count(), 0);
754 754 QCOMPARE(spy1.count(), 0);
755 755 QCOMPARE(spy2.count(), 0);
756 756 QCOMPARE(spy3.count(), 0);
757 757 QCOMPARE(spy4.count(), 0);
758 758 QCOMPARE(spy5.count(), 0);
759 759 QCOMPARE(spy6.count(), 0);
760 760 QCOMPARE(spy7.count(), 1);
761 761 QCOMPARE(spy8.count(), 0);
762 762
763 763 m_chart->setAxisX(m_axis, m_series);
764 764 m_view->show();
765 765 QTest::qWaitForWindowShown(m_view);
766 766 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
767 767 }
768 768
769 769 void tst_QAbstractAxis::show_data()
770 770 {
771 771
772 772 }
773 773
774 774 void tst_QAbstractAxis::show()
775 775 {
776 776 m_axis->hide();
777 777 QCOMPARE(m_axis->isVisible(), false);
778 778
779 779 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
780 780 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
781 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
781 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
782 782 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
783 783 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
784 784 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
785 785 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
786 786 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
787 787 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
788 788
789 789 m_axis->show();
790 790
791 791 QCOMPARE(spy0.count(), 0);
792 792 QCOMPARE(spy1.count(), 0);
793 793 QCOMPARE(spy2.count(), 0);
794 794 QCOMPARE(spy3.count(), 0);
795 795 QCOMPARE(spy4.count(), 0);
796 796 QCOMPARE(spy5.count(), 0);
797 797 QCOMPARE(spy6.count(), 0);
798 798 QCOMPARE(spy7.count(), 0);
799 799 QCOMPARE(spy8.count(), 1);
800 800 QCOMPARE(m_axis->isVisible(), true);
801 801 }
802 802
803 803 void tst_QAbstractAxis::hide_data()
804 804 {
805 805
806 806 }
807 807
808 808 void tst_QAbstractAxis::hide()
809 809 {
810 810 m_axis->show();
811 811 QCOMPARE(m_axis->isVisible(),true);
812 812
813 813 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
814 814 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
815 QSignalSpy spy2(m_axis, SIGNAL(gridLineVisibleChanged(bool)));
815 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
816 816 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
817 817 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
818 818 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
819 819 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
820 820 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
821 821 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
822 822
823 823 m_axis->hide();
824 824
825 825 QCOMPARE(spy0.count(), 0);
826 826 QCOMPARE(spy1.count(), 0);
827 827 QCOMPARE(spy2.count(), 0);
828 828 QCOMPARE(spy3.count(), 0);
829 829 QCOMPARE(spy4.count(), 0);
830 830 QCOMPARE(spy5.count(), 0);
831 831 QCOMPARE(spy6.count(), 0);
832 832 QCOMPARE(spy7.count(), 0);
833 833 QCOMPARE(spy8.count(), 1);
834 834 QCOMPARE(m_axis->isVisible(),false);
835 835 }
836 836
837 837
838 838
839 839
840 840
841 841
842 842
843 843
844 844
845 845
846 846
847 847
General Comments 0
You need to be logged in to leave comments. Login now