##// END OF EJS Templates
Added grid color property for value axis...
Titta Heikkala -
r2810:2db41b8cb90b
parent child
Show More
@@ -225,6 +225,26 void CartesianChartAxis::handleMinorGridPenChanged(const QPen &pen)
225 225 static_cast<QGraphicsLineItem *>(item)->setPen(pen);
226 226 }
227 227
228 void CartesianChartAxis::handleGridLineColorChanged(const QColor &color)
229 {
230 foreach (QGraphicsItem *item, gridItems()) {
231 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem *>(item);
232 QPen pen = lineItem->pen();
233 pen.setColor(color);
234 lineItem->setPen(pen);
235 }
236 }
237
238 void CartesianChartAxis::handleMinorGridLineColorChanged(const QColor &color)
239 {
240 foreach (QGraphicsItem *item, minorGridItems()) {
241 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem *>(item);
242 QPen pen = lineItem->pen();
243 pen.setColor(color);
244 lineItem->setPen(pen);
245 }
246 }
247
228 248 void CartesianChartAxis::handleShadesBrushChanged(const QBrush &brush)
229 249 {
230 250 foreach (QGraphicsItem *item, shadeItems())
@@ -62,6 +62,8 public Q_SLOTS:
62 62 virtual void handleShadesPenChanged(const QPen &pen);
63 63 virtual void handleMinorArrowPenChanged(const QPen &pen);
64 64 virtual void handleMinorGridPenChanged(const QPen &pen);
65 virtual void handleGridLineColorChanged(const QColor &color);
66 virtual void handleMinorGridLineColorChanged(const QColor &color);
65 67
66 68 private:
67 69 void createItems(int count);
@@ -106,6 +106,10 void ChartAxisElement::connectSlots()
106 106 this, SLOT(handleMinorGridVisibleChanged(bool)));
107 107 QObject::connect(axis(), SIGNAL(minorGridLinePenChanged(const QPen&)),
108 108 this, SLOT(handleMinorGridPenChanged(const QPen&)));
109 QObject::connect(axis(), SIGNAL(gridLineColorChanged(const QColor&)),
110 this, SLOT(handleGridLineColorChanged(const QColor&)));
111 QObject::connect(axis(), SIGNAL(minorGridLineColorChanged(const QColor&)),
112 this, SLOT(handleMinorGridLineColorChanged(const QColor&)));
109 113
110 114 if (axis()->type() == QAbstractAxis::AxisTypeCategory) {
111 115 QCategoryAxis *categoryAxis = static_cast<QCategoryAxis *>(axis());
@@ -122,6 +122,8 public Q_SLOTS:
122 122 virtual void handleGridPenChanged(const QPen &pen) = 0;
123 123 virtual void handleMinorArrowPenChanged(const QPen &pen) = 0;
124 124 virtual void handleMinorGridPenChanged(const QPen &pen) = 0;
125 virtual void handleMinorGridLineColorChanged(const QColor &color) = 0;
126 virtual void handleGridLineColorChanged(const QColor &color) = 0;
125 127 void handleLabelsBrushChanged(const QBrush &brush);
126 128 void handleLabelsFontChanged(const QFont &font);
127 129 void handleTitleBrushChanged(const QBrush &brush);
@@ -356,6 +356,26 void PolarChartAxisAngular::handleMinorGridPenChanged(const QPen &pen)
356 356 static_cast<QGraphicsLineItem *>(item)->setPen(pen);
357 357 }
358 358
359 void PolarChartAxisAngular::handleGridLineColorChanged(const QColor &color)
360 {
361 foreach (QGraphicsItem *item, gridItems()) {
362 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem *>(item);
363 QPen pen = lineItem->pen();
364 pen.setColor(color);
365 lineItem->setPen(pen);
366 }
367 }
368
369 void PolarChartAxisAngular::handleMinorGridLineColorChanged(const QColor &color)
370 {
371 foreach (QGraphicsItem *item, minorGridItems()) {
372 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem *>(item);
373 QPen pen = lineItem->pen();
374 pen.setColor(color);
375 lineItem->setPen(pen);
376 }
377 }
378
359 379 QSizeF PolarChartAxisAngular::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
360 380 {
361 381 Q_UNUSED(which);
@@ -54,6 +54,8 public Q_SLOTS:
54 54 virtual void handleGridPenChanged(const QPen &pen);
55 55 virtual void handleMinorArrowPenChanged(const QPen &pen);
56 56 virtual void handleMinorGridPenChanged(const QPen &pen);
57 virtual void handleGridLineColorChanged(const QColor &color);
58 virtual void handleMinorGridLineColorChanged(const QColor &color);
57 59
58 60 private:
59 61 QRectF moveLabelToPosition(qreal angularCoordinate, QPointF labelPoint, QRectF labelRect) const;
@@ -332,6 +332,26 void PolarChartAxisRadial::handleMinorGridPenChanged(const QPen &pen)
332 332 static_cast<QGraphicsEllipseItem *>(item)->setPen(pen);
333 333 }
334 334
335 void PolarChartAxisRadial::handleGridLineColorChanged(const QColor &color)
336 {
337 foreach (QGraphicsItem *item, gridItems()) {
338 QGraphicsEllipseItem *ellipseItem = static_cast<QGraphicsEllipseItem *>(item);
339 QPen pen = ellipseItem->pen();
340 pen.setColor(color);
341 ellipseItem->setPen(pen);
342 }
343 }
344
345 void PolarChartAxisRadial::handleMinorGridLineColorChanged(const QColor &color)
346 {
347 foreach (QGraphicsItem *item, minorGridItems()) {
348 QGraphicsEllipseItem *ellipseItem = static_cast<QGraphicsEllipseItem *>(item);
349 QPen pen = ellipseItem->pen();
350 pen.setColor(color);
351 ellipseItem->setPen(pen);
352 }
353 }
354
335 355 QSizeF PolarChartAxisRadial::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
336 356 {
337 357 Q_UNUSED(which);
@@ -54,6 +54,8 public Q_SLOTS:
54 54 virtual void handleGridPenChanged(const QPen &pen);
55 55 virtual void handleMinorArrowPenChanged(const QPen &pen);
56 56 virtual void handleMinorGridPenChanged(const QPen &pen);
57 virtual void handleGridLineColorChanged(const QColor &color);
58 virtual void handleMinorGridLineColorChanged(const QColor &color);
57 59 };
58 60
59 61 QT_CHARTS_END_NAMESPACE
@@ -142,6 +142,16 QT_CHARTS_BEGIN_NAMESPACE
142 142 */
143 143
144 144 /*!
145 \property QAbstractAxis::gridLineColor
146 The color of the grid line.
147 */
148
149 /*!
150 \property QAbstractAxis::minorGridLineColor
151 The color of the minor grid line. Applies only to QValueAxis.
152 */
153
154 /*!
145 155 \property QAbstractAxis::labelsFont
146 156 The font of the axis labels.
147 157 */
@@ -359,6 +369,16 QT_CHARTS_BEGIN_NAMESPACE
359 369 */
360 370
361 371 /*!
372 \fn void QAbstractAxis::gridLineColorChanged(const QColor &color)
373 The color of the pen of the grid line has changed to \a color.
374 */
375
376 /*!
377 \fn void QAbstractAxis::minorGridLineColorChanged(const QColor &color)
378 The color of the pen of the minor grid line has changed to \a color.
379 */
380
381 /*!
362 382 \fn void QAbstractAxis::colorChanged(QColor color)
363 383 Emitted if the \a color of the axis is changed.
364 384 */
@@ -584,6 +604,36 QPen QAbstractAxis::minorGridLinePen() const
584 604 return d_ptr->m_minorGridLinePen;
585 605 }
586 606
607 void QAbstractAxis::setGridLineColor(const QColor &color)
608 {
609 QPen pen = d_ptr->m_gridLinePen;
610 if (color != pen.color()) {
611 pen.setColor(color);
612 d_ptr->m_gridLinePen = pen;
613 emit gridLineColorChanged(color);
614 }
615 }
616
617 QColor QAbstractAxis::gridLineColor()
618 {
619 return d_ptr->m_gridLinePen.color();
620 }
621
622 void QAbstractAxis::setMinorGridLineColor(const QColor &color)
623 {
624 QPen pen = d_ptr->m_minorGridLinePen;
625 if (color != pen.color()) {
626 pen.setColor(color);
627 d_ptr->m_minorGridLinePen = pen;
628 emit minorGridLineColorChanged(color);
629 }
630 }
631
632 QColor QAbstractAxis::minorGridLineColor()
633 {
634 return d_ptr->m_minorGridLinePen.color();
635 }
636
587 637 void QAbstractAxis::setLabelsVisible(bool visible)
588 638 {
589 639 if (d_ptr->m_labelsVisible != visible) {
@@ -48,6 +48,8 class QT_CHARTS_EXPORT QAbstractAxis : public QObject
48 48 Q_PROPERTY(QPen gridLinePen READ gridLinePen WRITE setGridLinePen NOTIFY gridLinePenChanged)
49 49 Q_PROPERTY(bool minorGridVisible READ isMinorGridLineVisible WRITE setMinorGridLineVisible NOTIFY minorGridVisibleChanged)
50 50 Q_PROPERTY(QPen minorGridLinePen READ minorGridLinePen WRITE setMinorGridLinePen NOTIFY minorGridLinePenChanged)
51 Q_PROPERTY(QColor gridLineColor READ gridLineColor WRITE setGridLineColor NOTIFY gridLineColorChanged)
52 Q_PROPERTY(QColor minorGridLineColor READ minorGridLineColor WRITE setMinorGridLineColor NOTIFY minorGridLineColorChanged)
51 53 //shades
52 54 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
53 55 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
@@ -109,6 +111,10 public:
109 111 void setMinorGridLineVisible(bool visible = true);
110 112 void setMinorGridLinePen(const QPen &pen);
111 113 QPen minorGridLinePen() const;
114 void setGridLineColor(const QColor &color);
115 QColor gridLineColor();
116 void setMinorGridLineColor(const QColor &color);
117 QColor minorGridLineColor();
112 118
113 119 //labels handling
114 120 bool labelsVisible() const;
@@ -168,6 +174,8 Q_SIGNALS:
168 174 void gridVisibleChanged(bool visible);
169 175 void minorGridVisibleChanged(bool visible);
170 176 void minorGridLinePenChanged(const QPen &pen);
177 void gridLineColorChanged(const QColor &color);
178 void minorGridLineColorChanged(const QColor &color);
171 179 void colorChanged(QColor color);
172 180 void labelsColorChanged(QColor color);
173 181 void titleTextChanged(const QString &title);
@@ -2027,6 +2027,8 Module {
2027 2027 Property { name: "gridLinePen"; type: "QPen" }
2028 2028 Property { name: "minorGridVisible"; type: "bool" }
2029 2029 Property { name: "minorGridLinePen"; type: "QPen" }
2030 Property { name: "gridLineColor"; type: "QColor" }
2031 Property { name: "minorGridLineColor"; type: "QColor" }
2030 2032 Property { name: "shadesVisible"; type: "bool" }
2031 2033 Property { name: "shadesColor"; type: "QColor" }
2032 2034 Property { name: "shadesBorderColor"; type: "QColor" }
@@ -2084,6 +2086,14 Module {
2084 2086 Parameter { name: "pen"; type: "QPen" }
2085 2087 }
2086 2088 Signal {
2089 name: "gridLineColorChanged"
2090 Parameter { name: "color"; type: "QColor" }
2091 }
2092 Signal {
2093 name: "minorGridLineColorChanged"
2094 Parameter { name: "color"; type: "QColor" }
2095 }
2096 Signal {
2087 2097 name: "colorChanged"
2088 2098 Parameter { name: "color"; type: "QColor" }
2089 2099 }
@@ -65,6 +65,8 void tst_QAbstractAxis::qabstractaxis()
65 65 m_axis->setLinePenColor(QColor());
66 66 m_axis->setGridLinePen(QPen());
67 67 m_axis->setGridLineVisible(false);
68 m_axis->setGridLineColor(QColor());
69 m_axis->setMinorGridLineColor(QColor());
68 70 m_axis->setLabelsAngle(-1);
69 71 m_axis->setLabelsBrush(QBrush());
70 72 m_axis->setLabelsColor(QColor());
@@ -111,6 +113,8 void tst_QAbstractAxis::axisPen()
111 113 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
112 114 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
113 115 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
116 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
117 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
114 118
115 119 m_axis->setLinePen(axisPen);
116 120 QCOMPARE(m_axis->linePen(), axisPen);
@@ -125,6 +129,8 void tst_QAbstractAxis::axisPen()
125 129 QCOMPARE(spy7.count(), 0);
126 130 QCOMPARE(spy8.count(), 0);
127 131 QCOMPARE(spy9.count(), 0);
132 QCOMPARE(spy10.count(), 0);
133 QCOMPARE(spy11.count(), 0);
128 134
129 135 m_chart->setAxisX(m_axis, m_series);
130 136 m_view->show();
@@ -165,6 +171,9 void tst_QAbstractAxis::gridLinePen()
165 171 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
166 172 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
167 173 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
174 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
175 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
176 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
168 177
169 178 m_axis->setGridLinePen(gridLinePen);
170 179 QCOMPARE(m_axis->gridLinePen(), gridLinePen);
@@ -178,6 +187,9 void tst_QAbstractAxis::gridLinePen()
178 187 QCOMPARE(spy6.count(), 0);
179 188 QCOMPARE(spy7.count(), 0);
180 189 QCOMPARE(spy8.count(), 0);
190 QCOMPARE(spy9.count(), 0);
191 QCOMPARE(spy10.count(), 0);
192 QCOMPARE(spy11.count(), 0);
181 193
182 194 m_chart->setAxisX(m_axis, m_series);
183 195 m_view->show();
@@ -210,6 +222,8 void tst_QAbstractAxis::minorGridLinePen()
210 222 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
211 223 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
212 224 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
225 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
226 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
213 227
214 228 m_axis->setMinorGridLinePen(minorGridLinePen);
215 229 QCOMPARE(m_axis->minorGridLinePen(), minorGridLinePen);
@@ -224,6 +238,8 void tst_QAbstractAxis::minorGridLinePen()
224 238 QCOMPARE(spy7.count(), 0);
225 239 QCOMPARE(spy8.count(), 0);
226 240 QCOMPARE(spy9.count(), 0);
241 QCOMPARE(spy10.count(), 0);
242 QCOMPARE(spy11.count(), 0);
227 243
228 244 m_chart->setAxisX(m_axis, m_series);
229 245 m_view->show();
@@ -254,6 +270,8 void tst_QAbstractAxis::lineVisible()
254 270 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
255 271 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
256 272 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
273 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
274 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
257 275
258 276 m_axis->setLineVisible(lineVisible);
259 277 QCOMPARE(m_axis->isLineVisible(), lineVisible);
@@ -268,6 +286,8 void tst_QAbstractAxis::lineVisible()
268 286 QCOMPARE(spy7.count(), 0);
269 287 QCOMPARE(spy8.count(), 0);
270 288 QCOMPARE(spy9.count(), 0);
289 QCOMPARE(spy10.count(), 0);
290 QCOMPARE(spy11.count(), 0);
271 291
272 292 m_chart->setAxisX(m_axis, m_series);
273 293 m_view->show();
@@ -297,6 +317,7 void tst_QAbstractAxis::gridLineVisible()
297 317 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
298 318 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
299 319 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
320 QSignalSpy spy9(m_axis, SIGNAL(gridLineColorChanged(QColor)));
300 321
301 322 m_axis->setGridLineVisible(gridLineVisible);
302 323 QCOMPARE(m_axis->isGridLineVisible(), gridLineVisible);
@@ -310,6 +331,7 void tst_QAbstractAxis::gridLineVisible()
310 331 QCOMPARE(spy6.count(), 0);
311 332 QCOMPARE(spy7.count(), 0);
312 333 QCOMPARE(spy8.count(), 0);
334 QCOMPARE(spy9.count(), 0);
313 335
314 336 m_chart->setAxisX(m_axis, m_series);
315 337 m_view->show();
@@ -341,6 +363,8 void tst_QAbstractAxis::minorGridLineVisible()
341 363 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
342 364 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
343 365 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
366 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
367 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
344 368
345 369 m_axis->setMinorGridLineVisible(minorGridLineVisible);
346 370 QCOMPARE(m_axis->isMinorGridLineVisible(), minorGridLineVisible);
@@ -355,6 +379,8 void tst_QAbstractAxis::minorGridLineVisible()
355 379 QCOMPARE(spy7.count(), 0);
356 380 QCOMPARE(spy8.count(), 0);
357 381 QCOMPARE(spy9.count(), 1);
382 QCOMPARE(spy10.count(), 0);
383 QCOMPARE(spy11.count(), 0);
358 384
359 385 m_chart->setAxisX(m_axis, m_series);
360 386 m_view->show();
@@ -363,6 +389,100 void tst_QAbstractAxis::minorGridLineVisible()
363 389
364 390 }
365 391
392 void tst_QAbstractAxis::gridLineColor_data()
393 {
394 QTest::addColumn<QColor>("gridLineColor");
395 QTest::newRow("blue") << QColor(Qt::blue);
396 QTest::newRow("red") << QColor(Qt::red);
397 QTest::newRow("yellow") << QColor(Qt::yellow);
398 }
399
400 void tst_QAbstractAxis::gridLineColor()
401 {
402 QFETCH(QColor, gridLineColor);
403
404 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
405 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
406 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
407 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
408 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
409 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
410 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
411 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
412 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
413 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
414 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
415 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
416
417 m_axis->setGridLineColor(gridLineColor);
418 QCOMPARE(m_axis->gridLineColor(), gridLineColor);
419
420 QCOMPARE(spy0.count(), 0);
421 QCOMPARE(spy1.count(), 0);
422 QCOMPARE(spy2.count(), 0);
423 QCOMPARE(spy3.count(), 0);
424 QCOMPARE(spy4.count(), 0);
425 QCOMPARE(spy5.count(), 0);
426 QCOMPARE(spy6.count(), 0);
427 QCOMPARE(spy7.count(), 0);
428 QCOMPARE(spy8.count(), 0);
429 QCOMPARE(spy9.count(), 0);
430 QCOMPARE(spy10.count(), 1);
431 QCOMPARE(spy11.count(), 0);
432
433 m_chart->setAxisX(m_axis, m_series);
434 m_view->show();
435 QTest::qWaitForWindowShown(m_view);
436
437 }
438
439 void tst_QAbstractAxis::minorGridLineColor_data()
440 {
441 QTest::addColumn<QColor>("minorGridLineColor");
442 QTest::newRow("blue") << QColor(Qt::blue);
443 QTest::newRow("red") << QColor(Qt::red);
444 QTest::newRow("yellow") << QColor(Qt::yellow);
445 }
446
447 void tst_QAbstractAxis::minorGridLineColor()
448 {
449 QFETCH(QColor, minorGridLineColor);
450
451 QSignalSpy spy0(m_axis, SIGNAL(lineVisibleChanged(bool)));
452 QSignalSpy spy1(m_axis, SIGNAL(colorChanged(QColor)));
453 QSignalSpy spy2(m_axis, SIGNAL(gridVisibleChanged(bool)));
454 QSignalSpy spy3(m_axis, SIGNAL(labelsColorChanged(QColor)));
455 QSignalSpy spy4(m_axis, SIGNAL(labelsVisibleChanged(bool)));
456 QSignalSpy spy5(m_axis, SIGNAL(shadesBorderColorChanged(QColor)));
457 QSignalSpy spy6(m_axis, SIGNAL(shadesColorChanged(QColor)));
458 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
459 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
460 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
461 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
462 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
463
464 m_axis->setMinorGridLineColor(minorGridLineColor);
465 QCOMPARE(m_axis->minorGridLineColor(), minorGridLineColor);
466
467 QCOMPARE(spy0.count(), 0);
468 QCOMPARE(spy1.count(), 0);
469 QCOMPARE(spy2.count(), 0);
470 QCOMPARE(spy3.count(), 0);
471 QCOMPARE(spy4.count(), 0);
472 QCOMPARE(spy5.count(), 0);
473 QCOMPARE(spy6.count(), 0);
474 QCOMPARE(spy7.count(), 0);
475 QCOMPARE(spy8.count(), 0);
476 QCOMPARE(spy9.count(), 0);
477 QCOMPARE(spy10.count(), 0);
478 QCOMPARE(spy11.count(), 1);
479
480 m_chart->setAxisX(m_axis, m_series);
481 m_view->show();
482 QTest::qWaitForWindowShown(m_view);
483
484 }
485
366 486 void tst_QAbstractAxis::visible_data()
367 487 {
368 488 QTest::addColumn<bool>("visible");
@@ -386,6 +506,8 void tst_QAbstractAxis::visible()
386 506 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
387 507 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
388 508 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
509 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
510 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
389 511
390 512 m_axis->setVisible(visible);
391 513 QCOMPARE(m_axis->isVisible(), visible);
@@ -400,6 +522,8 void tst_QAbstractAxis::visible()
400 522 QCOMPARE(spy7.count(), 0);
401 523 QCOMPARE(spy8.count(), 1);
402 524 QCOMPARE(spy9.count(), 0);
525 QCOMPARE(spy10.count(), 0);
526 QCOMPARE(spy11.count(), 0);
403 527
404 528 m_chart->setAxisX(m_axis, m_series);
405 529 m_view->show();
@@ -429,6 +553,8 void tst_QAbstractAxis::labelsAngle()
429 553 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
430 554 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
431 555 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
556 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
557 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
432 558
433 559 m_axis->setLabelsAngle(labelsAngle);
434 560 QCOMPARE(m_axis->labelsAngle(), labelsAngle);
@@ -443,6 +569,8 void tst_QAbstractAxis::labelsAngle()
443 569 QCOMPARE(spy7.count(), 0);
444 570 QCOMPARE(spy8.count(), 0);
445 571 QCOMPARE(spy9.count(), 0);
572 QCOMPARE(spy10.count(), 0);
573 QCOMPARE(spy11.count(), 0);
446 574
447 575 m_chart->setAxisX(m_axis, m_series);
448 576 m_view->show();
@@ -474,6 +602,8 void tst_QAbstractAxis::labelsBrush()
474 602 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
475 603 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
476 604 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
605 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
606 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
477 607
478 608 m_axis->setLabelsBrush(labelsBrush);
479 609 QCOMPARE(m_axis->labelsBrush(), labelsBrush);
@@ -488,6 +618,8 void tst_QAbstractAxis::labelsBrush()
488 618 QCOMPARE(spy7.count(), 0);
489 619 QCOMPARE(spy8.count(), 0);
490 620 QCOMPARE(spy9.count(), 0);
621 QCOMPARE(spy10.count(), 0);
622 QCOMPARE(spy11.count(), 0);
491 623
492 624 m_view->show();
493 625 QTest::qWaitForWindowShown(m_view);
@@ -527,6 +659,8 void tst_QAbstractAxis::labelsFont()
527 659 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
528 660 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
529 661 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
662 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
663 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
530 664
531 665 m_axis->setLabelsFont(labelsFont);
532 666 QCOMPARE(m_axis->labelsFont(), labelsFont);
@@ -541,6 +675,8 void tst_QAbstractAxis::labelsFont()
541 675 QCOMPARE(spy7.count(), 0);
542 676 QCOMPARE(spy8.count(), 0);
543 677 QCOMPARE(spy9.count(), 0);
678 QCOMPARE(spy10.count(), 0);
679 QCOMPARE(spy11.count(), 0);
544 680
545 681 m_view->show();
546 682 QTest::qWaitForWindowShown(m_view);
@@ -571,6 +707,8 void tst_QAbstractAxis::labelsVisible()
571 707 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
572 708 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
573 709 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
710 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
711 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
574 712
575 713 m_axis->setLabelsVisible(labelsVisible);
576 714 QCOMPARE(m_axis->labelsVisible(), labelsVisible);
@@ -585,6 +723,8 void tst_QAbstractAxis::labelsVisible()
585 723 QCOMPARE(spy7.count(), 0);
586 724 QCOMPARE(spy8.count(), 0);
587 725 QCOMPARE(spy9.count(), 0);
726 QCOMPARE(spy10.count(), 0);
727 QCOMPARE(spy11.count(), 0);
588 728
589 729 m_chart->setAxisX(m_axis, m_series);
590 730 m_view->show();
@@ -613,6 +753,8 void tst_QAbstractAxis::orientation()
613 753 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
614 754 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
615 755 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
756 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
757 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
616 758
617 759 if(orientation==Qt::Vertical){
618 760 m_chart->setAxisY(m_axis,m_series);
@@ -631,6 +773,8 void tst_QAbstractAxis::orientation()
631 773 QCOMPARE(spy7.count(), 0);
632 774 QCOMPARE(spy8.count(), 0);
633 775 QCOMPARE(spy9.count(), 0);
776 QCOMPARE(spy10.count(), 0);
777 QCOMPARE(spy11.count(), 0);
634 778
635 779 m_view->show();
636 780 QTest::qWaitForWindowShown(m_view);
@@ -716,6 +860,8 void tst_QAbstractAxis::shadesBrush()
716 860 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
717 861 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
718 862 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
863 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
864 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
719 865
720 866 m_axis->setShadesBrush(shadesBrush);
721 867 QCOMPARE(m_axis->shadesBrush(), shadesBrush);
@@ -730,6 +876,8 void tst_QAbstractAxis::shadesBrush()
730 876 QCOMPARE(spy7.count(), 0);
731 877 QCOMPARE(spy8.count(), 0);
732 878 QCOMPARE(spy9.count(), 0);
879 QCOMPARE(spy10.count(), 0);
880 QCOMPARE(spy11.count(), 0);
733 881
734 882 m_view->show();
735 883 QTest::qWaitForWindowShown(m_view);
@@ -769,6 +917,8 void tst_QAbstractAxis::shadesPen()
769 917 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
770 918 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
771 919 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
920 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
921 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
772 922
773 923 m_axis->setShadesPen(shadesPen);
774 924 QCOMPARE(m_axis->shadesPen(), shadesPen);
@@ -783,6 +933,8 void tst_QAbstractAxis::shadesPen()
783 933 QCOMPARE(spy7.count(), 0);
784 934 QCOMPARE(spy8.count(), 0);
785 935 QCOMPARE(spy9.count(), 0);
936 QCOMPARE(spy10.count(), 0);
937 QCOMPARE(spy11.count(), 0);
786 938
787 939 m_chart->setAxisX(m_axis, m_series);
788 940 m_view->show();
@@ -813,6 +965,8 void tst_QAbstractAxis::shadesVisible()
813 965 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
814 966 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
815 967 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
968 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
969 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
816 970
817 971 m_axis->setShadesVisible(shadesVisible);
818 972 QCOMPARE(m_axis->shadesVisible(), shadesVisible);
@@ -827,6 +981,8 void tst_QAbstractAxis::shadesVisible()
827 981 QCOMPARE(spy7.count(), 1);
828 982 QCOMPARE(spy8.count(), 0);
829 983 QCOMPARE(spy9.count(), 0);
984 QCOMPARE(spy10.count(), 0);
985 QCOMPARE(spy11.count(), 0);
830 986
831 987 m_chart->setAxisX(m_axis, m_series);
832 988 m_view->show();
@@ -854,6 +1010,8 void tst_QAbstractAxis::show()
854 1010 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
855 1011 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
856 1012 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
1013 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
1014 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
857 1015
858 1016 m_axis->show();
859 1017
@@ -867,6 +1025,8 void tst_QAbstractAxis::show()
867 1025 QCOMPARE(spy7.count(), 0);
868 1026 QCOMPARE(spy8.count(), 1);
869 1027 QCOMPARE(spy9.count(), 0);
1028 QCOMPARE(spy10.count(), 0);
1029 QCOMPARE(spy11.count(), 0);
870 1030 QCOMPARE(m_axis->isVisible(), true);
871 1031 }
872 1032
@@ -890,6 +1050,8 void tst_QAbstractAxis::hide()
890 1050 QSignalSpy spy7(m_axis, SIGNAL(shadesVisibleChanged(bool)));
891 1051 QSignalSpy spy8(m_axis, SIGNAL(visibleChanged(bool)));
892 1052 QSignalSpy spy9(m_axis, SIGNAL(minorGridVisibleChanged(bool)));
1053 QSignalSpy spy10(m_axis, SIGNAL(gridLineColorChanged(QColor)));
1054 QSignalSpy spy11(m_axis, SIGNAL(minorGridLineColorChanged(QColor)));
893 1055
894 1056 m_axis->hide();
895 1057
@@ -903,6 +1065,8 void tst_QAbstractAxis::hide()
903 1065 QCOMPARE(spy7.count(), 0);
904 1066 QCOMPARE(spy8.count(), 1);
905 1067 QCOMPARE(spy9.count(), 0);
1068 QCOMPARE(spy10.count(), 0);
1069 QCOMPARE(spy11.count(), 0);
906 1070 QCOMPARE(m_axis->isVisible(),false);
907 1071 }
908 1072
@@ -51,6 +51,10 private slots:
51 51 void gridLineVisible();
52 52 void minorGridLineVisible_data();
53 53 void minorGridLineVisible();
54 void gridLineColor_data();
55 void gridLineColor();
56 void minorGridLineColor_data();
57 void minorGridLineColor();
54 58 void visible_data();
55 59 void visible();
56 60 void labelsAngle_data();
@@ -169,6 +169,8 MainWindow::MainWindow(QWidget *parent) :
169 169 this, SLOT(gridIndexChanged(int)));
170 170 connect(ui->minorGridComboBox, SIGNAL(currentIndexChanged(int)),
171 171 this, SLOT(minorGridIndexChanged(int)));
172 connect(ui->gridLineColorComboBox, SIGNAL(currentIndexChanged(int)),
173 this, SLOT(gridLineColorIndexChanged(int)));
172 174 connect(ui->arrowComboBox, SIGNAL(currentIndexChanged(int)),
173 175 this, SLOT(arrowIndexChanged(int)));
174 176 connect(ui->logBaseSpin, SIGNAL(valueChanged(double)),
@@ -956,6 +958,29 void MainWindow::minorGridIndexChanged(int index)
956 958 m_radialAxis->setMinorGridLineVisible(m_minorGridVisible);
957 959 }
958 960
961 void MainWindow::gridLineColorIndexChanged(int index)
962 {
963 QColor color;
964 switch (index) {
965 case 0:
966 color = Qt::black;
967 break;
968 case 1:
969 color = Qt::green;
970 break;
971 case 2:
972 color = Qt::red;
973 break;
974 default:
975 break;
976 }
977
978 m_angularAxis->setGridLineColor(color);
979 m_radialAxis->setGridLineColor(color);
980 m_angularAxis->setMinorGridLineColor(color);
981 m_radialAxis->setMinorGridLineColor(color);
982 }
983
959 984 void MainWindow::arrowIndexChanged(int index)
960 985 {
961 986 delete m_arrowPen;
@@ -70,6 +70,7 public slots:
70 70 void titleFontSizeChanged(int value);
71 71 void gridIndexChanged(int index);
72 72 void minorGridIndexChanged(int index);
73 void gridLineColorIndexChanged(int index);
73 74 void arrowIndexChanged(int index);
74 75 void angularRangeChanged(qreal min, qreal max);
75 76 void radialRangeChanged(qreal min, qreal max);
@@ -335,7 +335,7
335 335 <property name="geometry">
336 336 <rect>
337 337 <x>10</x>
338 <y>814</y>
338 <y>810</y>
339 339 <width>131</width>
340 340 <height>20</height>
341 341 </rect>
@@ -394,7 +394,7
394 394 <property name="geometry">
395 395 <rect>
396 396 <x>10</x>
397 <y>840</y>
397 <y>830</y>
398 398 <width>117</width>
399 399 <height>16</height>
400 400 </rect>
@@ -689,7 +689,7
689 689 <rect>
690 690 <x>10</x>
691 691 <y>680</y>
692 <width>191</width>
692 <width>198</width>
693 693 <height>31</height>
694 694 </rect>
695 695 </property>
@@ -714,7 +714,7
714 714 <property name="geometry">
715 715 <rect>
716 716 <x>10</x>
717 <y>740</y>
717 <y>730</y>
718 718 <width>221</width>
719 719 <height>22</height>
720 720 </rect>
@@ -736,7 +736,7
736 736 <property name="geometry">
737 737 <rect>
738 738 <x>10</x>
739 <y>766</y>
739 <y>760</y>
740 740 <width>136</width>
741 741 <height>42</height>
742 742 </rect>
@@ -912,6 +912,40
912 912 <string>Category Label On Tick</string>
913 913 </property>
914 914 </widget>
915 <widget class="QComboBox" name="gridLineColorComboBox">
916 <property name="geometry">
917 <rect>
918 <x>10</x>
919 <y>850</y>
920 <width>133</width>
921 <height>20</height>
922 </rect>
923 </property>
924 <property name="sizePolicy">
925 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
926 <horstretch>0</horstretch>
927 <verstretch>0</verstretch>
928 </sizepolicy>
929 </property>
930 <property name="currentIndex">
931 <number>0</number>
932 </property>
933 <item>
934 <property name="text">
935 <string>Black grid line</string>
936 </property>
937 </item>
938 <item>
939 <property name="text">
940 <string>Green grid line</string>
941 </property>
942 </item>
943 <item>
944 <property name="text">
945 <string>Red grid line</string>
946 </property>
947 </item>
948 </widget>
915 949 </widget>
916 950 </item>
917 951 </layout>
@@ -72,11 +72,16 ChartView {
72 72
73 73 ValueAxis{
74 74 id: axisX
75 minorGridVisible: false
76 minorTickCount: 2
75 77 onColorChanged: console.log("axisX.onColorChanged: " + color);
76 78 onLabelsVisibleChanged: console.log("axisX.onLabelsVisibleChanged: " + visible);
77 79 onLabelsColorChanged: console.log("axisX.onLabelsColorChanged: " + color);
78 80 onVisibleChanged: console.log("axisX.onVisibleChanged: " + visible);
79 81 onGridVisibleChanged: console.log("axisX.onGridVisibleChanged: " + visible);
82 onMinorGridVisibleChanged: console.log("axisX.onMinorGridVisibleChanged: " + visible);
83 onGridLineColorChanged: console.log("axisX.onGridLineColorChanged: " + color);
84 onMinorGridLineColorChanged: console.log("axisX.onMinorGridLineColorChanged: " + color);
80 85 onShadesVisibleChanged: console.log("axisX.onShadesVisibleChanged: " + visible);
81 86 onShadesColorChanged: console.log("axisX.onShadesColorChanged: " + color);
82 87 onShadesBorderColorChanged: console.log("axisX.onShadesBorderColorChanged: " + color);
@@ -87,11 +92,16 ChartView {
87 92
88 93 ValueAxis{
89 94 id: axisY
95 minorGridVisible: false
96 minorTickCount: 2
90 97 onColorChanged: console.log("axisY.onColorChanged: " + color);
91 98 onLabelsVisibleChanged: console.log("axisY.onLabelsVisibleChanged: " + visible);
92 99 onLabelsColorChanged: console.log("axisY.onLabelsColorChanged: " + color);
93 100 onVisibleChanged: console.log("axisY.onVisibleChanged: " + visible);
94 101 onGridVisibleChanged: console.log("axisY.onGridVisibleChanged: " + visible);
102 onMinorGridVisibleChanged: console.log("axisX.onMinorGridVisibleChanged: " + visible);
103 onGridLineColorChanged: console.log("axisX.onGridLineColorChanged: " + color);
104 onMinorGridLineColorChanged: console.log("axisX.onMinorGridLineColorChanged: " + color);
95 105 onShadesVisibleChanged: console.log("axisY.onShadesVisibleChanged: " + visible);
96 106 onShadesColorChanged: console.log("axisY.onShadesColorChanged: " + color);
97 107 onShadesBorderColorChanged: console.log("axisY.onShadesBorderColorChanged: " + color);
@@ -65,6 +65,14 Row {
65 65 onClicked: axis.minorGridVisible = !axis.minorGridVisible;
66 66 }
67 67 Button {
68 text: "axis grid color"
69 onClicked: axis.gridLineColor = main.nextColor();
70 }
71 Button {
72 text: "axis minor grid color"
73 onClicked: axis.minorGridLineColor = main.nextColor();
74 }
75 Button {
68 76 text: "axis shades visible"
69 77 onClicked: axis.shadesVisible = !axis.shadesVisible;
70 78 }
General Comments 0
You need to be logged in to leave comments. Login now