@@ -313,25 +313,10 void QChart::zoom(qreal factor) | |||||
313 | */ |
|
313 | */ | |
314 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const |
|
314 | QAbstractAxis *QChart::axisX(QAbstractSeries *series) const | |
315 | { |
|
315 | { | |
316 | if(!series && d_ptr->m_dataset->series().size()>0){ |
|
316 | QList<QAbstractAxis *> axisList = axes(Qt::Horizontal, series); | |
317 | series = d_ptr->m_dataset->series().first(); |
|
317 | if (axisList.count()) | |
318 | } |
|
318 | return axisList[0]; | |
319 |
|
319 | return 0; | ||
320 | QList<QAbstractAxis*> axes = series->attachedAxes(); |
|
|||
321 | QAbstractAxis* bottom=0; |
|
|||
322 | QAbstractAxis* top=0; |
|
|||
323 |
|
||||
324 | foreach(QAbstractAxis* axis, axes){ |
|
|||
325 |
|
||||
326 | if(axis->alignment()==Qt::AlignTop){ |
|
|||
327 | top=axis; |
|
|||
328 | } |
|
|||
329 |
|
||||
330 | if(axis->alignment()==Qt::AlignBottom){ |
|
|||
331 | bottom=axis; |
|
|||
332 | } |
|
|||
333 | } |
|
|||
334 | return bottom?bottom:top; |
|
|||
335 | } |
|
320 | } | |
336 |
|
321 | |||
337 | /*! |
|
322 | /*! | |
@@ -340,31 +325,15 QAbstractAxis *QChart::axisX(QAbstractSeries *series) const | |||||
340 | */ |
|
325 | */ | |
341 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const |
|
326 | QAbstractAxis *QChart::axisY(QAbstractSeries *series) const | |
342 | { |
|
327 | { | |
343 | if(!series && d_ptr->m_dataset->series().size()>0) { |
|
328 | QList<QAbstractAxis *> axisList = axes(Qt::Vertical, series); | |
344 | series = d_ptr->m_dataset->series().first(); |
|
329 | if (axisList.count()) | |
345 | } |
|
330 | return axisList[0]; | |
346 |
|
331 | return 0; | ||
347 | QList<QAbstractAxis*> axes = series->attachedAxes(); |
|
|||
348 |
|
||||
349 | QAbstractAxis* left=0; |
|
|||
350 | QAbstractAxis* right=0; |
|
|||
351 |
|
||||
352 | foreach(QAbstractAxis* axis, axes){ |
|
|||
353 |
|
||||
354 | if(axis->alignment()==Qt::AlignLeft){ |
|
|||
355 | left=axis; |
|
|||
356 | } |
|
|||
357 |
|
||||
358 | if(axis->alignment()==Qt::AlignRight){ |
|
|||
359 | right=axis; |
|
|||
360 | } |
|
|||
361 | } |
|
|||
362 |
|
||||
363 | return left?left:right; |
|
|||
364 | } |
|
332 | } | |
365 |
|
333 | |||
366 | /*! |
|
334 | /*! | |
367 | Returns the axes added for the \a series with \a orientation |
|
335 | Returns the axes added for the \a series with \a orientation. If no series is provided, then all axes with the | |
|
336 | specified orientation are returned. | |||
368 | \sa addAxis(), createDefaultAxes() |
|
337 | \sa addAxis(), createDefaultAxes() | |
369 | */ |
|
338 | */ | |
370 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const |
|
339 | QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSeries *series) const | |
@@ -377,11 +346,9 QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation, QAbstractSerie | |||||
377 | result << axis; |
|
346 | result << axis; | |
378 | } |
|
347 | } | |
379 | } else { |
|
348 | } else { | |
380 |
foreach (QAbstract |
|
349 | foreach (QAbstractAxis *axis, d_ptr->m_dataset->axes()){ | |
381 | foreach (QAbstractAxis *axis, s->attachedAxes()){ |
|
350 | if (orientation.testFlag(axis->orientation()) && !result.contains(axis)) | |
382 | if (orientation.testFlag(axis->orientation()) && !result.contains(axis)) |
|
351 | result << axis; | |
383 | result << axis; |
|
|||
384 | } |
|
|||
385 | } |
|
352 | } | |
386 | } |
|
353 | } | |
387 |
|
354 |
@@ -264,6 +264,7 void tst_ChartDataSet::removeAxis() | |||||
264 |
|
264 | |||
265 | m_dataset->removeAxis(axis); |
|
265 | m_dataset->removeAxis(axis); | |
266 |
|
266 | |||
|
267 | QCOMPARE(m_dataset->axes().count(),0); | |||
267 | QCOMPARE(m_dataset->series().count(),0); |
|
268 | QCOMPARE(m_dataset->series().count(),0); | |
268 | TRY_COMPARE(spy0.count(), 0); |
|
269 | TRY_COMPARE(spy0.count(), 0); | |
269 | TRY_COMPARE(spy1.count(), 1); |
|
270 | TRY_COMPARE(spy1.count(), 1); |
@@ -431,14 +431,15 void tst_QChart::removeAllSeries() | |||||
431 | m_view->show(); |
|
431 | m_view->show(); | |
432 | QTest::qWaitForWindowShown(m_view); |
|
432 | QTest::qWaitForWindowShown(m_view); | |
433 | m_chart->createDefaultAxes(); |
|
433 | m_chart->createDefaultAxes(); | |
|
434 | QCOMPARE(m_chart->axes().count(), 2); | |||
434 | QVERIFY(m_chart->axisY(series0)!=0); |
|
435 | QVERIFY(m_chart->axisY(series0)!=0); | |
435 | QVERIFY(m_chart->axisY(series1)!=0); |
|
436 | QVERIFY(m_chart->axisY(series1)!=0); | |
436 | QVERIFY(m_chart->axisY(series2)!=0); |
|
437 | QVERIFY(m_chart->axisY(series2)!=0); | |
437 |
|
438 | |||
438 | m_chart->removeAllSeries(); |
|
439 | m_chart->removeAllSeries(); | |
439 | QVERIFY(m_chart->axisY(series0)==0); |
|
440 | QCOMPARE(m_chart->axes().count(), 2); | |
440 |
QVERIFY(m_chart->axis |
|
441 | QVERIFY(m_chart->axisX() != 0); | |
441 |
QVERIFY(m_chart->axisY( |
|
442 | QVERIFY(m_chart->axisY() != 0); | |
442 | QCOMPARE(deleteSpy1.count(), 1); |
|
443 | QCOMPARE(deleteSpy1.count(), 1); | |
443 | QCOMPARE(deleteSpy2.count(), 1); |
|
444 | QCOMPARE(deleteSpy2.count(), 1); | |
444 | QCOMPARE(deleteSpy3.count(), 1); |
|
445 | QCOMPARE(deleteSpy3.count(), 1); | |
@@ -461,6 +462,8 void tst_QChart::removeSeries() | |||||
461 | m_chart->setAxisY(axis,series); |
|
462 | m_chart->setAxisY(axis,series); | |
462 | QCOMPARE(m_chart->axisY(series),axis); |
|
463 | QCOMPARE(m_chart->axisY(series),axis); | |
463 | m_chart->removeSeries(series); |
|
464 | m_chart->removeSeries(series); | |
|
465 | QCOMPARE(m_chart->axes().count(), 1); | |||
|
466 | QVERIFY(m_chart->axisY() != 0); | |||
464 | QVERIFY(m_chart->axisY(series)==0); |
|
467 | QVERIFY(m_chart->axisY(series)==0); | |
465 | QCOMPARE(deleteSpy.count(), 0); |
|
468 | QCOMPARE(deleteSpy.count(), 0); | |
466 | } |
|
469 | } |
General Comments 0
You need to be logged in to leave comments.
Login now