From daeb29af4a462af4257314baba50a97b30527c31 2012-08-29 08:19:20 From: Michal Klocek Date: 2012-08-29 08:19:20 Subject: [PATCH] Adds checkLayout call, when geometry of axis updated --- diff --git a/src/animations/axisanimation.cpp b/src/animations/axisanimation.cpp index fe7767c..8a10c84 100644 --- a/src/animations/axisanimation.cpp +++ b/src/animations/axisanimation.cpp @@ -131,6 +131,7 @@ void AxisAnimation::updateCurrentValue (const QVariant &value ) Q_ASSERT(vector.count() != 0); m_axis->setLayout(vector); m_axis->updateGeometry(); + m_axis->checkLayout(); } } diff --git a/src/axis/categoryaxis/chartcategoryaxisx.cpp b/src/axis/categoryaxis/chartcategoryaxisx.cpp index c094c36..32f1f95 100644 --- a/src/axis/categoryaxis/chartcategoryaxisx.cpp +++ b/src/axis/categoryaxis/chartcategoryaxisx.cpp @@ -120,6 +120,7 @@ void ChartCategoryAxisX::updateGeometry() lineItem = static_cast(axis.at(i+1)); lineItem->setLine(layout[i],m_rect.bottom(),layout[i], m_rect.bottom() + 5); } + } void ChartCategoryAxisX::handleAxisUpdated() diff --git a/src/axis/categoryaxis/chartcategoryaxisy.cpp b/src/axis/categoryaxis/chartcategoryaxisy.cpp index f946f15..7412a29 100644 --- a/src/axis/categoryaxis/chartcategoryaxisy.cpp +++ b/src/axis/categoryaxis/chartcategoryaxisy.cpp @@ -129,6 +129,7 @@ void ChartCategoryAxisY::updateGeometry() lineItem = static_cast(axis.at(i+1)); lineItem->setLine(m_rect.left()-5,layout[i],m_rect.left(),layout[i]); } + } void ChartCategoryAxisY::handleAxisUpdated() diff --git a/src/axis/chartaxis.cpp b/src/axis/chartaxis.cpp index 8c0b217..cdf79be 100644 --- a/src/axis/chartaxis.cpp +++ b/src/axis/chartaxis.cpp @@ -26,6 +26,7 @@ #include #include #include +#include QTCOMMERCIALCHART_BEGIN_NAMESPACE @@ -138,6 +139,7 @@ void ChartAxis::updateLayout(QVector &layout) else { setLayout(layout); updateGeometry(); + checkLayout(); } } @@ -381,6 +383,17 @@ void ChartAxis::createNumberLabels(QStringList &labels,qreal min, qreal max, int } } +void ChartAxis::checkLayout() +{ + if(m_minWidth > m_rect.width()) { + presenter()->layout()->invalidate(); + } + + if(m_minHeight > m_rect.height()) { + presenter()->layout()->invalidate(); + } +} + #include "moc_chartaxis_p.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/axis/chartaxis_p.h b/src/axis/chartaxis_p.h index 671acbf..4229e24 100644 --- a/src/axis/chartaxis_p.h +++ b/src/axis/chartaxis_p.h @@ -98,6 +98,7 @@ protected: virtual void updateGeometry() = 0; virtual QVector calculateLayout() const = 0; void createNumberLabels(QStringList &labels,qreal min, qreal max,int ticks) const; + void checkLayout(); public Q_SLOTS: virtual void handleAxisUpdated(); diff --git a/src/axis/valueaxis/chartvalueaxisx.cpp b/src/axis/valueaxis/chartvalueaxisx.cpp index 877af74..c7ebe96 100644 --- a/src/axis/valueaxis/chartvalueaxisx.cpp +++ b/src/axis/valueaxis/chartvalueaxisx.cpp @@ -107,6 +107,7 @@ void ChartValueAxisX::updateGeometry() lineItem = static_cast(axis.at(i+1)); lineItem->setLine(layout[i],m_rect.bottom(),layout[i],m_rect.bottom()+5); } + } void ChartValueAxisX::handleAxisUpdated() diff --git a/src/axis/valueaxis/chartvalueaxisy.cpp b/src/axis/valueaxis/chartvalueaxisy.cpp index 30629dd..ea50eb3 100644 --- a/src/axis/valueaxis/chartvalueaxisy.cpp +++ b/src/axis/valueaxis/chartvalueaxisy.cpp @@ -112,6 +112,7 @@ void ChartValueAxisY::updateGeometry() lineItem = static_cast(axis.at(i+1)); lineItem->setLine(m_rect.left()-5,layout[i],m_rect.left(),layout[i]); } + } void ChartValueAxisY::handleAxisUpdated()