@@ -386,16 +386,6 QList<QLegendMarker*> QLegend::markers(QAbstractSeries *series) const | |||||
386 | return d_ptr->markers(series); |
|
386 | return d_ptr->markers(series); | |
387 | } |
|
387 | } | |
388 |
|
388 | |||
389 | void QLegend::addSeries(QAbstractSeries *series) |
|
|||
390 | { |
|
|||
391 | d_ptr->addSeries(series); |
|
|||
392 | } |
|
|||
393 |
|
||||
394 | void QLegend::removeSeries(QAbstractSeries *series) |
|
|||
395 | { |
|
|||
396 | d_ptr->removeSeries(series); |
|
|||
397 | } |
|
|||
398 |
|
||||
399 | /*! |
|
389 | /*! | |
400 | \internal \a event see QGraphicsWidget for details |
|
390 | \internal \a event see QGraphicsWidget for details | |
401 | */ |
|
391 | */ | |
@@ -474,9 +464,8 QList<QLegendMarker*> QLegendPrivate::markers(QAbstractSeries *series) | |||||
474 | return markers; |
|
464 | return markers; | |
475 | } |
|
465 | } | |
476 |
|
466 | |||
477 |
void QLegendPrivate:: |
|
467 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series) | |
478 | { |
|
468 | { | |
479 | // Only allow one instance of series |
|
|||
480 | if (m_series.contains(series)) { |
|
469 | if (m_series.contains(series)) { | |
481 | return; |
|
470 | return; | |
482 | } |
|
471 | } | |
@@ -493,7 +482,7 void QLegendPrivate::addSeries(QAbstractSeries *series) | |||||
493 | m_layout->invalidate(); |
|
482 | m_layout->invalidate(); | |
494 | } |
|
483 | } | |
495 |
|
484 | |||
496 |
void QLegendPrivate:: |
|
485 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |
497 | { |
|
486 | { | |
498 | if (m_series.contains(series)) { |
|
487 | if (m_series.contains(series)) { | |
499 | m_series.removeOne(series); |
|
488 | m_series.removeOne(series); | |
@@ -514,20 +503,6 void QLegendPrivate::removeSeries(QAbstractSeries *series) | |||||
514 | m_layout->invalidate(); |
|
503 | m_layout->invalidate(); | |
515 | } |
|
504 | } | |
516 |
|
505 | |||
517 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series) |
|
|||
518 | { |
|
|||
519 | // Moved to appendSeries |
|
|||
520 | // This slot is just to make old code work for now. |
|
|||
521 | addSeries(series); |
|
|||
522 | } |
|
|||
523 |
|
||||
524 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
|
|||
525 | { |
|
|||
526 | // Moved to removeSeries |
|
|||
527 | // This slot is just to make old code work for now. |
|
|||
528 | removeSeries(series); |
|
|||
529 | } |
|
|||
530 |
|
||||
531 | void QLegendPrivate::handleSeriesVisibleChanged() |
|
506 | void QLegendPrivate::handleSeriesVisibleChanged() | |
532 | { |
|
507 | { | |
533 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); |
|
508 | QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender()); |
@@ -79,10 +79,7 public: | |||||
79 | void setBackgroundVisible(bool visible = true); |
|
79 | void setBackgroundVisible(bool visible = true); | |
80 | bool isBackgroundVisible() const; |
|
80 | bool isBackgroundVisible() const; | |
81 |
|
81 | |||
82 | // New stuff: |
|
|||
83 | QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const; |
|
82 | QList <QLegendMarker*> markers(QAbstractSeries *series = 0) const; | |
84 | void addSeries(QAbstractSeries *series); |
|
|||
85 | void removeSeries(QAbstractSeries *series); |
|
|||
86 |
|
83 | |||
87 | protected: |
|
84 | protected: | |
88 | void hideEvent(QHideEvent *event); |
|
85 | void hideEvent(QHideEvent *event); |
@@ -55,8 +55,6 public: | |||||
55 | QGraphicsItemGroup* items() { return m_items; } |
|
55 | QGraphicsItemGroup* items() { return m_items; } | |
56 |
|
56 | |||
57 | QList<QLegendMarker*> markers(QAbstractSeries *series = 0); |
|
57 | QList<QLegendMarker*> markers(QAbstractSeries *series = 0); | |
58 | void addSeries(QAbstractSeries *series); |
|
|||
59 | void removeSeries(QAbstractSeries *series); |
|
|||
60 |
|
58 | |||
61 | public Q_SLOTS: |
|
59 | public Q_SLOTS: | |
62 | void handleSeriesAdded(QAbstractSeries *series); |
|
60 | void handleSeriesAdded(QAbstractSeries *series); |
@@ -277,12 +277,12 void tst_QLegend::addAndRemoveSeries() | |||||
277 | pie->append(QString("slice2"), 2); |
|
277 | pie->append(QString("slice2"), 2); | |
278 | pie->append(QString("slice3"), 3); |
|
278 | pie->append(QString("slice3"), 3); | |
279 |
|
279 | |||
280 |
|
|
280 | m_chart->addSeries(pie); | |
281 |
|
281 | |||
282 | QList<QLegendMarker *> markers = legend->markers(); |
|
282 | QList<QLegendMarker *> markers = legend->markers(); | |
283 | QVERIFY(markers.count() == 3); |
|
283 | QVERIFY(markers.count() == 3); | |
284 |
|
284 | |||
285 |
|
|
285 | m_chart->removeSeries(pie); | |
286 |
|
286 | |||
287 | markers = legend->markers(); |
|
287 | markers = legend->markers(); | |
288 | QVERIFY(markers.count() == 0); |
|
288 | QVERIFY(markers.count() == 0); |
General Comments 0
You need to be logged in to leave comments.
Login now