|
@@
-459,6
+459,7
void QLegendPrivate::updateLayout()
|
|
459
|
QPointF point = m_rect.topLeft();
|
|
459
|
QPointF point = m_rect.topLeft();
|
|
460
|
m_width = 0;
|
|
460
|
m_width = 0;
|
|
461
|
foreach (QGraphicsItem *item, items) {
|
|
461
|
foreach (QGraphicsItem *item, items) {
|
|
|
|
|
462
|
if (item->isVisible()) {
|
|
462
|
item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2);
|
|
463
|
item->setPos(point.x(),m_rect.height()/2 -item->boundingRect().height()/2);
|
|
463
|
const QRectF& rect = item->boundingRect();
|
|
464
|
const QRectF& rect = item->boundingRect();
|
|
464
|
qreal w = rect.width();
|
|
465
|
qreal w = rect.width();
|
|
@@
-467,6
+468,7
void QLegendPrivate::updateLayout()
|
|
467
|
m_width+=w;
|
|
468
|
m_width+=w;
|
|
468
|
point.setX(point.x() + w);
|
|
469
|
point.setX(point.x() + w);
|
|
469
|
}
|
|
470
|
}
|
|
|
|
|
471
|
}
|
|
470
|
if(m_width<m_rect.width()) {
|
|
472
|
if(m_width<m_rect.width()) {
|
|
471
|
m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top());
|
|
473
|
m_markers->setPos(m_rect.width()/2-m_width/2,m_rect.top());
|
|
472
|
}
|
|
474
|
}
|
|
@@
-481,6
+483,7
void QLegendPrivate::updateLayout()
|
|
481
|
QPointF point = m_rect.topLeft();
|
|
483
|
QPointF point = m_rect.topLeft();
|
|
482
|
m_height = 0;
|
|
484
|
m_height = 0;
|
|
483
|
foreach (QGraphicsItem *item, items) {
|
|
485
|
foreach (QGraphicsItem *item, items) {
|
|
|
|
|
486
|
if (item->isVisible()) {
|
|
484
|
item->setPos(point);
|
|
487
|
item->setPos(point);
|
|
485
|
const QRectF& rect = item->boundingRect();
|
|
488
|
const QRectF& rect = item->boundingRect();
|
|
486
|
qreal h = rect.height();
|
|
489
|
qreal h = rect.height();
|
|
@@
-489,6
+492,7
void QLegendPrivate::updateLayout()
|
|
489
|
m_height+=h;
|
|
492
|
m_height+=h;
|
|
490
|
point.setY(point.y() + h);
|
|
493
|
point.setY(point.y() + h);
|
|
491
|
}
|
|
494
|
}
|
|
|
|
|
495
|
}
|
|
492
|
if(m_height<m_rect.height()) {
|
|
496
|
if(m_height<m_rect.height()) {
|
|
493
|
m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2);
|
|
497
|
m_markers->setPos(m_rect.left(),m_rect.height()/2-m_height/2);
|
|
494
|
}
|
|
498
|
}
|
|
@@
-530,6
+534,7
void QLegendPrivate::updateDetachedLayout()
|
|
530
|
m_height = 0;
|
|
534
|
m_height = 0;
|
|
531
|
for (int i=0; i<items.count(); i++) {
|
|
535
|
for (int i=0; i<items.count(); i++) {
|
|
532
|
QGraphicsItem *item = items.at(i);
|
|
536
|
QGraphicsItem *item = items.at(i);
|
|
|
|
|
537
|
if (item->isVisible()) {
|
|
533
|
const QRectF& rect = item->boundingRect();
|
|
538
|
const QRectF& rect = item->boundingRect();
|
|
534
|
qreal w = rect.width();
|
|
539
|
qreal w = rect.width();
|
|
535
|
qreal h = rect.height();
|
|
540
|
qreal h = rect.height();
|
|
@@
-547,6
+552,7
void QLegendPrivate::updateDetachedLayout()
|
|
547
|
}
|
|
552
|
}
|
|
548
|
}
|
|
553
|
}
|
|
549
|
}
|
|
554
|
}
|
|
|
|
|
555
|
}
|
|
550
|
m_markers->setPos(m_rect.topLeft());
|
|
556
|
m_markers->setPos(m_rect.topLeft());
|
|
551
|
m_width = m_minWidth;
|
|
557
|
m_width = m_minWidth;
|
|
552
|
|
|
558
|
|
|
@@
-562,6
+568,7
void QLegendPrivate::updateDetachedLayout()
|
|
562
|
m_height = 0;
|
|
568
|
m_height = 0;
|
|
563
|
for (int i=0; i<items.count(); i++) {
|
|
569
|
for (int i=0; i<items.count(); i++) {
|
|
564
|
QGraphicsItem *item = items.at(i);
|
|
570
|
QGraphicsItem *item = items.at(i);
|
|
|
|
|
571
|
if (item->isVisible()) {
|
|
565
|
const QRectF& rect = item->boundingRect();
|
|
572
|
const QRectF& rect = item->boundingRect();
|
|
566
|
qreal w = rect.width();
|
|
573
|
qreal w = rect.width();
|
|
567
|
qreal h = rect.height();
|
|
574
|
qreal h = rect.height();
|
|
@@
-579,6
+586,7
void QLegendPrivate::updateDetachedLayout()
|
|
579
|
}
|
|
586
|
}
|
|
580
|
}
|
|
587
|
}
|
|
581
|
}
|
|
588
|
}
|
|
|
|
|
589
|
}
|
|
582
|
m_markers->setPos(m_rect.topLeft());
|
|
590
|
m_markers->setPos(m_rect.topLeft());
|
|
583
|
m_width = m_minWidth;
|
|
591
|
m_width = m_minWidth;
|
|
584
|
|
|
592
|
|
|
@@
-595,6
+603,7
void QLegendPrivate::updateDetachedLayout()
|
|
595
|
qreal maxWidth = 0;
|
|
603
|
qreal maxWidth = 0;
|
|
596
|
for (int i=0; i<items.count(); i++) {
|
|
604
|
for (int i=0; i<items.count(); i++) {
|
|
597
|
QGraphicsItem *item = items.at(i);
|
|
605
|
QGraphicsItem *item = items.at(i);
|
|
|
|
|
606
|
if (item->isVisible()) {
|
|
598
|
const QRectF& rect = item->boundingRect();
|
|
607
|
const QRectF& rect = item->boundingRect();
|
|
599
|
qreal w = rect.width();
|
|
608
|
qreal w = rect.width();
|
|
600
|
qreal h = rect.height();
|
|
609
|
qreal h = rect.height();
|
|
@@
-613,6
+622,7
void QLegendPrivate::updateDetachedLayout()
|
|
613
|
}
|
|
622
|
}
|
|
614
|
}
|
|
623
|
}
|
|
615
|
}
|
|
624
|
}
|
|
|
|
|
625
|
}
|
|
616
|
m_width += maxWidth;
|
|
626
|
m_width += maxWidth;
|
|
617
|
m_markers->setPos(m_rect.topLeft());
|
|
627
|
m_markers->setPos(m_rect.topLeft());
|
|
618
|
m_height = m_minHeight;
|
|
628
|
m_height = m_minHeight;
|
|
@@
-630,6
+640,7
void QLegendPrivate::updateDetachedLayout()
|
|
630
|
qreal maxWidth = 0;
|
|
640
|
qreal maxWidth = 0;
|
|
631
|
for (int i=0; i<items.count(); i++) {
|
|
641
|
for (int i=0; i<items.count(); i++) {
|
|
632
|
QGraphicsItem *item = items.at(i);
|
|
642
|
QGraphicsItem *item = items.at(i);
|
|
|
|
|
643
|
if (item->isVisible()) {
|
|
633
|
const QRectF& rect = item->boundingRect();
|
|
644
|
const QRectF& rect = item->boundingRect();
|
|
634
|
qreal w = rect.width();
|
|
645
|
qreal w = rect.width();
|
|
635
|
qreal h = rect.height();
|
|
646
|
qreal h = rect.height();
|
|
@@
-648,6
+659,7
void QLegendPrivate::updateDetachedLayout()
|
|
648
|
}
|
|
659
|
}
|
|
649
|
}
|
|
660
|
}
|
|
650
|
}
|
|
661
|
}
|
|
|
|
|
662
|
}
|
|
651
|
m_width += maxWidth;
|
|
663
|
m_width += maxWidth;
|
|
652
|
m_markers->setPos(m_rect.topLeft());
|
|
664
|
m_markers->setPos(m_rect.topLeft());
|
|
653
|
m_height = m_minHeight;
|
|
665
|
m_height = m_minHeight;
|
|
@@
-682,6
+694,8
void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
|
|
682
|
foreach(LegendMarker* marker, markers)
|
|
694
|
foreach(LegendMarker* marker, markers)
|
|
683
|
m_markers->addToGroup(marker);
|
|
695
|
m_markers->addToGroup(marker);
|
|
684
|
|
|
696
|
|
|
|
|
|
697
|
QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
|
|
|
|
|
698
|
|
|
685
|
if(series->type() == QAbstractSeries::SeriesTypePie) {
|
|
699
|
if(series->type() == QAbstractSeries::SeriesTypePie) {
|
|
686
|
QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
|
|
700
|
QPieSeries *pieSeries = static_cast<QPieSeries *>(series);
|
|
687
|
QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
|
|
701
|
QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries()));
|
|
@@
-730,6
+744,21
void QLegendPrivate::handleUpdatePieSeries()
|
|
730
|
handleSeriesAdded(series, 0);
|
|
744
|
handleSeriesAdded(series, 0);
|
|
731
|
}
|
|
745
|
}
|
|
732
|
|
|
746
|
|
|
|
|
|
747
|
void QLegendPrivate::handleSeriesVisibleChanged()
|
|
|
|
|
748
|
{
|
|
|
|
|
749
|
QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender());
|
|
|
|
|
750
|
QList<QGraphicsItem *> items = m_markers->childItems();
|
|
|
|
|
751
|
|
|
|
|
|
752
|
foreach (QGraphicsItem *markers, items) {
|
|
|
|
|
753
|
LegendMarker *marker = static_cast<LegendMarker*>(markers);
|
|
|
|
|
754
|
if (marker->series() == series) {
|
|
|
|
|
755
|
marker->setVisible(!marker->isVisible());
|
|
|
|
|
756
|
}
|
|
|
|
|
757
|
}
|
|
|
|
|
758
|
|
|
|
|
|
759
|
updateLayout();
|
|
|
|
|
760
|
}
|
|
|
|
|
761
|
|
|
733
|
|
|
762
|
|
|
734
|
#include "moc_qlegend.cpp"
|
|
763
|
#include "moc_qlegend.cpp"
|
|
735
|
#include "moc_qlegend_p.cpp"
|
|
764
|
#include "moc_qlegend_p.cpp"
|