##// END OF EJS Templates
Fixed a bug with legend not updating series labels
Tero Ahola -
r1328:a05051bade54
parent child
Show More
@@ -36,7 +36,8
36 36
37 37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 38
39 LegendMarker::LegendMarker(QAbstractSeries *series, QLegend *legend) : QGraphicsObject(legend),
39 LegendMarker::LegendMarker(QAbstractSeries *series, QLegend *legend) :
40 QGraphicsObject(legend),
40 41 m_series(series),
41 42 m_markerRect(0,0,10.0,10.0),
42 43 m_boundingRect(0,0,0,0),
@@ -125,6 +126,7 m_series(series)
125 126 {
126 127 //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected()));
127 128 QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
129 QObject::connect(series, SIGNAL(nameChanged()), this, SLOT(updated()));
128 130 updated();
129 131 }
130 132
@@ -173,6 +175,7 m_series(series)
173 175 {
174 176 //QObject::connect(this, SIGNAL(selected()), series, SIGNAL(selected()));
175 177 QObject::connect(series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
178 QObject::connect(series, SIGNAL(nameChanged()), this, SLOT(updated()));
176 179 updated();
177 180 }
178 181
@@ -422,8 +422,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
422 422 foreach(LegendMarker* marker , markers)
423 423 m_markers->addToGroup(marker);
424 424
425 if(series->type() == QAbstractSeries::SeriesTypePie)
426 {
425 if(series->type() == QAbstractSeries::SeriesTypePie) {
427 426 QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
428 427 QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
429 428 QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
@@ -434,7 +433,6 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
434 433
435 434 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
436 435 {
437
438 436 QList<QGraphicsItem *> items = m_markers->childItems();
439 437
440 438 foreach (QGraphicsItem *markers, items) {
@@ -90,7 +90,10 QAbstractSeries::~QAbstractSeries()
90 90
91 91 void QAbstractSeries::setName(const QString& name)
92 92 {
93 if (name != d_ptr->m_name) {
93 94 d_ptr->m_name = name;
95 nameChanged();
96 }
94 97 }
95 98
96 99 /*!
@@ -33,7 +33,7 class QChart;
33 33 class QTCOMMERCIALCHART_EXPORT QAbstractSeries : public QObject
34 34 {
35 35 Q_OBJECT
36 Q_PROPERTY(QString name READ name WRITE setName)
36 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
37 37 Q_ENUMS(SeriesType)
38 38
39 39 public:
@@ -59,6 +59,9 public:
59 59 QString name() const;
60 60 QChart* chart() const;
61 61
62 Q_SIGNALS:
63 void nameChanged();
64
62 65 protected:
63 66 QScopedPointer<QAbstractSeriesPrivate> d_ptr;
64 67 friend class ChartDataSet;
General Comments 0
You need to be logged in to leave comments. Login now