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