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