From 66e3930a320419183bbc953bbf16859c29d0e2fc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 13 Aug 2009 11:47:21 +1000 Subject: Fix demo KeyActions -> Keys --- demos/declarative/flickr/content/MediaLineEdit.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/flickr/content/MediaLineEdit.qml b/demos/declarative/flickr/content/MediaLineEdit.qml index 4a55ff5..e175b4e 100644 --- a/demos/declarative/flickr/content/MediaLineEdit.qml +++ b/demos/declarative/flickr/content/MediaLineEdit.qml @@ -102,8 +102,8 @@ Item { anchors.fill: Container targets: [(ReturnKey), (Editor)] } - KeyActions { + Item { id: ReturnKey - keyReturn: "Container.state = ''" + Keys.onReturnPressed: "Container.state = ''" } } -- cgit v0.12 From 4a8f38ed6ef6c1cb4a0ac7d2e123b6c42332fd07 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Aug 2009 12:31:54 +1000 Subject: Add delay parameter to the destroy function on QML objects Also updated dynamic example to have a fadeout effect on deletion. Also slipped in a toStr function, as it didn't work when I called it toString. --- examples/declarative/dynamic/DynRect.qml | 8 +++++++- examples/declarative/dynamic/dynamic.qml | 4 +++- src/declarative/qml/qmlengine.cpp | 34 +++++++++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/examples/declarative/dynamic/DynRect.qml b/examples/declarative/dynamic/DynRect.qml index 3f83afb..ec27441 100644 --- a/examples/declarative/dynamic/DynRect.qml +++ b/examples/declarative/dynamic/DynRect.qml @@ -1,3 +1,9 @@ import Qt 4.6 -Rect { color: "steelblue"; width: 100; height: 100; id: newRect } +Item { + states: State{ name: "dying"; SetProperties{ target: newRect; opacity: 0 } } + transitions: Transition{ + NumberAnimation{ properties: "opacity"; target: newRect; duration:500 } + } + Rect {color: "steelblue"; width: 100; height: 100; id: newRect } +} diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 286e449..54d8dc8 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -19,10 +19,12 @@ Rect { id: page; width: 800; height: 800; color:"black" if(a!=null) { a.parent = targetItem2;//BUG: this should happen automatically fourthBox = a; + print(a.toStr()); extendStars = true; } } else { - fourthBox.destroy(); + fourthBox.state = 'dying'; + fourthBox.destroy(500); fourthBox = null; extendStars = false; } diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index bdbf2e7..5a10c3b 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -929,12 +930,37 @@ void QmlValueTypeScriptClass::setProperty(QScriptValue &object, QtScript for QML. */ +QScriptValue QmlObjectToString(QScriptContext *context, QScriptEngine *engine) +{ + QObject* obj = context->thisObject().data().toQObject(); + QString ret = QLatin1String("Qml Object, "); + if(obj){ + //###Should this be designer or developer details? Dev for now. + //TODO: Can we print the id too? + ret += QLatin1String("\""); + ret += obj->objectName(); + ret += QLatin1String("\" "); + ret += obj->metaObject()->className(); + ret += QLatin1String("(0x"); + ret += QString::number((int)obj,16); + ret += QLatin1String(")"); + }else{ + ret += "null"; + } + return engine->newVariant(ret); +} + QScriptValue QmlObjectDestroy(QScriptContext *context, QScriptEngine *engine) { QObject* obj = context->thisObject().data().toQObject(); - if(obj) - delete obj; - context->thisObject().setData(QScriptValue(engine, 0)); + if(obj){ + int delay = 0; + if(context->argumentCount() > 0) + delay = context->argument(0).toInt32(); + QTimer::singleShot(delay, obj, SLOT(deleteLater())); + //### Should this be delayed as well? + context->thisObject().setData(QScriptValue(engine, 0)); + } return engine->nullValue(); } @@ -944,6 +970,8 @@ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) engine = bindEngine; QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(bindEngine); prototypeObject = scriptEngine->newObject(); + prototypeObject.setProperty(QLatin1String("toStr"),//TODO: Why won't toString work? + scriptEngine->newFunction(QmlObjectToString)); prototypeObject.setProperty(QLatin1String("destroy"), scriptEngine->newFunction(QmlObjectDestroy)); } -- cgit v0.12 From c65d294a7a6adb2a83271904db74fe3598af1256 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 13 Aug 2009 12:52:59 +1000 Subject: doc --- src/declarative/fx/qfxwebview.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 37e5d59..a80152c 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -523,6 +523,37 @@ void QFxWebView::setCacheSize(int pixels) d->max_imagecache_size = pixels; } +/*! + \qmlproperty list WebView::javaScriptWindowObjects + + This property is a list of object that are available from within + the webview's JavaScript context. + + The \a object will be inserted as a child of the frame's window + object, under the name given by the attached property \c WebView.windowObjectName. + + \qml + WebView { + javaScriptWindowObjects: Object { + WebView.windowObjectName: "coordinates" + } + } + \endqml + + Properties of the object will be exposed as JavaScript properties and slots as + JavaScript methods. + + If Javascript is not enabled for this page, then this property does nothing. +*/ + +/*! + \property QFxWebView::javaScriptWindowObjects + + The list of object that are available from within + the webview's JavaScript context. + + \sa QWebFrame::addToJavaScriptWindowObject +*/ QmlList *QFxWebView::javaScriptWindowObjects() { Q_D(QFxWebView); -- cgit v0.12 From 019ae3a99ec0a308a7dd7efb6bdc54472e6e63aa Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Aug 2009 13:28:05 +1000 Subject: Rename layouts to positioners --- examples/declarative/easing/easing.qml | 2 +- examples/declarative/fonts/fonts.qml | 2 +- examples/declarative/listview/highlight.qml | 2 +- examples/declarative/listview/itemlist.qml | 2 +- examples/declarative/listview/listview.qml | 2 +- examples/declarative/listview/recipes.qml | 4 +- examples/declarative/listview/sections.qml | 2 +- examples/declarative/modules/installed-version.qml | 2 +- examples/declarative/modules/local-qualified.qml | 2 +- examples/declarative/smooth/rect-painting.qml | 2 +- examples/declarative/snow/snow.qml | 2 +- .../1_Drawing_and_animation.qml | 2 +- .../tutorials/contacts/2_Reuse/2_Reuse.qml | 2 +- .../tutorials/contacts/2_Reuse/3/Contact.qml | 2 +- .../tutorials/contacts/2_Reuse/4/Contact.qml | 2 +- .../contacts/3_Collections/3_Collections.qml | 2 +- .../contacts/3_Collections/lib/Contact.qml | 2 +- .../tutorials/helloworld/t2/tutorial2.qml | 2 +- .../tutorials/helloworld/t3/tutorial3.qml | 2 +- examples/declarative/velocity/velocity.qml | 2 +- examples/declarative/webview/autosize.qml | 2 +- src/declarative/fx/fx.pri | 6 +- src/declarative/fx/qfxlayouts.cpp | 1110 -------------------- src/declarative/fx/qfxlayouts.h | 174 --- src/declarative/fx/qfxlayouts_p.h | 107 -- src/declarative/fx/qfxpositioners.cpp | 1110 ++++++++++++++++++++ src/declarative/fx/qfxpositioners.h | 174 +++ src/declarative/fx/qfxpositioners_p.h | 107 ++ src/declarative/fx/qfxtext.cpp | 4 +- src/declarative/fx/qfxtextedit.cpp | 2 +- src/declarative/util/qfxperf.cpp | 2 +- src/declarative/util/qmllistmodel.cpp | 2 +- 32 files changed, 1421 insertions(+), 1421 deletions(-) delete mode 100644 src/declarative/fx/qfxlayouts.cpp delete mode 100644 src/declarative/fx/qfxlayouts.h delete mode 100644 src/declarative/fx/qfxlayouts_p.h create mode 100644 src/declarative/fx/qfxpositioners.cpp create mode 100644 src/declarative/fx/qfxpositioners.h create mode 100644 src/declarative/fx/qfxpositioners_p.h diff --git a/examples/declarative/easing/easing.qml b/examples/declarative/easing/easing.qml index e3c22c9..8089f16 100644 --- a/examples/declarative/easing/easing.qml +++ b/examples/declarative/easing/easing.qml @@ -51,7 +51,7 @@ Rect { ListElement { type: "easeOutInBounce" } } - VerticalLayout { + VerticalPositioner { id: Layout anchors.left: Window.left anchors.right: Window.right diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index c981e51..9fd409a 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -16,7 +16,7 @@ Rect { FontLoader { id: WebFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } FontLoader { id: WebFont2; source: "http://wrong.address.org" } - VerticalLayout { + VerticalPositioner { anchors.fill: parent anchors.leftMargin: 10; anchors.rightMargin: 10 Text { diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 092ce66..ea9feb0 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -14,7 +14,7 @@ Rect { Item { id: Wrapper width: 200; height: 50 - VerticalLayout { + VerticalPositioner { Text { text: 'Name: ' + name } Text { text: 'Type: ' + type } Text { text: 'Age: ' + age } diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml index 046321b..4b81614 100644 --- a/examples/declarative/listview/itemlist.qml +++ b/examples/declarative/listview/itemlist.qml @@ -40,7 +40,7 @@ Rect { height: 30 width: 240 - HorizontalLayout { + HorizontalPositioner { anchors.centerIn: parent spacing: 20 Repeater { diff --git a/examples/declarative/listview/listview.qml b/examples/declarative/listview/listview.qml index 82b04ed..6b8d3d6 100644 --- a/examples/declarative/listview/listview.qml +++ b/examples/declarative/listview/listview.qml @@ -14,7 +14,7 @@ Rect { Item { id: Wrapper width: 200; height: 50 - VerticalLayout { + VerticalPositioner { Text { text: 'Name: ' + name } Text { text: 'Type: ' + type } Text { text: 'Age: ' + age } diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index 8b12527..7abadd0 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -37,7 +37,7 @@ Rect { // Layout the page. Picture, title and ingredients at the top, method at the // bottom. Note that elements that should not be visible in the list // mode have their opacity set to wrapper.detailsOpacity. - HorizontalLayout { + HorizontalPositioner { id: topLayout x: 10; y: 10; height: recipePic.height; width: parent.width spacing: 10 @@ -45,7 +45,7 @@ Rect { id: recipePic source: picture; width: 48; height: 48 } - VerticalLayout { + VerticalPositioner { height: recipePic.height; width: background.width-recipePic.width-20 spacing: 5 Text { id: name; text: title; font.bold: true; font.size: 16 } diff --git a/examples/declarative/listview/sections.qml b/examples/declarative/listview/sections.qml index 415f524..ab9fbdf 100644 --- a/examples/declarative/listview/sections.qml +++ b/examples/declarative/listview/sections.qml @@ -36,7 +36,7 @@ Rect { x: 5 height: Layout.height + 4 anchors.top: Separator.bottom - VerticalLayout { + VerticalPositioner { id: Layout y: 2 Text { text: 'Name: ' + name } diff --git a/examples/declarative/modules/installed-version.qml b/examples/declarative/modules/installed-version.qml index 8098b9b..0d3fa09 100644 --- a/examples/declarative/modules/installed-version.qml +++ b/examples/declarative/modules/installed-version.qml @@ -2,7 +2,7 @@ import Qt 4.6 import com.nokia.Foo 1.6 import com.nokia.Foo 1.7 as NewFoo -VerticalLayout { +VerticalPositioner { Bar { } Baz { } NewFoo.Bar { } diff --git a/examples/declarative/modules/local-qualified.qml b/examples/declarative/modules/local-qualified.qml index 8658031..f321738 100644 --- a/examples/declarative/modules/local-qualified.qml +++ b/examples/declarative/modules/local-qualified.qml @@ -3,7 +3,7 @@ import Qt 4.6 import "local" as X import "local/SubLib" as Y -VerticalLayout { +VerticalPositioner { X.Foo { } Y.Bar { } } diff --git a/examples/declarative/smooth/rect-painting.qml b/examples/declarative/smooth/rect-painting.qml index 2f01e4b..ba6c16f 100644 --- a/examples/declarative/smooth/rect-painting.qml +++ b/examples/declarative/smooth/rect-painting.qml @@ -12,7 +12,7 @@ Rect { color: "#eeeeee" } - GridLayout { + GridPositioner { anchors.centerIn: parent columns: 8; rows:4; spacing: 30 diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml index 5dd0006..f091371 100644 --- a/examples/declarative/snow/snow.qml +++ b/examples/declarative/snow/snow.qml @@ -22,7 +22,7 @@ Rect { Item { anchors.centerIn: parent - HorizontalLayout { + HorizontalPositioner { id: MyLayout property real targetX: -(selectedX + imageWidth / 2) diff --git a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml index 92ca377..a70ef16 100644 --- a/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml +++ b/examples/declarative/tutorials/contacts/1_Drawing_and_Animation/1_Drawing_and_animation.qml @@ -5,7 +5,7 @@ Rect { width: layout.width height: layout.height color: "white" - VerticalLayout { + VerticalPositioner { id: layout width: contents.width GroupBox { diff --git a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml index 3b0ef67..7ac513e 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/2_Reuse.qml @@ -5,7 +5,7 @@ Rect { width: layout.width height: layout.height color: "white" - GridLayout { + GridPositioner { id: layout columns: 2 rows: 4 diff --git a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml index 4c458c8..8c54cd6 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/3/Contact.qml @@ -14,7 +14,7 @@ Item { onEmailChanged: { emailField.value = email } onPhoneChanged: { phoneField.value = phone } - VerticalLayout { + VerticalPositioner { id: layout anchors.fill: parent spacing: 5 diff --git a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml index f70153b..37fd8d3 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/4/Contact.qml @@ -17,7 +17,7 @@ Item { onEmailChanged: { emailField.value = email } onPhoneChanged: { phoneField.value = phone } - VerticalLayout { + VerticalPositioner { id: layout anchors.fill: parent spacing: 5 diff --git a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml index 21615cb..d61705c 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/3_Collections.qml @@ -11,7 +11,7 @@ Rect { } // relies on the current focus behavior whereby setting focus=true on a // component removes focus from any previous element - GridLayout { + GridPositioner { id: layout width: contents.width height: contents.height diff --git a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml index 129ea85..6f40e24 100644 --- a/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml +++ b/examples/declarative/tutorials/contacts/3_Collections/lib/Contact.qml @@ -13,7 +13,7 @@ Item { onEmailChanged: { emailField.value = email } onPhoneChanged: { phoneField.value = phone } - VerticalLayout { + VerticalPositioner { id: layout anchors.fill: parent spacing: 5 diff --git a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml index fdb8f3c..efbdbf1 100644 --- a/examples/declarative/tutorials/helloworld/t2/tutorial2.qml +++ b/examples/declarative/tutorials/helloworld/t2/tutorial2.qml @@ -13,7 +13,7 @@ Rect { y: 30 anchors.horizontalCenter: Page.horizontalCenter } - GridLayout { + GridPositioner { id: ColorPicker x: 0 anchors.bottom: Page.bottom diff --git a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml index 557f2ca..3e93632 100644 --- a/examples/declarative/tutorials/helloworld/t3/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/t3/tutorial3.qml @@ -40,7 +40,7 @@ Rect { ] } MouseRegion { id: MouseRegion; anchors.fill: HelloText } - GridLayout { + GridPositioner { id: ColorPicker x: 0 anchors.bottom: Page.bottom diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index a1fbcc1..f609537 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -98,7 +98,7 @@ Rect { id: Flick anchors.fill: parent viewportWidth: Lay.width - HorizontalLayout { + HorizontalPositioner { id: Lay Repeater { dataSource: List diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index 2930657..d8e2063 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -7,7 +7,7 @@ Rect { color: "white" width: 200 height: Layout.height - VerticalLayout { + VerticalPositioner { id: Layout spacing: 2 WebView { diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 8b37009..5f574cd 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -20,8 +20,8 @@ HEADERS += \ fx/qfxitem_p.h \ fx/qfxfocusscope.h \ fx/qfxkeyproxy.h \ - fx/qfxlayouts.h \ - fx/qfxlayouts_p.h \ + fx/qfxpositioners.h \ + fx/qfxpositioners_p.h \ fx/qfxloader.h \ fx/qfxloader_p.h \ fx/qfxmouseregion.h \ @@ -61,7 +61,7 @@ SOURCES += \ fx/qfxitem.cpp \ fx/qfxfocusscope.cpp \ fx/qfxkeyproxy.cpp \ - fx/qfxlayouts.cpp \ + fx/qfxpositioners.cpp \ fx/qfxloader.cpp \ fx/qfxmouseregion.cpp \ fx/qfxpath.cpp \ diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp deleted file mode 100644 index 836e3e4..0000000 --- a/src/declarative/fx/qfxlayouts.cpp +++ /dev/null @@ -1,1110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include "qml.h" -#include "qmlstate.h" -#include "qmlstategroup.h" -#include "qmlstateoperations.h" -#include "private/qfxperf_p.h" -#include "qfxlayouts.h" -#include "qfxlayouts_p.h" - - -QT_BEGIN_NAMESPACE - -/*! - \internal - \class QFxBaseLayout - \brief The QFxBaseLayout class provides a base for QFx layouts. - - To create a QFx Layout, simple subclass QFxBaseLayout and implement - doLayout(), which is automatically called when the layout might need - updating. - - It is strongly recommended that in your implementation of doLayout() - that you use the move, remove and add transitions when those conditions - arise. - - \ingroup group_layouts -*/ -QFxBaseLayout::QFxBaseLayout(AutoUpdateType at, QFxItem *parent) - : QFxItem(*(new QFxBaseLayoutPrivate), parent) -{ - Q_D(QFxBaseLayout); - d->init(at); -} - -QFxBaseLayout::QFxBaseLayout(QFxBaseLayoutPrivate &dd, AutoUpdateType at, QFxItem *parent) - : QFxItem(dd, parent) -{ - Q_D(QFxBaseLayout); - d->init(at); -} - -/*! - \property QFxBaseLayout::spacing - \brief the amount of spacing between items (in px) - - Note that the subclass is repsonsible for ensuring this. -*/ -int QFxBaseLayout::spacing() const -{ - Q_D(const QFxBaseLayout); - return d->_spacing; -} - -void QFxBaseLayout::setSpacing(int s) -{ - Q_D(QFxBaseLayout); - if (s==d->_spacing) - return; - d->_spacing = s; - preLayout(); -} - -/*! - \property QFxBaseLayout::margin - \brief the size of the margin around all items (in px) - -*/ -int QFxBaseLayout::margin() const -{ - Q_D(const QFxBaseLayout); - return d->_margin; -} - -void QFxBaseLayout::setMargin(int s) -{ - Q_D(QFxBaseLayout); - if (s==d->_margin) - return; - d->_margin = s; - preLayout(); -} - - -/*! - \property QFxBaseLayout::move - \brief the transition when moving an item. - - \qml -BaseLayout { - id: layout - y: 0 - move: Transition { - NumberAnimation { - properties: "y" - ease: "easeOutBounce" - } - } -} - \endqml -*/ -QmlTransition *QFxBaseLayout::move() const -{ - Q_D(const QFxBaseLayout); - return d->moveTransition; -} - -void QFxBaseLayout::setMove(QmlTransition *mt) -{ - Q_D(QFxBaseLayout); - d->moveTransition = mt; -} - -/*! - \property QFxBaseLayout::add - \brief the transition when adding an item. - - \qml -BaseLayout { - id: layout - y: 0 - add: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 0 - to: 1 - duration: 500 - } - } -} - \endqml -*/ -QmlTransition *QFxBaseLayout::add() const -{ - Q_D(const QFxBaseLayout); - return d->addTransition; -} - -void QFxBaseLayout::setAdd(QmlTransition *add) -{ - Q_D(QFxBaseLayout); - d->addTransition = add; -} - - -/*! - \property QFxBaseLayout::remove - \brief the transition when removing an item. - - Note that the item may be 'removed' because its opacity is zero. This can make certain - transitions difficult to see. - \qml -BaseLayout { - id: layout - y: 0 - remove: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 1 - to: 0 - duration: 500 - } - } -} - \endqml -*/ -QmlTransition *QFxBaseLayout::remove() const -{ - Q_D(const QFxBaseLayout); - return d->removeTransition; -} - -void QFxBaseLayout::setRemove(QmlTransition *remove) -{ - Q_D(QFxBaseLayout); - d->removeTransition = remove; -} - -/*! - \property QFxBaseLayout::item - - The item that is currently being laid out. Used to target transitions that apply - only to the item being laid out, such as in the add transition. -*/ - -QFxItem *QFxBaseLayout::layoutItem() const -{ - Q_D(const QFxBaseLayout); - return d->_layoutItem; -} - -/*! - \internal -*/ -void QFxBaseLayout::setLayoutItem(QFxItem *li) -{ - Q_D(QFxBaseLayout); - if (li == d->_layoutItem) - return; - d->_layoutItem = li; - emit layoutItemChanged(); -} - -void QFxBaseLayout::componentComplete() -{ - QFxItem::componentComplete(); -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer cc; -#endif - preLayout(); -} - -QVariant QFxBaseLayout::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - if (change == ItemChildAddedChange || - change == ItemChildRemovedChange) { - preLayout(); - } - - return QFxItem::itemChange(change, value); -} - -bool QFxBaseLayout::event(QEvent *e) -{ - Q_D(QFxBaseLayout); - if (e->type() == QEvent::User) { - d->_ep = false; - d->_stableItems += d->_newItems; - d->_leavingItems.clear(); - d->_newItems.clear(); - return true; - } - return QFxItem::event(e); -} - -/*! - Items that have just been added to the layout. This includes invisible items - that have turned visible. -*/ -QSet* QFxBaseLayout::newItems() -{ - Q_D(QFxBaseLayout); - return &d->_newItems; -} - -/*! - Items that are visible in the layout, not including ones that have just been added. -*/ -QSet* QFxBaseLayout::items() -{ - Q_D(QFxBaseLayout); - return &d->_stableItems; -} - -/*! - Items that have just left the layout. This includes visible items - that have turned invisible. -*/ -QSet* QFxBaseLayout::leavingItems() -{ - Q_D(QFxBaseLayout); - return &d->_leavingItems; -} - -void QFxBaseLayout::preLayout() -{ - Q_D(QFxBaseLayout); - if (!isComponentComplete() || d->_movingItem) - return; - - if (!d->_ep) { - d->_ep = true; - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); - } - QSet allItems; - QList children = childItems(); - for (int ii = 0; ii < children.count(); ++ii) { - QFxItem *child = qobject_cast(children.at(ii)); - if (!child) - continue; - if (!d->_items.contains(child)){ - QObject::connect(child, SIGNAL(visibleChanged()), - this, SLOT(preLayout())); - QObject::connect(child, SIGNAL(opacityChanged()), - this, SLOT(preLayout())); - QObject::connect(child, SIGNAL(heightChanged()), - this, SLOT(preLayout())); - QObject::connect(child, SIGNAL(widthChanged()), - this, SLOT(preLayout())); - d->_items += child; - } - if (child->opacity() == 0.0){ - if (d->_stableItems.contains(child)){ - d->_leavingItems += child; - d->_stableItems -= child; - } - }else if (!d->_stableItems.contains(child)){ - d->_newItems+=child; - } - allItems += child; - } - QSet deletedItems = d->_items - allItems; - foreach(QFxItem *child, d->_items){ - if (!allItems.contains(child)){ - if (!deletedItems.contains(child)) { - QObject::disconnect(child, SIGNAL(opacityChanged()), - this, SLOT(preLayout())); - QObject::disconnect(child, SIGNAL(heightChanged()), - this, SLOT(preLayout())); - QObject::disconnect(child, SIGNAL(widthChanged()), - this, SLOT(preLayout())); - } - d->_items -= child; - } - } - d->_animated.clear(); - doLayout(); - //Set the layout's size to be the rect containing all children - //d->aut determines whether a dimension is sum or max - //Also sets the margin - qreal width=0; - qreal height=0; - qreal maxWidth=0; - qreal maxHeight=0; - foreach(QFxItem *item, d->_items){ - if (item->opacity() != 0.0){ - if (!d->_animated.contains(item)){ - setMovingItem(item); - QPointF p(item->x(), item->y()); - if(d->aut & Horizontal) - p.setX(p.x() + d->_margin); - if(d->aut & Vertical) - p.setY(p.y() + d->_margin); - item->setPos(p); - setMovingItem(0); - } - maxWidth = qMax(maxWidth, item->width()); - maxHeight = qMax(maxHeight, item->height()); - width = qMax(width, item->x() + item->width()); - height = qMax(height, item->y() + item->height()); - } - } - width += d->_margin; - height+= d->_margin; - - if(d->aut & Both){ - setImplicitHeight(int(height)); - setImplicitWidth(int(width)); - }else if (d->aut & Horizontal){ - setImplicitWidth(int(width)); - setImplicitHeight(int(maxHeight)); - } else if (d->aut & Vertical){ - setImplicitHeight(int(height)); - setImplicitWidth(int(maxWidth)); - }else{ - setImplicitHeight(int(maxHeight)); - setImplicitWidth(int(maxWidth)); - } - setLayoutItem(0); -} - -void QFxBaseLayout::applyTransition(const QList >& changes, QFxItem* target, QmlStateOperation::ActionList &actions) -{ - Q_D(QFxBaseLayout); - if (!target) - return; - setLayoutItem(target); - - for (int ii=0; ii_margin && - (changes[ii].first == QLatin1String("x") || - changes[ii].first == QLatin1String("y"))) { - val = QVariant(val.toInt() + d->_margin); - } - - actions << Action(target, changes[ii].first, val); - - } - - d->_animated << target; -} - -void QFxBaseLayout::finishApplyTransitions() -{ - Q_D(QFxBaseLayout); - d->addTransitionManager.transition(d->addActions, d->addTransition); - d->moveTransitionManager.transition(d->moveActions, d->moveTransition); - d->removeTransitionManager.transition(d->removeActions, d->removeTransition); - d->addActions.clear(); - d->moveActions.clear(); - d->removeActions.clear(); -} -void QFxBaseLayout::setMovingItem(QFxItem *i) -{ - Q_D(QFxBaseLayout); - d->_movingItem = i; -} - -/*! - Applies the layout's add transition to the \a target item.\a changes is a list of property,value - pairs which will be changed on the target using the add transition. -*/ -void QFxBaseLayout::applyAdd(const QList >& changes, QFxItem* target) -{ - Q_D(QFxBaseLayout); - applyTransition(changes,target, d->addActions); -} - -/*! - Applies the layout's move transition to the \a target.\a changes is a list of property,value pairs - which will be changed on the target using the move transition. -*/ -void QFxBaseLayout::applyMove(const QList >& changes, QFxItem* target) -{ - Q_D(QFxBaseLayout); - applyTransition(changes,target, d->moveActions); -} - -/*! - Applies the layout's remove transition to the \a target item.\a changes is a list of - property,value pairs which will be changed on the target using the remove transition. -*/ -void QFxBaseLayout::applyRemove(const QList >& changes, QFxItem* target) -{ - Q_D(QFxBaseLayout); - applyTransition(changes,target, d->removeActions); -} - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VerticalLayout,QFxVerticalLayout) -/*! - \qmlclass VerticalLayout - \brief The VerticalLayout item arranges its children in a vertical layout. - \inherits Item - - The VerticalLayout item arranges its child items so that they are vertically - aligned and not overlapping. Spacing between items can be added, as can a margin around all the items. - - The below example lays out differently shaped rectangles using a VerticalLayout. - \table - \row - \o \image verticalLayout_example.png - \o - \qml -VerticalLayout { - spacing: 2 - Rect { color: "red"; width: 50; height: 50 } - Rect { color: "green"; width: 20; height: 50 } - Rect { color: "blue"; width: 50; height: 20 } -} - \endqml - \endtable - - VerticalLayout also provides for transitions to be set when items are added, moved, - or removed in the layout. Adding and removing apply both to items which are deleted - or have their position in the document changed so as to no longer be children of the layout, - as well as to items which have their opacity set to or from zero so as to appear or disappear. - - \table - \row - \o \image verticalLayout_transition.gif - \o - \qml -VerticalLayout { - spacing: 2 - remove: ... - add: ... - move: ... - ... -} - \endqml - \endtable - - -*/ -/*! - \qmlproperty Transition VerticalLayout::remove - This property holds the transition to apply when removing an item from the layout. - - Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible. - - Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example. - - \table - \row - \o \image layout-remove.gif - \o - \qml -VerticalLayout { - id: layout - remove: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 1 - to: 0 - duration: 500 - } - } -} - \endqml - \endtable - -*/ -/*! - \qmlproperty Transition VerticalLayout::add - This property holds the transition to be applied when adding an item to the layout. - - Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible. - - \table - \row - \o \image layout-add.gif - \o - \qml -VerticalLayout { - id: layout - add: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 0 - to: 1 - duration: 500 - } - } -} - \endqml - \endtable - -*/ -/*! - \qmlproperty Transition VerticalLayout::move - This property holds the transition to apply when moving an item within the layout. - - This can happen when other items are added or removed from the layout, or when items resize themselves. - - \table - \row - \o \image layout-move.gif - \o - \qml -VerticalLayout { - id: layout - move: Transition { - NumberAnimation { - properties: "y" - ease: "easeOutBounce" - } - } -} - \endqml - \endtable -*/ -/*! - \qmlproperty Item VerticalLayout::item - - The item that is currently being laid out. Used to target transitions that apply - only to the item being laid out, such as in the add transition. - -*/ -/*! - \qmlproperty int VerticalLayout::spacing - \qmlproperty int VerticalLayout::margin - - spacing and margin allow you to control the empty space surrounding - items in layouts. - - spacing is the amount in pixels left empty between each adjacent - item. margin is the amount in pixels which will be left empty - around the inside edge of the layout. Both default to 0. - - The below example places a GridLayout containing a red, a blue and a - green rectangle on a gray background. The area the grid layout - occupies is colored white. The top layout has a spacing of 2 and a - margin of 5, the bottom layout has the defaults of no margin or - spacing. - - \image spacing_a.png - \image spacing_b.png - -*/ -/*! - \internal - \class QFxVerticalLayout - \brief The QFxVerticalLayout class lines up items vertically. - \ingroup group_layouts -*/ -QFxVerticalLayout::QFxVerticalLayout(QFxItem *parent) -: QFxBaseLayout(Vertical, parent) -{ -} - -void QFxVerticalLayout::doLayout() -{ - int voffset = 0; - - foreach(QFxItem* item, *leavingItems()){ - if (remove()){ - QList > changes; - applyRemove(changes, item); - } - } - - QList children = childItems(); - for (int ii = 0; ii < children.count(); ++ii) { - QFxItem *child = qobject_cast(children.at(ii)); - if (!child || child->opacity() == 0.0) - continue; - - bool needMove = (child->y() != voffset || child->x()); - - QList > changes; - changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset)); - changes << qMakePair(QString(QLatin1String("x")),QVariant(0)); - if (needMove && items()->contains(child) && move()) { - applyMove(changes,child); - } else if (!items()->contains(child) && add()) { - applyAdd(changes,child); - } else if (needMove) { - setMovingItem(child); - child->setY(voffset); - setMovingItem(0); - } - voffset += child->height(); - voffset += spacing(); - } - finishApplyTransitions(); - setMovingItem(this); - setMovingItem(0); -} - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,HorizontalLayout,QFxHorizontalLayout) -/*! - \qmlclass HorizontalLayout - \brief The HorizontalLayout item arranges its children in a horizontal layout. - \inherits Item - - The HorizontalLayout item arranges its child items so that they are horizontally aligned and not overlapping. Spacing can be added between the items, and a margin around all items can also be added. It also provides for transitions to be set when items are added, moved, or removed in the layout. Adding and removing apply both to items which are deleted or have their position in the document changed so as to no longer be children of the layout, as well as to items which have their opacity set to or from zero so as to appear or disappear. - - The below example lays out differently shaped rectangles using a HorizontalLayout. - \qml -HorizontalLayout { - spacing: 2 - Rect { color: "red"; width: 50; height: 50 } - Rect { color: "green"; width: 20; height: 50 } - Rect { color: "blue"; width: 50; height: 20 } -} - \endqml - \image horizontalLayout_example.png - -*/ -/*! - \qmlproperty Transition HorizontalLayout::remove - This property holds the transition to apply when removing an item from the layout. - - Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible. - - Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example. - - \qml -HorizontalLayout { - id: layout - remove: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 1 - to: 0 - duration: 500 - } - } -} - \endqml - -*/ -/*! - \qmlproperty Transition HorizontalLayout::add - This property holds the transition to apply when adding an item to the layout. - - Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible. - - \qml -HorizontalLayout { - id: layout - add: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 0 - to: 1 - duration: 500 - } - } -} - \endqml - -*/ -/*! - \qmlproperty Transition HorizontalLayout::move - This property holds the transition to apply when moving an item within the layout. - - This can happen when other items are added or removed from the layout, or when items resize themselves. - - \qml -HorizontalLayout { - id: layout - move: Transition { - NumberAnimation { - properties: "x" - ease: "easeOutBounce" - } - } -} - \endqml - -*/ -/*! - \qmlproperty Item HorizontalLayout::item - - The item that is currently being laid out. Used to target transitions that apply - only to the item being laid out, such as in the add transition. - -*/ -/*! - \qmlproperty int HorizontalLayout::spacing - - The spacing, in pixels, left empty between each adjacent item. -*/ -/*! - \qmlproperty int HorizontalLayout::margin - - The margin size, in pixels, which will be left empty around the inside edge of the layout. -*/ -/*! - \qmlproperty int HorizontalLayout::spacing - \qmlproperty int HorizontalLayout::margin - - spacing and margin allow you to control the empty space surrounding items in layouts. - - spacing is the amount in pixels left empty between each adjacent item. - margin is the amount in pixels which will be left empty around the inside edge of the layout. - Both default to 0. - - The below example places a GridLayout containing a red, a blue and a green rectangle on a gray background. The area the grid layout occupies is colored white. The top layout has a spacing of 2 and a margin of 5, the bottom layout has the defaults of no margin or spacing. - - \image spacing_a.png - \image spacing_b.png - -*/ -/*! - \internal - \class QFxHorizontalLayout - \brief The QFxHorizontalLayout class lines up items horizontally. - \ingroup group_layouts -*/ -QFxHorizontalLayout::QFxHorizontalLayout(QFxItem *parent) -: QFxBaseLayout(Horizontal, parent) -{ -} - -void QFxHorizontalLayout::doLayout() -{ - int hoffset = 0; - - foreach(QFxItem* item, *leavingItems()){ - if (remove()){ - QList > changes; - applyRemove(changes, item); - } - } - QList children = childItems(); - for (int ii = 0; ii < children.count(); ++ii) { - QFxItem *child = qobject_cast(children.at(ii)); - if (!child || child->opacity() == 0.0) - continue; - - bool needMove = (child->x() != hoffset || child->y()); - - QList > changes; - changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset)); - changes << qMakePair(QString(QLatin1String("y")),QVariant(0)); - if (needMove && items()->contains(child) && move()) { - applyMove(changes,child); - } else if (!items()->contains(child) && add()) { - applyAdd(changes,child); - } else if (needMove) { - setMovingItem(child); - child->setX(hoffset); - setMovingItem(0); - } - hoffset += child->width(); - hoffset += spacing(); - } - finishApplyTransitions(); -} - -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridLayout,QFxGridLayout) - -/*! - \qmlclass GridLayout QFxGridLayout - \brief The GridLayout item arranges its children in a grid layout. - \inherits Item - - The GridLayout item arranges its child items so that they are - aligned in a grid and are not overlapping. Spacing can be added - between the items, and a margin around all the items can also be - defined. It also provides for transitions to be set when items are - added, moved, or removed in the layout. Adding and removing apply - both to items which are deleted or have their position in the - document changed so as to no longer be children of the layout, as - well as to items which have their opacity set to or from zero so - as to appear or disappear. - - The GridLayout defaults to using four columns, and as many rows as - are necessary to fit all the child items. The number of rows - and/or the number of columns can be constrained by setting the rows - or columns properties. The grid layout calculates a grid with - rectangular cells of sufficient size to hold all items, and then - places the items in the cells, going across then down, and - positioning each item at the (0,0) corner of the cell. The below - example demonstrates this. - - \table - \row - \o \image gridLayout_example.png - \o - \qml -GridLayout { - columns: 3 - spacing: 2 - Rect { color: "red"; width: 50; height: 50 } - Rect { color: "green"; width: 20; height: 50 } - Rect { color: "blue"; width: 50; height: 20 } - Rect { color: "cyan"; width: 50; height: 50 } - Rect { color: "magenta"; width: 10; height: 10 } -} - \endqml - \endtable -*/ -/*! - \qmlproperty Transition GridLayout::remove - This property holds the transition to apply when removing an item from the layout. - - Removed can mean that either the object has been deleted or - reparented, and thus is now longer a child of the layout, or that - the object has had its opacity set to zero, and thus is no longer - visible. - - Note that if the item counts as removed because its opacity is - zero it will not be visible during the transition unless you set - the opacity in the transition, like in the below example. - - \qml -GridLayout { - id: layout - remove: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 1 - to: 0 - duration: 500 - } - } -} - \endqml - -*/ -/*! - \qmlproperty Transition GridLayout::add - This property holds the transition to apply when adding an item to the layout. - - Added can mean that either the object has been created or - reparented, and thus is now a child or the layout, or that the - object has had its opacity increased from zero, and thus is now - visible. - - \qml -GridLayout { - id: layout - add: Transition { - NumberAnimation { - target: layout.item - properties: "opacity" - from: 0 - to: 1 - duration: 500 - } - } -} - \endqml - -*/ -/*! - \qmlproperty Transition GridLayout::move - This property holds the transition to apply when moving an item within the layout. - - This can happen when other items are added or removed from the layout, or - when items resize themselves. - - \qml -GridLayout { - id: layout - move: Transition { - NumberAnimation { - properties: "x,y" - ease: "easeOutBounce" - } - } -} - \endqml - -*/ -/*! - \qmlproperty Item GridLayout::item - - The item that is currently being laid out. Used to target - transitions that apply only to the item being laid out, such as in - the add transition. - -*/ -/*! - \qmlproperty int GridLayout::spacing - \qmlproperty int GridLayout::margin - - spacing and margin allow you to control the empty space surrounding - items in layouts. - - spacing is the amount in pixels left empty between each adjacent - item. margin is the amount in pixels which will be left empty - around the inside edge of the layout. Both default to 0. - - The below example places a GridLayout containing a red, a blue and a - green rectangle on a gray background. The area the grid layout - occupies is colored white. The top layout has a spacing of 2 and a - margin of 5, the bottom layout has the defaults of no margin or - spacing. - - \image spacing_a.png - \image spacing_b.png - -*/ -/*! - \internal - \class QFxGridLayout - \brief The QFxGridLayout class lays out items in a grid. - \ingroup group_layouts - -*/ -QFxGridLayout::QFxGridLayout(QFxItem *parent) : - QFxBaseLayout(Both, parent) -{ - _columns=-1; - _rows=-1; -} - -/*! - \qmlproperty int GridLayout::columns - This property holds the number of columns in the grid. - - When the columns property is set the GridLayout will always have - that many columns. Note that if you do not have enough items to - fill this many columns some columns will be of zero width. -*/ - -/*! - \qmlproperty int GridLayout::rows - This property holds the number of rows in the grid. - - When the rows property is set the GridLayout will always have that - many rows. Note that if you do not have enough items to fill this - many rows some rows will be of zero width. -*/ - -/*! - \property QFxGridLayout::columns - \brief the number of columns in the grid. -*/ - -/*! - \property QFxGridLayout::rows - \brief the number of rows in the grid. -*/ - -void QFxGridLayout::doLayout() -{ - int c=_columns,r=_rows;//Actual number of rows/columns - int numVisible = items()->size() + newItems()->size(); - if (_columns==-1 && _rows==-1){ - c = 4; - r = (numVisible+2)/3; - }else if (_rows==-1){ - r = (numVisible+(_columns-1))/_columns; - }else if (_columns==-1){ - c = (numVisible+(_rows-1))/_rows; - } - - QList maxColWidth; - QList maxRowHeight; - int childIndex =0; - QList children = childItems(); - for (int i=0; i(children.at(childIndex++)); - if (!child || child->opacity() == 0.0) - continue; - if (child->width() > maxColWidth[j]) - maxColWidth[j] = child->width(); - if (child->height() > maxRowHeight[i]) - maxRowHeight[i] = child->height(); - } - } - - int xoffset=0; - int yoffset=0; - int curRow =0; - int curCol =0; - foreach(QFxItem* item, *leavingItems()){ - if (remove()){ - QList > changes; - applyRemove(changes, item); - } - } - foreach(QGraphicsItem* schild, children){ - QFxItem *child = qobject_cast(schild); - if (!child || child->opacity() == 0.0) - continue; - bool needMove = (child->x()!=xoffset)||(child->y()!=yoffset); - QList > changes; - changes << qMakePair(QString(QLatin1String("x")),QVariant(xoffset)); - changes << qMakePair(QString(QLatin1String("y")),QVariant(yoffset)); - if (newItems()->contains(child) && add()) { - applyAdd(changes,child); - } else if (needMove) { - if (move()){ - applyMove(changes,child); - }else{ - setMovingItem(child); - child->setPos(QPointF(xoffset, yoffset)); - setMovingItem(0); - } - } - xoffset+=maxColWidth[curCol]+spacing(); - curCol++; - curCol%=c; - if (!curCol){ - yoffset+=maxRowHeight[curRow]+spacing(); - xoffset=0; - curRow++; - if (curRow>=r) - return; - } - } - finishApplyTransitions(); -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h deleted file mode 100644 index e9c7f51..0000000 --- a/src/declarative/fx/qfxlayouts.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXLAYOUTS_H -#define QFXLAYOUTS_H - -#include -#include -#include -#include - - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) -class QFxBaseLayoutPrivate; - -class Q_DECLARATIVE_EXPORT QFxBaseLayout : public QFxItem -{ - Q_OBJECT - - Q_PROPERTY(int spacing READ spacing WRITE setSpacing) - Q_PROPERTY(int margin READ margin WRITE setMargin) - Q_PROPERTY(QmlTransition *move READ move WRITE setMove) - Q_PROPERTY(QmlTransition *add READ add WRITE setAdd) - Q_PROPERTY(QmlTransition *remove READ remove WRITE setRemove) - Q_PROPERTY(QFxItem *item READ layoutItem NOTIFY layoutItemChanged) -public: - enum AutoUpdateType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; - QFxBaseLayout(AutoUpdateType, QFxItem *parent); - - int spacing() const; - void setSpacing(int); - - int margin() const; - void setMargin(int); - - QmlTransition *move() const; - void setMove(QmlTransition *); - - QmlTransition *add() const; - void setAdd(QmlTransition *); - - QmlTransition *remove() const; - void setRemove(QmlTransition *); - - QFxItem *layoutItem() const; - -protected: - virtual void componentComplete(); - virtual QVariant itemChange(GraphicsItemChange, const QVariant &); - virtual bool event(QEvent *); - QSet* newItems(); - QSet* leavingItems(); - QSet* items(); - void applyAdd(const QList >& changes, QFxItem* target); - void applyMove(const QList >& changes, QFxItem* target); - void applyRemove(const QList >& changes, QFxItem* target); - void finishApplyTransitions(); - -Q_SIGNALS: - void layoutItemChanged(); - -protected Q_SLOTS: - virtual void doLayout()=0; - void setLayoutItem(QFxItem *); - -private Q_SLOTS: - void preLayout(); - -protected: - QFxBaseLayout(QFxBaseLayoutPrivate &dd, AutoUpdateType at, QFxItem *parent); - void setMovingItem(QFxItem *); - -private: - void applyTransition(const QList >& changes, QFxItem* target, - QmlStateOperation::ActionList &actions); - Q_DISABLE_COPY(QFxBaseLayout) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxBaseLayout) -}; - -class Q_DECLARATIVE_EXPORT QFxVerticalLayout : public QFxBaseLayout -{ - Q_OBJECT -public: - QFxVerticalLayout(QFxItem *parent=0); -protected Q_SLOTS: - virtual void doLayout(); -private: - Q_DISABLE_COPY(QFxVerticalLayout) -}; - -class Q_DECLARATIVE_EXPORT QFxHorizontalLayout: public QFxBaseLayout -{ - Q_OBJECT -public: - QFxHorizontalLayout(QFxItem *parent=0); -protected Q_SLOTS: - virtual void doLayout(); -private: - Q_DISABLE_COPY(QFxHorizontalLayout) -}; - -class Q_DECLARATIVE_EXPORT QFxGridLayout : public QFxBaseLayout -{ - Q_OBJECT - Q_PROPERTY(int rows READ rows WRITE setRows) - Q_PROPERTY(int columns READ columns WRITE setcolumns) -public: - QFxGridLayout(QFxItem *parent=0); - - int rows() const {return _rows;} - void setRows(const int rows){_rows = rows;} - - int columns() const {return _columns;} - void setcolumns(const int columns){_columns = columns;} -protected Q_SLOTS: - virtual void doLayout(); - -private: - int _rows; - int _columns; - Q_DISABLE_COPY(QFxGridLayout) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxVerticalLayout) -QML_DECLARE_TYPE(QFxHorizontalLayout) -QML_DECLARE_TYPE(QFxGridLayout) - -QT_END_HEADER - -#endif diff --git a/src/declarative/fx/qfxlayouts_p.h b/src/declarative/fx/qfxlayouts_p.h deleted file mode 100644 index 87b944c..0000000 --- a/src/declarative/fx/qfxlayouts_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXLAYOUTS_P_H -#define QFXLAYOUTS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QFxBaseLayoutPrivate : public QFxItemPrivate -{ - Q_DECLARE_PUBLIC(QFxBaseLayout) - -public: - QFxBaseLayoutPrivate() - : _ep(false), _componentComplete(false), _spacing(0), - _margin(0), aut(QFxBaseLayout::None), moveTransition(0), addTransition(0), - removeTransition(0), _layoutItem(0), _movingItem(0) - { - } - - void init(QFxBaseLayout::AutoUpdateType at) - { - aut = at; - } - - bool _ep; - bool _componentComplete; - int _spacing; - int _margin; - QFxBaseLayout::AutoUpdateType aut; - QmlTransition *moveTransition; - QmlTransition *addTransition; - QmlTransition *removeTransition; - QSet _items; - QSet _leavingItems; - QSet _stableItems; - QSet _newItems; - QSet _animated; - QFxItem *_layoutItem; - QmlStateOperation::ActionList addActions; - QmlStateOperation::ActionList moveActions; - QmlStateOperation::ActionList removeActions; - QmlTransitionManager addTransitionManager; - QmlTransitionManager moveTransitionManager; - QmlTransitionManager removeTransitionManager; -// QmlStateGroup *stateGroup; - QFxItem *_movingItem; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp new file mode 100644 index 0000000..270524d --- /dev/null +++ b/src/declarative/fx/qfxpositioners.cpp @@ -0,0 +1,1110 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "qml.h" +#include "qmlstate.h" +#include "qmlstategroup.h" +#include "qmlstateoperations.h" +#include "private/qfxperf_p.h" +#include "qfxpositioners.h" +#include "qfxpositioners_p.h" + + +QT_BEGIN_NAMESPACE + +/*! + \internal + \class QFxBasePositioner + \brief The QFxBasePositioner class provides a base for QFx layouts. + + To create a QFx Layout, simple subclass QFxBasePositioner and implement + doLayout(), which is automatically called when the layout might need + updating. + + It is strongly recommended that in your implementation of doLayout() + that you use the move, remove and add transitions when those conditions + arise. + + \ingroup group_layouts +*/ +QFxBasePositioner::QFxBasePositioner(AutoUpdateType at, QFxItem *parent) + : QFxItem(*(new QFxBasePositionerPrivate), parent) +{ + Q_D(QFxBasePositioner); + d->init(at); +} + +QFxBasePositioner::QFxBasePositioner(QFxBasePositionerPrivate &dd, AutoUpdateType at, QFxItem *parent) + : QFxItem(dd, parent) +{ + Q_D(QFxBasePositioner); + d->init(at); +} + +/*! + \property QFxBasePositioner::spacing + \brief the amount of spacing between items (in px) + + Note that the subclass is repsonsible for ensuring this. +*/ +int QFxBasePositioner::spacing() const +{ + Q_D(const QFxBasePositioner); + return d->_spacing; +} + +void QFxBasePositioner::setSpacing(int s) +{ + Q_D(QFxBasePositioner); + if (s==d->_spacing) + return; + d->_spacing = s; + preLayout(); +} + +/*! + \property QFxBasePositioner::margin + \brief the size of the margin around all items (in px) + +*/ +int QFxBasePositioner::margin() const +{ + Q_D(const QFxBasePositioner); + return d->_margin; +} + +void QFxBasePositioner::setMargin(int s) +{ + Q_D(QFxBasePositioner); + if (s==d->_margin) + return; + d->_margin = s; + preLayout(); +} + + +/*! + \property QFxBasePositioner::move + \brief the transition when moving an item. + + \qml +BaseLayout { + id: layout + y: 0 + move: Transition { + NumberAnimation { + properties: "y" + ease: "easeOutBounce" + } + } +} + \endqml +*/ +QmlTransition *QFxBasePositioner::move() const +{ + Q_D(const QFxBasePositioner); + return d->moveTransition; +} + +void QFxBasePositioner::setMove(QmlTransition *mt) +{ + Q_D(QFxBasePositioner); + d->moveTransition = mt; +} + +/*! + \property QFxBasePositioner::add + \brief the transition when adding an item. + + \qml +BaseLayout { + id: layout + y: 0 + add: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 0 + to: 1 + duration: 500 + } + } +} + \endqml +*/ +QmlTransition *QFxBasePositioner::add() const +{ + Q_D(const QFxBasePositioner); + return d->addTransition; +} + +void QFxBasePositioner::setAdd(QmlTransition *add) +{ + Q_D(QFxBasePositioner); + d->addTransition = add; +} + + +/*! + \property QFxBasePositioner::remove + \brief the transition when removing an item. + + Note that the item may be 'removed' because its opacity is zero. This can make certain + transitions difficult to see. + \qml +BaseLayout { + id: layout + y: 0 + remove: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 1 + to: 0 + duration: 500 + } + } +} + \endqml +*/ +QmlTransition *QFxBasePositioner::remove() const +{ + Q_D(const QFxBasePositioner); + return d->removeTransition; +} + +void QFxBasePositioner::setRemove(QmlTransition *remove) +{ + Q_D(QFxBasePositioner); + d->removeTransition = remove; +} + +/*! + \property QFxBasePositioner::item + + The item that is currently being laid out. Used to target transitions that apply + only to the item being laid out, such as in the add transition. +*/ + +QFxItem *QFxBasePositioner::layoutItem() const +{ + Q_D(const QFxBasePositioner); + return d->_layoutItem; +} + +/*! + \internal +*/ +void QFxBasePositioner::setLayoutItem(QFxItem *li) +{ + Q_D(QFxBasePositioner); + if (li == d->_layoutItem) + return; + d->_layoutItem = li; + emit layoutItemChanged(); +} + +void QFxBasePositioner::componentComplete() +{ + QFxItem::componentComplete(); +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer cc; +#endif + preLayout(); +} + +QVariant QFxBasePositioner::itemChange(GraphicsItemChange change, + const QVariant &value) +{ + if (change == ItemChildAddedChange || + change == ItemChildRemovedChange) { + preLayout(); + } + + return QFxItem::itemChange(change, value); +} + +bool QFxBasePositioner::event(QEvent *e) +{ + Q_D(QFxBasePositioner); + if (e->type() == QEvent::User) { + d->_ep = false; + d->_stableItems += d->_newItems; + d->_leavingItems.clear(); + d->_newItems.clear(); + return true; + } + return QFxItem::event(e); +} + +/*! + Items that have just been added to the layout. This includes invisible items + that have turned visible. +*/ +QSet* QFxBasePositioner::newItems() +{ + Q_D(QFxBasePositioner); + return &d->_newItems; +} + +/*! + Items that are visible in the layout, not including ones that have just been added. +*/ +QSet* QFxBasePositioner::items() +{ + Q_D(QFxBasePositioner); + return &d->_stableItems; +} + +/*! + Items that have just left the layout. This includes visible items + that have turned invisible. +*/ +QSet* QFxBasePositioner::leavingItems() +{ + Q_D(QFxBasePositioner); + return &d->_leavingItems; +} + +void QFxBasePositioner::preLayout() +{ + Q_D(QFxBasePositioner); + if (!isComponentComplete() || d->_movingItem) + return; + + if (!d->_ep) { + d->_ep = true; + QCoreApplication::postEvent(this, new QEvent(QEvent::User)); + } + QSet allItems; + QList children = childItems(); + for (int ii = 0; ii < children.count(); ++ii) { + QFxItem *child = qobject_cast(children.at(ii)); + if (!child) + continue; + if (!d->_items.contains(child)){ + QObject::connect(child, SIGNAL(visibleChanged()), + this, SLOT(preLayout())); + QObject::connect(child, SIGNAL(opacityChanged()), + this, SLOT(preLayout())); + QObject::connect(child, SIGNAL(heightChanged()), + this, SLOT(preLayout())); + QObject::connect(child, SIGNAL(widthChanged()), + this, SLOT(preLayout())); + d->_items += child; + } + if (child->opacity() == 0.0){ + if (d->_stableItems.contains(child)){ + d->_leavingItems += child; + d->_stableItems -= child; + } + }else if (!d->_stableItems.contains(child)){ + d->_newItems+=child; + } + allItems += child; + } + QSet deletedItems = d->_items - allItems; + foreach(QFxItem *child, d->_items){ + if (!allItems.contains(child)){ + if (!deletedItems.contains(child)) { + QObject::disconnect(child, SIGNAL(opacityChanged()), + this, SLOT(preLayout())); + QObject::disconnect(child, SIGNAL(heightChanged()), + this, SLOT(preLayout())); + QObject::disconnect(child, SIGNAL(widthChanged()), + this, SLOT(preLayout())); + } + d->_items -= child; + } + } + d->_animated.clear(); + doLayout(); + //Set the layout's size to be the rect containing all children + //d->aut determines whether a dimension is sum or max + //Also sets the margin + qreal width=0; + qreal height=0; + qreal maxWidth=0; + qreal maxHeight=0; + foreach(QFxItem *item, d->_items){ + if (item->opacity() != 0.0){ + if (!d->_animated.contains(item)){ + setMovingItem(item); + QPointF p(item->x(), item->y()); + if(d->aut & Horizontal) + p.setX(p.x() + d->_margin); + if(d->aut & Vertical) + p.setY(p.y() + d->_margin); + item->setPos(p); + setMovingItem(0); + } + maxWidth = qMax(maxWidth, item->width()); + maxHeight = qMax(maxHeight, item->height()); + width = qMax(width, item->x() + item->width()); + height = qMax(height, item->y() + item->height()); + } + } + width += d->_margin; + height+= d->_margin; + + if(d->aut & Both){ + setImplicitHeight(int(height)); + setImplicitWidth(int(width)); + }else if (d->aut & Horizontal){ + setImplicitWidth(int(width)); + setImplicitHeight(int(maxHeight)); + } else if (d->aut & Vertical){ + setImplicitHeight(int(height)); + setImplicitWidth(int(maxWidth)); + }else{ + setImplicitHeight(int(maxHeight)); + setImplicitWidth(int(maxWidth)); + } + setLayoutItem(0); +} + +void QFxBasePositioner::applyTransition(const QList >& changes, QFxItem* target, QmlStateOperation::ActionList &actions) +{ + Q_D(QFxBasePositioner); + if (!target) + return; + setLayoutItem(target); + + for (int ii=0; ii_margin && + (changes[ii].first == QLatin1String("x") || + changes[ii].first == QLatin1String("y"))) { + val = QVariant(val.toInt() + d->_margin); + } + + actions << Action(target, changes[ii].first, val); + + } + + d->_animated << target; +} + +void QFxBasePositioner::finishApplyTransitions() +{ + Q_D(QFxBasePositioner); + d->addTransitionManager.transition(d->addActions, d->addTransition); + d->moveTransitionManager.transition(d->moveActions, d->moveTransition); + d->removeTransitionManager.transition(d->removeActions, d->removeTransition); + d->addActions.clear(); + d->moveActions.clear(); + d->removeActions.clear(); +} +void QFxBasePositioner::setMovingItem(QFxItem *i) +{ + Q_D(QFxBasePositioner); + d->_movingItem = i; +} + +/*! + Applies the layout's add transition to the \a target item.\a changes is a list of property,value + pairs which will be changed on the target using the add transition. +*/ +void QFxBasePositioner::applyAdd(const QList >& changes, QFxItem* target) +{ + Q_D(QFxBasePositioner); + applyTransition(changes,target, d->addActions); +} + +/*! + Applies the layout's move transition to the \a target.\a changes is a list of property,value pairs + which will be changed on the target using the move transition. +*/ +void QFxBasePositioner::applyMove(const QList >& changes, QFxItem* target) +{ + Q_D(QFxBasePositioner); + applyTransition(changes,target, d->moveActions); +} + +/*! + Applies the layout's remove transition to the \a target item.\a changes is a list of + property,value pairs which will be changed on the target using the remove transition. +*/ +void QFxBasePositioner::applyRemove(const QList >& changes, QFxItem* target) +{ + Q_D(QFxBasePositioner); + applyTransition(changes,target, d->removeActions); +} + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VerticalPositioner,QFxVerticalPositioner) +/*! + \qmlclass VerticalPositioner + \brief The VerticalPositioner item arranges its children in a vertical layout. + \inherits Item + + The VerticalPositioner item arranges its child items so that they are vertically + aligned and not overlapping. Spacing between items can be added, as can a margin around all the items. + + The below example lays out differently shaped rectangles using a VerticalPositioner. + \table + \row + \o \image verticalLayout_example.png + \o + \qml +VerticalPositioner { + spacing: 2 + Rect { color: "red"; width: 50; height: 50 } + Rect { color: "green"; width: 20; height: 50 } + Rect { color: "blue"; width: 50; height: 20 } +} + \endqml + \endtable + + VerticalPositioner also provides for transitions to be set when items are added, moved, + or removed in the layout. Adding and removing apply both to items which are deleted + or have their position in the document changed so as to no longer be children of the layout, + as well as to items which have their opacity set to or from zero so as to appear or disappear. + + \table + \row + \o \image verticalLayout_transition.gif + \o + \qml +VerticalPositioner { + spacing: 2 + remove: ... + add: ... + move: ... + ... +} + \endqml + \endtable + + +*/ +/*! + \qmlproperty Transition VerticalPositioner::remove + This property holds the transition to apply when removing an item from the layout. + + Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible. + + Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example. + + \table + \row + \o \image layout-remove.gif + \o + \qml +VerticalPositioner { + id: layout + remove: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 1 + to: 0 + duration: 500 + } + } +} + \endqml + \endtable + +*/ +/*! + \qmlproperty Transition VerticalPositioner::add + This property holds the transition to be applied when adding an item to the layout. + + Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible. + + \table + \row + \o \image layout-add.gif + \o + \qml +VerticalPositioner { + id: layout + add: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 0 + to: 1 + duration: 500 + } + } +} + \endqml + \endtable + +*/ +/*! + \qmlproperty Transition VerticalPositioner::move + This property holds the transition to apply when moving an item within the layout. + + This can happen when other items are added or removed from the layout, or when items resize themselves. + + \table + \row + \o \image layout-move.gif + \o + \qml +VerticalPositioner { + id: layout + move: Transition { + NumberAnimation { + properties: "y" + ease: "easeOutBounce" + } + } +} + \endqml + \endtable +*/ +/*! + \qmlproperty Item VerticalPositioner::item + + The item that is currently being laid out. Used to target transitions that apply + only to the item being laid out, such as in the add transition. + +*/ +/*! + \qmlproperty int VerticalPositioner::spacing + \qmlproperty int VerticalPositioner::margin + + spacing and margin allow you to control the empty space surrounding + items in layouts. + + spacing is the amount in pixels left empty between each adjacent + item. margin is the amount in pixels which will be left empty + around the inside edge of the layout. Both default to 0. + + The below example places a GridPositioner containing a red, a blue and a + green rectangle on a gray background. The area the grid layout + occupies is colored white. The top layout has a spacing of 2 and a + margin of 5, the bottom layout has the defaults of no margin or + spacing. + + \image spacing_a.png + \image spacing_b.png + +*/ +/*! + \internal + \class QFxVerticalPositioner + \brief The QFxVerticalPositioner class lines up items vertically. + \ingroup group_layouts +*/ +QFxVerticalPositioner::QFxVerticalPositioner(QFxItem *parent) +: QFxBasePositioner(Vertical, parent) +{ +} + +void QFxVerticalPositioner::doLayout() +{ + int voffset = 0; + + foreach(QFxItem* item, *leavingItems()){ + if (remove()){ + QList > changes; + applyRemove(changes, item); + } + } + + QList children = childItems(); + for (int ii = 0; ii < children.count(); ++ii) { + QFxItem *child = qobject_cast(children.at(ii)); + if (!child || child->opacity() == 0.0) + continue; + + bool needMove = (child->y() != voffset || child->x()); + + QList > changes; + changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset)); + changes << qMakePair(QString(QLatin1String("x")),QVariant(0)); + if (needMove && items()->contains(child) && move()) { + applyMove(changes,child); + } else if (!items()->contains(child) && add()) { + applyAdd(changes,child); + } else if (needMove) { + setMovingItem(child); + child->setY(voffset); + setMovingItem(0); + } + voffset += child->height(); + voffset += spacing(); + } + finishApplyTransitions(); + setMovingItem(this); + setMovingItem(0); +} + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,HorizontalPositioner,QFxHorizontalPositioner) +/*! + \qmlclass HorizontalPositioner + \brief The HorizontalPositioner item arranges its children in a horizontal layout. + \inherits Item + + The HorizontalPositioner item arranges its child items so that they are horizontally aligned and not overlapping. Spacing can be added between the items, and a margin around all items can also be added. It also provides for transitions to be set when items are added, moved, or removed in the layout. Adding and removing apply both to items which are deleted or have their position in the document changed so as to no longer be children of the layout, as well as to items which have their opacity set to or from zero so as to appear or disappear. + + The below example lays out differently shaped rectangles using a HorizontalPositioner. + \qml +HorizontalPositioner { + spacing: 2 + Rect { color: "red"; width: 50; height: 50 } + Rect { color: "green"; width: 20; height: 50 } + Rect { color: "blue"; width: 50; height: 20 } +} + \endqml + \image horizontalLayout_example.png + +*/ +/*! + \qmlproperty Transition HorizontalPositioner::remove + This property holds the transition to apply when removing an item from the layout. + + Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the layout, or that the object has had its opacity set to zero, and thus is no longer visible. + + Note that if the item counts as removed because its opacity is zero it will not be visible during the transition unless you set the opacity in the transition, like in the below example. + + \qml +HorizontalPositioner { + id: layout + remove: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 1 + to: 0 + duration: 500 + } + } +} + \endqml + +*/ +/*! + \qmlproperty Transition HorizontalPositioner::add + This property holds the transition to apply when adding an item to the layout. + + Added can mean that either the object has been created or reparented, and thus is now a child or the layout, or that the object has had its opacity increased from zero, and thus is now visible. + + \qml +HorizontalPositioner { + id: layout + add: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 0 + to: 1 + duration: 500 + } + } +} + \endqml + +*/ +/*! + \qmlproperty Transition HorizontalPositioner::move + This property holds the transition to apply when moving an item within the layout. + + This can happen when other items are added or removed from the layout, or when items resize themselves. + + \qml +HorizontalPositioner { + id: layout + move: Transition { + NumberAnimation { + properties: "x" + ease: "easeOutBounce" + } + } +} + \endqml + +*/ +/*! + \qmlproperty Item HorizontalPositioner::item + + The item that is currently being laid out. Used to target transitions that apply + only to the item being laid out, such as in the add transition. + +*/ +/*! + \qmlproperty int HorizontalPositioner::spacing + + The spacing, in pixels, left empty between each adjacent item. +*/ +/*! + \qmlproperty int HorizontalPositioner::margin + + The margin size, in pixels, which will be left empty around the inside edge of the layout. +*/ +/*! + \qmlproperty int HorizontalPositioner::spacing + \qmlproperty int HorizontalPositioner::margin + + spacing and margin allow you to control the empty space surrounding items in layouts. + + spacing is the amount in pixels left empty between each adjacent item. + margin is the amount in pixels which will be left empty around the inside edge of the layout. + Both default to 0. + + The below example places a GridPositioner containing a red, a blue and a green rectangle on a gray background. The area the grid layout occupies is colored white. The top layout has a spacing of 2 and a margin of 5, the bottom layout has the defaults of no margin or spacing. + + \image spacing_a.png + \image spacing_b.png + +*/ +/*! + \internal + \class QFxHorizontalPositioner + \brief The QFxHorizontalPositioner class lines up items horizontally. + \ingroup group_layouts +*/ +QFxHorizontalPositioner::QFxHorizontalPositioner(QFxItem *parent) +: QFxBasePositioner(Horizontal, parent) +{ +} + +void QFxHorizontalPositioner::doLayout() +{ + int hoffset = 0; + + foreach(QFxItem* item, *leavingItems()){ + if (remove()){ + QList > changes; + applyRemove(changes, item); + } + } + QList children = childItems(); + for (int ii = 0; ii < children.count(); ++ii) { + QFxItem *child = qobject_cast(children.at(ii)); + if (!child || child->opacity() == 0.0) + continue; + + bool needMove = (child->x() != hoffset || child->y()); + + QList > changes; + changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset)); + changes << qMakePair(QString(QLatin1String("y")),QVariant(0)); + if (needMove && items()->contains(child) && move()) { + applyMove(changes,child); + } else if (!items()->contains(child) && add()) { + applyAdd(changes,child); + } else if (needMove) { + setMovingItem(child); + child->setX(hoffset); + setMovingItem(0); + } + hoffset += child->width(); + hoffset += spacing(); + } + finishApplyTransitions(); +} + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridPositioner,QFxGridPositioner) + +/*! + \qmlclass GridPositioner QFxGridPositioner + \brief The GridPositioner item arranges its children in a grid layout. + \inherits Item + + The GridPositioner item arranges its child items so that they are + aligned in a grid and are not overlapping. Spacing can be added + between the items, and a margin around all the items can also be + defined. It also provides for transitions to be set when items are + added, moved, or removed in the layout. Adding and removing apply + both to items which are deleted or have their position in the + document changed so as to no longer be children of the layout, as + well as to items which have their opacity set to or from zero so + as to appear or disappear. + + The GridPositioner defaults to using four columns, and as many rows as + are necessary to fit all the child items. The number of rows + and/or the number of columns can be constrained by setting the rows + or columns properties. The grid layout calculates a grid with + rectangular cells of sufficient size to hold all items, and then + places the items in the cells, going across then down, and + positioning each item at the (0,0) corner of the cell. The below + example demonstrates this. + + \table + \row + \o \image gridLayout_example.png + \o + \qml +GridPositioner { + columns: 3 + spacing: 2 + Rect { color: "red"; width: 50; height: 50 } + Rect { color: "green"; width: 20; height: 50 } + Rect { color: "blue"; width: 50; height: 20 } + Rect { color: "cyan"; width: 50; height: 50 } + Rect { color: "magenta"; width: 10; height: 10 } +} + \endqml + \endtable +*/ +/*! + \qmlproperty Transition GridPositioner::remove + This property holds the transition to apply when removing an item from the layout. + + Removed can mean that either the object has been deleted or + reparented, and thus is now longer a child of the layout, or that + the object has had its opacity set to zero, and thus is no longer + visible. + + Note that if the item counts as removed because its opacity is + zero it will not be visible during the transition unless you set + the opacity in the transition, like in the below example. + + \qml +GridPositioner { + id: layout + remove: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 1 + to: 0 + duration: 500 + } + } +} + \endqml + +*/ +/*! + \qmlproperty Transition GridPositioner::add + This property holds the transition to apply when adding an item to the layout. + + Added can mean that either the object has been created or + reparented, and thus is now a child or the layout, or that the + object has had its opacity increased from zero, and thus is now + visible. + + \qml +GridPositioner { + id: layout + add: Transition { + NumberAnimation { + target: layout.item + properties: "opacity" + from: 0 + to: 1 + duration: 500 + } + } +} + \endqml + +*/ +/*! + \qmlproperty Transition GridPositioner::move + This property holds the transition to apply when moving an item within the layout. + + This can happen when other items are added or removed from the layout, or + when items resize themselves. + + \qml +GridPositioner { + id: layout + move: Transition { + NumberAnimation { + properties: "x,y" + ease: "easeOutBounce" + } + } +} + \endqml + +*/ +/*! + \qmlproperty Item GridPositioner::item + + The item that is currently being laid out. Used to target + transitions that apply only to the item being laid out, such as in + the add transition. + +*/ +/*! + \qmlproperty int GridPositioner::spacing + \qmlproperty int GridPositioner::margin + + spacing and margin allow you to control the empty space surrounding + items in layouts. + + spacing is the amount in pixels left empty between each adjacent + item. margin is the amount in pixels which will be left empty + around the inside edge of the layout. Both default to 0. + + The below example places a GridPositioner containing a red, a blue and a + green rectangle on a gray background. The area the grid layout + occupies is colored white. The top layout has a spacing of 2 and a + margin of 5, the bottom layout has the defaults of no margin or + spacing. + + \image spacing_a.png + \image spacing_b.png + +*/ +/*! + \internal + \class QFxGridPositioner + \brief The QFxGridPositioner class lays out items in a grid. + \ingroup group_layouts + +*/ +QFxGridPositioner::QFxGridPositioner(QFxItem *parent) : + QFxBasePositioner(Both, parent) +{ + _columns=-1; + _rows=-1; +} + +/*! + \qmlproperty int GridPositioner::columns + This property holds the number of columns in the grid. + + When the columns property is set the GridPositioner will always have + that many columns. Note that if you do not have enough items to + fill this many columns some columns will be of zero width. +*/ + +/*! + \qmlproperty int GridPositioner::rows + This property holds the number of rows in the grid. + + When the rows property is set the GridPositioner will always have that + many rows. Note that if you do not have enough items to fill this + many rows some rows will be of zero width. +*/ + +/*! + \property QFxGridPositioner::columns + \brief the number of columns in the grid. +*/ + +/*! + \property QFxGridPositioner::rows + \brief the number of rows in the grid. +*/ + +void QFxGridPositioner::doLayout() +{ + int c=_columns,r=_rows;//Actual number of rows/columns + int numVisible = items()->size() + newItems()->size(); + if (_columns==-1 && _rows==-1){ + c = 4; + r = (numVisible+2)/3; + }else if (_rows==-1){ + r = (numVisible+(_columns-1))/_columns; + }else if (_columns==-1){ + c = (numVisible+(_rows-1))/_rows; + } + + QList maxColWidth; + QList maxRowHeight; + int childIndex =0; + QList children = childItems(); + for (int i=0; i(children.at(childIndex++)); + if (!child || child->opacity() == 0.0) + continue; + if (child->width() > maxColWidth[j]) + maxColWidth[j] = child->width(); + if (child->height() > maxRowHeight[i]) + maxRowHeight[i] = child->height(); + } + } + + int xoffset=0; + int yoffset=0; + int curRow =0; + int curCol =0; + foreach(QFxItem* item, *leavingItems()){ + if (remove()){ + QList > changes; + applyRemove(changes, item); + } + } + foreach(QGraphicsItem* schild, children){ + QFxItem *child = qobject_cast(schild); + if (!child || child->opacity() == 0.0) + continue; + bool needMove = (child->x()!=xoffset)||(child->y()!=yoffset); + QList > changes; + changes << qMakePair(QString(QLatin1String("x")),QVariant(xoffset)); + changes << qMakePair(QString(QLatin1String("y")),QVariant(yoffset)); + if (newItems()->contains(child) && add()) { + applyAdd(changes,child); + } else if (needMove) { + if (move()){ + applyMove(changes,child); + }else{ + setMovingItem(child); + child->setPos(QPointF(xoffset, yoffset)); + setMovingItem(0); + } + } + xoffset+=maxColWidth[curCol]+spacing(); + curCol++; + curCol%=c; + if (!curCol){ + yoffset+=maxRowHeight[curRow]+spacing(); + xoffset=0; + curRow++; + if (curRow>=r) + return; + } + } + finishApplyTransitions(); +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpositioners.h b/src/declarative/fx/qfxpositioners.h new file mode 100644 index 0000000..6acb393 --- /dev/null +++ b/src/declarative/fx/qfxpositioners.h @@ -0,0 +1,174 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXLAYOUTS_H +#define QFXLAYOUTS_H + +#include +#include +#include +#include + + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class QFxBasePositionerPrivate; + +class Q_DECLARATIVE_EXPORT QFxBasePositioner : public QFxItem +{ + Q_OBJECT + + Q_PROPERTY(int spacing READ spacing WRITE setSpacing) + Q_PROPERTY(int margin READ margin WRITE setMargin) + Q_PROPERTY(QmlTransition *move READ move WRITE setMove) + Q_PROPERTY(QmlTransition *add READ add WRITE setAdd) + Q_PROPERTY(QmlTransition *remove READ remove WRITE setRemove) + Q_PROPERTY(QFxItem *item READ layoutItem NOTIFY layoutItemChanged) +public: + enum AutoUpdateType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; + QFxBasePositioner(AutoUpdateType, QFxItem *parent); + + int spacing() const; + void setSpacing(int); + + int margin() const; + void setMargin(int); + + QmlTransition *move() const; + void setMove(QmlTransition *); + + QmlTransition *add() const; + void setAdd(QmlTransition *); + + QmlTransition *remove() const; + void setRemove(QmlTransition *); + + QFxItem *layoutItem() const; + +protected: + virtual void componentComplete(); + virtual QVariant itemChange(GraphicsItemChange, const QVariant &); + virtual bool event(QEvent *); + QSet* newItems(); + QSet* leavingItems(); + QSet* items(); + void applyAdd(const QList >& changes, QFxItem* target); + void applyMove(const QList >& changes, QFxItem* target); + void applyRemove(const QList >& changes, QFxItem* target); + void finishApplyTransitions(); + +Q_SIGNALS: + void layoutItemChanged(); + +protected Q_SLOTS: + virtual void doLayout()=0; + void setLayoutItem(QFxItem *); + +private Q_SLOTS: + void preLayout(); + +protected: + QFxBasePositioner(QFxBasePositionerPrivate &dd, AutoUpdateType at, QFxItem *parent); + void setMovingItem(QFxItem *); + +private: + void applyTransition(const QList >& changes, QFxItem* target, + QmlStateOperation::ActionList &actions); + Q_DISABLE_COPY(QFxBasePositioner) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxBasePositioner) +}; + +class Q_DECLARATIVE_EXPORT QFxVerticalPositioner : public QFxBasePositioner +{ + Q_OBJECT +public: + QFxVerticalPositioner(QFxItem *parent=0); +protected Q_SLOTS: + virtual void doLayout(); +private: + Q_DISABLE_COPY(QFxVerticalPositioner) +}; + +class Q_DECLARATIVE_EXPORT QFxHorizontalPositioner: public QFxBasePositioner +{ + Q_OBJECT +public: + QFxHorizontalPositioner(QFxItem *parent=0); +protected Q_SLOTS: + virtual void doLayout(); +private: + Q_DISABLE_COPY(QFxHorizontalPositioner) +}; + +class Q_DECLARATIVE_EXPORT QFxGridPositioner : public QFxBasePositioner +{ + Q_OBJECT + Q_PROPERTY(int rows READ rows WRITE setRows) + Q_PROPERTY(int columns READ columns WRITE setcolumns) +public: + QFxGridPositioner(QFxItem *parent=0); + + int rows() const {return _rows;} + void setRows(const int rows){_rows = rows;} + + int columns() const {return _columns;} + void setcolumns(const int columns){_columns = columns;} +protected Q_SLOTS: + virtual void doLayout(); + +private: + int _rows; + int _columns; + Q_DISABLE_COPY(QFxGridPositioner) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxVerticalPositioner) +QML_DECLARE_TYPE(QFxHorizontalPositioner) +QML_DECLARE_TYPE(QFxGridPositioner) + +QT_END_HEADER + +#endif diff --git a/src/declarative/fx/qfxpositioners_p.h b/src/declarative/fx/qfxpositioners_p.h new file mode 100644 index 0000000..53f5dcd --- /dev/null +++ b/src/declarative/fx/qfxpositioners_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXLAYOUTS_P_H +#define QFXLAYOUTS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QFxBasePositionerPrivate : public QFxItemPrivate +{ + Q_DECLARE_PUBLIC(QFxBasePositioner) + +public: + QFxBasePositionerPrivate() + : _ep(false), _componentComplete(false), _spacing(0), + _margin(0), aut(QFxBasePositioner::None), moveTransition(0), addTransition(0), + removeTransition(0), _layoutItem(0), _movingItem(0) + { + } + + void init(QFxBasePositioner::AutoUpdateType at) + { + aut = at; + } + + bool _ep; + bool _componentComplete; + int _spacing; + int _margin; + QFxBasePositioner::AutoUpdateType aut; + QmlTransition *moveTransition; + QmlTransition *addTransition; + QmlTransition *removeTransition; + QSet _items; + QSet _leavingItems; + QSet _stableItems; + QSet _newItems; + QSet _animated; + QFxItem *_layoutItem; + QmlStateOperation::ActionList addActions; + QmlStateOperation::ActionList moveActions; + QmlStateOperation::ActionList removeActions; + QmlTransitionManager addTransitionManager; + QmlTransitionManager moveTransitionManager; + QmlTransitionManager removeTransitionManager; +// QmlStateGroup *stateGroup; + QFxItem *_movingItem; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index c3872c4..0315a75 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -229,7 +229,7 @@ QColor QFxText::color() const Supported text styles are \c Normal, \c Outline, \c Raised and \c Sunken. \qml - HorizontalLayout { + HorizontalPositioner { Text { font.size: 24; text: "Normal" } Text { font.size: 24; text: "Raised"; style: "Raised"; styleColor: "#AAAAAA" } Text { font.size: 24; text: "Outline"; style: "Outline"; styleColor: "red" } @@ -386,7 +386,7 @@ void QFxText::setWrap(bool w) \row \o \qml -VerticalLayout { +VerticalPositioner { TextEdit { font.size: 24 text: "Hello World!" diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index fcc9e69..3013ac2 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -179,7 +179,7 @@ void QFxTextEdit::setText(const QString &text) \row \o \qml -VerticalLayout { +VerticalPositioner { TextEdit { font.size: 24 text: "Hello World!" diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index f768827..90f639e 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -59,7 +59,7 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QFxItem::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QFxImage::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete, " QFxComponentInstance::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QFxBaseLayout::componentComplete") + Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QFxBasePositioner::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QFxText::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText") Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine") diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 718040e..e2575ab 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -153,7 +153,7 @@ struct ListModelData width: 200; height: 50 Text { id: Name; text: name } Text { text: '$'+cost; anchors.right: parent.right } - HorizontalLayout { + HorizontalPositioner { anchors.top: Name.bottom spacing: 5 Text { text: "Attributes:" } -- cgit v0.12 From f73493f1ac5a8c1a5e739d7645135a8edfb60261 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Aug 2009 15:13:39 +1000 Subject: Missed converting demos when renaming layout->positioner --- demos/declarative/calculator/calculator.qml | 10 +++++----- demos/declarative/contacts/Contact.qml | 2 +- demos/declarative/flickr/content/LikeOMeter.qml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index a4e16e4..42e1422 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -7,7 +7,7 @@ Rect { Palette { id: Palette } Script { source: "calculator.js" } - VerticalLayout { + VerticalPositioner { x: 2; spacing: 10; margin: 2 Rect { @@ -56,7 +56,7 @@ Rect { CalcButton { operation: "C"; id: C; width: 76 } CalcButton { operation: "AC"; id: AC; x: 78; width: 76 } - GridLayout { + GridPositioner { id: NumKeypad; y: 32; spacing: 2; columns: 3 CalcButton { operation: "7" } @@ -70,7 +70,7 @@ Rect { CalcButton { operation: "3" } } - HorizontalLayout { + HorizontalPositioner { y: 128; spacing: 2 CalcButton { operation: "0"; width: 50 } @@ -78,7 +78,7 @@ Rect { CalcButton { operation: "="; id: Equals; x: 77; width: 102 } } - VerticalLayout { + VerticalPositioner { id: SimpleOperations x: 156; y: 0; spacing: 2 @@ -89,7 +89,7 @@ Rect { } } - GridLayout { + GridPositioner { id: AdvancedButtons x: 350; spacing: 2; columns: 2; opacity: 0 diff --git a/demos/declarative/contacts/Contact.qml b/demos/declarative/contacts/Contact.qml index 77189e9..c6ed906 100644 --- a/demos/declarative/contacts/Contact.qml +++ b/demos/declarative/contacts/Contact.qml @@ -80,7 +80,7 @@ Item { function remove() { removeContactQuery.exec(); } - VerticalLayout { + VerticalPositioner { id: layout anchors.fill: parent spacing: 5 diff --git a/demos/declarative/flickr/content/LikeOMeter.qml b/demos/declarative/flickr/content/LikeOMeter.qml index 88a28b6..0ba79b1 100644 --- a/demos/declarative/flickr/content/LikeOMeter.qml +++ b/demos/declarative/flickr/content/LikeOMeter.qml @@ -5,7 +5,7 @@ Item { property int rating: 2 - HorizontalLayout { + HorizontalPositioner { Star { rating: 0 onClicked: { Container.rating = rating } -- cgit v0.12