summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-05-11 00:17:52 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-11 00:43:44 +0200
commit91fc9b1823c0a95190005f3baaa4aa2276290f3a (patch)
treed36db347a292495e43367bd2c92d4d07f955553b
parentb4e424e0e13f9336234dd06a556f3ec2899d173a (diff)
Revert "Return infinity instead of -1 as a default value for max sizes"
This reverts commit a4158c97d84d5c76126307213baf22d12babdbc2 This commit breaks the basiclayouts example so I am reverting it until we have a revised ifx. Change-Id: I901924d292606ffe1e797232ad2f5ff02d8fc2d6 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
-rw-r--r--src/layouts/qquickgridlayoutengine.cpp5
-rw-r--r--src/layouts/qquicklayout.cpp58
-rw-r--r--src/layouts/qquicklayout_p.h13
-rw-r--r--src/layouts/qquicklinearlayout.cpp12
-rw-r--r--src/layouts/qquicklinearlayout_p.h1
-rw-r--r--tests/auto/controls/data/tst_rowlayout.qml33
6 files changed, 36 insertions, 86 deletions
diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp
index bacfd965b..e734e9fef 100644
--- a/src/layouts/qquickgridlayoutengine.cpp
+++ b/src/layouts/qquickgridlayoutengine.cpp
@@ -204,8 +204,9 @@ Fixed | Layout.fillWidth | Expanding if layout, Fixed if item |
}
}
//--- GATHER MAXIMUM SIZE HINTS ---
- combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), std::numeric_limits<qreal>::infinity());
- combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), std::numeric_limits<qreal>::infinity());
+ // They are always q_declarativeLayoutMaxSize
+ combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), q_declarativeLayoutMaxSize);
+ combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), q_declarativeLayoutMaxSize);
//--- GATHER DESCENT
// ### Not implemented
diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp
index d26737e2d..6d36a92e6 100644
--- a/src/layouts/qquicklayout.cpp
+++ b/src/layouts/qquicklayout.cpp
@@ -43,7 +43,6 @@
#include <QEvent>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qnumeric.h>
-#include <limits>
/*!
\qmltype Layout
@@ -79,8 +78,8 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
m_minimumHeight(0),
m_preferredWidth(-1),
m_preferredHeight(-1),
- m_maximumWidth(std::numeric_limits<qreal>::infinity()),
- m_maximumHeight(std::numeric_limits<qreal>::infinity()),
+ m_maximumWidth(-1),
+ m_maximumHeight(-1),
m_row(-1),
m_column(-1),
m_rowSpan(1),
@@ -102,15 +101,8 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent)
/*!
\qmlproperty real Layout::minimumWidth
- This property holds the maximum width of an item in a layout.
- The default value is the items implicit minimum width.
-
- If the item is a layout, the implicit minimum width will be the minimum width the layout can
- have without any of its items shrink beyond their minimum width.
- The implicit minimum width for any other item is \c 0.
-
- Setting this value to -1 will reset the width back to its implicit minimum width.
-
+ This property holds the minimum width of an item in a layout.
+ The default is \c 0.
\sa preferredWidth
\sa maximumWidth
@@ -131,13 +123,8 @@ void QQuickLayoutAttached::setMinimumWidth(qreal width)
/*!
\qmlproperty real Layout::minimumHeight
- The default value is the items implicit minimum height.
-
- If the item is a layout, the implicit minimum height will be the minimum height the layout can
- have without any of its items shrink beyond their minimum height.
- The implicit minimum height for any other item is \c 0.
-
- Setting this value to -1 will reset the height back to its implicit minimum height.
+ This property holds the minimum height of an item in a layout.
+ The default is \c 0.
\sa preferredHeight
\sa maximumHeight
@@ -201,13 +188,10 @@ void QQuickLayoutAttached::setPreferredHeight(qreal height)
\qmlproperty real Layout::maximumWidth
This property holds the maximum width of an item in a layout.
- The default value is the items implicit maximum width.
-
- If the item is a layout, the implicit maximum width will be the maximum width the layout can
- have without any of its items grow beyond their maximum width.
- The implicit maximum width for any other item is \c Number.POSITIVE_INFINITE.
+ The default is \c -1, which means it there is no limit on the maxiumum width.
- Setting this value to -1 will reset the width back to its implicit maximum width.
+ \note There is actually a limit on the maximum width, but it's set to such a
+ large number that the arrangement is virtually the same as if it didn't have a limit.
\sa minimumWidth
\sa preferredWidth
@@ -228,13 +212,11 @@ void QQuickLayoutAttached::setMaximumWidth(qreal width)
/*!
\qmlproperty real Layout::maximumHeight
- The default value is the items implicit maximum height.
+ This property holds the maximum height of an item in a layout.
+ The default is \c -1, which means it there is no limit on the maxiumum height.
- If the item is a layout, the implicit maximum height will be the maximum height the layout can
- have without any of its items grow beyond their maximum height.
- The implicit maximum height for any other item is \c Number.POSITIVE_INFINITE.
-
- Setting this value to -1 will reset the height back to its implicit maximum height.
+ \note There is actually a limit on the maximum height, but it's set to such a
+ large number that the arrangement is virtually the same as if it didn't have a limit.
\sa minimumHeight
\sa preferredHeight
@@ -407,20 +389,6 @@ void QQuickLayoutAttached::setColumn(int column)
\sa column
*/
-
-qreal QQuickLayoutAttached::sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const
-{
- qreal result = 0;
- if (QQuickLayout *layout = qobject_cast<QQuickLayout *>(item())) {
- const QSizeF sz = layout->sizeHint(which);
- result = (orientation == Qt::Horizontal ? sz.width() : sz.height());
- } else {
- if (which == Qt::MaximumSize)
- result = std::numeric_limits<qreal>::infinity();
- }
- return result;
-}
-
void QQuickLayoutAttached::invalidateItem()
{
if (!m_changesNotificationEnabled)
diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h
index 8a334677a..8d9464476 100644
--- a/src/layouts/qquicklayout_p.h
+++ b/src/layouts/qquicklayout_p.h
@@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
class QQuickLayoutAttached;
+static const qreal q_declarativeLayoutMaxSize = 10e8;
+
#if 0 && !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_OUTPUT)
# define quickLayoutDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug
#else
@@ -75,7 +77,6 @@ public:
void componentComplete();
- virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0;
virtual void invalidate(QQuickItem * childItem = 0);
protected:
bool event(QEvent *e);
@@ -122,10 +123,10 @@ class QQuickLayoutAttached : public QObject
public:
QQuickLayoutAttached(QObject *object);
- qreal minimumWidth() const { return m_minimumWidth < 0 ? sizeHint(Qt::MinimumSize, Qt::Horizontal) : m_minimumWidth; }
+ qreal minimumWidth() const { return m_minimumWidth; }
void setMinimumWidth(qreal width);
- qreal minimumHeight() const { return m_minimumHeight < 0 ? sizeHint(Qt::MinimumSize, Qt::Vertical) : m_minimumHeight; }
+ qreal minimumHeight() const { return m_minimumHeight; }
void setMinimumHeight(qreal height);
qreal preferredWidth() const { return m_preferredWidth; }
@@ -134,10 +135,10 @@ public:
qreal preferredHeight() const { return m_preferredHeight; }
void setPreferredHeight(qreal width);
- qreal maximumWidth() const { return m_maximumWidth < 0 ? sizeHint(Qt::MaximumSize, Qt::Horizontal) : m_maximumWidth; }
+ qreal maximumWidth() const { return m_maximumWidth; }
void setMaximumWidth(qreal width);
- qreal maximumHeight() const { return m_maximumHeight < 0 ? sizeHint(Qt::MaximumSize, Qt::Vertical) : m_maximumHeight; }
+ qreal maximumHeight() const { return m_maximumHeight; }
void setMaximumHeight(qreal height);
void setMinimumImplicitSize(const QSizeF &sz);
@@ -173,8 +174,6 @@ public:
return old;
}
- qreal sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const;
-
signals:
void minimumWidthChanged();
void minimumHeightChanged();
diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp
index d5bd503a7..c45310027 100644
--- a/src/layouts/qquicklinearlayout.cpp
+++ b/src/layouts/qquicklinearlayout.cpp
@@ -171,12 +171,6 @@ void QQuickGridLayoutBase::setOrientation(Qt::Orientation orientation)
invalidate();
}
-QSizeF QQuickGridLayoutBase::sizeHint(Qt::SizeHint whichSizeHint) const
-{
- Q_D(const QQuickGridLayoutBase);
- return d->engine.sizeHint(whichSizeHint, QSizeF());
-}
-
void QQuickGridLayoutBase::componentComplete()
{
Q_D(QQuickGridLayoutBase);
@@ -247,9 +241,9 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
QQuickLayoutAttached *info = attachedLayoutObject(this);
- const QSizeF min = sizeHint(Qt::MinimumSize);
- const QSizeF pref = sizeHint(Qt::PreferredSize);
- const QSizeF max = sizeHint(Qt::MaximumSize);
+ const QSizeF min = d->engine.sizeHint(Qt::MinimumSize, QSizeF());
+ const QSizeF pref = d->engine.sizeHint(Qt::PreferredSize, QSizeF());
+ const QSizeF max = d->engine.sizeHint(Qt::MaximumSize, QSizeF());
const bool old = info->setChangesNotificationEnabled(false);
info->setMinimumImplicitSize(min);
diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h
index 76cc206b9..f1a9b39f5 100644
--- a/src/layouts/qquicklinearlayout_p.h
+++ b/src/layouts/qquicklinearlayout_p.h
@@ -68,7 +68,6 @@ public:
void invalidate(QQuickItem *childItem = 0);
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orientation);
- QSizeF sizeHint(Qt::SizeHint whichSizeHint) const Q_DECL_OVERRIDE;
protected:
void updateLayoutItems();
diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml
index 6e2d1334a..1b9573e0c 100644
--- a/tests/auto/controls/data/tst_rowlayout.qml
+++ b/tests/auto/controls/data/tst_rowlayout.qml
@@ -129,8 +129,6 @@ Item {
tmp.width = 30
compare(tmp.r1.width, 10);
compare(tmp.r2.width, 20);
- compare(tmp.Layout.minimumWidth, 0)
- compare(tmp.Layout.maximumWidth, Number.POSITIVE_INFINITY)
tmp.destroy()
}
@@ -395,8 +393,8 @@ Item {
function test_sizeHintNormalization_data() {
return [
- { tag: "fallbackValues", widthHints: [-1, -1, -1], implicitWidth: 42, expected:[0,42,Number.POSITIVE_INFINITY]},
- { tag: "acceptZeroWidths", widthHints: [0, 0, 0], implicitWidth: 42, expected:[0,0,0]},
+ { tag: "fallbackValues", widthHints: [-1, -1, -1], expected:[0,42,1000000000], implicitWidth: 42},
+ { tag: "acceptZeroWidths", widthHints: [0, 0, 0], expected:[0,0,0], implicitWidth: 42},
{ tag: "123", widthHints: [1,2,3], expected:[1,2,3]},
{ tag: "132", widthHints: [1,3,2], expected:[1,2,2]},
{ tag: "213", widthHints: [2,1,3], expected:[2,2,3]},
@@ -404,12 +402,12 @@ Item {
{ tag: "321", widthHints: [3,2,1], expected:[1,1,1]},
{ tag: "312", widthHints: [3,1,2], expected:[2,2,2]},
- { tag: "1i3", widthHints: [1,-1,3], implicitWidth: 2, expected:[1,2,3]},
- { tag: "1i2", widthHints: [1,-1,2], implicitWidth: 3, expected:[1,2,2]},
- { tag: "2i3", widthHints: [2,-1,3], implicitWidth: 1, expected:[2,2,3]},
- { tag: "2i1", widthHints: [2,-1,1], implicitWidth: 3, expected:[1,1,1]},
- { tag: "3i1", widthHints: [3,-1,1], implicitWidth: 2, expected:[1,1,1]},
- { tag: "3i2", widthHints: [3,-1,2], implicitWidth: 1, expected:[2,2,2]},
+ { tag: "1i3", widthHints: [1,-1,3], expected:[1,2,3], implicitWidth: 2},
+ { tag: "1i2", widthHints: [1,-1,2], expected:[1,2,2], implicitWidth: 3},
+ { tag: "2i3", widthHints: [2,-1,3], expected:[2,2,3], implicitWidth: 1},
+ { tag: "2i1", widthHints: [2,-1,1], expected:[1,1,1], implicitWidth: 3},
+ { tag: "3i1", widthHints: [3,-1,1], expected:[1,1,1], implicitWidth: 2},
+ { tag: "3i2", widthHints: [3,-1,2], expected:[2,2,2], implicitWidth: 1},
];
}
@@ -497,19 +495,15 @@ Item {
child.Layout.preferredWidth = -1
compare(itemSizeHints(layout), [0, 0, 3])
child.Layout.maximumWidth = -1
- compare(itemSizeHints(layout), [0, 0, Number.POSITIVE_INFINITY])
- layout.Layout.maximumWidth = 1000
- compare(itemSizeHints(layout), [0, 0, 1000])
- layout.Layout.maximumWidth = -1
- compare(itemSizeHints(layout), [0, 0, Number.POSITIVE_INFINITY])
+ compare(itemSizeHints(layout), [0, 0, 1000000000])
layout.implicitWidthChangedCount = 0
child.Layout.minimumWidth = 10
- compare(itemSizeHints(layout), [10, 10, Number.POSITIVE_INFINITY])
+ compare(itemSizeHints(layout), [10, 10, 1000000000])
compare(layout.implicitWidthChangedCount, 1)
child.Layout.preferredWidth = 20
- compare(itemSizeHints(layout), [10, 20, Number.POSITIVE_INFINITY])
+ compare(itemSizeHints(layout), [10, 20, 1000000000])
compare(layout.implicitWidthChangedCount, 2)
child.Layout.maximumWidth = 30
@@ -524,11 +518,6 @@ Item {
compare(itemSizeHints(layout), [10, 20, 30])
compare(layout.implicitWidthChangedCount, 4)
- layout.Layout.maximumWidth = 29
- compare(layout.Layout.maximumWidth, 29)
- layout.Layout.maximumWidth = -1
- compare(layout.Layout.maximumWidth, 30)
-
layout.destroy()
}
Component {