Don't rely on hasChanged() in ensureGeometries

It can be removed now because we now have a better caching
mechanism than before. It should therefore not be needed anymore.

Since nothing else calls hasChanged, we can finally get rid of it.
This simplifies the code and enables us to further improvements to the
code.

Change-Id: I51afe5a97311e3e361ae8b491ecbcd21bbedacd1
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
This commit is contained in:
Jan Arve Saether 2014-01-02 17:44:34 +01:00 committed by Jan Arve Sæther
parent 9431321c65
commit 7cea5949ca
6 changed files with 7 additions and 32 deletions

View File

@ -35,11 +35,4 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
bool QAbstractLayoutStyleInfo::hasChanged() const
{
if (m_changed == Unknown)
m_changed = hasChangedCore() ? Changed : Unchanged;
return m_changed == Changed;
}
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -53,13 +53,8 @@ QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QAbstractLayoutStyleInfo { class Q_GUI_EXPORT QAbstractLayoutStyleInfo {
public: public:
typedef enum {
Unknown = 0,
Changed,
Unchanged
} ChangedState;
QAbstractLayoutStyleInfo() : m_isWindow(false), m_changed(Changed) {} QAbstractLayoutStyleInfo() : m_isWindow(false) {}
virtual ~QAbstractLayoutStyleInfo() {} virtual ~QAbstractLayoutStyleInfo() {}
virtual qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes /*controls1*/, virtual qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes /*controls1*/,
QLayoutPolicy::ControlTypes /*controls2*/, Qt::Orientation /*orientation*/) const { QLayoutPolicy::ControlTypes /*controls2*/, Qt::Orientation /*orientation*/) const {
@ -74,15 +69,9 @@ public:
virtual qreal spacing(Qt::Orientation orientation) const = 0; virtual qreal spacing(Qt::Orientation orientation) const = 0;
virtual bool hasChangedCore() const = 0; virtual bool hasChangedCore() const { return false; } // ### Remove when usage is gone from subclasses
void updateChanged(ChangedState change) { virtual void invalidate() { }
m_changed = change;
}
bool hasChanged() const;
virtual void invalidate() { updateChanged(Changed);}
virtual qreal windowMargin(Qt::Orientation orientation) const = 0; virtual qreal windowMargin(Qt::Orientation orientation) const = 0;
@ -92,7 +81,9 @@ public:
protected: protected:
unsigned m_isWindow : 1; unsigned m_isWindow : 1;
mutable unsigned m_changed : 2; mutable unsigned m_hSpacingState: 2;
mutable unsigned m_vSpacingState: 2;
mutable qreal m_spacing[2];
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -1590,7 +1590,7 @@ Qt::Orientation QGridLayoutEngine::constraintOrientation() const
void QGridLayoutEngine::ensureGeometries(const QSizeF &size, void QGridLayoutEngine::ensureGeometries(const QSizeF &size,
const QAbstractLayoutStyleInfo *styleInfo) const const QAbstractLayoutStyleInfo *styleInfo) const
{ {
if (!styleInfo->hasChanged() && q_cachedSize == size) if (q_cachedSize == size)
return; return;
q_cachedSize = size; q_cachedSize = size;

View File

@ -108,7 +108,6 @@ QGraphicsLayoutStyleInfo *QGraphicsGridLayoutPrivate::styleInfo() const
{ {
if (!m_styleInfo) if (!m_styleInfo)
m_styleInfo = new QGraphicsLayoutStyleInfo(this); m_styleInfo = new QGraphicsLayoutStyleInfo(this);
m_styleInfo->updateChanged(QAbstractLayoutStyleInfo::Unknown);
return m_styleInfo; return m_styleInfo;
} }

View File

@ -77,13 +77,6 @@ public:
QAbstractLayoutStyleInfo::invalidate(); QAbstractLayoutStyleInfo::invalidate();
} }
virtual bool hasChangedCore() const Q_DECL_OVERRIDE
{
QStyle *s = m_style;
// Note that style() will change m_style
return s != style();
}
QWidget *widget() const; QWidget *widget() const;
QStyle *style() const; QStyle *style() const;

View File

@ -173,7 +173,6 @@ QGraphicsLayoutStyleInfo *QGraphicsLinearLayoutPrivate::styleInfo() const
{ {
if (!m_styleInfo) if (!m_styleInfo)
m_styleInfo = new QGraphicsLayoutStyleInfo(this); m_styleInfo = new QGraphicsLayoutStyleInfo(this);
m_styleInfo->updateChanged(QAbstractLayoutStyleInfo::Unknown);
return m_styleInfo; return m_styleInfo;
} }