##// END OF EJS Templates
Fix title font resize does not invalidate layout
Michal Klocek -
r2088:5149de44ec86
parent child
Show More
@@ -25,7 +25,6
25 #include "charttitle_p.h"
25 #include "charttitle_p.h"
26 #include "chartbackground_p.h"
26 #include "chartbackground_p.h"
27 #include "legendmarker_p.h"
27 #include "legendmarker_p.h"
28 #include <QDebug>
29
28
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31
30
@@ -87,6 +87,14 QPointF LegendLayout::offset() const
87 return QPointF(m_offsetX,m_offsetY);
87 return QPointF(m_offsetX,m_offsetY);
88 }
88 }
89
89
90 void LegendLayout::invalidate()
91 {
92 QGraphicsLayout::invalidate();
93 if(m_legend->isAttachedToChart()){
94 m_legend->d_ptr->m_presenter->layout()->invalidate();
95 }
96 }
97
90 void LegendLayout::setGeometry(const QRectF& rect)
98 void LegendLayout::setGeometry(const QRectF& rect)
91 {
99 {
92 m_legend->d_ptr->items()->setVisible(m_legend->isVisible());
100 m_legend->d_ptr->items()->setVisible(m_legend->isVisible());
@@ -39,6 +39,7 public:
39 void setOffset(qreal x, qreal y);
39 void setOffset(qreal x, qreal y);
40 QPointF offset() const;
40 QPointF offset() const;
41
41
42 void invalidate();
42 protected:
43 protected:
43 QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
44 QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
44 int count() const { return 0; }
45 int count() const { return 0; }
@@ -77,6 +77,7 void LegendMarker::setFont(const QFont &font)
77 QFontMetrics fn(font);
77 QFontMetrics fn(font);
78 m_markerRect = QRectF(0,0,fn.height()/2,fn.height()/2);
78 m_markerRect = QRectF(0,0,fn.height()/2,fn.height()/2);
79 updateGeometry();
79 updateGeometry();
80 m_legend->layout()->invalidate();
80 }
81 }
81
82
82 QFont LegendMarker::font() const
83 QFont LegendMarker::font() const
@@ -165,7 +166,6 QSizeF LegendMarker::sizeHint(Qt::SizeHint which, const QSizeF& constraint) cons
165 default:
166 default:
166 break;
167 break;
167 }
168 }
168
169 return sh;
169 return sh;
170 }
170 }
171
171
@@ -336,13 +336,9 void QLegend::setAlignment(Qt::Alignment alignment)
336 {
336 {
337 if(d_ptr->m_alignment!=alignment) {
337 if(d_ptr->m_alignment!=alignment) {
338 d_ptr->m_alignment = alignment;
338 d_ptr->m_alignment = alignment;
339 if(isAttachedToChart()){
340 d_ptr->m_presenter->layout()->invalidate();
341 }else{
342 layout()->invalidate();
339 layout()->invalidate();
343 }
340 }
344 }
341 }
345 }
346
342
347 Qt::Alignment QLegend::alignment() const
343 Qt::Alignment QLegend::alignment() const
348 {
344 {
@@ -355,7 +351,7 Qt::Alignment QLegend::alignment() const
355 void QLegend::detachFromChart()
351 void QLegend::detachFromChart()
356 {
352 {
357 d_ptr->m_attachedToChart = false;
353 d_ptr->m_attachedToChart = false;
358 d_ptr->m_layout->invalidate();
354 layout()->invalidate();
359 setParent(0);
355 setParent(0);
360
356
361 }
357 }
@@ -366,7 +362,7 void QLegend::detachFromChart()
366 void QLegend::attachToChart()
362 void QLegend::attachToChart()
367 {
363 {
368 d_ptr->m_attachedToChart = true;
364 d_ptr->m_attachedToChart = true;
369 d_ptr->m_presenter->layout()->invalidate();
365 layout()->invalidate();
370 setParent(d_ptr->m_chart);
366 setParent(d_ptr->m_chart);
371 }
367 }
372
368
@@ -406,14 +402,12 void QLegend::hideEvent(QHideEvent *event)
406 if(isAttachedToChart()) d_ptr->m_presenter->layout()->invalidate();
402 if(isAttachedToChart()) d_ptr->m_presenter->layout()->invalidate();
407 QGraphicsWidget::hideEvent(event);
403 QGraphicsWidget::hideEvent(event);
408 }
404 }
409
410 /*!
405 /*!
411 \internal \a event see QGraphicsWidget for details
406 \internal \a event see QGraphicsWidget for details
412 */
407 */
413 void QLegend::showEvent(QShowEvent *event)
408 void QLegend::showEvent(QShowEvent *event)
414 {
409 {
415 if(isAttachedToChart()) {
410 if(isAttachedToChart()) {
416 d_ptr->m_presenter->layout()->invalidate();
417 d_ptr->items()->setVisible(false);
411 d_ptr->items()->setVisible(false);
418 layout()->invalidate();
412 layout()->invalidate();
419 }
413 }
@@ -478,8 +472,7 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain)
478 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
472 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
479
473
480 m_items->setVisible(false);
474 m_items->setVisible(false);
481 q_ptr->layout()->invalidate();
475 m_layout->invalidate();
482 m_presenter->layout()->invalidate();
483 }
476 }
484
477
485 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
478 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
@@ -493,8 +486,7 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
493
486
494 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
487 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
495 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
488 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
496
489 m_layout->invalidate();
497 q_ptr->layout()->invalidate();
498 }
490 }
499
491
500 void QLegendPrivate::handleSeriesVisibleChanged()
492 void QLegendPrivate::handleSeriesVisibleChanged()
@@ -507,8 +499,7 void QLegendPrivate::handleSeriesVisibleChanged()
507 marker->setVisible(series->isVisible());
499 marker->setVisible(series->isVisible());
508 }
500 }
509 }
501 }
510
502 m_layout->invalidate();
511 q_ptr->layout()->invalidate();
512 }
503 }
513
504
514 void QLegendPrivate::handleCountChanged()
505 void QLegendPrivate::handleCountChanged()
@@ -79,6 +79,7 private:
79 bool m_backgroundVisible;
79 bool m_backgroundVisible;
80
80
81 friend class QLegend;
81 friend class QLegend;
82 friend class LegendLayout;
82
83
83 };
84 };
84
85
General Comments 0
You need to be logged in to leave comments. Login now