From 659ade794246c64029809eb4e57d37d7ef7a477b 2012-10-17 07:46:32 From: sauimone Date: 2012-10-17 07:46:32 Subject: [PATCH] fix to QTRD-1674: layout is not calculated correctly after the change in the text of legend marker --- diff --git a/src/legend/qarealegendmarker.cpp b/src/legend/qarealegendmarker.cpp index 4866485..03469b4 100644 --- a/src/legend/qarealegendmarker.cpp +++ b/src/legend/qarealegendmarker.cpp @@ -77,6 +77,7 @@ void QAreaLegendMarkerPrivate::updated() { m_item->setBrush(m_series->brush()); m_item->setLabel(m_series->name()); + invalidateLegend(); } #include "moc_qarealegendmarker.cpp" diff --git a/src/legend/qbarlegendmarker.cpp b/src/legend/qbarlegendmarker.cpp index e3e6b56..ae0f9ec 100644 --- a/src/legend/qbarlegendmarker.cpp +++ b/src/legend/qbarlegendmarker.cpp @@ -86,6 +86,7 @@ void QBarLegendMarkerPrivate::updated() m_item->setPen(m_barset->pen()); m_item->setBrush(m_barset->brush()); m_item->setLabel(m_barset->label()); + invalidateLegend(); } #include "moc_qbarlegendmarker.cpp" diff --git a/src/legend/qlegend.h b/src/legend/qlegend.h index a75971f..d33b0b9 100644 --- a/src/legend/qlegend.h +++ b/src/legend/qlegend.h @@ -102,6 +102,7 @@ private: friend class LegendLayout; friend class ChartLayout; friend class LegendMarkerItem; + friend class QLegendMarkerPrivate; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/legend/qlegend_p.h b/src/legend/qlegend_p.h index 1c4d85a..f3c16f0 100644 --- a/src/legend/qlegend_p.h +++ b/src/legend/qlegend_p.h @@ -93,6 +93,7 @@ private: friend class QLegend; friend class LegendMarkerItem; friend class LegendLayout; + friend class QLegendMarkerPrivate; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/legend/qlegendmarker.cpp b/src/legend/qlegendmarker.cpp index cc77a26..ced5847 100644 --- a/src/legend/qlegendmarker.cpp +++ b/src/legend/qlegendmarker.cpp @@ -22,6 +22,8 @@ #include "qlegendmarker_p.h" #include "legendmarkeritem_p.h" #include "qlegend.h" +#include "qlegend_p.h" +#include "legendlayout_p.h" #include #include #include @@ -112,6 +114,12 @@ QLegendMarkerPrivate::~QLegendMarkerPrivate() { } +void QLegendMarkerPrivate::invalidateLegend() +{ + m_legend->d_ptr->m_layout->invalidate(); +} + + #include "moc_qlegendmarker.cpp" #include "moc_qlegendmarker_p.cpp" diff --git a/src/legend/qlegendmarker_p.h b/src/legend/qlegendmarker_p.h index 8c16005..2b373fe 100644 --- a/src/legend/qlegendmarker_p.h +++ b/src/legend/qlegendmarker_p.h @@ -65,8 +65,10 @@ public: virtual QAbstractSeries* series() = 0; virtual QObject* relatedObject() = 0; + void invalidateLegend(); + public Q_SLOTS: - virtual void updated() {}; + virtual void updated() { invalidateLegend(); } protected: LegendMarkerItem *m_item; diff --git a/src/legend/qpielegendmarker.cpp b/src/legend/qpielegendmarker.cpp index d20447b..006db7f 100644 --- a/src/legend/qpielegendmarker.cpp +++ b/src/legend/qpielegendmarker.cpp @@ -86,6 +86,7 @@ void QPieLegendMarkerPrivate::updated() m_item->setPen(m_slice->pen()); m_item->setBrush(m_slice->brush()); m_item->setLabel(m_slice->label()); + invalidateLegend(); } #include "moc_qpielegendmarker.cpp" diff --git a/src/legend/qxylegendmarker.cpp b/src/legend/qxylegendmarker.cpp index 975cbce..cb090a7 100644 --- a/src/legend/qxylegendmarker.cpp +++ b/src/legend/qxylegendmarker.cpp @@ -82,6 +82,7 @@ void QXYLegendMarkerPrivate::updated() } else { m_item->setBrush(QBrush(m_series->pen().color())); } + invalidateLegend(); } #include "moc_qxylegendmarker.cpp"