##// END OF EJS Templates
Fix deprecation errors from Qt5
Jani Honkonen -
r2241:9223452f638c
parent child
Show More
@@ -31,21 +31,21 BrushTool::BrushTool(QString title, QWidget *parent)
31
31
32 m_colorButton = new QPushButton();
32 m_colorButton = new QPushButton();
33 m_styleCombo = new QComboBox();
33 m_styleCombo = new QComboBox();
34 m_styleCombo->addItem("Nobrush", Qt::NoBrush);
34 m_styleCombo->addItem("Nobrush", (int) Qt::NoBrush);
35 m_styleCombo->addItem("Solidpattern", Qt::SolidPattern);
35 m_styleCombo->addItem("Solidpattern", (int) Qt::SolidPattern);
36 m_styleCombo->addItem("Dense1pattern", Qt::Dense1Pattern);
36 m_styleCombo->addItem("Dense1pattern", (int) Qt::Dense1Pattern);
37 m_styleCombo->addItem("Dense2attern", Qt::Dense2Pattern);
37 m_styleCombo->addItem("Dense2attern", (int) Qt::Dense2Pattern);
38 m_styleCombo->addItem("Dense3Pattern", Qt::Dense3Pattern);
38 m_styleCombo->addItem("Dense3Pattern", (int) Qt::Dense3Pattern);
39 m_styleCombo->addItem("Dense4Pattern", Qt::Dense4Pattern);
39 m_styleCombo->addItem("Dense4Pattern", (int) Qt::Dense4Pattern);
40 m_styleCombo->addItem("Dense5Pattern", Qt::Dense5Pattern);
40 m_styleCombo->addItem("Dense5Pattern", (int) Qt::Dense5Pattern);
41 m_styleCombo->addItem("Dense6Pattern", Qt::Dense6Pattern);
41 m_styleCombo->addItem("Dense6Pattern", (int) Qt::Dense6Pattern);
42 m_styleCombo->addItem("Dense7Pattern", Qt::Dense7Pattern);
42 m_styleCombo->addItem("Dense7Pattern", (int) Qt::Dense7Pattern);
43 m_styleCombo->addItem("HorPattern", Qt::HorPattern);
43 m_styleCombo->addItem("HorPattern", (int) Qt::HorPattern);
44 m_styleCombo->addItem("VerPattern", Qt::VerPattern);
44 m_styleCombo->addItem("VerPattern", (int) Qt::VerPattern);
45 m_styleCombo->addItem("CrossPattern", Qt::CrossPattern);
45 m_styleCombo->addItem("CrossPattern", (int) Qt::CrossPattern);
46 m_styleCombo->addItem("BDiagPattern", Qt::BDiagPattern);
46 m_styleCombo->addItem("BDiagPattern", (int) Qt::BDiagPattern);
47 m_styleCombo->addItem("FDiagPattern", Qt::FDiagPattern);
47 m_styleCombo->addItem("FDiagPattern", (int) Qt::FDiagPattern);
48 m_styleCombo->addItem("DiagCrossPattern", Qt::DiagCrossPattern);
48 m_styleCombo->addItem("DiagCrossPattern", (int) Qt::DiagCrossPattern);
49
49
50 QFormLayout *layout = new QFormLayout();
50 QFormLayout *layout = new QFormLayout();
51 layout->addRow("Color", m_colorButton);
51 layout->addRow("Color", m_colorButton);
@@ -48,8 +48,13 TableWidget::TableWidget(QWidget *parent)
48 QTableView *tableView = new QTableView;
48 QTableView *tableView = new QTableView;
49 tableView->setModel(model);
49 tableView->setModel(model);
50 tableView->setMinimumWidth(300);
50 tableView->setMinimumWidth(300);
51 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
52 tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
53 tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
54 #else
51 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
55 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
52 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
56 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
57 #endif
53 //! [2]
58 //! [2]
54
59
55 //! [3]
60 //! [3]
@@ -43,8 +43,13 TableWidget::TableWidget(QWidget *parent)
43 // create table view and add model to it
43 // create table view and add model to it
44 QTableView *tableView = new QTableView;
44 QTableView *tableView = new QTableView;
45 tableView->setModel(model);
45 tableView->setModel(model);
46 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
47 tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
48 tableView->verticalHeader()->setSectionResizeMode(QHeaderView::Stretch);
49 #else
46 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
50 tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
47 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
51 tableView->verticalHeader()->setResizeMode(QHeaderView::Stretch);
52 #endif
48 //! [2]
53 //! [2]
49
54
50 //! [3]
55 //! [3]
@@ -50,7 +50,7 QVariant AbstractBarAnimation::interpolated(const QVariant &from, const QVariant
50
50
51 void AbstractBarAnimation::updateCurrentValue(const QVariant &value)
51 void AbstractBarAnimation::updateCurrentValue(const QVariant &value)
52 {
52 {
53 QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value);
53 QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value);
54 m_item->setLayout(layout);
54 m_item->setLayout(layout);
55 }
55 }
56
56
@@ -113,8 +113,8 void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayo
113
113
114 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
114 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
115 {
115 {
116 QVector<qreal> startVector = qVariantValue<QVector<qreal> >(start);
116 QVector<qreal> startVector = qvariant_cast<QVector<qreal> >(start);
117 QVector<qreal> endVecotr = qVariantValue<QVector<qreal> >(end);
117 QVector<qreal> endVecotr = qvariant_cast<QVector<qreal> >(end);
118 QVector<qreal> result;
118 QVector<qreal> result;
119
119
120 Q_ASSERT(startVector.count() == endVecotr.count()) ;
120 Q_ASSERT(startVector.count() == endVecotr.count()) ;
@@ -130,7 +130,7 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end,
130 void AxisAnimation::updateCurrentValue(const QVariant &value)
130 void AxisAnimation::updateCurrentValue(const QVariant &value)
131 {
131 {
132 if (state() != QAbstractAnimation::Stopped) { //workaround
132 if (state() != QAbstractAnimation::Stopped) { //workaround
133 QVector<qreal> vector = qVariantValue<QVector<qreal> >(value);
133 QVector<qreal> vector = qvariant_cast<QVector<qreal> >(value);
134 Q_ASSERT(vector.count() != 0);
134 Q_ASSERT(vector.count() != 0);
135 m_axis->setLayout(vector);
135 m_axis->setLayout(vector);
136 m_axis->updateGeometry();
136 m_axis->updateGeometry();
@@ -38,8 +38,8 BarAnimation::~BarAnimation()
38
38
39 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
39 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 {
40 {
41 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
41 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
42 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
42 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
43 QVector<QRectF> result;
43 QVector<QRectF> result;
44
44
45 Q_ASSERT(startVector.count() == endVector.count());
45 Q_ASSERT(startVector.count() == endVector.count());
@@ -39,8 +39,8 HorizontalBarAnimation::~HorizontalBarAnimation()
39
39
40 QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 QVariant HorizontalBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
41 {
41 {
42 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
42 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
43 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
43 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
44 QVector<QRectF> result;
44 QVector<QRectF> result;
45
45
46 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
@@ -39,8 +39,8 HorizontalPercentBarAnimation::~HorizontalPercentBarAnimation()
39
39
40 QVariant HorizontalPercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 QVariant HorizontalPercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
41 {
41 {
42 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
42 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
43 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
43 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
44 QVector<QRectF> result;
44 QVector<QRectF> result;
45
45
46 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
@@ -39,8 +39,8 HorizontalStackedBarAnimation::~HorizontalStackedBarAnimation()
39
39
40 QVariant HorizontalStackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 QVariant HorizontalStackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
41 {
41 {
42 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
42 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
43 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
43 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
44 QVector<QRectF> result;
44 QVector<QRectF> result;
45
45
46 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
@@ -39,8 +39,8 PercentBarAnimation::~PercentBarAnimation()
39
39
40 QVariant PercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 QVariant PercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
41 {
41 {
42 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
42 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
43 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
43 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
44 QVector<QRectF> result;
44 QVector<QRectF> result;
45
45
46 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
@@ -99,8 +99,8 PieSliceData PieSliceAnimation::currentSliceValue()
99
99
100 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
100 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
101 {
101 {
102 PieSliceData startValue = qVariantValue<PieSliceData>(start);
102 PieSliceData startValue = qvariant_cast<PieSliceData>(start);
103 PieSliceData endValue = qVariantValue<PieSliceData>(end);
103 PieSliceData endValue = qvariant_cast<PieSliceData>(end);
104
104
105 PieSliceData result;
105 PieSliceData result;
106 result = endValue;
106 result = endValue;
@@ -118,7 +118,7 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &
118 void PieSliceAnimation::updateCurrentValue(const QVariant &value)
118 void PieSliceAnimation::updateCurrentValue(const QVariant &value)
119 {
119 {
120 if (state() != QAbstractAnimation::Stopped) { //workaround
120 if (state() != QAbstractAnimation::Stopped) { //workaround
121 m_currentValue = qVariantValue<PieSliceData>(value);
121 m_currentValue = qvariant_cast<PieSliceData>(value);
122 m_sliceItem->setLayout(m_currentValue);
122 m_sliceItem->setLayout(m_currentValue);
123 }
123 }
124 }
124 }
@@ -120,8 +120,8 void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPo
120 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
120 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
121 {
121 {
122
122
123 SplineVector startPair = qVariantValue< SplineVector >(start);
123 SplineVector startPair = qvariant_cast< SplineVector >(start);
124 SplineVector endPair = qVariantValue< SplineVector >(end);
124 SplineVector endPair = qvariant_cast< SplineVector >(end);
125 SplineVector result;
125 SplineVector result;
126
126
127 switch (animationType()) {
127 switch (animationType()) {
@@ -170,7 +170,7 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &en
170 void SplineAnimation::updateCurrentValue(const QVariant &value)
170 void SplineAnimation::updateCurrentValue(const QVariant &value)
171 {
171 {
172 if (state() != QAbstractAnimation::Stopped && m_valid) { //workaround
172 if (state() != QAbstractAnimation::Stopped && m_valid) { //workaround
173 QPair<QVector<QPointF >, QVector<QPointF > > pair = qVariantValue< QPair< QVector<QPointF>, QVector<QPointF> > >(value);
173 QPair<QVector<QPointF >, QVector<QPointF > > pair = qvariant_cast< QPair< QVector<QPointF>, QVector<QPointF> > >(value);
174 m_item->setGeometryPoints(pair.first);
174 m_item->setGeometryPoints(pair.first);
175 m_item->setControlGeometryPoints(pair.second);
175 m_item->setControlGeometryPoints(pair.second);
176 m_item->updateGeometry();
176 m_item->updateGeometry();
@@ -38,8 +38,8 StackedBarAnimation::~StackedBarAnimation()
38
38
39 QVariant StackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
39 QVariant StackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 {
40 {
41 QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from);
41 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
42 QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to);
42 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
43 QVector<QRectF> result;
43 QVector<QRectF> result;
44
44
45 Q_ASSERT(startVector.count() == endVector.count());
45 Q_ASSERT(startVector.count() == endVector.count());
@@ -88,8 +88,8 void XYAnimation::setup(const QVector<QPointF> &oldPoints, const QVector<QPointF
88
88
89 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
89 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
90 {
90 {
91 QVector<QPointF> startVector = qVariantValue<QVector<QPointF> >(start);
91 QVector<QPointF> startVector = qvariant_cast<QVector<QPointF> >(start);
92 QVector<QPointF> endVector = qVariantValue<QVector<QPointF> >(end);
92 QVector<QPointF> endVector = qvariant_cast<QVector<QPointF> >(end);
93 QVector<QPointF> result;
93 QVector<QPointF> result;
94
94
95 switch (m_type) {
95 switch (m_type) {
@@ -125,7 +125,7 void XYAnimation::updateCurrentValue(const QVariant &value)
125 {
125 {
126 if (state() != QAbstractAnimation::Stopped) { //workaround
126 if (state() != QAbstractAnimation::Stopped) { //workaround
127
127
128 QVector<QPointF> vector = qVariantValue<QVector<QPointF> >(value);
128 QVector<QPointF> vector = qvariant_cast<QVector<QPointF> >(value);
129 m_item->setGeometryPoints(vector);
129 m_item->setGeometryPoints(vector);
130 m_item->updateGeometry();
130 m_item->updateGeometry();
131 m_item->setDirty(true);
131 m_item->setDirty(true);
@@ -78,10 +78,10 void ChartAxis::setLayout(QVector<qreal> &layout)
78
78
79 void ChartAxis::createItems(int count)
79 void ChartAxis::createItems(int count)
80 {
80 {
81 if (m_arrow->children().size() == 0)
81 if (m_arrow->childItems().size() == 0)
82 m_arrow->addToGroup(new AxisItem(this, presenter()->rootItem()));
82 m_arrow->addToGroup(new AxisItem(this, presenter()->rootItem()));
83
83
84 if (m_intervalAxis && m_grid->children().size() == 0) {
84 if (m_intervalAxis && m_grid->childItems().size() == 0) {
85 for (int i = 0 ; i < 2 ; i ++)
85 for (int i = 0 ; i < 2 ; i ++)
86 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
86 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
87 }
87 }
@@ -440,7 +440,7 QStringList ChartAxis::createValueLabels(int ticks) const
440 labels << QString::number(value, 'f', n);
440 labels << QString::number(value, 'f', n);
441 }
441 }
442 } else {
442 } else {
443 QByteArray array = format.toAscii();
443 QByteArray array = format.toLatin1();
444 for (int i = 0; i < ticks; i++) {
444 for (int i = 0; i < ticks; i++) {
445 qreal value = m_min + (i * (m_max - m_min) / (ticks - 1));
445 qreal value = m_min + (i * (m_max - m_min) / (ticks - 1));
446 labels << QString().sprintf(array, value);
446 labels << QString().sprintf(array, value);
@@ -43,7 +43,7 LegendMarkerItem::LegendMarkerItem(QLegendMarkerPrivate *marker, QGraphicsObject
43 m_pressPos(0, 0)
43 m_pressPos(0, 0)
44 {
44 {
45 m_rectItem->setRect(m_markerRect);
45 m_rectItem->setRect(m_markerRect);
46 setAcceptsHoverEvents(true);
46 setAcceptHoverEvents(true);
47 }
47 }
48
48
49 LegendMarkerItem::~LegendMarkerItem()
49 LegendMarkerItem::~LegendMarkerItem()
@@ -24,6 +24,17
24 #include <QtTest/QtTest>
24 #include <QtTest/QtTest>
25 #include <QPushButton>
25 #include <QPushButton>
26
26
27 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
28 namespace QTest
29 {
30 // This was deprecated in Qt5. This is a small hack for the sake of compatibility.
31 inline static bool qWaitForWindowShown(QWidget *window)
32 {
33 return QTest::qWaitForWindowExposed(window);
34 }
35 }
36 #endif
37
27 #define TRY_COMPARE(actual, expected) { \
38 #define TRY_COMPARE(actual, expected) { \
28 do { \
39 do { \
29 const int timeout(1000); \
40 const int timeout(1000); \
@@ -22,6 +22,7
22 #include <qbarset.h>
22 #include <qbarset.h>
23 #include <qbarseries.h>
23 #include <qbarseries.h>
24 #include <qchartview.h>
24 #include <qchartview.h>
25 #include "tst_definitions.h"
25
26
26 QTCOMMERCIALCHART_USE_NAMESPACE
27 QTCOMMERCIALCHART_USE_NAMESPACE
27
28
@@ -31,6 +31,7
31 #include <qstackedbarseries.h>
31 #include <qstackedbarseries.h>
32 #include <qvalueaxis.h>
32 #include <qvalueaxis.h>
33 #include <qbarcategoryaxis.h>
33 #include <qbarcategoryaxis.h>
34 #include "tst_definitions.h"
34
35
35 QTCOMMERCIALCHART_USE_NAMESPACE
36 QTCOMMERCIALCHART_USE_NAMESPACE
36
37
@@ -466,10 +467,10 void tst_QChart::removeSeries()
466
467
467 void tst_QChart::scroll_right_data()
468 void tst_QChart::scroll_right_data()
468 {
469 {
469 QTest::addColumn<QAbstractSeries *>("series");
470 QTest::addColumn<QAbstractSeries *>("series");
470
471
471 QLineSeries* series0 = new QLineSeries(this);
472 QLineSeries* series0 = new QLineSeries(this);
472 *series0 << QPointF(0, 0) << QPointF(100, 100);
473 *series0 << QPointF(0, 0) << QPointF(100, 100);
473
474
474 QTest::newRow("lineSeries") << (QAbstractSeries*) series0;
475 QTest::newRow("lineSeries") << (QAbstractSeries*) series0;
475
476
@@ -490,77 +491,77 void tst_QChart::scroll_right()
490 {
491 {
491 case QAbstractAxis::AxisTypeValue:{
492 case QAbstractAxis::AxisTypeValue:{
492 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
493 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
493 QVERIFY(vaxis!=0);
494 QVERIFY(vaxis!=0);
494 qreal min = vaxis->min();
495 qreal min = vaxis->min();
495 qreal max = vaxis->max();
496 qreal max = vaxis->max();
496 QVERIFY(max>min);
497 QVERIFY(max>min);
497 m_chart->scroll(50, 0);
498 m_chart->scroll(50, 0);
498 QVERIFY(min<vaxis->min());
499 QVERIFY(min<vaxis->min());
499 QVERIFY(max<vaxis->max());
500 QVERIFY(max<vaxis->max());
500 break;
501 break;
501 }
502 }
502 case QAbstractAxis::AxisTypeBarCategory:{
503 case QAbstractAxis::AxisTypeBarCategory:{
503 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
504 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
504 QVERIFY(caxis!=0);
505 QVERIFY(caxis!=0);
505 qreal min = caxis->min().toDouble();
506 qreal min = caxis->min().toDouble();
506 qreal max = caxis->max().toDouble();
507 qreal max = caxis->max().toDouble();
507 m_chart->scroll(50, 0);
508 m_chart->scroll(50, 0);
508 QVERIFY(min<caxis->min().toDouble());
509 QVERIFY(min<caxis->min().toDouble());
509 QVERIFY(max<caxis->max().toDouble());
510 QVERIFY(max<caxis->max().toDouble());
510 break;
511 break;
511 }
512 }
512 default:
513 default:
513 qFatal("Unsupported type");
514 qFatal("Unsupported type");
514 break;
515 break;
515 }
516 }
516 }
517 }
517
518
518 void tst_QChart::scroll_left_data()
519 void tst_QChart::scroll_left_data()
519 {
520 {
520 scroll_right_data();
521 scroll_right_data();
521 }
522 }
522
523
523 void tst_QChart::scroll_left()
524 void tst_QChart::scroll_left()
524 {
525 {
525 QFETCH(QAbstractSeries *, series);
526 QFETCH(QAbstractSeries *, series);
526 m_chart->addSeries(series);
527 m_chart->addSeries(series);
527 m_chart->createDefaultAxes();
528 m_chart->createDefaultAxes();
528 m_view->show();
529 m_view->show();
529 QTest::qWaitForWindowShown(m_view);
530 QTest::qWaitForWindowShown(m_view);
530 QAbstractAxis * axis = m_chart->axisX();
531 QAbstractAxis * axis = m_chart->axisX();
531 QVERIFY(axis!=0);
532 QVERIFY(axis!=0);
532
533
533 switch(axis->type())
534 switch(axis->type())
534 {
535 {
535 case QAbstractAxis::AxisTypeValue:{
536 case QAbstractAxis::AxisTypeValue:{
536 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
537 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
537 QVERIFY(vaxis!=0);
538 QVERIFY(vaxis!=0);
538 qreal min = vaxis->min();
539 qreal min = vaxis->min();
539 qreal max = vaxis->max();
540 qreal max = vaxis->max();
540 m_chart->scroll(-50, 0);
541 m_chart->scroll(-50, 0);
541 QVERIFY(min>vaxis->min());
542 QVERIFY(min>vaxis->min());
542 QVERIFY(max>vaxis->max());
543 QVERIFY(max>vaxis->max());
543 break;
544 break;
544 }
545 }
545 case QAbstractAxis::AxisTypeBarCategory:{
546 case QAbstractAxis::AxisTypeBarCategory:{
546 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
547 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
547 QVERIFY(caxis!=0);
548 QVERIFY(caxis!=0);
548 qreal min = caxis->min().toDouble();
549 qreal min = caxis->min().toDouble();
549 qreal max = caxis->max().toDouble();
550 qreal max = caxis->max().toDouble();
550 m_chart->scroll(-50, 0);
551 m_chart->scroll(-50, 0);
551 QVERIFY(min>caxis->min().toDouble());
552 QVERIFY(min>caxis->min().toDouble());
552 QVERIFY(max>caxis->max().toDouble());
553 QVERIFY(max>caxis->max().toDouble());
553 break;
554 break;
554 }
555 }
555 default:
556 default:
556 qFatal("Unsupported type");
557 qFatal("Unsupported type");
557 break;
558 break;
558 }
559 }
559 }
560 }
560
561
561 void tst_QChart::scroll_up_data()
562 void tst_QChart::scroll_up_data()
562 {
563 {
563 scroll_right_data();
564 scroll_right_data();
564 }
565 }
565
566
566 void tst_QChart::scroll_up()
567 void tst_QChart::scroll_up()
@@ -577,71 +578,71 void tst_QChart::scroll_up()
577 {
578 {
578 case QAbstractAxis::AxisTypeValue:{
579 case QAbstractAxis::AxisTypeValue:{
579 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
580 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
580 QVERIFY(vaxis!=0);
581 QVERIFY(vaxis!=0);
581 qreal min = vaxis->min();
582 qreal min = vaxis->min();
582 qreal max = vaxis->max();
583 qreal max = vaxis->max();
583 m_chart->scroll(0, 50);
584 m_chart->scroll(0, 50);
584 QVERIFY(min<vaxis->min());
585 QVERIFY(min<vaxis->min());
585 QVERIFY(max<vaxis->max());
586 QVERIFY(max<vaxis->max());
586 break;
587 break;
587 }
588 }
588 case QAbstractAxis::AxisTypeBarCategory:{
589 case QAbstractAxis::AxisTypeBarCategory:{
589 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
590 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
590 QVERIFY(caxis!=0);
591 QVERIFY(caxis!=0);
591 qreal min = caxis->min().toDouble();
592 qreal min = caxis->min().toDouble();
592 qreal max = caxis->max().toDouble();
593 qreal max = caxis->max().toDouble();
593 m_chart->scroll(0, 50);
594 m_chart->scroll(0, 50);
594 QVERIFY(min<caxis->min().toDouble());
595 QVERIFY(min<caxis->min().toDouble());
595 QVERIFY(max<caxis->max().toDouble());
596 QVERIFY(max<caxis->max().toDouble());
596 break;
597 break;
597 }
598 }
598 default:
599 default:
599 qFatal("Unsupported type");
600 qFatal("Unsupported type");
600 break;
601 break;
601 }
602 }
602 }
603 }
603
604
604 void tst_QChart::scroll_down_data()
605 void tst_QChart::scroll_down_data()
605 {
606 {
606 scroll_right_data();
607 scroll_right_data();
607 }
608 }
608
609
609 void tst_QChart::scroll_down()
610 void tst_QChart::scroll_down()
610 {
611 {
611 QFETCH(QAbstractSeries *, series);
612 QFETCH(QAbstractSeries *, series);
612 m_chart->addSeries(series);
613 m_chart->addSeries(series);
613 m_chart->createDefaultAxes();
614 m_chart->createDefaultAxes();
614 m_view->show();
615 m_view->show();
615 QTest::qWaitForWindowShown(m_view);
616 QTest::qWaitForWindowShown(m_view);
616 QAbstractAxis * axis = m_chart->axisY();
617 QAbstractAxis * axis = m_chart->axisY();
617 QVERIFY(axis!=0);
618 QVERIFY(axis!=0);
618
619
619 switch(axis->type())
620 switch(axis->type())
620 {
621 {
621 case QAbstractAxis::AxisTypeValue:{
622 case QAbstractAxis::AxisTypeValue:{
622 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
623 QValueAxis* vaxis = qobject_cast<QValueAxis*>(axis);
623 QVERIFY(vaxis!=0);
624 QVERIFY(vaxis!=0);
624 qreal min = vaxis->min();
625 qreal min = vaxis->min();
625 qreal max = vaxis->max();
626 qreal max = vaxis->max();
626 m_chart->scroll(0, -50);
627 m_chart->scroll(0, -50);
627 QVERIFY(min>vaxis->min());
628 QVERIFY(min>vaxis->min());
628 QVERIFY(max>vaxis->max());
629 QVERIFY(max>vaxis->max());
629 break;
630 break;
630 }
631 }
631 case QAbstractAxis::AxisTypeBarCategory:{
632 case QAbstractAxis::AxisTypeBarCategory:{
632 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
633 QBarCategoryAxis* caxis = qobject_cast<QBarCategoryAxis*>(axis);
633 QVERIFY(caxis!=0);
634 QVERIFY(caxis!=0);
634 qreal min = caxis->min().toDouble();
635 qreal min = caxis->min().toDouble();
635 qreal max = caxis->max().toDouble();
636 qreal max = caxis->max().toDouble();
636 m_chart->scroll(0, -50);
637 m_chart->scroll(0, -50);
637 QVERIFY(min>caxis->min().toDouble());
638 QVERIFY(min>caxis->min().toDouble());
638 QVERIFY(max>caxis->max().toDouble());
639 QVERIFY(max>caxis->max().toDouble());
639 break;
640 break;
640 }
641 }
641 default:
642 default:
642 qFatal("Unsupported type");
643 qFatal("Unsupported type");
643 break;
644 break;
644 }
645 }
645 }
646 }
646
647
647 void tst_QChart::theme_data()
648 void tst_QChart::theme_data()
General Comments 0
You need to be logged in to leave comments. Login now