From 5ea9e4fa75c8c36d6ff15630a0d3c6d2d7203d91 2012-11-26 12:58:47 From: Michal Klocek Date: 2012-11-26 12:58:47 Subject: [PATCH] Adds domains swap logic --- diff --git a/src/axis/qabstractaxis.cpp b/src/axis/qabstractaxis.cpp index e4a83a4..f40e4c5 100644 --- a/src/axis/qabstractaxis.cpp +++ b/src/axis/qabstractaxis.cpp @@ -862,6 +862,7 @@ void QAbstractAxisPrivate::initializeAnimations(QChart::AnimationOptions options } + #include "moc_qabstractaxis.cpp" #include "moc_qabstractaxis_p.cpp" diff --git a/src/axis/qabstractaxis.h b/src/axis/qabstractaxis.h index f08126d..de612f8 100644 --- a/src/axis/qabstractaxis.h +++ b/src/axis/qabstractaxis.h @@ -189,6 +189,7 @@ protected: friend class ChartAxis; friend class ChartPresenter; friend class ChartThemeManager; + friend class AbstractDomain; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index c2d0874..301e58c 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -52,8 +52,8 @@ ChartDataSet::ChartDataSet(QChart *chart) ChartDataSet::~ChartDataSet() { - removeAllSeries(); - removeAllAxes(); + deleteAllSeries(); + deleteAllAxes(); } /* @@ -126,6 +126,7 @@ void ChartDataSet::removeSeries(QAbstractSeries *series) axis->d_ptr->m_series.removeAll(series); series->d_ptr->m_axes.removeAll(axis); } + } /* @@ -153,7 +154,7 @@ void ChartDataSet::removeAxis(QAbstractAxis *axis) } /* - * This method attach axis to series, return true if success. + * This method attaches axis to series, return true if success. */ bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis) { @@ -162,7 +163,6 @@ bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis) QList attachedSeriesList = axis->d_ptr->m_series; QList attachedAxisList = series->d_ptr->m_axes; - QSharedPointer domain = series->d_ptr->m_domain; if (!m_seriesList.contains(series)) { qWarning() << QObject::tr("Can not find series on the chart."); @@ -179,38 +179,42 @@ bool ChartDataSet::attachAxis(QAbstractSeries* series,QAbstractAxis *axis) return false; } - Q_ASSERT(!attachedSeriesList.contains(series)); - Q_ASSERT(!domain.isNull()); + if (attachedSeriesList.contains(series)) { + qWarning() << QObject::tr("Axis already attached to series."); + return false; + } + + QSharedPointer domain = series->d_ptr->domain(); + AbstractDomain::DomainType type = selectDomain(attachedAxisList<d_ptr->domain(); - Q_ASSERT(!domain.isNull()); - series->d_ptr->setDomain(domain); + if(domain->type()!=type){ + domain = QSharedPointer(createDomain(type)); } + if(domain.isNull()) return false; + + if(!domain->attachAxis(axis)) return false; + series->d_ptr->m_axes<d_ptr->m_series<d_ptr->setDomain(domain); + series->d_ptr->initializeDomain(); series->d_ptr->initializeAxes(); axis->d_ptr->initializeDomain(domain.data()); - if(axis->orientation()==Qt::Vertical){ - QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleVerticalAxisRangeChanged(qreal,qreal))); - QObject::connect(domain.data(), SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); - } - - if(axis->orientation()==Qt::Horizontal){ - QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleHorizontalAxisRangeChanged(qreal,qreal))); - QObject::connect(domain.data(), SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); + if(attachedSeriesList.count()>0 && attachedAxisList.count()>0){ + //TODO optimatization: joinDomain(attachedAxisList, attachedSeriesList); } return true; } /* - * This method detach axis to series, return true if success. + * This method detaches axis to series, return true if success. */ bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis) { @@ -238,19 +242,10 @@ bool ChartDataSet::detachAxis(QAbstractSeries* series,QAbstractAxis *axis) Q_ASSERT(axis->d_ptr->m_series.contains(series)); + domain->detachAxis(axis); series->d_ptr->m_axes.removeAll(axis); axis->d_ptr->m_series.removeAll(series); - if(axis->orientation()==Qt::Vertical){ - QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleVerticalAxisRangeChanged(qreal,qreal))); - QObject::disconnect(domain.data(), SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); - } - - if(axis->orientation()==Qt::Horizontal){ - QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), domain.data(), SLOT(handleHorizontalAxisRangeChanged(qreal,qreal))); - QObject::disconnect(domain.data(), SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); - } - return true; } @@ -263,7 +258,7 @@ void ChartDataSet::createDefaultAxes() QAbstractAxis::AxisTypes typeY(0); // Remove possibly existing axes - removeAllAxes(); + deleteAllAxes(); Q_ASSERT(m_axisList.isEmpty()); @@ -326,22 +321,22 @@ void ChartDataSet::createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation ori } } -void ChartDataSet::removeAllSeries() +void ChartDataSet::deleteAllSeries() { - foreach (QAbstractSeries *s , m_seriesList) + foreach (QAbstractSeries *s , m_seriesList){ removeSeries(s); - + delete s; + } Q_ASSERT(m_seriesList.count() == 0); - qDeleteAll(m_seriesList); } -void ChartDataSet::removeAllAxes() +void ChartDataSet::deleteAllAxes() { - foreach (QAbstractAxis *a , m_axisList) + foreach (QAbstractAxis *a , m_axisList){ removeAxis(a); - + delete a; + } Q_ASSERT(m_axisList.count() == 0); - qDeleteAll(m_axisList); } void ChartDataSet::zoomInDomain(const QRectF &rect) @@ -405,6 +400,72 @@ QList ChartDataSet::series() const return m_seriesList; } +AbstractDomain::DomainType ChartDataSet::selectDomain(QList axes) +{ + enum Type { + LogType = 0x1, + ValueType = 0x2 + }; + + int horizontal(ValueType); + int vertical(ValueType); + + foreach(QAbstractAxis* axis, axes) + { + switch(axis->type()) { + case QAbstractAxis::AxisTypeLogValue: + axis->orientation()==Qt::Horizontal?horizontal:vertical|=LogType; + break; + case QAbstractAxis::AxisTypeValue: + case QAbstractAxis::AxisTypeBarCategory: + case QAbstractAxis::AxisTypeCategory: + case QAbstractAxis::AxisTypeDateTime: + axis->orientation()==Qt::Horizontal?horizontal:vertical|=ValueType; + break; + default: + qWarning()<<"Undefined type"; + break; + } + } + + if(vertical==ValueType && horizontal== ValueType) { + return AbstractDomain::XYDomain; + } + + if(vertical==LogType && horizontal== ValueType) { + return AbstractDomain::XLogYDomain; + } + + if(vertical==ValueType && horizontal== LogType) { + return AbstractDomain::LogXYDomain; + } + + if(vertical==LogType && horizontal== LogType) { + return AbstractDomain::XLogYLogDomain; + } + + return AbstractDomain::UndefinedDomain; +} + + +//refactor create factory +AbstractDomain* ChartDataSet::createDomain(AbstractDomain::DomainType type) +{ + switch(type) + { + case AbstractDomain::XLogYLogDomain: + return 0; + case AbstractDomain::XYDomain: + return new XYDomain(); + case AbstractDomain::XLogYDomain: + return 0; + case AbstractDomain::LogXYDomain: + return 0; + default: + return 0; + } +} + #include "moc_chartdataset_p.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/chartdataset_p.h b/src/chartdataset_p.h index d04feed..e39879e 100644 --- a/src/chartdataset_p.h +++ b/src/chartdataset_p.h @@ -50,12 +50,10 @@ public: void addSeries(QAbstractSeries *series); void removeSeries(QAbstractSeries *series); QList series() const; - void removeAllSeries(); void addAxis(QAbstractAxis *axis,Qt::Alignment aligment); void removeAxis(QAbstractAxis *axis); QList axes() const; - void removeAllAxes(); bool attachAxis(QAbstractSeries* series,QAbstractAxis *axis); bool detachAxis(QAbstractSeries* series,QAbstractAxis *axis); @@ -75,7 +73,10 @@ Q_SIGNALS: private: void createAxes(QAbstractAxis::AxisTypes type, Qt::Orientation orientation); QAbstractAxis *createAxis(QAbstractAxis::AxisType type, Qt::Orientation orientation); - + AbstractDomain::DomainType selectDomain(QList axes); + AbstractDomain* createDomain(AbstractDomain::DomainType type); + void deleteAllAxes(); + void deleteAllSeries(); private: QList m_seriesList; QList m_axisList; diff --git a/src/domain/abstractdomain.cpp b/src/domain/abstractdomain.cpp index 889aece..4915a96 100644 --- a/src/domain/abstractdomain.cpp +++ b/src/domain/abstractdomain.cpp @@ -161,6 +161,35 @@ qreal AbstractDomain::niceNumber(qreal x, bool ceiling) return q * z; } +bool AbstractDomain::attachAxis(QAbstractAxis* axis) +{ + if(axis->orientation()==Qt::Vertical) { + QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleVerticalAxisRangeChanged(qreal,qreal))); + QObject::connect(this, SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); + } + + if(axis->orientation()==Qt::Horizontal) { + QObject::connect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleHorizontalAxisRangeChanged(qreal,qreal))); + QObject::connect(this, SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); + } + + return true; +} + +bool AbstractDomain::detachAxis(QAbstractAxis* axis) +{ + if(axis->orientation()==Qt::Vertical) { + QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleVerticalAxisRangeChanged(qreal,qreal))); + QObject::disconnect(this, SIGNAL(rangeVerticalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); + } + + if(axis->orientation()==Qt::Horizontal) { + QObject::disconnect(axis->d_ptr.data(), SIGNAL(rangeChanged(qreal,qreal)), this, SLOT(handleHorizontalAxisRangeChanged(qreal,qreal))); + QObject::disconnect(this, SIGNAL(rangeHorizontalChanged(qreal,qreal)), axis->d_ptr.data(), SLOT(handleRangeChanged(qreal,qreal))); + } + + return true; +} // operators diff --git a/src/domain/abstractdomain_p.h b/src/domain/abstractdomain_p.h index 957508e..ab47ec3 100644 --- a/src/domain/abstractdomain_p.h +++ b/src/domain/abstractdomain_p.h @@ -36,16 +36,22 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE +class QAbstractAxis; + class QTCOMMERCIALCHART_AUTOTEST_EXPORT AbstractDomain: public QObject { Q_OBJECT public: + enum DomainType { UndefinedDomain, XYDomain, XLogYDomain, LogXYDomain, XLogYLogDomain }; +public: explicit AbstractDomain(QObject *object = 0); virtual ~AbstractDomain(); void setSize(const QSizeF& size); QSizeF size() const; + virtual DomainType type() = 0; + virtual void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) = 0; void setRangeX(qreal min, qreal max); void setRangeY(qreal min, qreal max); @@ -63,11 +69,9 @@ public: qreal spanY() const; bool isEmpty() const; - void blockAxisSignals(bool block); bool axisSignalsBlocked() const { return m_axisSignalsBlocked; } - friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const AbstractDomain &domain1, const AbstractDomain &domain2); friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator!= (const AbstractDomain &domain1, const AbstractDomain &domain2); friend QDebug QTCOMMERCIALCHART_AUTOTEST_EXPORT operator<<(QDebug dbg, const AbstractDomain &domain); @@ -80,6 +84,9 @@ public: virtual QPointF calculateDomainPoint(const QPointF &point) const = 0; virtual QVector calculateGeometryPoints(const QList& vector) const = 0; + virtual bool attachAxis(QAbstractAxis* axis); + virtual bool detachAxis(QAbstractAxis* axis); + static void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount); static qreal niceNumber(qreal x, bool ceiling); diff --git a/src/domain/xydomain_p.h b/src/domain/xydomain_p.h index 30136cc..9ec7a85 100644 --- a/src/domain/xydomain_p.h +++ b/src/domain/xydomain_p.h @@ -42,6 +42,8 @@ public: explicit XYDomain(QObject *object = 0); virtual ~XYDomain(); + DomainType type(){ return AbstractDomain::XYDomain;} + void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY); friend bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const XYDomain &Domain1, const XYDomain &Domain2); diff --git a/src/legend/qlegend_p.h b/src/legend/qlegend_p.h index 9b68ca0..09a639c 100644 --- a/src/legend/qlegend_p.h +++ b/src/legend/qlegend_p.h @@ -38,7 +38,6 @@ class QChart; class ChartPresenter; class QAbstractSeries; class LegendLayout; -class Domain; class QLegendMarker; class QLegendPrivate : public QObject diff --git a/src/qchart.cpp b/src/qchart.cpp index 6ff8d03..41860aa 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -160,7 +160,10 @@ void QChart::removeSeries(QAbstractSeries *series) */ void QChart::removeAllSeries() { - d_ptr->m_dataset->removeAllSeries(); + foreach (QAbstractSeries *s , d_ptr->m_dataset->series()){ + removeSeries(s); + delete s; + } } /*! diff --git a/tests/auto/chartdataset/tst_chartdataset.cpp b/tests/auto/chartdataset/tst_chartdataset.cpp index 25a5b21..2f86d00 100644 --- a/tests/auto/chartdataset/tst_chartdataset.cpp +++ b/tests/auto/chartdataset/tst_chartdataset.cpp @@ -71,6 +71,8 @@ Q_DECLARE_METATYPE(QLineSeries *) class tst_ChartDataSet: public QObject { Q_OBJECT +public: + tst_ChartDataSet():m_dataset(0){}; public Q_SLOTS: void initTestCase(); @@ -85,14 +87,10 @@ private Q_SLOTS: void addSeries(); void removeSeries_data(); void removeSeries(); - void removeAllSeries_data(); - void removeAllSeries(); void addAxis_data(); void addAxis(); void removeAxis_data(); void removeAxis(); - void removeAllAxes_data(); - void removeAllAxes(); void attachAxis_data(); void attachAxis(); void detachAxis_data(); @@ -115,17 +113,15 @@ void tst_ChartDataSet::cleanupTestCase() void tst_ChartDataSet::init() { + Q_ASSERT(!m_dataset); m_dataset = new ChartDataSet(0); } void tst_ChartDataSet::cleanup() { - QList series = m_dataset->series(); - foreach (QAbstractSeries* serie, series) - { - m_dataset->removeSeries(serie); - } + delete m_dataset; + m_dataset=0; } void tst_ChartDataSet::chartdataset_data() @@ -145,21 +141,27 @@ void tst_ChartDataSet::addSeries_data() QTest::addColumn("series"); QAbstractSeries* line = new QLineSeries(this); - QAbstractSeries* area = new QAreaSeries(static_cast(line)); - QAbstractSeries* scatter = new QScatterSeries(this); - QAbstractSeries* spline = new QSplineSeries(this); - QAbstractSeries* pie = new QPieSeries(this); - QAbstractSeries* bar = new QBarSeries(this); - QAbstractSeries* percent = new QPercentBarSeries(this); - QAbstractSeries* stacked = new QStackedBarSeries(this); - QTest::newRow("line") << line; + + QAbstractSeries* area = new QAreaSeries(static_cast(new QLineSeries(this))); QTest::newRow("area") << area; + + QAbstractSeries* scatter = new QScatterSeries(this); QTest::newRow("scatter") << scatter; + + QAbstractSeries* spline = new QSplineSeries(this); QTest::newRow("spline") << spline; + + QAbstractSeries* pie = new QPieSeries(this); QTest::newRow("pie") << pie; + + QAbstractSeries* bar = new QBarSeries(this); QTest::newRow("bar") << bar; + + QAbstractSeries* percent = new QPercentBarSeries(this); QTest::newRow("percent") << percent; + + QAbstractSeries* stacked = new QStackedBarSeries(this); QTest::newRow("stacked") << stacked; } @@ -175,7 +177,6 @@ void tst_ChartDataSet::addSeries() m_dataset->addSeries(series); - QCOMPARE(m_dataset->series().count(),1); TRY_COMPARE(spy0.count(), 0); TRY_COMPARE(spy1.count(), 0); @@ -208,56 +209,6 @@ void tst_ChartDataSet::removeSeries() TRY_COMPARE(spy3.count(), 1); } -void tst_ChartDataSet::removeAllSeries_data() -{ - QTest::addColumn >("seriesList"); - QTest::addColumn >("axisList"); - - QList series; - QList axis; - - series << new QLineSeries(this) << new QSplineSeries(this) << new QScatterSeries(this); - axis << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this); - - QTest::newRow("3 series , 3 axis") << series << axis; -} - -void tst_ChartDataSet::removeAllSeries() -{ - QFETCH(QList, seriesList); - QFETCH(QList, axisList); - - QCOMPARE(m_dataset->series().count(),0); - QCOMPARE(m_dataset->axes().count(),0); - - foreach (QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - foreach (QAbstractAxis* axis, axisList) { - m_dataset->addAxis(axis,Qt::AlignBottom); - } - - for (int i = 0; i < seriesList.count(); i++) { - m_dataset->attachAxis(seriesList.at(i),axisList.at(i)); - } - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); - - m_dataset->removeAllSeries(); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), 0); - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), seriesList.count()); - - QCOMPARE(m_dataset->series().count(),0); - QCOMPARE(m_dataset->axes().count(),axisList.count()); -} - void tst_ChartDataSet::addAxis_data() { QTest::addColumn("axis"); @@ -316,58 +267,9 @@ void tst_ChartDataSet::removeAxis() TRY_COMPARE(spy3.count(), 0); } -void tst_ChartDataSet::removeAllAxes_data() -{ - QTest::addColumn >("seriesList"); - QTest::addColumn >("axisList"); - - QList series; - QList axis; - - series << new QLineSeries(this) << new QSplineSeries(this) << new QScatterSeries(this); - axis << new QValueAxis(this) << new QValueAxis(this) << new QValueAxis(this); - - QTest::newRow("3 series , 3 axis") << series << axis; -} - -void tst_ChartDataSet::removeAllAxes() -{ - QFETCH(QList, seriesList); - QFETCH(QList, axisList); - - QCOMPARE(m_dataset->series().count(),0); - QCOMPARE(m_dataset->axes().count(),0); - - foreach (QAbstractSeries* series, seriesList) { - m_dataset->addSeries(series); - } - - foreach (QAbstractAxis* axis, axisList) { - m_dataset->addAxis(axis,Qt::AlignBottom); - } - - for (int i = 0; i < seriesList.count(); i++) { - m_dataset->attachAxis(seriesList.at(i),axisList.at(i)); - } - - QSignalSpy spy0(m_dataset, SIGNAL(axisAdded(QAbstractAxis*))); - QSignalSpy spy1(m_dataset, SIGNAL(axisRemoved(QAbstractAxis*))); - QSignalSpy spy2(m_dataset, SIGNAL(seriesAdded(QAbstractSeries*))); - QSignalSpy spy3(m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*))); - - m_dataset->removeAllAxes(); - - TRY_COMPARE(spy0.count(), 0); - TRY_COMPARE(spy1.count(), axisList.count()); - TRY_COMPARE(spy2.count(), 0); - TRY_COMPARE(spy3.count(), 0); - - QCOMPARE(m_dataset->series().count(),seriesList.count()); - QCOMPARE(m_dataset->axes().count(),0); -} - void tst_ChartDataSet::attachAxis_data() { + QTest::addColumn >("series"); QTest::addColumn >("axis"); QTest::addColumn >("alignment"); @@ -375,12 +277,7 @@ void tst_ChartDataSet::attachAxis_data() QTest::addColumn("attachAxis"); QTest::addColumn("success"); - QList series; - QList axes; - QList alignment; - - QAbstractSeries* line = new QLineSeries(this); - QAbstractSeries* area = new QAreaSeries(static_cast(line)); + //QAbstractSeries* area = new QAreaSeries(static_cast(line)); QAbstractSeries* scatter = new QScatterSeries(this); QAbstractSeries* spline = new QSplineSeries(this); QAbstractSeries* pie = new QPieSeries(this); @@ -388,17 +285,35 @@ void tst_ChartDataSet::attachAxis_data() QAbstractSeries* percent = new QPercentBarSeries(this); QAbstractSeries* stacked = new QStackedBarSeries(this); - QAbstractAxis* value1 = new QValueAxis(this); - QAbstractAxis* value2 = new QValueAxis(this); QAbstractAxis* category = new QCategoryAxis(this); QAbstractAxis* barcategory = new QBarCategoryAxis(this); QAbstractAxis* datetime = new QDateTimeAxis(this); + { + QList series; + QList axes; + QList alignment; + QAbstractSeries* line = new QLineSeries(this); + QAbstractAxis* value1 = new QValueAxis(this); + QAbstractAxis* value2 = new QValueAxis(this); + series << line << 0; + axes << value1 << value2; + alignment << Qt::AlignBottom << Qt::AlignLeft; + QTest::newRow("first") << series << axes << alignment << line << value2 << true ; + } - series << line << 0; - axes << value1 << value2; - alignment << Qt::AlignBottom << Qt::AlignLeft; - QTest::newRow("line + two axes") << series << axes << alignment << line << value2 << true; + { + QList series; + QList axes; + QList alignment; + QAbstractSeries* line = new QLineSeries(this); + QAbstractAxis* value1 = new QValueAxis(this); + QAbstractAxis* value2 = new QValueAxis(this); + series << 0 << line; + axes << value1 << value2; + alignment << Qt::AlignBottom << Qt::AlignLeft; + QTest::newRow("second") << series << axes << alignment << line << value1 << true; + } } @@ -440,15 +355,15 @@ void tst_ChartDataSet::detachAxis_data() QTest::addColumn("detachAxis"); QTest::addColumn("success"); + { QList series; QList axes; - QAbstractSeries* line = new QLineSeries(this); QAbstractAxis* value = new QValueAxis(this); - series << line; axes << value; - QTest::newRow("line + axis") << series << axes << line << value << true; + QTest::newRow("first") << series << axes << line << value << true; + } } void tst_ChartDataSet::detachAxis()