@@ -106,6 +106,7 void BarChartItem::dataChanged() | |||
|
106 | 106 | } |
|
107 | 107 | } |
|
108 | 108 | } |
|
109 | ||
|
109 | 110 | QVector<QRectF> BarChartItem::calculateLayout() |
|
110 | 111 | { |
|
111 | 112 | QVector<QRectF> layout; |
@@ -507,20 +507,42 void QLegend::updateLayout() | |||
|
507 | 507 | return; |
|
508 | 508 | } |
|
509 | 509 | |
|
510 | // Find out widest item. | |
|
511 | QSizeF markerMaxSize = maximumMarkerSize(); | |
|
512 | 510 | checkFirstMarkerBounds(); |
|
513 | 511 | |
|
514 | // Use max height as scroll button size | |
|
515 | rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height())); | |
|
516 | ||
|
517 | qreal totalWidth = 0; | |
|
518 | qreal totalHeight = 0; | |
|
519 | 512 | switch (m_alignment) |
|
520 | 513 | { |
|
521 | 514 | // Both cases organise items horizontally |
|
522 | 515 | case QLegend::AlignmentBottom: |
|
523 | 516 | case QLegend::AlignmentTop: { |
|
517 | layoutHorizontal(); | |
|
518 | break; | |
|
519 | } | |
|
520 | // Both cases organize items vertically | |
|
521 | case QLegend::AlignmentLeft: | |
|
522 | case QLegend::AlignmentRight: { | |
|
523 | layoutVertical(); | |
|
524 | break; | |
|
525 | } | |
|
526 | default: { | |
|
527 | break; | |
|
528 | } | |
|
529 | } | |
|
530 | ||
|
531 | } | |
|
532 | ||
|
533 | /*! | |
|
534 | \internal Organizes markers horizontally. | |
|
535 | Causes legend to be resized. | |
|
536 | */ | |
|
537 | void QLegend::layoutHorizontal() | |
|
538 | { | |
|
539 | // Find out widest item. | |
|
540 | QSizeF markerMaxSize = maximumMarkerSize(); | |
|
541 | // Use max height as scroll button size | |
|
542 | rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height())); | |
|
543 | ||
|
544 | qreal totalWidth = 0; | |
|
545 | qreal totalHeight = 0; | |
|
524 | 546 | |
|
525 | 547 |
|
|
526 | 548 |
|
@@ -571,11 +593,24 void QLegend::updateLayout() | |||
|
571 | 593 |
|
|
572 | 594 |
|
|
573 | 595 | |
|
574 | break; | |
|
596 | m_size.setWidth(totalWidth); | |
|
597 | m_size.setHeight(totalHeight); | |
|
575 | 598 | } |
|
576 | // Both cases organize items vertically | |
|
577 | case QLegend::AlignmentLeft: | |
|
578 | case QLegend::AlignmentRight: { | |
|
599 | ||
|
600 | /*! | |
|
601 | \internal Organizes markers vertically. | |
|
602 | Causes legend to be resized. | |
|
603 | */ | |
|
604 | void QLegend::layoutVertical() | |
|
605 | { | |
|
606 | // Find out widest item. | |
|
607 | QSizeF markerMaxSize = maximumMarkerSize(); | |
|
608 | // Use max height as scroll button size | |
|
609 | rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height())); | |
|
610 | ||
|
611 | qreal totalWidth = 0; | |
|
612 | qreal totalHeight = 0; | |
|
613 | ||
|
579 | 614 |
|
|
580 | 615 |
|
|
581 | 616 |
|
@@ -622,17 +657,9 void QLegend::updateLayout() | |||
|
622 | 657 | |
|
623 | 658 |
|
|
624 | 659 |
|
|
625 | break; | |
|
626 | } | |
|
627 | default: { | |
|
628 | break; | |
|
629 | } | |
|
630 | } | |
|
631 | 660 | |
|
632 | 661 | m_size.setWidth(totalWidth); |
|
633 | 662 | m_size.setHeight(totalHeight); |
|
634 | ||
|
635 | update(); | |
|
636 | 663 | } |
|
637 | 664 | |
|
638 | 665 | /*! |
@@ -109,6 +109,8 private: | |||
|
109 | 109 | void appendMarkers(QPieSeries *series); |
|
110 | 110 | void deleteMarkers(QSeries *series); |
|
111 | 111 | void updateLayout(); |
|
112 | void layoutHorizontal(); | |
|
113 | void layoutVertical(); | |
|
112 | 114 | void rescaleScrollButtons(const QSize &size); |
|
113 | 115 | QSizeF maximumMarkerSize(); |
|
114 | 116 | void checkFirstMarkerBounds(); |
General Comments 0
You need to be logged in to leave comments.
Login now