summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp (renamed from src/imports/widgets/graphicslayouts.cpp)0
-rw-r--r--examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro13
-rw-r--r--examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml77
-rw-r--r--examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc5
-rw-r--r--examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h (renamed from src/imports/widgets/graphicslayouts_p.h)0
-rw-r--r--examples/declarative/layouts/graphicsLayouts/main.cpp (renamed from src/imports/widgets/widgets.cpp)37
-rw-r--r--examples/declarative/layouts/layoutItem/layoutItem.pro13
-rw-r--r--examples/declarative/layouts/layoutItem/layoutItem.qml16
-rw-r--r--examples/declarative/layouts/layoutItem/layoutItem.qrc5
-rw-r--r--examples/declarative/layouts/layoutItem/main.cpp73
-rw-r--r--examples/declarative/layouts/layouts.qml29
-rw-r--r--examples/declarative/layouts/positioners/Button.qml (renamed from examples/declarative/layouts/Button.qml)0
-rw-r--r--examples/declarative/layouts/positioners/add.png (renamed from examples/declarative/layouts/add.png)bin1577 -> 1577 bytes
-rw-r--r--examples/declarative/layouts/positioners/del.png (renamed from examples/declarative/layouts/del.png)bin1661 -> 1661 bytes
-rw-r--r--examples/declarative/layouts/positioners/positioners.qml (renamed from examples/declarative/layouts/positioners.qml)0
-rw-r--r--examples/declarative/layouts/positioners/positioners.qmlproject (renamed from examples/declarative/layouts/layouts.qmlproject)2
-rw-r--r--examples/declarative/layouts/positioners/positioners.qmlproject.user41
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp5
-rw-r--r--src/imports/imports.pro2
-rw-r--r--src/imports/widgets/qmldir1
-rw-r--r--src/imports/widgets/widgets.pro30
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml9
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro (renamed from tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro)8
-rw-r--r--tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp115
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/data/layouts.qml31
-rw-r--r--tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp147
26 files changed, 390 insertions, 269 deletions
diff --git a/src/imports/widgets/graphicslayouts.cpp b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp
index 25cf994..25cf994 100644
--- a/src/imports/widgets/graphicslayouts.cpp
+++ b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.cpp
diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro
new file mode 100644
index 0000000..e5d91b2
--- /dev/null
+++ b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = graphicslayouts
+QT += declarative
+
+SOURCES += \
+ graphicslayouts.cpp \
+ main.cpp
+
+HEADERS += \
+ graphicslayouts_p.h
+
+RESOURCES += \
+ graphicslayouts.qrc
diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml
new file mode 100644
index 0000000..fcd78d5
--- /dev/null
+++ b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qml
@@ -0,0 +1,77 @@
+import Qt 4.7
+import GraphicsLayouts 4.7
+
+Item {
+ id: resizable
+
+ width: 800
+ height: 400
+
+ QGraphicsWidget {
+ size.width: parent.width/2
+ size.height: parent.height
+
+ layout: QGraphicsLinearLayout {
+ LayoutItem {
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { color: "yellow"; anchors.fill: parent }
+ }
+ LayoutItem {
+ minimumSize: "100x100"
+ maximumSize: "400x400"
+ preferredSize: "200x200"
+ Rectangle { color: "green"; anchors.fill: parent }
+ }
+ }
+ }
+ QGraphicsWidget {
+ x: parent.width/2
+ size.width: parent.width/2
+ size.height: parent.height
+
+ layout: QGraphicsGridLayout {
+ LayoutItem {
+ QGraphicsGridLayout.row: 0
+ QGraphicsGridLayout.column: 0
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { color: "red"; anchors.fill: parent }
+ }
+ LayoutItem {
+ QGraphicsGridLayout.row: 1
+ QGraphicsGridLayout.column: 0
+ minimumSize: "100x100"
+ maximumSize: "200x200"
+ preferredSize: "100x100"
+ Rectangle { color: "orange"; anchors.fill: parent }
+ }
+ LayoutItem {
+ QGraphicsGridLayout.row: 2
+ QGraphicsGridLayout.column: 0
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "200x200"
+ Rectangle { color: "yellow"; anchors.fill: parent }
+ }
+ LayoutItem {
+ QGraphicsGridLayout.row: 0
+ QGraphicsGridLayout.column: 1
+ minimumSize: "100x100"
+ maximumSize: "200x200"
+ preferredSize: "200x200"
+ Rectangle { color: "green"; anchors.fill: parent }
+ }
+ LayoutItem {
+ QGraphicsGridLayout.row: 1
+ QGraphicsGridLayout.column: 1
+ minimumSize: "100x100"
+ maximumSize: "400x400"
+ preferredSize: "200x200"
+ Rectangle { color: "blue"; anchors.fill: parent }
+ }
+ }
+ }
+}
diff --git a/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc
new file mode 100644
index 0000000..a199f8d
--- /dev/null
+++ b/examples/declarative/layouts/graphicsLayouts/graphicslayouts.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>graphicslayouts.qml</file>
+</qresource>
+</RCC>
diff --git a/src/imports/widgets/graphicslayouts_p.h b/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h
index ea9c614..ea9c614 100644
--- a/src/imports/widgets/graphicslayouts_p.h
+++ b/examples/declarative/layouts/graphicsLayouts/graphicslayouts_p.h
diff --git a/src/imports/widgets/widgets.cpp b/examples/declarative/layouts/graphicsLayouts/main.cpp
index 20de1fe..89b69bf 100644
--- a/src/imports/widgets/widgets.cpp
+++ b/examples/declarative/layouts/graphicsLayouts/main.cpp
@@ -39,33 +39,22 @@
**
****************************************************************************/
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QApplication>
#include <QtDeclarative/qdeclarative.h>
-#include <QGraphicsWidget>
-
#include "graphicslayouts_p.h"
-#include <private/qdeclarativegraphicswidget_p.h>
-QT_BEGIN_NAMESPACE
+#include <QtDeclarative/QDeclarativeView>
-class QWidgetsQmlModule : public QDeclarativeExtensionPlugin
+int main(int argc, char* argv[])
{
- Q_OBJECT
-public:
- virtual void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.widgets"));
-
- qmlRegisterInterface<QGraphicsLayoutItem>("QGraphicsLayoutItem");
- qmlRegisterInterface<QGraphicsLayout>("QGraphicsLayout");
- qmlRegisterType<QGraphicsLinearLayoutStretchItemObject>(uri,4,7,"QGraphicsLinearLayoutStretchItem");
- qmlRegisterType<QGraphicsLinearLayoutObject>(uri,4,7,"QGraphicsLinearLayout");
- qmlRegisterType<QGraphicsGridLayoutObject>(uri,4,7,"QGraphicsGridLayout");
- }
+ QApplication app(argc, argv);
+ QDeclarativeView view;
+ qmlRegisterInterface<QGraphicsLayoutItem>("QGraphicsLayoutItem");
+ qmlRegisterInterface<QGraphicsLayout>("QGraphicsLayout");
+ qmlRegisterType<QGraphicsLinearLayoutStretchItemObject>("GraphicsLayouts",4,7,"QGraphicsLinearLayoutStretchItem");
+ qmlRegisterType<QGraphicsLinearLayoutObject>("GraphicsLayouts",4,7,"QGraphicsLinearLayout");
+ qmlRegisterType<QGraphicsGridLayoutObject>("GraphicsLayouts",4,7,"QGraphicsGridLayout");
+ view.setSource(QUrl(":graphicslayouts.qml"));
+ view.show();
+ return app.exec();
};
-QT_END_NAMESPACE
-
-#include "widgets.moc"
-
-Q_EXPORT_PLUGIN2(qtwidgetsqmlmodule, QT_PREPEND_NAMESPACE(QWidgetsQmlModule));
-
diff --git a/examples/declarative/layouts/layoutItem/layoutItem.pro b/examples/declarative/layouts/layoutItem/layoutItem.pro
new file mode 100644
index 0000000..4a3fc73
--- /dev/null
+++ b/examples/declarative/layouts/layoutItem/layoutItem.pro
@@ -0,0 +1,13 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Tue May 4 13:36:26 2010
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+QT += declarative
+
+# Input
+SOURCES += main.cpp
+RESOURCES += layoutItem.qrc
diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qml b/examples/declarative/layouts/layoutItem/layoutItem.qml
new file mode 100644
index 0000000..9b9db22
--- /dev/null
+++ b/examples/declarative/layouts/layoutItem/layoutItem.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+import Qt.widgets 4.7
+
+LayoutItem {//Sized by the layout
+ id: resizable
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { color: "yellow"; anchors.fill: parent }
+ Rectangle {
+ width: 100; height: 100;
+ anchors.top: parent.top;
+ anchors.right: parent.right;
+ color: "green";
+ }
+}
diff --git a/examples/declarative/layouts/layoutItem/layoutItem.qrc b/examples/declarative/layouts/layoutItem/layoutItem.qrc
new file mode 100644
index 0000000..deb0fba
--- /dev/null
+++ b/examples/declarative/layouts/layoutItem/layoutItem.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>layoutItem.qml</file>
+</qresource>
+</RCC>
diff --git a/examples/declarative/layouts/layoutItem/main.cpp b/examples/declarative/layouts/layoutItem/main.cpp
new file mode 100644
index 0000000..a104251
--- /dev/null
+++ b/examples/declarative/layouts/layoutItem/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QGraphicsView>
+#include <QGraphicsScene>
+#include <QGraphicsWidget>
+#include <QGraphicsLinearLayout>
+#include <QDeclarativeComponent>
+#include <QDeclarativeEngine>
+
+/* This example demonstrates using a LayoutItem to let QML snippets integrate
+ nicely with existing QGraphicsView applications designed with GraphicsLayouts
+*/
+int main(int argc, char* argv[])
+{
+ QApplication app(argc, argv);
+ //Set up a graphics scene with a QGraphicsWidget and Layout
+ QGraphicsView view;
+ QGraphicsScene scene;
+ QGraphicsWidget *widget = new QGraphicsWidget();
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
+ widget->setLayout(layout);
+ scene.addItem(widget);
+ view.setScene(&scene);
+ //Add the QML snippet into the layout
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl(":layoutItem.qml"));
+ QGraphicsLayoutItem* obj = qobject_cast<QGraphicsLayoutItem*>(c.create());
+ layout->addItem(obj);
+
+ widget->setGeometry(QRectF(0,0, 400,400));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml
deleted file mode 100644
index 391eab7..0000000
--- a/examples/declarative/layouts/layouts.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import Qt 4.7
-import Qt.widgets 4.7
-
-Item {
- id: resizable
-
- width: 400
- height: 400
-
- QGraphicsWidget {
- size.width: parent.width
- size.height: parent.height
-
- layout: QGraphicsLinearLayout {
- LayoutItem {
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { color: "yellow"; anchors.fill: parent }
- }
- LayoutItem {
- minimumSize: "100x100"
- maximumSize: "400x400"
- preferredSize: "200x200"
- Rectangle { color: "green"; anchors.fill: parent }
- }
- }
- }
-}
diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/positioners/Button.qml
index d03eeb5..d03eeb5 100644
--- a/examples/declarative/layouts/Button.qml
+++ b/examples/declarative/layouts/positioners/Button.qml
diff --git a/examples/declarative/layouts/add.png b/examples/declarative/layouts/positioners/add.png
index f29d84b..f29d84b 100644
--- a/examples/declarative/layouts/add.png
+++ b/examples/declarative/layouts/positioners/add.png
Binary files differ
diff --git a/examples/declarative/layouts/del.png b/examples/declarative/layouts/positioners/del.png
index 1d753a3..1d753a3 100644
--- a/examples/declarative/layouts/del.png
+++ b/examples/declarative/layouts/positioners/del.png
Binary files differ
diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners/positioners.qml
index 2cb0b8b..2cb0b8b 100644
--- a/examples/declarative/layouts/positioners.qml
+++ b/examples/declarative/layouts/positioners/positioners.qml
diff --git a/examples/declarative/layouts/layouts.qmlproject b/examples/declarative/layouts/positioners/positioners.qmlproject
index d4909f8..e526217 100644
--- a/examples/declarative/layouts/layouts.qmlproject
+++ b/examples/declarative/layouts/positioners/positioners.qmlproject
@@ -1,3 +1,5 @@
+/* File generated by QtCreator */
+
import QmlProject 1.0
Project {
diff --git a/examples/declarative/layouts/positioners/positioners.qmlproject.user b/examples/declarative/layouts/positioners/positioners.qmlproject.user
new file mode 100644
index 0000000..593479d
--- /dev/null
+++ b/examples/declarative/layouts/positioners/positioners.qmlproject.user
@@ -0,0 +1,41 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value key="EditorConfiguration.Codec" type="QByteArray">UTF-8</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">QML Runtime</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QmlProjectManager.QmlTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">-1</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">QML Runtime</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QmlProjectManager.QmlRunConfiguration</value>
+ <value key="QmlProjectManager.QmlRunConfiguration.DebugServerAddress" type="QString">127.0.0.1</value>
+ <value key="QmlProjectManager.QmlRunConfiguration.DebugServerPort" type="int">3768</value>
+ <value key="QmlProjectManager.QmlRunConfiguration.MainScript" type="QString">positioners.qml</value>
+ <value key="QmlProjectManager.QmlRunConfiguration.QDeclarativeViewer" type="QString"></value>
+ <value key="QmlProjectManager.QmlRunConfiguration.QDeclarativeViewerArguments" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">4</value>
+ </data>
+</qtcreator>
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index ac60758..6ddd01e 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1029,7 +1029,10 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
if (!component.isReady())
return ctxt->throwError("Qt.createQmlObject(): Component is not ready");
- QObject *obj = component.create(context->asQDeclarativeContext());
+ QObject *obj = component.beginCreate(context->asQDeclarativeContext());
+ if(obj)
+ QDeclarativeData::get(obj, true)->setImplicitDestructible();
+ component.completeCreate();
if(component.isError()) {
QList<QDeclarativeError> errors = component.errors();
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index ecde0cc..1754908 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
-SUBDIRS += widgets particles
+SUBDIRS += particles
contains(QT_CONFIG, webkit): SUBDIRS += webkit
contains(QT_CONFIG, mediaservices): SUBDIRS += multimedia
diff --git a/src/imports/widgets/qmldir b/src/imports/widgets/qmldir
deleted file mode 100644
index 6f19878..0000000
--- a/src/imports/widgets/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin widgets
diff --git a/src/imports/widgets/widgets.pro b/src/imports/widgets/widgets.pro
deleted file mode 100644
index 234ff1e..0000000
--- a/src/imports/widgets/widgets.pro
+++ /dev/null
@@ -1,30 +0,0 @@
-TARGET = widgets
-TARGETPATH = Qt/widgets
-include(../qimportbase.pri)
-
-QT += declarative
-
-SOURCES += \
- graphicslayouts.cpp \
- widgets.cpp
-
-HEADERS += \
- graphicslayouts_p.h
-
-QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH
-target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-
-qmldir.files += $$PWD/qmldir
-qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
-
-symbian:{
- load(data_caging_paths)
- include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri)
-
- importFiles.sources = widgets.dll qmldir
- importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
-
- DEPLOYMENT = importFiles
-}
-
-INSTALLS += target qmldir
diff --git a/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml
new file mode 100644
index 0000000..ee881a2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml
@@ -0,0 +1,9 @@
+import Qt 4.7
+
+LayoutItem {//Sized by the layout
+ id: resizable
+ objectName: "resizable"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "200x200"
+}
diff --git a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
index a2065f4..eeb784d 100644
--- a/tests/auto/declarative/qdeclarativelayouts/qdeclarativelayouts.pro
+++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro
@@ -1,10 +1,8 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative
-SOURCES += tst_qdeclarativelayouts.cpp
+contains(QT_CONFIG,declarative): QT += declarative gui
macx:CONFIG -= app_bundle
+SOURCES += tst_qdeclarativelayoutitem.cpp
+
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
new file mode 100644
index 0000000..2207635
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <qdeclarativecomponent.h>
+#include <qdeclarativeengine.h>
+#include <qdeclarativeitem.h>
+#include <private/qdeclarativelayoutitem_p.h>
+#include <qgraphicsview.h>
+#include <qgraphicsscene.h>
+#include <qgraphicswidget.h>
+#include <qgraphicslinearlayout.h>
+#include "../../../shared/util.h"
+
+class tst_qdeclarativelayoutitem : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qdeclarativelayoutitem();
+
+private slots:
+ void test_resizing();
+};
+
+tst_qdeclarativelayoutitem::tst_qdeclarativelayoutitem()
+{
+}
+
+void tst_qdeclarativelayoutitem::test_resizing()
+{
+ //Create Layout (must be done in C++)
+ QGraphicsView view;
+ QGraphicsScene scene;
+ QGraphicsWidget *widget = new QGraphicsWidget();
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout();
+ widget->setLayout(layout);
+ scene.addItem(widget);
+ view.setScene(&scene);
+ //Add the QML snippet into the layout
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl(SRCDIR "/data/layoutItem.qml"));
+ QDeclarativeLayoutItem* obj = static_cast<QDeclarativeLayoutItem*>(c.create());
+ layout->addItem(obj);
+ layout->setContentsMargins(0,0,0,0);
+ widget->setContentsMargins(0,0,0,0);
+ view.show();
+
+ QVERIFY(obj!= 0);
+
+ widget->setGeometry(QRectF(0,0, 400,400));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+
+ widget->setGeometry(QRectF(0,0, 300,300));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+
+ widget->setGeometry(QRectF(0,0, 200,200));
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 200.0);
+
+ widget->setGeometry(QRectF(0,0, 100,100));
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 100.0);
+
+ widget->setGeometry(QRectF(0,0, 40,40));
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 100.0);
+
+ widget->setGeometry(QRectF(0,0, 412,112));
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 112.0);
+}
+
+
+QTEST_MAIN(tst_qdeclarativelayoutitem)
+
+#include "tst_qdeclarativelayoutitem.moc"
diff --git a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml b/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml
deleted file mode 100644
index 0538738..0000000
--- a/tests/auto/declarative/qdeclarativelayouts/data/layouts.qml
+++ /dev/null
@@ -1,31 +0,0 @@
-import Qt 4.7
-import Qt.widgets 4.7
-
-Item {
- id: resizable
- width:300
- height:300
- QGraphicsWidget {
- x : resizable.x
- y : resizable.y
- width : resizable.width
- height : resizable.height
- layout: QGraphicsLinearLayout {
- spacing: 0
- LayoutItem {
- objectName: "left"
- minimumSize: "100x100"
- maximumSize: "300x300"
- preferredSize: "100x100"
- Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent }
- }
- LayoutItem {
- objectName: "right"
- minimumSize: "100x100"
- maximumSize: "400x400"
- preferredSize: "200x200"
- Rectangle { objectName: "greenRect"; color: "green"; anchors.fill: parent }
- }
- }
- }
-}
diff --git a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp b/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp
deleted file mode 100644
index 412c3b7..0000000
--- a/tests/auto/declarative/qdeclarativelayouts/tst_qdeclarativelayouts.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** 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, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <qdeclarativeview.h>
-#include <private/qdeclarativelayoutitem_p.h>
-#include <qdeclarativeexpression.h>
-#include <QStyle>
-
-class tst_QDeclarativeLayouts : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativeLayouts();
-
-private slots:
- void test_qml();//GraphicsLayout set up in Qml
- void test_cpp();//GraphicsLayout set up in C++
-
-private:
- QDeclarativeView *createView(const QString &filename);
-};
-
-tst_QDeclarativeLayouts::tst_QDeclarativeLayouts()
-{
-}
-
-void tst_QDeclarativeLayouts::test_qml()
-{
- QDeclarativeView *canvas = createView(SRCDIR "/data/layouts.qml");
-
- qApp->processEvents();
- QDeclarativeLayoutItem *left = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("left"));
- QVERIFY(left != 0);
-
- QDeclarativeLayoutItem *right = static_cast<QDeclarativeLayoutItem*>(canvas->rootObject()->findChild<QDeclarativeItem*>("right"));
- QVERIFY(right != 0);
-
- qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
- qreal r = QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin);
- qreal t = QApplication::style()->pixelMetric(QStyle::PM_LayoutTopMargin);
- qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
- QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins.");
- qreal gvMargin = l;
-
- QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
-
- //Preferred Size
- rootItem->setWidth(300 + 2*gvMargin);
- rootItem->setHeight(300 + 2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->y(), gvMargin);
- QCOMPARE(left->width(), 100.0);
- QCOMPARE(left->height(), 300.0);
-
- QCOMPARE(right->x(), 100.0 + gvMargin);
- QCOMPARE(right->y(), 0.0 + gvMargin);
- QCOMPARE(right->width(), 200.0);
- QCOMPARE(right->height(), 300.0);
-
- //Minimum Size
- rootItem->setWidth(10+2*gvMargin);
- rootItem->setHeight(10+2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->width(), 100.0);
- QCOMPARE(left->height(), 100.0);
-
- QCOMPARE(right->x(), 100.0 + gvMargin);
- QCOMPARE(right->width(), 100.0);
- QCOMPARE(right->height(), 100.0);
-
- //Between preferred and Maximum Size
- /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior
- is to shrink them down to preferred size. So the exact maximum size can't
- be used*/
- rootItem->setWidth(670 + 2*gvMargin);
- rootItem->setHeight(300 + 2*gvMargin);
-
- QCOMPARE(left->x(), gvMargin);
- QCOMPARE(left->width(), 270.0);
- QCOMPARE(left->height(), 300.0);
-
- QCOMPARE(right->x(), 270.0 + gvMargin);
- QCOMPARE(right->width(), 400.0);
- QCOMPARE(right->height(), 300.0);
-
- delete canvas;
-}
-
-void tst_QDeclarativeLayouts::test_cpp()
-{
- //TODO: This test!
-}
-
-QDeclarativeView *tst_QDeclarativeLayouts::createView(const QString &filename)
-{
- QDeclarativeView *canvas = new QDeclarativeView(0);
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_QDeclarativeLayouts)
-
-#include "tst_qdeclarativelayouts.moc"