##// END OF EJS Templates
Fixes blinking and minimal false size for legend
Michal Klocek -
r1538:8f0be28e5215
parent child
Show More
@@ -21,6 +21,7
21 #include "chartlayout_p.h"
21 #include "chartlayout_p.h"
22 #include "chartpresenter_p.h"
22 #include "chartpresenter_p.h"
23 #include "chartaxis_p.h"
23 #include "chartaxis_p.h"
24 #include <QDebug>
24
25
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
27
@@ -41,6 +42,7 ChartLayout::~ChartLayout()
41
42
42 void ChartLayout::setGeometry(const QRectF& rect)
43 void ChartLayout::setGeometry(const QRectF& rect)
43 {
44 {
45
44 if (!rect.isValid()) return;
46 if (!rect.isValid()) return;
45
47
46 QGraphicsLayout::setGeometry(rect);
48 QGraphicsLayout::setGeometry(rect);
@@ -22,6 +22,7
22 #include "chartpresenter_p.h"
22 #include "chartpresenter_p.h"
23 #include "legendmarker_p.h"
23 #include "legendmarker_p.h"
24 #include "qlegend_p.h"
24 #include "qlegend_p.h"
25 #include <QDebug>
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28
@@ -85,7 +86,6 QPointF LegendLayout::offset() const
85
86
86 void LegendLayout::setGeometry(const QRectF& rect)
87 void LegendLayout::setGeometry(const QRectF& rect)
87 {
88 {
88 if (!rect.isValid()) return;
89
89
90 QGraphicsLayout::setGeometry(rect);
90 QGraphicsLayout::setGeometry(rect);
91
91
@@ -99,6 +99,7 void LegendLayout::setGeometry(const QRectF& rect)
99
99
100 void LegendLayout::setAttachedGeometry(const QRectF& rect)
100 void LegendLayout::setAttachedGeometry(const QRectF& rect)
101 {
101 {
102 if (!rect.isValid()) return;
102
103
103 m_offsetX=0;
104 m_offsetX=0;
104 m_offsetY=0;
105 m_offsetY=0;
@@ -170,6 +171,8 void LegendLayout::setAttachedGeometry(const QRectF& rect)
170
171
171 void LegendLayout::setDettachedGeometry(const QRectF& rect)
172 void LegendLayout::setDettachedGeometry(const QRectF& rect)
172 {
173 {
174 if (!rect.isValid()) return;
175
173 // Detached layout is different.
176 // Detached layout is different.
174 // In detached mode legend may have multiple rows and columns, so layout calculations
177 // In detached mode legend may have multiple rows and columns, so layout calculations
175 // differ a log from attached mode.
178 // differ a log from attached mode.
@@ -335,6 +338,8 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) c
335 qreal left, top, right, bottom;
338 qreal left, top, right, bottom;
336 getContentsMargins(&left, &top, &right, &bottom);
339 getContentsMargins(&left, &top, &right, &bottom);
337
340
341 if(which!=Qt::PreferredSize) return QSizeF(-1,-1);
342
338 if(constraint.isValid()) {
343 if(constraint.isValid()) {
339 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
344 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
340 size = size.expandedTo(marker->effectiveSizeHint(which));
345 size = size.expandedTo(marker->effectiveSizeHint(which));
@@ -366,7 +371,10 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) c
366 }
371 }
367 }
372 }
368 size += QSize(left + right, top + bottom);
373 size += QSize(left + right, top + bottom);
374
369 return size;
375 return size;
376
377
370 }
378 }
371
379
372 QTCOMMERCIALCHART_END_NAMESPACE
380 QTCOMMERCIALCHART_END_NAMESPACE
@@ -492,6 +492,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
492 }
492 }
493
493
494 q_ptr->layout()->invalidate();
494 q_ptr->layout()->invalidate();
495 q_ptr->layout()->activate();
495 }
496 }
496
497
497 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
498 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
General Comments 0
You need to be logged in to leave comments. Login now