summaryrefslogtreecommitdiff
path: root/src/controls
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-02-28 13:00:16 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-06 16:53:44 +0100
commit9c59d474479d21ba08ac5c2ef49b77557493c3fb (patch)
treecdabeba5d4db8bac26b10438ef0828e7a71b946a /src/controls
parent795fa39d8e86f3ae6f053611ebefda0a880b65ae (diff)
downloadqtquickcontrols-9c59d474479d21ba08ac5c2ef49b77557493c3fb.tar.gz
Change the layout engine of RowLayout and ColumnLayout.
It now uses the gridlayoutengine from graphicsview, which also gives us a well tested grid layout engine almost for free. Change-Id: I939ae4d2b321c8079935ff3374e8e5d10d02384b Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/ApplicationWindow.qml2
-rw-r--r--src/controls/SplitView.qml1
-rw-r--r--src/controls/plugin.cpp6
-rw-r--r--src/controls/plugin.pri6
-rw-r--r--src/controls/plugins.qmltypes43
-rw-r--r--src/controls/qquicklayout.cpp206
-rw-r--r--src/controls/qquicklayout_p.h142
-rw-r--r--src/controls/qquicklayoutengine.cpp295
-rw-r--r--src/controls/qquicklayoutengine_p.h89
-rw-r--r--src/controls/qquicklinearlayout.cpp270
-rw-r--r--src/controls/qquicklinearlayout_p.h116
11 files changed, 3 insertions, 1173 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index d483a075..9fa5c374 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -41,6 +41,8 @@
import QtQuick 2.0
import QtQuick.Window 2.0
import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
+import QtQuick.Controls.Private 1.0
/*!
\qmltype ApplicationWindow
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml
index 3b226ac2..ac858258 100644
--- a/src/controls/SplitView.qml
+++ b/src/controls/SplitView.qml
@@ -40,6 +40,7 @@
import QtQuick 2.0
import QtQuick.Controls 1.0
+import QtQuick.Layouts 1.0
import QtQuick.Controls.Private 1.0 as Private
/*!
diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp
index b81347c0..20d2f394 100644
--- a/src/controls/plugin.cpp
+++ b/src/controls/plugin.cpp
@@ -44,7 +44,6 @@
#include "qtexclusivegroup_p.h"
#include "qtmenu_p.h"
#include "qtmenubar_p.h"
-#include "qquicklinearlayout_p.h"
#include "qpagestatus.h"
#include <qimage.h>
@@ -87,11 +86,6 @@ void StylePlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<QtMenuBase>(uri, 1, 0, "MenuBase",
QLatin1String("Do not create objects of type MenuBase"));
- qmlRegisterType<QQuickComponentsRowLayout>(uri, 1, 0, "RowLayout");
- qmlRegisterType<QQuickComponentsColumnLayout>(uri, 1, 0, "ColumnLayout");
- qmlRegisterUncreatableType<QQuickComponentsLayout>(uri, 1, 0, "Layout",
- QLatin1String("Do not create objects of type Layout"));
-
qmlRegisterUncreatableType<QPageStatus>(uri, 1, 0, "PageStatus", QLatin1String("Do not create objects of type PageStatus"));
}
diff --git a/src/controls/plugin.pri b/src/controls/plugin.pri
index 5637e75c..338645e4 100644
--- a/src/controls/plugin.pri
+++ b/src/controls/plugin.pri
@@ -1,7 +1,4 @@
HEADERS += \
- $$PWD/qquicklayout_p.h \
- $$PWD/qquicklayoutengine_p.h \
- $$PWD/qquicklinearlayout_p.h \
$$PWD/plugin_p.h \
$$PWD/qtaction_p.h \
$$PWD/qtexclusivegroup_p.h \
@@ -12,9 +9,6 @@ HEADERS += \
$$PWD/qpagestatus.h
SOURCES += \
- $$PWD/qquicklayout.cpp \
- $$PWD/qquicklayoutengine.cpp \
- $$PWD/qquicklinearlayout.cpp \
$$PWD/plugin.cpp \
$$PWD/qtaction.cpp \
$$PWD/qtexclusivegroup.cpp \
diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes
index 1e8d179d..1cfb3477 100644
--- a/src/controls/plugins.qmltypes
+++ b/src/controls/plugins.qmltypes
@@ -21,49 +21,6 @@ Module {
}
}
Component {
- name: "QQuickComponentsColumnLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLinearLayout"
- exports: ["ColumnLayout 1.0"]
- }
- Component {
- name: "QQuickComponentsLayout"
- defaultProperty: "data"
- prototype: "QQuickItem"
- exports: ["Layout 1.0"]
- attachedType: "QQuickComponentsLayoutAttached"
- Enum {
- name: "SizePolicy"
- values: {
- "Fixed": 0,
- "Expanding": 1
- }
- }
- }
- Component {
- name: "QQuickComponentsLayoutAttached"
- prototype: "QObject"
- Property { name: "minimumWidth"; type: "double" }
- Property { name: "minimumHeight"; type: "double" }
- Property { name: "maximumWidth"; type: "double" }
- Property { name: "maximumHeight"; type: "double" }
- Property { name: "verticalSizePolicy"; type: "QQuickComponentsLayout::SizePolicy" }
- Property { name: "horizontalSizePolicy"; type: "QQuickComponentsLayout::SizePolicy" }
- }
- Component {
- name: "QQuickComponentsLinearLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLayout"
- Property { name: "spacing"; type: "double" }
- Signal { name: "orientationChanged" }
- }
- Component {
- name: "QQuickComponentsRowLayout"
- defaultProperty: "data"
- prototype: "QQuickComponentsLinearLayout"
- exports: ["RowLayout 1.0"]
- }
- Component {
name: "QtAction"
prototype: "QObject"
exports: ["Action 1.0"]
diff --git a/src/controls/qquicklayout.cpp b/src/controls/qquicklayout.cpp
deleted file mode 100644
index 2013a487..00000000
--- a/src/controls/qquicklayout.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquicklayout_p.h"
-#include <QEvent>
-#include <QApplication>
-#include <QtCore/qnumeric.h>
-
-QT_BEGIN_NAMESPACE
-
-static const qreal q_declarativeLayoutMaxSize = 10e8;
-
-
-QQuickComponentsLayoutAttached::QQuickComponentsLayoutAttached(QObject *parent)
- : QObject(parent),
- m_minimumWidth(0),
- m_minimumHeight(0),
- m_maximumWidth(q_declarativeLayoutMaxSize),
- m_maximumHeight(q_declarativeLayoutMaxSize),
- m_verticalSizePolicy(QQuickComponentsLayout::Fixed),
- m_horizontalSizePolicy(QQuickComponentsLayout::Fixed)
-{
-
-}
-
-void QQuickComponentsLayoutAttached::setMinimumWidth(qreal width)
-{
- if (qIsNaN(width) || m_minimumWidth == width)
- return;
-
- m_minimumWidth = width;
- updateLayout();
- emit minimumWidthChanged();
-}
-
-void QQuickComponentsLayoutAttached::setMinimumHeight(qreal height)
-{
- if (qIsNaN(height) || m_minimumHeight == height)
- return;
-
- m_minimumHeight = height;
- updateLayout();
- emit minimumHeightChanged();
-}
-
-void QQuickComponentsLayoutAttached::setMaximumWidth(qreal width)
-{
- if (qIsNaN(width) || m_maximumWidth == width)
- return;
-
- m_maximumWidth = width;
- updateLayout();
- emit maximumWidthChanged();
-}
-
-void QQuickComponentsLayoutAttached::setMaximumHeight(qreal height)
-{
- if (qIsNaN(height) || m_maximumHeight == height)
- return;
-
- m_maximumHeight = height;
- updateLayout();
- emit maximumHeightChanged();
-}
-
-void QQuickComponentsLayoutAttached::setVerticalSizePolicy(QQuickComponentsLayout::SizePolicy policy)
-{
- if (m_verticalSizePolicy != policy) {
- m_verticalSizePolicy = policy;
- updateLayout();
- emit verticalSizePolicyChanged();
- }
-}
-
-void QQuickComponentsLayoutAttached::setHorizontalSizePolicy(QQuickComponentsLayout::SizePolicy policy)
-{
- if (m_horizontalSizePolicy != policy) {
- m_horizontalSizePolicy = policy;
- updateLayout();
- emit horizontalSizePolicyChanged();
- }
-}
-
-void QQuickComponentsLayoutAttached::updateLayout()
-{
- if (m_layout)
- m_layout->invalidate();
-}
-
-
-
-QQuickComponentsLayout::QQuickComponentsLayout(QQuickItem *parent)
- : QQuickItem(parent),
- m_dirty(false)
-{
-
-}
-
-QQuickComponentsLayout::~QQuickComponentsLayout()
-{
-
-}
-
-void QQuickComponentsLayout::setupItemLayout(QQuickItem *item)
-{
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(item);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
- info->m_layout = this;
-}
-
-QQuickComponentsLayoutAttached *QQuickComponentsLayout::qmlAttachedProperties(QObject *object)
-{
- return new QQuickComponentsLayoutAttached(object);
-}
-
-bool QQuickComponentsLayout::event(QEvent *e)
-{
- if (e->type() == QEvent::LayoutRequest)
- reconfigureTopDown();
-
- return QQuickItem::event(e);
-}
-
-void QQuickComponentsLayout::invalidate()
-{
- if (m_dirty)
- return;
-
- QQuickComponentsLayout *layout = this;
- QQuickComponentsLayout *parentLayout = 0;
-
- while (!layout->m_dirty) {
- layout->m_dirty = true;
- parentLayout = qobject_cast<QQuickComponentsLayout *>(layout->parentItem());
-
- if (!parentLayout)
- break;
- else
- layout = parentLayout;
- }
-
- // just post events for top level layouts
- if (!parentLayout)
- QApplication::postEvent(layout, new QEvent(QEvent::LayoutRequest));
-}
-
-void QQuickComponentsLayout::reconfigureTopDown()
-{
- const QList<QQuickItem *> &children = childItems();
-
- reconfigureLayout();
-
- foreach (QQuickItem *child, children) {
- QQuickComponentsLayout *layout = qobject_cast<QQuickComponentsLayout *>(child);
-
- if (layout && layout->m_dirty)
- layout->reconfigureTopDown();
- }
-
- m_dirty = false;
-}
-
-void QQuickComponentsLayout::reconfigureLayout()
-{
-
-}
-
-QT_END_NAMESPACE
diff --git a/src/controls/qquicklayout_p.h b/src/controls/qquicklayout_p.h
deleted file mode 100644
index f8f88657..00000000
--- a/src/controls/qquicklayout_p.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKLAYOUT_P_H
-#define QQUICKLAYOUT_P_H
-
-#include <QPointer>
-#include <QQuickItem>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickComponentsLayoutAttached;
-
-
-class QQuickComponentsLayout : public QQuickItem
-{
- Q_OBJECT
- Q_ENUMS(SizePolicy)
-
-public:
- enum SizePolicy {
- Fixed,
- Expanding
- };
-
- explicit QQuickComponentsLayout(QQuickItem *parent = 0);
- ~QQuickComponentsLayout();
-
- static QQuickComponentsLayoutAttached *qmlAttachedProperties(QObject *object);
-
-protected:
- void invalidate();
- bool event(QEvent *e);
- void reconfigureTopDown();
- virtual void reconfigureLayout();
- void setupItemLayout(QQuickItem *item);
-
-private:
- bool m_dirty;
-
- friend class QQuickComponentsLayoutAttached;
-};
-
-
-class QQuickComponentsLayoutAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
- Q_PROPERTY(qreal minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
- Q_PROPERTY(qreal maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
- Q_PROPERTY(qreal maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
- Q_PROPERTY(QQuickComponentsLayout::SizePolicy verticalSizePolicy READ verticalSizePolicy WRITE setVerticalSizePolicy NOTIFY verticalSizePolicyChanged)
- Q_PROPERTY(QQuickComponentsLayout::SizePolicy horizontalSizePolicy READ horizontalSizePolicy WRITE setHorizontalSizePolicy NOTIFY horizontalSizePolicyChanged)
-
-public:
- QQuickComponentsLayoutAttached(QObject *object);
-
- qreal minimumWidth() const { return m_minimumWidth; }
- void setMinimumWidth(qreal width);
-
- qreal minimumHeight() const { return m_minimumHeight; }
- void setMinimumHeight(qreal height);
-
- qreal maximumWidth() const { return m_maximumWidth; }
- void setMaximumWidth(qreal width);
-
- qreal maximumHeight() const { return m_maximumHeight; }
- void setMaximumHeight(qreal height);
-
- QQuickComponentsLayout::SizePolicy verticalSizePolicy() const { return m_verticalSizePolicy; }
- void setVerticalSizePolicy(QQuickComponentsLayout::SizePolicy policy);
-
- QQuickComponentsLayout::SizePolicy horizontalSizePolicy() const { return m_horizontalSizePolicy; }
- void setHorizontalSizePolicy(QQuickComponentsLayout::SizePolicy policy);
-
-signals:
- void minimumWidthChanged();
- void minimumHeightChanged();
- void maximumWidthChanged();
- void maximumHeightChanged();
- void verticalSizePolicyChanged();
- void horizontalSizePolicyChanged();
-
-protected:
- void updateLayout();
-
-private:
- qreal m_minimumWidth;
- qreal m_minimumHeight;
- qreal m_maximumWidth;
- qreal m_maximumHeight;
- QQuickComponentsLayout::SizePolicy m_verticalSizePolicy;
- QQuickComponentsLayout::SizePolicy m_horizontalSizePolicy;
- QPointer<QQuickComponentsLayout> m_layout;
-
- friend class QQuickComponentsLayout;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QQuickComponentsLayout)
-QML_DECLARE_TYPEINFO(QQuickComponentsLayout, QML_HAS_ATTACHED_PROPERTIES)
-
-#endif // QQUICKLAYOUT_P_H
diff --git a/src/controls/qquicklayoutengine.cpp b/src/controls/qquicklayoutengine.cpp
deleted file mode 100644
index 1811b453..00000000
--- a/src/controls/qquicklayoutengine.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquicklayoutengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*
- This function is a modification of qGeomCalc() included in "QtCore/kernel/qlayoutengine_p.h".
- It is used as a helper function to handle linear layout recalculations for QQuickItems.
-
- chain contains input and output parameters describing the geometry.
- count is the count of items in the chain; pos and space give the
- interval (relative to parentWidget topLeft).
-*/
-void qDeclarativeLayoutCalculate(QVector<QQuickComponentsLayoutInfo> &chain, int start,
- int count, qreal pos, qreal space, qreal spacer)
-{
- if (chain.count() == 0)
- return;
-
- bool wannaGrow = false;
- qreal totalStretch = 0;
- qreal totalSpacing = 0;
- qreal totalSizeHint = 0;
- qreal totalMinimumSize = 0;
-
- const int end = start + count;
- const int spacerCount = chain.count() - 1;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- data->done = false;
-
- totalStretch += data->stretch;
- totalSizeHint += data->smartSizeHint();
- totalMinimumSize += data->minimumSize;
-
- // don't count last spacing
- if (i < end - 1)
- totalSpacing += data->effectiveSpacer(spacer);
-
- wannaGrow = (wannaGrow || data->expansive || data->stretch > 0);
- }
-
- qreal extraSpace = 0;
-
- if (space < totalMinimumSize + totalSpacing) {
- // Less space than minimumSize; take from the biggest first
- qreal minSize = totalMinimumSize + totalSpacing;
-
- // shrink the spacers proportionally
- if (spacer >= 0) {
- spacer = minSize > 0 ? spacer * space / minSize : 0;
- totalSpacing = spacer * spacerCount;
- }
-
- QList<qreal> list;
-
- for (int i = start; i < end; i++)
- list << chain.at(i).minimumSize;
-
- qSort(list);
-
- qreal spaceLeft = space - totalSpacing;
-
- qreal sum = 0;
- int idx = 0;
- qreal spaceUsed = 0;
- qreal current = 0;
-
- while (idx < count && spaceUsed < spaceLeft) {
- current = list.at(idx);
- spaceUsed = sum + current * (count - idx);
- sum += current;
- ++idx;
- }
-
- --idx;
-
- int items = count - idx;
- qreal deficit = spaceUsed - spaceLeft;
- qreal deficitPerItem = deficit / items;
- qreal maxval = current - deficitPerItem;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
- data->done = true;
-
- if (data->minimumSize > 0)
- data->size = data->minimumSize;
- else
- data->size = qMin<qreal>(data->minimumSize, maxval);
- }
- } else if (space < totalSizeHint + totalSpacing) {
- /*
- Less space than smartSizeHint(), but more than minimumSize.
- Currently take space equally from each, as in Qt 2.x.
- Commented-out lines will give more space to stretchier
- items.
- */
- int n = count;
- qreal spaceLeft = space - totalSpacing;
- qreal overdraft = totalSizeHint - spaceLeft;
-
- // first give to the fixed ones
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->minimumSize >= data->smartSizeHint()) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->smartSizeHint();
- n--;
- }
- }
-
- bool finished = (n == 0);
-
- while (!finished) {
- finished = true;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- qreal w = overdraft / n;
- data->size = data->smartSizeHint() - w;
-
- if (data->size < data->minimumSize) {
- data->done = true;
- data->size = data->minimumSize;
- finished = false;
- overdraft -= data->smartSizeHint() - data->minimumSize;
- n--;
- break;
- }
- }
- }
- } else { // extra space
- int n = count;
- qreal spaceLeft = space - totalSpacing;
-
- // first give to the fixed ones, and handle non-expansiveness
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- if (data->maximumSize <= data->smartSizeHint()
- || (wannaGrow && !data->expansive && data->stretch == 0)
- || (!data->expansive && data->stretch == 0)) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->size;
- totalStretch -= data->stretch;
- n--;
- }
- }
-
- extraSpace = spaceLeft;
-
- /*
- Do a trial distribution and calculate how much it is off.
- If there are more deficit pixels than surplus pixels, give
- the minimum size items what they need, and repeat.
- Otherwise give to the maximum size items, and repeat.
-
- Paul Olav Tvete has a wonderful mathematical proof of the
- correctness of this principle, but unfortunately this
- comment is too small to contain it.
- */
- qreal surplus, deficit;
-
- do {
- surplus = deficit = 0;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (data->done)
- continue;
-
- extraSpace = 0;
-
- qreal w;
-
- if (totalStretch <= 0)
- w = (spaceLeft / n);
- else
- w = (spaceLeft * data->stretch) / totalStretch;
-
- data->size = w;
-
- if (w < data->smartSizeHint())
- deficit += data->smartSizeHint() - w;
- else if (w > data->maximumSize)
- surplus += w - data->maximumSize;
- }
-
- if (deficit > 0 && surplus <= deficit) {
- // give to the ones that have too little
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->size < data->smartSizeHint()) {
- data->done = true;
- data->size = data->smartSizeHint();
- spaceLeft -= data->smartSizeHint();
- totalStretch -= data->stretch;
- n--;
- }
- }
- }
-
- if (surplus > 0 && surplus >= deficit) {
- // take from the ones that have too much
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
-
- if (!data->done && data->size > data->maximumSize) {
- data->done = true;
- data->size = data->maximumSize;
- spaceLeft -= data->maximumSize;
- totalStretch -= data->stretch;
- n--;
- }
- }
- }
- } while (n > 0 && surplus != deficit);
-
- if (n == 0)
- extraSpace = spaceLeft;
- }
-
- /*
- As a last resort, we distribute the unwanted space equally
- among the spacers (counting the start and end of the chain). We
- could, but don't, attempt a sub-pixel allocation of the extra
- space.
- */
- qreal extra = extraSpace / (spacerCount + 2);
- qreal p = pos + extra;
-
- for (int i = start; i < end; i++) {
- QQuickComponentsLayoutInfo *data = &chain[i];
- data->pos = p;
- p += data->size;
- p += data->effectiveSpacer(spacer) + extra;
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/controls/qquicklayoutengine_p.h b/src/controls/qquicklayoutengine_p.h
deleted file mode 100644
index f83da4b1..00000000
--- a/src/controls/qquicklayoutengine_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKLAYOUTENGINE_P_H
-#define QQUICKLAYOUTENGINE_P_H
-
-#include <QVector>
-
-QT_BEGIN_NAMESPACE
-
-struct QQuickComponentsLayoutInfo
-{
- QQuickComponentsLayoutInfo()
- : stretch(1),
- sizeHint(0),
- spacing(0),
- minimumSize(0),
- maximumSize(0),
- expansive(true),
- done(false),
- pos(0),
- size(0)
- { }
-
- inline qreal smartSizeHint() {
- return (stretch > 0) ? minimumSize : sizeHint;
- }
-
- inline qreal effectiveSpacer(qreal value) const {
- return value + spacing;
- }
-
- qreal stretch;
- qreal sizeHint;
- qreal spacing;
- qreal minimumSize;
- qreal maximumSize;
- bool expansive;
-
- // result
- bool done;
- qreal pos;
- qreal size;
-};
-
-void qDeclarativeLayoutCalculate(QVector<QQuickComponentsLayoutInfo> &chain, int start,
- int count, qreal pos, qreal space, qreal spacer);
-
-QT_END_NAMESPACE
-
-#endif // QQUICKLAYOUTENGINE_P_H
diff --git a/src/controls/qquicklinearlayout.cpp b/src/controls/qquicklinearlayout.cpp
deleted file mode 100644
index baf1d19d..00000000
--- a/src/controls/qquicklinearlayout.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquicklinearlayout_p.h"
-#include "qquicklayoutengine_p.h"
-#include <QtCore/qnumeric.h>
-
-/*!
- \qmltype RowLayout
- \instantiates QQuickComponentsRowLayout
- \inqmlmodule QtQuick.Controls 1.0
- \brief RowLayout is doing bla...bla...
-*/
-
-/*!
- \qmltype ColumnLayout
- \instantiates QQuickComponentsColumnLayout
- \inqmlmodule QtQuick.Controls 1.0
- \brief ColumnLayout is doing bla...bla...
-*/
-
-QT_BEGIN_NAMESPACE
-
-static const qreal q_declarativeLayoutDefaultSpacing = 4.0;
-
-
-QQuickComponentsLinearLayout::QQuickComponentsLinearLayout(Orientation orientation,
- QQuickItem *parent)
- : QQuickComponentsLayout(parent),
- m_spacing(q_declarativeLayoutDefaultSpacing),
- m_orientation(orientation)
-{
-
-}
-
-qreal QQuickComponentsLinearLayout::spacing() const
-{
- return m_spacing;
-}
-
-void QQuickComponentsLinearLayout::setSpacing(qreal spacing)
-{
- if (qIsNaN(spacing) || m_spacing == spacing)
- return;
-
- m_spacing = spacing;
- invalidate();
-}
-
-QQuickComponentsLinearLayout::Orientation QQuickComponentsLinearLayout::orientation() const
-{
- return m_orientation;
-}
-
-void QQuickComponentsLinearLayout::setOrientation(Orientation orientation)
-{
- if (m_orientation == orientation)
- return;
-
- m_orientation = orientation;
- invalidate();
-
- emit orientationChanged();
-}
-
-void QQuickComponentsLinearLayout::componentComplete()
-{
- QQuickComponentsLayout::componentComplete();
- updateLayoutItems();
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::updateLayoutItems()
-{
- const QList<QQuickItem *> &children = childItems();
- qreal implicitWidth = 0;
- qreal implicitHeight = 0;
- foreach (QQuickItem *child, children) {
- if (m_orientation == Horizontal) {
- implicitWidth += child->implicitWidth();
- implicitHeight = qMax(implicitHeight, child->implicitHeight());
- } else {
- implicitHeight += child->implicitHeight();
- implicitWidth = qMax(implicitWidth, child->implicitWidth());
- }
- insertLayoutItem(child);
- }
- setImplicitWidth(implicitWidth);
- setImplicitHeight(implicitHeight);
-}
-
-void QQuickComponentsLinearLayout::itemChange(ItemChange change, const ItemChangeData &value)
-{
- if (isComponentComplete()) {
- if (change == ItemChildAddedChange)
- insertLayoutItem(value.item);
- else if (change == ItemChildRemovedChange)
- removeLayoutItem(value.item);
- }
-
- QQuickComponentsLayout::itemChange(change, value);
-}
-
-void QQuickComponentsLinearLayout::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- QQuickComponentsLayout::geometryChanged(newGeometry, oldGeometry);
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::insertLayoutItem(QQuickItem *item)
-{
- m_items.append(item);
- setupItemLayout(item);
-
- invalidate();
- QObject::connect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
- QObject::connect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
-}
-
-void QQuickComponentsLinearLayout::removeLayoutItem(QQuickItem *item)
-{
- if (!m_items.removeOne(item))
- return;
-
- invalidate();
- QObject::disconnect(item, SIGNAL(destroyed()), this, SLOT(onItemDestroyed()));
- QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged()));
-}
-
-void QQuickComponentsLinearLayout::onItemVisibleChanged()
-{
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::onItemDestroyed()
-{
- if (!m_items.removeOne(static_cast<QQuickItem *>(sender())))
- return;
-
- invalidate();
-}
-
-void QQuickComponentsLinearLayout::reconfigureLayout()
-{
- if (!isComponentComplete())
- return;
-
- const int count = m_items.count();
-
- if (count == 0)
- return;
-
- qreal totalSpacing = 0;
- qreal totalSizeHint = 0;
- qreal totalMinimumSize = 0;
- qreal totalMaximumSize = 0;
-
- QVector<QQuickComponentsLayoutInfo> itemData;
-
- for (int i = 0; i < count; i++) {
- QQuickItem *item = m_items.at(i);
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(item);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
-
- QQuickComponentsLayoutInfo data;
-
- if (item->isVisible()) {
- if (m_orientation == Horizontal) {
- data.sizeHint = item->implicitWidth();
- data.minimumSize = info->minimumWidth();
- data.maximumSize = info->maximumWidth();
- data.expansive = (info->horizontalSizePolicy() == QQuickComponentsLayout::Expanding);
- data.stretch = info->horizontalSizePolicy() == Expanding ? 1.0 : 0;
- } else {
- data.sizeHint = item->implicitHeight();
- data.minimumSize = info->minimumHeight();
- data.maximumSize = info->maximumHeight();
- data.expansive = (info->verticalSizePolicy() == QQuickComponentsLayout::Expanding);
- data.stretch = info->verticalSizePolicy() == Expanding ? 1.0 : 0;
- }
-
- itemData.append(data);
- // sum
- totalSizeHint += data.sizeHint;
- totalMinimumSize += data.minimumSize;
- totalMaximumSize += data.maximumSize;
-
- // don't count last spacing
- if (i < count - 1)
- totalSpacing += data.spacing + m_spacing;
- }
- }
-
- qreal extent = m_orientation == Horizontal ? width() : height();
- qDeclarativeLayoutCalculate(itemData, 0, itemData.count(), 0, extent, m_spacing);
-
- int i = 0;
- int id = 0;
- while (i < count) {
- QQuickItem *item = m_items.at(i++);
- if (!item->isVisible())
- continue;
- const QQuickComponentsLayoutInfo &data = itemData.at(id);
-
- if (m_orientation == Horizontal) {
- item->setX(data.pos);
- item->setY(height()/2 - item->height()/2);
- item->setWidth(data.size);
- } else {
- item->setY(data.pos);
- item->setX(width()/2 - item->width()/2);
- item->setHeight(data.size);
- }
- ++id;
- }
-
- // propagate hints to upper levels
- QObject *attached = qmlAttachedPropertiesObject<QQuickComponentsLayout>(this);
- QQuickComponentsLayoutAttached *info = static_cast<QQuickComponentsLayoutAttached *>(attached);
-
- if (m_orientation == Horizontal) {
- setImplicitWidth(totalSizeHint);
- info->setMinimumWidth(totalMinimumSize + totalSpacing);
- info->setMaximumWidth(totalMaximumSize + totalSpacing);
- } else {
- setImplicitHeight(totalSizeHint);
- info->setMinimumHeight(totalMinimumSize + totalSpacing);
- info->setMaximumHeight(totalMaximumSize + totalSpacing);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/controls/qquicklinearlayout_p.h b/src/controls/qquicklinearlayout_p.h
deleted file mode 100644
index 6db7562d..00000000
--- a/src/controls/qquicklinearlayout_p.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the Qt Quick Controls module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKLINEARLAYOUT_P_H
-#define QQUICKLINEARLAYOUT_P_H
-
-#include "qquicklayout_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QQuickComponentsLinearLayout : public QQuickComponentsLayout
-{
- Q_OBJECT
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
-
-public:
- enum Orientation {
- Vertical,
- Horizontal
- };
-
- explicit QQuickComponentsLinearLayout(Orientation orientation,
- QQuickItem *parent = 0);
- ~QQuickComponentsLinearLayout() {}
-
- qreal spacing() const;
- void setSpacing(qreal spacing);
-
- Orientation orientation() const;
- void setOrientation(Orientation orientation);
-
- void componentComplete();
-
-signals:
- void spacingChanged();
- void orientationChanged();
-
-protected:
- void updateLayoutItems();
- void reconfigureLayout();
- void insertLayoutItem(QQuickItem *item);
- void removeLayoutItem(QQuickItem *item);
- void itemChange(ItemChange change, const ItemChangeData &data);
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-
-protected slots:
- void onItemVisibleChanged();
- void onItemDestroyed();
-
-private:
- qreal m_spacing;
- Orientation m_orientation;
- QList<QQuickItem *> m_items;
-};
-
-
-class QQuickComponentsRowLayout : public QQuickComponentsLinearLayout
-{
- Q_OBJECT
-
-public:
- explicit QQuickComponentsRowLayout(QQuickItem *parent = 0)
- : QQuickComponentsLinearLayout(Horizontal, parent) {}
-};
-
-
-class QQuickComponentsColumnLayout : public QQuickComponentsLinearLayout
-{
- Q_OBJECT
-
-public:
- explicit QQuickComponentsColumnLayout(QQuickItem *parent = 0)
- : QQuickComponentsLinearLayout(Vertical, parent) {}
-};
-
-QT_END_NAMESPACE
-
-#endif // QQUICKLINEARLAYOUT_P_H