summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2014-01-02 17:44:34 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2014-12-01 14:37:02 +0100
commit7cea5949ca5c23a840978dcb80014085e467e9eb (patch)
tree289931e6189ed5b4f436f7a5cfd5a0da56cdbd07
parent9431321c653e4f387d7d27c410d22aabb2d042ef (diff)
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>
-rw-r--r--src/gui/util/qabstractlayoutstyleinfo.cpp7
-rw-r--r--src/gui/util/qabstractlayoutstyleinfo_p.h21
-rw-r--r--src/gui/util/qgridlayoutengine.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.cpp1
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h7
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp1
6 files changed, 7 insertions, 32 deletions
diff --git a/src/gui/util/qabstractlayoutstyleinfo.cpp b/src/gui/util/qabstractlayoutstyleinfo.cpp
index 4338a0ccbf..af4ad0470b 100644
--- a/src/gui/util/qabstractlayoutstyleinfo.cpp
+++ b/src/gui/util/qabstractlayoutstyleinfo.cpp
@@ -35,11 +35,4 @@
QT_BEGIN_NAMESPACE
-bool QAbstractLayoutStyleInfo::hasChanged() const
-{
- if (m_changed == Unknown)
- m_changed = hasChangedCore() ? Changed : Unchanged;
- return m_changed == Changed;
-}
-
QT_END_NAMESPACE
diff --git a/src/gui/util/qabstractlayoutstyleinfo_p.h b/src/gui/util/qabstractlayoutstyleinfo_p.h
index 3479c47c4e..d64cb94aa4 100644
--- a/src/gui/util/qabstractlayoutstyleinfo_p.h
+++ b/src/gui/util/qabstractlayoutstyleinfo_p.h
@@ -53,13 +53,8 @@ QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QAbstractLayoutStyleInfo {
public:
- typedef enum {
- Unknown = 0,
- Changed,
- Unchanged
- } ChangedState;
- QAbstractLayoutStyleInfo() : m_isWindow(false), m_changed(Changed) {}
+ QAbstractLayoutStyleInfo() : m_isWindow(false) {}
virtual ~QAbstractLayoutStyleInfo() {}
virtual qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes /*controls1*/,
QLayoutPolicy::ControlTypes /*controls2*/, Qt::Orientation /*orientation*/) const {
@@ -74,15 +69,9 @@ public:
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) {
- m_changed = change;
- }
-
- bool hasChanged() const;
-
- virtual void invalidate() { updateChanged(Changed);}
+ virtual void invalidate() { }
virtual qreal windowMargin(Qt::Orientation orientation) const = 0;
@@ -92,7 +81,9 @@ public:
protected:
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
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp
index 65f2297fce..43d1ed3b6c 100644
--- a/src/gui/util/qgridlayoutengine.cpp
+++ b/src/gui/util/qgridlayoutengine.cpp
@@ -1590,7 +1590,7 @@ Qt::Orientation QGridLayoutEngine::constraintOrientation() const
void QGridLayoutEngine::ensureGeometries(const QSizeF &size,
const QAbstractLayoutStyleInfo *styleInfo) const
{
- if (!styleInfo->hasChanged() && q_cachedSize == size)
+ if (q_cachedSize == size)
return;
q_cachedSize = size;
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
index 9720bbf9ba..5f689edef6 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
@@ -108,7 +108,6 @@ QGraphicsLayoutStyleInfo *QGraphicsGridLayoutPrivate::styleInfo() const
{
if (!m_styleInfo)
m_styleInfo = new QGraphicsLayoutStyleInfo(this);
- m_styleInfo->updateChanged(QAbstractLayoutStyleInfo::Unknown);
return m_styleInfo;
}
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
index 9e216c8200..1cf94d3962 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
@@ -77,13 +77,6 @@ public:
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;
QStyle *style() const;
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index cad049c30a..baf68d6eef 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
@@ -173,7 +173,6 @@ QGraphicsLayoutStyleInfo *QGraphicsLinearLayoutPrivate::styleInfo() const
{
if (!m_styleInfo)
m_styleInfo = new QGraphicsLayoutStyleInfo(this);
- m_styleInfo->updateChanged(QAbstractLayoutStyleInfo::Unknown);
return m_styleInfo;
}