##// END OF EJS Templates
solid brush for all legend markers
sauimone -
r800:32248fc3cb26
parent child
Show More
@@ -169,19 +169,23 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
169
169
170 void LegendMarker::changed()
170 void LegendMarker::changed()
171 {
171 {
172 setPen(Qt::NoPen);
172 switch (m_series->type()) {
173 switch (m_series->type()) {
173 case QSeries::SeriesTypeArea: {
174 case QSeries::SeriesTypeArea: {
174 QAreaSeries* s = static_cast<QAreaSeries*> (m_series);
175 QAreaSeries* s = static_cast<QAreaSeries*> (m_series);
175 setPen(s->pen());
176 setBrush(s->brush());
176 setBrush(s->brush());
177 setName(s->name());
177 setName(s->name());
178 break;
178 break;
179 }
179 }
180 case QSeries::SeriesTypeLine:
180 case QSeries::SeriesTypeLine:
181 case QSeries::SeriesTypeScatter:
182 case QSeries::SeriesTypeSpline: {
181 case QSeries::SeriesTypeSpline: {
183 QXYSeries* s = static_cast<QXYSeries*> (m_series);
182 QXYSeries* s = static_cast<QXYSeries*> (m_series);
184 setPen(s->pen());
183 setBrush(QBrush(s->pen().color(),Qt::SolidPattern));
184 setName(s->name());
185 break;
186 }
187 case QSeries::SeriesTypeScatter: {
188 QXYSeries* s = static_cast<QXYSeries*> (m_series);
185 setBrush(s->brush());
189 setBrush(s->brush());
186 setName(s->name());
190 setName(s->name());
187 break;
191 break;
@@ -189,7 +193,6 void LegendMarker::changed()
189 case QSeries::SeriesTypeBar:
193 case QSeries::SeriesTypeBar:
190 case QSeries::SeriesTypeStackedBar:
194 case QSeries::SeriesTypeStackedBar:
191 case QSeries::SeriesTypePercentBar: {
195 case QSeries::SeriesTypePercentBar: {
192 setPen(m_barset->pen());
193 setBrush(m_barset->brush());
196 setBrush(m_barset->brush());
194 setName(m_barset->name());
197 setName(m_barset->name());
195 break;
198 break;
@@ -200,6 +203,7 void LegendMarker::changed()
200 break;
203 break;
201 }
204 }
202 default: {
205 default: {
206 setBrush(Qt::NoBrush);
203 break;
207 break;
204 }
208 }
205 }
209 }
@@ -372,7 +372,7 void QChartPrivate::updateLegendLayout()
372 switch (m_legend->alignment())
372 switch (m_legend->alignment())
373 {
373 {
374 case QLegend::AlignmentTop: {
374 case QLegend::AlignmentTop: {
375 legendRect = m_rect.adjusted(0,0,0,-padding - plotRect.height());
375 legendRect = m_rect.adjusted(0,padding,0,-padding - plotRect.height());
376 break;
376 break;
377 }
377 }
378 case QLegend::AlignmentBottom: {
378 case QLegend::AlignmentBottom: {
@@ -93,7 +93,7 QLegend::QLegend(QChart *chart):QGraphicsWidget(chart),
93 m_maximumSize(150,100),
93 m_maximumSize(150,100),
94 m_size(m_minimumSize),
94 m_size(m_minimumSize),
95 m_brush(Qt::darkGray), // TODO: default should come from theme
95 m_brush(Qt::darkGray), // TODO: default should come from theme
96 m_alignment(QLegend::AlignmentRight),
96 m_alignment(QLegend::AlignmentTop),
97 mFirstMarker(0),
97 mFirstMarker(0),
98 m_attachedToChart(true)
98 m_attachedToChart(true)
99 {
99 {
@@ -419,12 +419,10 bool QLegend::attachedToChart()
419 void QLegend::appendMarkers(QAreaSeries* series)
419 void QLegend::appendMarkers(QAreaSeries* series)
420 {
420 {
421 LegendMarker* marker = new LegendMarker(series,this);
421 LegendMarker* marker = new LegendMarker(series,this);
422 marker->setName(series->name());
423 marker->setPen(series->pen());
424 marker->setBrush(series->brush());
425 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
422 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
426 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
423 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
427 connect(series,SIGNAL(updated()),marker,SLOT(changed()));
424 connect(series,SIGNAL(updated()),marker,SLOT(changed()));
425 marker->changed();
428 m_markers.append(marker);
426 m_markers.append(marker);
429 childItems().append(marker);
427 childItems().append(marker);
430 }
428 }
@@ -435,12 +433,10 void QLegend::appendMarkers(QAreaSeries* series)
435 void QLegend::appendMarkers(QXYSeries* series)
433 void QLegend::appendMarkers(QXYSeries* series)
436 {
434 {
437 LegendMarker* marker = new LegendMarker(series,this);
435 LegendMarker* marker = new LegendMarker(series,this);
438 marker->setName(series->name());
439 marker->setPen(series->pen());
440 marker->setBrush(series->brush());
441 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
436 connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton)));
442 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
437 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
443 connect(series,SIGNAL(updated()),marker,SLOT(changed()));
438 connect(series,SIGNAL(updated()),marker,SLOT(changed()));
439 marker->changed();
444 m_markers.append(marker);
440 m_markers.append(marker);
445 childItems().append(marker);
441 childItems().append(marker);
446 }
442 }
@@ -452,13 +448,11 void QLegend::appendMarkers(QBarSeries *series)
452 {
448 {
453 foreach(QBarSet* set, series->barSets()) {
449 foreach(QBarSet* set, series->barSets()) {
454 LegendMarker* marker = new LegendMarker(series, set, this);
450 LegendMarker* marker = new LegendMarker(series, set, this);
455 marker->setName(set->name());
456 marker->setPen(set->pen());
457 marker->setBrush(set->brush());
458 connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)),
451 connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)),
459 this, SIGNAL(clicked(QBarSet *, Qt::MouseButton)));
452 this, SIGNAL(clicked(QBarSet *, Qt::MouseButton)));
460 connect(set, SIGNAL(valueChanged()), marker, SLOT(changed()));
453 connect(set, SIGNAL(valueChanged()), marker, SLOT(changed()));
461 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
454 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
455 marker->changed();
462 m_markers.append(marker);
456 m_markers.append(marker);
463 childItems().append(marker);
457 childItems().append(marker);
464 }
458 }
@@ -471,14 +465,12 void QLegend::appendMarkers(QPieSeries *series)
471 {
465 {
472 foreach(QPieSlice* slice, series->slices()) {
466 foreach(QPieSlice* slice, series->slices()) {
473 LegendMarker* marker = new LegendMarker(series, slice, this);
467 LegendMarker* marker = new LegendMarker(series, slice, this);
474 marker->setName(slice->label());
475 marker->setPen(slice->pen());
476 marker->setBrush(slice->brush());
477 connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)),
468 connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)),
478 this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)));
469 this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)));
479 connect(slice, SIGNAL(changed()), marker, SLOT(changed()));
470 connect(slice, SIGNAL(changed()), marker, SLOT(changed()));
480 connect(slice, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
471 connect(slice, SIGNAL(destroyed()), marker, SLOT(deleteLater()));
481 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
472 connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed()));
473 marker->changed();
482 m_markers.append(marker);
474 m_markers.append(marker);
483 childItems().append(marker);
475 childItems().append(marker);
484 }
476 }
General Comments 0
You need to be logged in to leave comments. Login now