##// END OF EJS Templates
fixed crash in legendmarker when calling update from private constructor
sauimone -
r2227:d68dfe34c17e
parent child
Show More
@@ -158,17 +158,31 void MainWidget::handleMarkerClicked()
158
158
159 //![6]
159 //![6]
160 // Dim the marker, if series is not visible
160 // Dim the marker, if series is not visible
161 QBrush labelBrush = marker->labelBrush();
161 qreal alpha = 1.0;
162 QColor color = labelBrush.color();
163
162
164 if (marker->series()->isVisible()) {
163 if (!marker->series()->isVisible()) {
165 color.setAlphaF(1.0);
164 alpha = 0.5;
166 } else {
167 color.setAlphaF(0.5);
168 }
165 }
169
166
170 labelBrush.setColor(color);
167 QColor color;
171 marker->setLabelBrush(labelBrush);
168 QBrush brush = marker->labelBrush();
169 color = brush.color();
170 color.setAlphaF(alpha);
171 brush.setColor(color);
172 marker->setLabelBrush(brush);
173
174 brush = marker->brush();
175 color = brush.color();
176 color.setAlphaF(alpha);
177 brush.setColor(color);
178 marker->setBrush(brush);
179
180 QPen pen = marker->pen();
181 color = pen.color();
182 color.setAlphaF(alpha);
183 pen.setColor(color);
184 marker->setPen(pen);
185
172 //![6]
186 //![6]
173 break;
187 break;
174 }
188 }
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) :
46 QAreaLegendMarker::QAreaLegendMarker(QAreaSeries *series, QLegend *legend, QObject *parent) :
47 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
47 QLegendMarker(*new QAreaLegendMarkerPrivate(this,series,legend), parent)
48 {
48 {
49 d_ptr->updated();
49 }
50 }
50
51
51 /*!
52 /*!
@@ -76,11 +77,11 QAreaSeries* QAreaLegendMarker::series()
76
77
77 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
78 QAreaLegendMarkerPrivate::QAreaLegendMarkerPrivate(QAreaLegendMarker *q, QAreaSeries *series, QLegend *legend) :
78 QLegendMarkerPrivate(q,legend),
79 QLegendMarkerPrivate(q,legend),
80 q_ptr(q),
79 m_series(series)
81 m_series(series)
80 {
82 {
81 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
83 QObject::connect(m_series->d_func(),SIGNAL(updated()), this, SLOT(updated()));
82 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
84 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
83 updated();
84 }
85 }
85
86
86 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
87 QAreaLegendMarkerPrivate::~QAreaLegendMarkerPrivate()
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) :
46 QBarLegendMarker::QBarLegendMarker(QAbstractBarSeries *series, QBarSet *barset, QLegend *legend, QObject *parent) :
47 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
47 QLegendMarker(*new QBarLegendMarkerPrivate(this,series,barset,legend), parent)
48 {
48 {
49 d_ptr->updated();
49 }
50 }
50
51
51 /*!
52 /*!
@@ -85,13 +86,13 QBarSet* QBarLegendMarker::barset()
85
86
86 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
87 QBarLegendMarkerPrivate::QBarLegendMarkerPrivate(QBarLegendMarker *q, QAbstractBarSeries *series, QBarSet *barset, QLegend *legend) :
87 QLegendMarkerPrivate(q,legend),
88 QLegendMarkerPrivate(q,legend),
89 q_ptr(q),
88 m_series(series),
90 m_series(series),
89 m_barset(barset)
91 m_barset(barset)
90 {
92 {
91 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
93 QObject::connect(m_barset, SIGNAL(penChanged()), this, SLOT(updated()));
92 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
94 QObject::connect(m_barset, SIGNAL(labelChanged()), this, SLOT(updated()));
93 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
95 QObject::connect(m_barset, SIGNAL(brushChanged()), this, SLOT(updated()));
94 updated();
95 }
96 }
96
97
97 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
98 QBarLegendMarkerPrivate::~QBarLegendMarkerPrivate()
@@ -68,7 +68,7 public:
68 void invalidateLegend();
68 void invalidateLegend();
69
69
70 public Q_SLOTS:
70 public Q_SLOTS:
71 virtual void updated() { invalidateLegend(); }
71 virtual void updated() = 0;
72
72
73 protected:
73 protected:
74 LegendMarkerItem *m_item;
74 LegendMarkerItem *m_item;
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) :
46 QPieLegendMarker::QPieLegendMarker(QPieSeries *series, QPieSlice *slice, QLegend *legend, QObject *parent) :
47 QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent)
47 QLegendMarker(*new QPieLegendMarkerPrivate(this,series,slice,legend), parent)
48 {
48 {
49 d_ptr->updated();
49 }
50 }
50
51
51 /*!
52 /*!
@@ -85,13 +86,13 QPieSlice* QPieLegendMarker::slice()
85
86
86 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) :
87 QPieLegendMarkerPrivate::QPieLegendMarkerPrivate(QPieLegendMarker *q, QPieSeries *series, QPieSlice *slice, QLegend *legend) :
87 QLegendMarkerPrivate(q,legend),
88 QLegendMarkerPrivate(q,legend),
89 q_ptr(q),
88 m_series(series),
90 m_series(series),
89 m_slice(slice)
91 m_slice(slice)
90 {
92 {
91 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
93 QObject::connect(m_slice, SIGNAL(labelChanged()), this, SLOT(updated()));
92 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
94 QObject::connect(m_slice, SIGNAL(brushChanged()), this, SLOT(updated()));
93 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
95 QObject::connect(m_slice, SIGNAL(penChanged()), this, SLOT(updated()));
94 updated();
95 }
96 }
96
97
97 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
98 QPieLegendMarkerPrivate::~QPieLegendMarkerPrivate()
@@ -46,6 +46,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
46 QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) :
46 QXYLegendMarker::QXYLegendMarker(QXYSeries *series, QLegend *legend, QObject *parent) :
47 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
47 QLegendMarker(*new QXYLegendMarkerPrivate(this,series,legend), parent)
48 {
48 {
49 d_ptr->updated();
49 }
50 }
50
51
51 /*!
52 /*!
@@ -76,11 +77,11 QXYSeries* QXYLegendMarker::series()
76
77
77 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
78 QXYLegendMarkerPrivate::QXYLegendMarkerPrivate(QXYLegendMarker *q, QXYSeries *series, QLegend *legend) :
78 QLegendMarkerPrivate(q,legend),
79 QLegendMarkerPrivate(q,legend),
80 q_ptr(q),
79 m_series(series)
81 m_series(series)
80 {
82 {
81 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
83 QObject::connect(m_series, SIGNAL(nameChanged()), this, SLOT(updated()));
82 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
84 QObject::connect(m_series->d_func(), SIGNAL(updated()), this, SLOT(updated()));
83 updated();
84 }
85 }
85
86
86 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
87 QXYLegendMarkerPrivate::~QXYLegendMarkerPrivate()
@@ -114,9 +115,7 void QXYLegendMarkerPrivate::updated()
114 }
115 }
115 } else {
116 } else {
116 if (m_item->brush().color() != m_series->pen().color()) {
117 if (m_item->brush().color() != m_series->pen().color()) {
117 QBrush b = m_item->brush();
118 m_item->setBrush(QBrush(m_series->pen().color()));
118 b.setColor(m_series->pen().color());
119 m_item->setBrush(b);
120 brushChanged = true;
119 brushChanged = true;
121 }
120 }
122 }
121 }
General Comments 0
You need to be logged in to leave comments. Login now