From ab4920a8fd23613da010d45e4f7be1bdc40d7c9a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Aug 2009 18:10:16 +1000 Subject: Cleanup and example for positioners Interim progress on fixing up the positioners. - Removes margins and setting and implicit size - Purges the word 'layout' from the source files - Fixes a bug with the grid positioner, it works now - Cleaned up the code somewhat. Also adds some basic examples which demonstrate that it (mostly) works. Be warned that practically all the comments are woefully out of date. --- examples/declarative/layouts/Button.qml | 20 ++ examples/declarative/layouts/add.png | Bin 0 -> 1577 bytes examples/declarative/layouts/del.png | Bin 0 -> 1661 bytes examples/declarative/layouts/layouts.qml | 25 +++ examples/declarative/layouts/positioners.qml | 51 +++++ src/declarative/fx/qfxpositioners.cpp | 317 ++++++++++----------------- src/declarative/fx/qfxpositioners.h | 18 +- src/declarative/fx/qfxpositioners_p.h | 6 +- 8 files changed, 217 insertions(+), 220 deletions(-) create mode 100644 examples/declarative/layouts/Button.qml create mode 100644 examples/declarative/layouts/add.png create mode 100644 examples/declarative/layouts/del.png create mode 100644 examples/declarative/layouts/layouts.qml create mode 100644 examples/declarative/layouts/positioners.qml diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml new file mode 100644 index 0000000..de11dc9 --- /dev/null +++ b/examples/declarative/layouts/Button.qml @@ -0,0 +1,20 @@ +import Qt 4.6 +Rect { border.color: "black"; color: "steelblue"; radius: 5; width: pix.width + text.width + 13; height: pix.height + 10; id: page + property string text + property string icon + signal clicked + Image { id: pix; x: 5; y:5; source: parent.icon} + Text { id: text; text: page.text; color: "white"; x:pix.width+pix.x+3; anchors.verticalCenter: pix.verticalCenter;} + MouseRegion{ id:mr; anchors.fill: parent; onClicked: {parent.focus = true; page.clicked()}} + + states: + State{ name:"pressed"; when:mr.pressed + SetProperties {target:text; x: 5} + SetProperties {target:pix; x:text.x+text.width + 3} + } + + transitions: + Transition{ + NumberAnimation{ properties:"x,left"; easing:"easeInOutQuad"; duration:200 } + } +} diff --git a/examples/declarative/layouts/add.png b/examples/declarative/layouts/add.png new file mode 100644 index 0000000..f29d84b Binary files /dev/null and b/examples/declarative/layouts/add.png differ diff --git a/examples/declarative/layouts/del.png b/examples/declarative/layouts/del.png new file mode 100644 index 0000000..1d753a3 Binary files /dev/null and b/examples/declarative/layouts/del.png differ diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml new file mode 100644 index 0000000..d049e0a --- /dev/null +++ b/examples/declarative/layouts/layouts.qml @@ -0,0 +1,25 @@ +import Qt 4.6 + +QGraphicsView{ +QGraphicsScene{ +QGraphicsWidget{ + visible: true + opacity: 1 + geometry: "0,0,400x400" + layout: QGraphicsLinearLayout{ + LayoutItem{ + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rect { color: "yellow"; anchors.fill: parent } + } + LayoutItem{ + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rect { color: "green"; anchors.fill: parent } + } + } +} +} +} diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml new file mode 100644 index 0000000..44f9509 --- /dev/null +++ b/examples/declarative/layouts/positioners.qml @@ -0,0 +1,51 @@ +import Qt 4.6 +Rect { width: 420; height: 420; id:page; color:"white" + VerticalPositioner { id: layout1; y:0; //width: 100; height:250; + move: Transition{ NumberAnimation {properties: "y"; easing: "easeOutBounce" }} + add: Transition{ NumberAnimation { properties: "y"; from: 500; duration:500; easing: "easeOutQuad"}} + remove: Transition { NumberAnimation { properties:"y"; to: 500; duration:500; easing: "easeInQuad"}} + Rect { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + Rect { id: blueV1; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15 + //opacity: Behavior{ NumberAnimation {}} + } + Rect { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + Rect { id: blueV2; color: "lightsteelblue"; width: 100; height: 50; border.color: "black"; radius: 15 + //opacity: Behavior{ NumberAnimation {}} + } + Rect { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + HorizontalPositioner { id: layout2; y:300; + move: Transition{ NumberAnimation {properties: "x"; easing: "easeOutBounce" }} + add: Transition{ NumberAnimation { properties: "x"; from: 500; duration:500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; from: 0; duration: 500;}} + remove: Transition { NumberAnimation { properties: "x"; to: 500; duration:500; easing: "easeInQuad"} + NumberAnimation { properties: "opacity"; from: 1; duration: 500}} + Rect { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { id: blueH1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { id: blueH2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + Button { text: "Remove"; icon: "del.png"; x: 135; y:90; + onClicked: {blueH2.opacity=0; blueH1.opacity=0; blueV1.opacity=0; blueV2.opacity=0; blueG1.opacity=0; blueG2.opacity=0; blueG3.opacity=0;} + } + Button { text: "Add"; icon: "add.png"; x: 145; y:140; + onClicked: {blueH2.opacity=1; blueH1.opacity=1; blueV1.opacity=1; blueV2.opacity=1; blueG1.opacity=1; blueG2.opacity=1; blueG3.opacity=1;} + } + GridPositioner { x:260; y:0; columns:3 + remove: Transition { NumberAnimation{ properties: "opacity"; from: 1; to: 0; duration: 500} + NumberAnimation{properties: "x,y"; easing: "easeOutBounce"} } + move: Transition { NumberAnimation{ properties: "x,y"; easing: "easeOutBounce" }} + add: Transition { NumberAnimation{ properties: "opacity"; from: 0; to: 1; duration: 500} + NumberAnimation{properties: "x,y"; easing: "easeOutBounce"} } + Rect { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { id: blueG1; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { id: blueG2; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { id: blueG3; color: "lightsteelblue"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + Rect { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } +} diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp index 270524d..c1e175b 100644 --- a/src/declarative/fx/qfxpositioners.cpp +++ b/src/declarative/fx/qfxpositioners.cpp @@ -55,17 +55,24 @@ QT_BEGIN_NAMESPACE /*! \internal \class QFxBasePositioner - \brief The QFxBasePositioner class provides a base for QFx layouts. + \brief The QFxBasePositioner class provides a base for Fx Positioners. - To create a QFx Layout, simple subclass QFxBasePositioner and implement - doLayout(), which is automatically called when the layout might need + Fx positioners are fluid UI positioners, which only position items and do not + resize them. In fluid UIs you can bind width and height to relative + expressions and/or use anchors to get dynamic sizing of items. + + To create an Fx positioner, simply subclass QFxBasePositioner and implement + doPositioning(), which is automatically called when the positioner might need updating. - It is strongly recommended that in your implementation of doLayout() + It is strongly recommended that in your implementation of doPositioning() that you use the move, remove and add transitions when those conditions - arise. + arise (if a transition is set). Use them through the functions applyAdd, + applyMove and applyRemove. - \ingroup group_layouts + TODO: Update every other doc comment in this file. + + \ingroup group_positioners */ QFxBasePositioner::QFxBasePositioner(AutoUpdateType at, QFxItem *parent) : QFxItem(*(new QFxBasePositionerPrivate), parent) @@ -99,37 +106,16 @@ void QFxBasePositioner::setSpacing(int s) 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(); + prePositioning(); } - /*! \property QFxBasePositioner::move \brief the transition when moving an item. \qml -BaseLayout { - id: layout +Basepositioner { + id: positioner y: 0 move: Transition { NumberAnimation { @@ -157,12 +143,12 @@ void QFxBasePositioner::setMove(QmlTransition *mt) \brief the transition when adding an item. \qml -BaseLayout { - id: layout +Basepositioner { + id: positioner y: 0 add: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 0 to: 1 @@ -192,12 +178,12 @@ void QFxBasePositioner::setAdd(QmlTransition *add) Note that the item may be 'removed' because its opacity is zero. This can make certain transitions difficult to see. \qml -BaseLayout { - id: layout +Basepositioner { + id: positioner y: 0 remove: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 1 to: 0 @@ -219,38 +205,13 @@ void QFxBasePositioner::setRemove(QmlTransition *remove) 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; + QFxPerfTimer cc; #endif - preLayout(); + prePositioning(); } QVariant QFxBasePositioner::itemChange(GraphicsItemChange change, @@ -258,7 +219,7 @@ QVariant QFxBasePositioner::itemChange(GraphicsItemChange change, { if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { - preLayout(); + prePositioning(); } return QFxItem::itemChange(change, value); @@ -278,7 +239,7 @@ bool QFxBasePositioner::event(QEvent *e) } /*! - Items that have just been added to the layout. This includes invisible items + Items that have just been added to the positioner. This includes invisible items that have turned visible. */ QSet* QFxBasePositioner::newItems() @@ -288,7 +249,7 @@ QSet* QFxBasePositioner::newItems() } /*! - Items that are visible in the layout, not including ones that have just been added. + Items that are visible in the positioner, not including ones that have just been added. */ QSet* QFxBasePositioner::items() { @@ -297,7 +258,7 @@ QSet* QFxBasePositioner::items() } /*! - Items that have just left the layout. This includes visible items + Items that have just left the positioner. This includes visible items that have turned invisible. */ QSet* QFxBasePositioner::leavingItems() @@ -306,7 +267,7 @@ QSet* QFxBasePositioner::leavingItems() return &d->_leavingItems; } -void QFxBasePositioner::preLayout() +void QFxBasePositioner::prePositioning() { Q_D(QFxBasePositioner); if (!isComponentComplete() || d->_movingItem) @@ -324,13 +285,13 @@ void QFxBasePositioner::preLayout() continue; if (!d->_items.contains(child)){ QObject::connect(child, SIGNAL(visibleChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); QObject::connect(child, SIGNAL(opacityChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); QObject::connect(child, SIGNAL(heightChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); QObject::connect(child, SIGNAL(widthChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); d->_items += child; } if (child->opacity() == 0.0){ @@ -348,59 +309,18 @@ void QFxBasePositioner::preLayout() if (!allItems.contains(child)){ if (!deletedItems.contains(child)) { QObject::disconnect(child, SIGNAL(opacityChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); QObject::disconnect(child, SIGNAL(heightChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); QObject::disconnect(child, SIGNAL(widthChanged()), - this, SLOT(preLayout())); + this, SLOT(prePositioning())); } 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); + doPositioning(); + finishApplyTransitions(); } void QFxBasePositioner::applyTransition(const QList >& changes, QFxItem* target, QmlStateOperation::ActionList &actions) @@ -408,17 +328,10 @@ void QFxBasePositioner::applyTransition(const QList >& 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); } @@ -429,6 +342,9 @@ void QFxBasePositioner::applyTransition(const QList >& void QFxBasePositioner::finishApplyTransitions() { Q_D(QFxBasePositioner); + // Note that if a transition is not set the transition manager will + // apply the changes directly, in the case someone uses applyAdd/Move/Remove + // without testing add()/move()/remove(). d->addTransitionManager.transition(d->addActions, d->addTransition); d->moveTransitionManager.transition(d->moveActions, d->moveTransition); d->removeTransitionManager.transition(d->removeActions, d->removeTransition); @@ -443,7 +359,7 @@ void QFxBasePositioner::setMovingItem(QFxItem *i) } /*! - Applies the layout's add transition to the \a target item.\a changes is a list of property,value + Applies the positioner'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) @@ -453,7 +369,7 @@ void QFxBasePositioner::applyAdd(const QList >& changes } /*! - Applies the layout's move transition to the \a target.\a changes is a list of property,value pairs + Applies the positioner'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) @@ -463,7 +379,7 @@ void QFxBasePositioner::applyMove(const QList >& change } /*! - Applies the layout's remove transition to the \a target item.\a changes is a list of + Applies the positioner'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) @@ -475,16 +391,16 @@ void QFxBasePositioner::applyRemove(const QList >& chan 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. + \brief The VerticalPositioner item arranges its children in a vertical positioner. \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. + aligned and not overlapping. Spacing between items can be added. The below example lays out differently shaped rectangles using a VerticalPositioner. \table \row - \o \image verticalLayout_example.png + \o \image verticalpositioner_example.png \o \qml VerticalPositioner { @@ -497,13 +413,13 @@ VerticalPositioner { \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, + or removed in the positioner. 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 positioner, 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 \image verticalpositioner_transition.gif \o \qml VerticalPositioner { @@ -520,22 +436,22 @@ VerticalPositioner { */ /*! \qmlproperty Transition VerticalPositioner::remove - This property holds the transition to apply when removing an item from the layout. + This property holds the transition to apply when removing an item from the positioner. - 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. + Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, 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 \image positioner-remove.gif \o \qml VerticalPositioner { - id: layout + id: positioner remove: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 1 to: 0 @@ -549,20 +465,20 @@ VerticalPositioner { */ /*! \qmlproperty Transition VerticalPositioner::add - This property holds the transition to be applied when adding an item to the layout. + This property holds the transition to be applied when adding an item to the positioner. - 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. + Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible. \table \row - \o \image layout-add.gif + \o \image positioner-add.gif \o \qml VerticalPositioner { - id: layout + id: positioner add: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 0 to: 1 @@ -576,17 +492,17 @@ VerticalPositioner { */ /*! \qmlproperty Transition VerticalPositioner::move - This property holds the transition to apply when moving an item within the layout. + This property holds the transition to apply when moving an item within the positioner. - This can happen when other items are added or removed from the layout, or when items resize themselves. + This can happen when other items are added or removed from the positioner, or when items resize themselves. \table \row - \o \image layout-move.gif + \o \image positioner-move.gif \o \qml VerticalPositioner { - id: layout + id: positioner move: Transition { NumberAnimation { properties: "y" @@ -609,16 +525,16 @@ VerticalPositioner { \qmlproperty int VerticalPositioner::margin spacing and margin allow you to control the empty space surrounding - items in layouts. + items in positioners. 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. + around the inside edge of the positioner. 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 + green rectangle on a gray background. The area the grid positioner + occupies is colored white. The top positioner has a spacing of 2 and a + margin of 5, the bottom positioner has the defaults of no margin or spacing. \image spacing_a.png @@ -629,14 +545,14 @@ VerticalPositioner { \internal \class QFxVerticalPositioner \brief The QFxVerticalPositioner class lines up items vertically. - \ingroup group_layouts + \ingroup group_positioners */ QFxVerticalPositioner::QFxVerticalPositioner(QFxItem *parent) : QFxBasePositioner(Vertical, parent) { } -void QFxVerticalPositioner::doLayout() +void QFxVerticalPositioner::doPositioning() { int voffset = 0; @@ -670,18 +586,15 @@ void QFxVerticalPositioner::doLayout() 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. + \brief The HorizontalPositioner item arranges its children in a horizontal positioner. \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 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 positioner. 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 positioner, 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 @@ -692,23 +605,23 @@ HorizontalPositioner { Rect { color: "blue"; width: 50; height: 20 } } \endqml - \image horizontalLayout_example.png + \image horizontalpositioner_example.png */ /*! \qmlproperty Transition HorizontalPositioner::remove - This property holds the transition to apply when removing an item from the layout. + This property holds the transition to apply when removing an item from the positioner. - 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. + Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, 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 + id: positioner remove: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 1 to: 0 @@ -721,16 +634,16 @@ HorizontalPositioner { */ /*! \qmlproperty Transition HorizontalPositioner::add - This property holds the transition to apply when adding an item to the layout. + This property holds the transition to apply when adding an item to the positioner. - 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. + Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible. \qml HorizontalPositioner { - id: layout + id: positioner add: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 0 to: 1 @@ -743,13 +656,13 @@ HorizontalPositioner { */ /*! \qmlproperty Transition HorizontalPositioner::move - This property holds the transition to apply when moving an item within the layout. + This property holds the transition to apply when moving an item within the positioner. - This can happen when other items are added or removed from the layout, or when items resize themselves. + This can happen when other items are added or removed from the positioner, or when items resize themselves. \qml HorizontalPositioner { - id: layout + id: positioner move: Transition { NumberAnimation { properties: "x" @@ -775,19 +688,19 @@ HorizontalPositioner { /*! \qmlproperty int HorizontalPositioner::margin - The margin size, in pixels, which will be left empty around the inside edge of the layout. + The margin size, in pixels, which will be left empty around the inside edge of the positioner. */ /*! \qmlproperty int HorizontalPositioner::spacing \qmlproperty int HorizontalPositioner::margin - spacing and margin allow you to control the empty space surrounding items in layouts. + spacing and margin allow you to control the empty space surrounding items in positioners. 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. + margin is the amount in pixels which will be left empty around the inside edge of the positioner. 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. + The below example places a GridPositioner containing a red, a blue and a green rectangle on a gray background. The area the grid positioner occupies is colored white. The top positioner has a spacing of 2 and a margin of 5, the bottom positioner has the defaults of no margin or spacing. \image spacing_a.png \image spacing_b.png @@ -797,14 +710,14 @@ HorizontalPositioner { \internal \class QFxHorizontalPositioner \brief The QFxHorizontalPositioner class lines up items horizontally. - \ingroup group_layouts + \ingroup group_positioners */ QFxHorizontalPositioner::QFxHorizontalPositioner(QFxItem *parent) : QFxBasePositioner(Horizontal, parent) { } -void QFxHorizontalPositioner::doLayout() +void QFxHorizontalPositioner::doPositioning() { int hoffset = 0; @@ -837,30 +750,29 @@ void QFxHorizontalPositioner::doLayout() 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. + \brief The GridPositioner item arranges its children in a grid positioner. \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 + added, moved, or removed in the positioner. 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 + document changed so as to no longer be children of the positioner, 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 + or columns properties. The grid positioner 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 @@ -868,7 +780,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridPositioner,QFxGridPositioner \table \row - \o \image gridLayout_example.png + \o \image gridlayout_example.png \o \qml GridPositioner { @@ -885,10 +797,10 @@ GridPositioner { */ /*! \qmlproperty Transition GridPositioner::remove - This property holds the transition to apply when removing an item from the layout. + This property holds the transition to apply when removing an item from the positioner. Removed can mean that either the object has been deleted or - reparented, and thus is now longer a child of the layout, or that + reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible. @@ -898,10 +810,10 @@ GridPositioner { \qml GridPositioner { - id: layout + id: positioner remove: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 1 to: 0 @@ -914,19 +826,19 @@ GridPositioner { */ /*! \qmlproperty Transition GridPositioner::add - This property holds the transition to apply when adding an item to the layout. + This property holds the transition to apply when adding an item to the positioner. Added can mean that either the object has been created or - reparented, and thus is now a child or the layout, or that the + reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible. \qml GridPositioner { - id: layout + id: positioner add: Transition { NumberAnimation { - target: layout.item + target: positioner.item properties: "opacity" from: 0 to: 1 @@ -939,14 +851,14 @@ GridPositioner { */ /*! \qmlproperty Transition GridPositioner::move - This property holds the transition to apply when moving an item within the layout. + This property holds the transition to apply when moving an item within the positioner. - This can happen when other items are added or removed from the layout, or + This can happen when other items are added or removed from the positioner, or when items resize themselves. \qml GridPositioner { - id: layout + id: positioner move: Transition { NumberAnimation { properties: "x,y" @@ -970,16 +882,16 @@ GridPositioner { \qmlproperty int GridPositioner::margin spacing and margin allow you to control the empty space surrounding - items in layouts. + items in positioners. 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. + around the inside edge of the positioner. 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 + green rectangle on a gray background. The area the grid positioner + occupies is colored white. The top positioner has a spacing of 2 and a + margin of 5, the bottom positioner has the defaults of no margin or spacing. \image spacing_a.png @@ -1028,7 +940,7 @@ QFxGridPositioner::QFxGridPositioner(QFxItem *parent) : \brief the number of rows in the grid. */ -void QFxGridPositioner::doLayout() +void QFxGridPositioner::doPositioning() { int c=_columns,r=_rows;//Actual number of rows/columns int numVisible = items()->size() + newItems()->size(); @@ -1101,10 +1013,9 @@ void QFxGridPositioner::doLayout() xoffset=0; curRow++; if (curRow>=r) - return; + break; } } - finishApplyTransitions(); } QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpositioners.h b/src/declarative/fx/qfxpositioners.h index 6acb393..9560925 100644 --- a/src/declarative/fx/qfxpositioners.h +++ b/src/declarative/fx/qfxpositioners.h @@ -60,11 +60,9 @@ 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); @@ -72,9 +70,6 @@ public: int spacing() const; void setSpacing(int); - int margin() const; - void setMargin(int); - QmlTransition *move() const; void setMove(QmlTransition *); @@ -84,8 +79,6 @@ public: QmlTransition *remove() const; void setRemove(QmlTransition *); - QFxItem *layoutItem() const; - protected: virtual void componentComplete(); virtual QVariant itemChange(GraphicsItemChange, const QVariant &); @@ -102,11 +95,10 @@ Q_SIGNALS: void layoutItemChanged(); protected Q_SLOTS: - virtual void doLayout()=0; - void setLayoutItem(QFxItem *); + virtual void doPositioning()=0; private Q_SLOTS: - void preLayout(); + void prePositioning(); protected: QFxBasePositioner(QFxBasePositionerPrivate &dd, AutoUpdateType at, QFxItem *parent); @@ -125,7 +117,7 @@ class Q_DECLARATIVE_EXPORT QFxVerticalPositioner : public QFxBasePositioner public: QFxVerticalPositioner(QFxItem *parent=0); protected Q_SLOTS: - virtual void doLayout(); + virtual void doPositioning(); private: Q_DISABLE_COPY(QFxVerticalPositioner) }; @@ -136,7 +128,7 @@ class Q_DECLARATIVE_EXPORT QFxHorizontalPositioner: public QFxBasePositioner public: QFxHorizontalPositioner(QFxItem *parent=0); protected Q_SLOTS: - virtual void doLayout(); + virtual void doPositioning(); private: Q_DISABLE_COPY(QFxHorizontalPositioner) }; @@ -155,7 +147,7 @@ public: int columns() const {return _columns;} void setcolumns(const int columns){_columns = columns;} protected Q_SLOTS: - virtual void doLayout(); + virtual void doPositioning(); private: int _rows; diff --git a/src/declarative/fx/qfxpositioners_p.h b/src/declarative/fx/qfxpositioners_p.h index 53f5dcd..8960952 100644 --- a/src/declarative/fx/qfxpositioners_p.h +++ b/src/declarative/fx/qfxpositioners_p.h @@ -69,8 +69,8 @@ class QFxBasePositionerPrivate : public QFxItemPrivate public: QFxBasePositionerPrivate() : _ep(false), _componentComplete(false), _spacing(0), - _margin(0), aut(QFxBasePositioner::None), moveTransition(0), addTransition(0), - removeTransition(0), _layoutItem(0), _movingItem(0) + aut(QFxBasePositioner::None), moveTransition(0), addTransition(0), + removeTransition(0), _movingItem(0) { } @@ -82,7 +82,6 @@ public: bool _ep; bool _componentComplete; int _spacing; - int _margin; QFxBasePositioner::AutoUpdateType aut; QmlTransition *moveTransition; QmlTransition *addTransition; @@ -92,7 +91,6 @@ public: QSet _stableItems; QSet _newItems; QSet _animated; - QFxItem *_layoutItem; QmlStateOperation::ActionList addActions; QmlStateOperation::ActionList moveActions; QmlStateOperation::ActionList removeActions; -- cgit v0.12 From 0a6386075faee6c1438b3ca871c0658269ff6afd Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 18 Aug 2009 15:34:56 +1000 Subject: More doc cleanup Positioners now don't refer to 'laying out' nor to the removed properties, like margins. --- doc/src/declarative/pics/spacing_a.png | Bin 495 -> 547 bytes doc/src/declarative/pics/spacing_b.png | Bin 462 -> 560 bytes src/declarative/fx/qfxpositioners.cpp | 111 +++++++++------------------------ 3 files changed, 31 insertions(+), 80 deletions(-) diff --git a/doc/src/declarative/pics/spacing_a.png b/doc/src/declarative/pics/spacing_a.png index ff07e2e..c0fe895 100644 Binary files a/doc/src/declarative/pics/spacing_a.png and b/doc/src/declarative/pics/spacing_a.png differ diff --git a/doc/src/declarative/pics/spacing_b.png b/doc/src/declarative/pics/spacing_b.png index 94304ee..24cf640 100644 Binary files a/doc/src/declarative/pics/spacing_b.png and b/doc/src/declarative/pics/spacing_b.png differ diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp index 15e70de..a164f67 100644 --- a/src/declarative/fx/qfxpositioners.cpp +++ b/src/declarative/fx/qfxpositioners.cpp @@ -311,10 +311,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,VerticalPositioner,QFxVerticalPo \brief The VerticalPositioner item lines up its children vertically. \inherits Item - The VerticalPositioner item arranges its child items so that they are vertically + The VerticalPositioner item positions its child items so that they are vertically aligned and not overlapping. Spacing between items can be added. - The below example lays out differently shaped rectangles using a VerticalPositioner. + The below example positions differently shaped rectangles using a VerticalPositioner. \table \row \o \image verticalpositioner_example.png @@ -353,7 +353,7 @@ VerticalPositioner { */ /*! \qmlproperty Transition VerticalPositioner::remove - This property holds the transition to apply when removing an item from the positioner. + This property holds the transition to apply when removing an item from the positioner. The transition is only applied to the removed items. Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible. @@ -365,10 +365,8 @@ VerticalPositioner { \o \qml VerticalPositioner { - id: positioner remove: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 1 to: 0 @@ -382,7 +380,7 @@ VerticalPositioner { */ /*! \qmlproperty Transition VerticalPositioner::add - This property holds the transition to be applied when adding an item to the positioner. + This property holds the transition to be applied when adding an item to the positioner. The transition will only be applied to the added item(s). Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible. @@ -392,10 +390,8 @@ VerticalPositioner { \o \qml VerticalPositioner { - id: positioner add: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 0 to: 1 @@ -419,7 +415,6 @@ VerticalPositioner { \o \qml VerticalPositioner { - id: positioner move: Transition { NumberAnimation { properties: "y" @@ -431,28 +426,15 @@ VerticalPositioner { \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 positioners. 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 positioner. Both default to 0. + item, and defaults 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 positioner - occupies is colored white. The top positioner has a spacing of 2 and a - margin of 5, the bottom positioner has the defaults of no margin or - spacing. + occupies is colored white. The top positioner has the default of no spacing, + and the bottom positioner has its spacing set to 2. \image spacing_a.png \image spacing_b.png @@ -511,7 +493,14 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,HorizontalPositioner,QFxHorizont \brief The HorizontalPositioner item lines up its children horizontally. \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 positioner. 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 positioner, as well as to items which have their opacity set to or from zero so as to appear or disappear. + The HorizontalPositioner item positions 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 + positioner. 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 + positioner, 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 @@ -528,6 +517,7 @@ HorizontalPositioner { /*! \qmlproperty Transition HorizontalPositioner::remove This property holds the transition to apply when removing an item from the positioner. + The transition will only be applied to the removed item(s). Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that the object has had its opacity set to zero, and thus is no longer visible. @@ -535,10 +525,8 @@ HorizontalPositioner { \qml HorizontalPositioner { - id: positioner remove: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 1 to: 0 @@ -552,15 +540,14 @@ HorizontalPositioner { /*! \qmlproperty Transition HorizontalPositioner::add This property holds the transition to apply when adding an item to the positioner. + The transition will only be applied to the added item(s). Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the object has had its opacity increased from zero, and thus is now visible. \qml HorizontalPositioner { - id: positioner add: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 0 to: 1 @@ -591,33 +578,15 @@ HorizontalPositioner { */ /*! - \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 positioner. -*/ -/*! \qmlproperty int HorizontalPositioner::spacing - \qmlproperty int HorizontalPositioner::margin - spacing and margin allow you to control the empty space surrounding items in positioners. - - 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 positioner. - Both default to 0. + spacing is the amount in pixels left empty between each adjacent + item, and defaults 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 positioner occupies is colored white. The top positioner has a spacing of 2 and a margin of 5, the bottom positioner has the defaults of no margin or spacing. + The below example places a GridPositioner containing a red, a blue and a + green rectangle on a gray background. The area the grid positioner + occupies is colored white. The top positioner has the default of no spacing, + and the bottom positioner has its spacing set to 2. \image spacing_a.png \image spacing_b.png @@ -676,10 +645,9 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,GridPositioner,QFxGridPositioner \brief The GridPositioner item positions its children in a grid. \inherits Item - The GridPositioner item arranges its child items so that they are + The GridPositioner item positions 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 + between the items. It also provides for transitions to be set when items are added, moved, or removed in the positioner. 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 positioner, as @@ -715,6 +683,7 @@ GridPositioner { /*! \qmlproperty Transition GridPositioner::remove This property holds the transition to apply when removing an item from the positioner. + The transition is only applied to the removed item(s). Removed can mean that either the object has been deleted or reparented, and thus is now longer a child of the positioner, or that @@ -727,10 +696,8 @@ GridPositioner { \qml GridPositioner { - id: positioner remove: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 1 to: 0 @@ -744,6 +711,7 @@ GridPositioner { /*! \qmlproperty Transition GridPositioner::add This property holds the transition to apply when adding an item to the positioner. + The transition is only applied to the added item(s). Added can mean that either the object has been created or reparented, and thus is now a child or the positioner, or that the @@ -752,10 +720,8 @@ GridPositioner { \qml GridPositioner { - id: positioner add: Transition { NumberAnimation { - target: positioner.item properties: "opacity" from: 0 to: 1 @@ -775,7 +741,6 @@ GridPositioner { \qml GridPositioner { - id: positioner move: Transition { NumberAnimation { properties: "x,y" @@ -787,29 +752,15 @@ GridPositioner { */ /*! - \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 positioners. 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 positioner. Both default to 0. + item, and defaults 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 positioner - occupies is colored white. The top positioner has a spacing of 2 and a - margin of 5, the bottom positioner has the defaults of no margin or - spacing. + occupies is colored white. The top positioner has the default of no spacing, + and the bottom positioner has its spacing set to 2. \image spacing_a.png \image spacing_b.png @@ -853,7 +804,7 @@ void QFxGridPositioner::doPositioning() int numVisible = items()->size() + newItems()->size(); if (_columns==-1 && _rows==-1){ c = 4; - r = (numVisible+2)/3; + r = (numVisible+3)/4; }else if (_rows==-1){ r = (numVisible+(_columns-1))/_columns; }else if (_columns==-1){ -- cgit v0.12 From 003d629e3485a21ae9cf365bc3749d839593d9ba Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 18 Aug 2009 15:36:56 +1000 Subject: doc cleanup --- src/declarative/fx/qfxpath.cpp | 38 ++++---------------------------------- src/declarative/fx/qfxpathview.cpp | 35 ++++------------------------------- src/declarative/fx/qfxrepeater.cpp | 31 +++++++++++-------------------- 3 files changed, 19 insertions(+), 85 deletions(-) diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp index aff8a6d..26fafc5 100644 --- a/src/declarative/fx/qfxpath.cpp +++ b/src/declarative/fx/qfxpath.cpp @@ -114,12 +114,6 @@ QFxPath::~QFxPath() \qmlproperty real Path::startY This property holds the starting position of the path. */ - -/*! - \property QFxPath::startX - \brief the starting x position of the path. -*/ - qreal QFxPath::startX() const { Q_D(const QFxPath); @@ -132,12 +126,6 @@ void QFxPath::setStartX(qreal x) d->startX = x; } - -/*! - \property QFxPath::startY - \brief the starting y position of the path. -*/ - qreal QFxPath::startY() const { Q_D(const QFxPath); @@ -292,7 +280,7 @@ void QFxPath::componentComplete() QSet attrs; // First gather up all the attributes foreach (QFxPathElement *pathElement, d->_pathElements) { - if (QFxPathAttribute *attribute = + if (QFxPathAttribute *attribute = qobject_cast(pathElement)) attrs.insert(attribute->name()); } @@ -304,7 +292,7 @@ void QFxPath::componentComplete() connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); } -QPainterPath QFxPath::path() const +QPainterPath QFxPath::path() const { Q_D(const QFxPath); return d->_path; @@ -431,9 +419,9 @@ qreal QFxPath::attributeAt(const QString &name, qreal percent) const if (point.percent == percent) { return point.values.value(name); } else if (point.percent > percent) { - qreal lastValue = + qreal lastValue = ii?(d->_attributePoints.at(ii - 1).values.value(name)):0; - qreal lastPercent = + qreal lastPercent = ii?(d->_attributePoints.at(ii - 1).percent):0; qreal curValue = point.values.value(name); qreal curPercent = point.percent; @@ -723,11 +711,6 @@ void QFxPathQuad::addToPath(QPainterPath &path) Defines the position of the first control point. */ - -/*! - \property QFxPathCubic::control1X - \brief the x position of the first control point. -*/ qreal QFxPathCubic::control1X() const { return _control1X; @@ -741,10 +724,6 @@ void QFxPathCubic::setControl1X(qreal x) } } -/*! - \property QFxPathCubic::control1Y - \brief the y position of the first control point. -*/ qreal QFxPathCubic::control1Y() const { return _control1Y; @@ -764,11 +743,6 @@ void QFxPathCubic::setControl1Y(qreal y) Defines the position of the second control point. */ - -/*! - \property QFxPathCubic::control2X - \brief the x position of the second control point. -*/ qreal QFxPathCubic::control2X() const { return _control2X; @@ -782,10 +756,6 @@ void QFxPathCubic::setControl2X(qreal x) } } -/*! - \property QFxPathCubic::control2Y - \brief the y position of the second control point. -*/ qreal QFxPathCubic::control2Y() const { return _control2Y; diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 45ff51c..469e9f3 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -70,9 +70,9 @@ public: QFxPathView::attachedProperties.remove(parent()); } - QVariant value(const QByteArray &name) const - { - return mo->value(name); + QVariant value(const QByteArray &name) const + { + return mo->value(name); } void setValue(const QByteArray &name, const QVariant &val) { @@ -138,14 +138,6 @@ QFxPathView::~QFxPathView() For large or dynamic datasets the model is usually provided by a C++ model object. Models can also be created directly in XML, using the ListModel element. */ - -/*! - \property QFxPathView::model - \brief the model providing data for the view. - - The model must be either a \l QListModelInterface or - \l QFxVisualModel subclass. -*/ QVariant QFxPathView::model() const { Q_D(const QFxPathView); @@ -282,14 +274,8 @@ void QFxPathViewPrivate::setOffset(qreal o) /*! \qmlproperty real PathView::snapPosition - This property holds the position (0-100) the current item snaps to. -*/ - -/*! - \property QFxPathView::snapPosition - \brief sets the position (0-100) the current item snaps to. - This property determines the position the nearest item will snap to. + This property determines the position (0-100) the nearest item will snap to. */ qreal QFxPathView::snapPosition() const { @@ -332,15 +318,6 @@ void QFxPathView::setDragMargin(qreal dragMargin) Here is an example delegate: \snippet doc/src/snippets/declarative/pathview/pathview.qml 1 */ - -/*! - \property QFxPathView::delegate - \brief the component to use to render the items. - - The delegate is a component that the view will instantiate and destroy - as needed to display the items. - -*/ QmlComponent *QFxPathView::delegate() const { Q_D(const QFxPathView); @@ -366,10 +343,6 @@ void QFxPathView::setDelegate(QmlComponent *c) } /*! - \property QFxPathView::pathItemCount - \brief the number of items visible on the path at any one time - */ -/*! \qmlproperty int PathView::pathItemCount This property holds the number of items visible on the path at any one time */ diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp index 8f30324..a9d9977 100644 --- a/src/declarative/fx/qfxrepeater.cpp +++ b/src/declarative/fx/qfxrepeater.cpp @@ -80,7 +80,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) \brief The Repeater item allows you to repeat a component based on a data source. - The Repeater item is used when you want to create a large number of + The Repeater item is used when you want to create a large number of similar items. For each entry in the data source, an item is instantiated in a context seeded with data from the data source. If the repeater will be instantiating a large number of instances, it may be more efficient to @@ -93,11 +93,11 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) or object) is available as the \c modelData property. In the case of a Qt model, all roles are available as named properties just like in the view classes. - Items instantiated by the Repeater are inserted, in order, as + Items instantiated by the Repeater are inserted, in order, as children of the Repeater's parent. The insertion starts immediately after the repeater's position in its parent stacking list. This is to allow you to use a Repeater inside a layout. The following QML example shows how - the instantiated items would visually appear stacked between the red and + the instantiated items would visually appear stacked between the red and blue rectangles. \snippet doc/src/snippets/declarative/repeater.qml 0 @@ -115,10 +115,10 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) \ingroup group_utility \qmlclass Repeater - \brief The QFxRepeater class allows you to repeat a component based on a + \brief The QFxRepeater class allows you to repeat a component based on a data source. - The QFxRepeater class is used when you want to create a large number of + The QFxRepeater class is used when you want to create a large number of similar items. For each entry in the data source, an item is instantiated in a context seeded with data from the data source. @@ -133,11 +133,11 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Repeater,QFxRepeater) create that many instances of the component. They will also be assigned an index based on the order they are created. - Items instantiated by the QFxRepeater class are inserted, in order, as + Items instantiated by the QFxRepeater class are inserted, in order, as children of the repeater's parent. The insertion starts immediately after the repeater's position in its parent stacking list. This is to allow you to use a repeater inside a layout. The following QML example shows how - the instantiated items would visually appear stacked between the red and + the instantiated items would visually appear stacked between the red and blue rectangles. \snippet doc/src/snippets/declarative/repeater.qml 0 @@ -161,7 +161,7 @@ QFxRepeater::QFxRepeater(QFxItem *parent) } /*! - \internal + \internal */ QFxRepeater::QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent) : QFxItem(dd, parent) @@ -169,7 +169,7 @@ QFxRepeater::QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent) } /*! - Destroy the repeater instance. All items it instantiated are also + Destroy the repeater instance. All items it instantiated are also destroyed. */ QFxRepeater::~QFxRepeater() @@ -192,11 +192,6 @@ QFxRepeater::~QFxRepeater() create that many instances of the component. They will also be assigned an index based on the order they are created. */ - -/*! - \property QFxRepeater::dataSource - \brief The source of data for the repeater. - */ QVariant QFxRepeater::dataSource() const { return QVariant(); @@ -215,10 +210,6 @@ void QFxRepeater::setDataSource(const QVariant &v) The component to repeat. */ -/*! - \property QFxRepeater::component - \brief The component to repeat. - */ QmlComponent *QFxRepeater::component() const { Q_D(const QFxRepeater); @@ -261,8 +252,8 @@ QVariant QFxRepeater::itemChange(GraphicsItemChange change, void QFxRepeater::regenerate() { Q_D(QFxRepeater); - - qDeleteAll(d->deletables); + + qDeleteAll(d->deletables); d->deletables.clear(); if (!d->component || !parentItem() || !isComponentComplete()) return; -- cgit v0.12 From 1ab70725f76433a0f601fdfd70abc55bd6228ac3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Aug 2009 09:05:07 +0200 Subject: Make qml metatype db fully discoverable again Allow access to all registered types, and also expose the exact version range a type is provided for. --- src/declarative/qml/qmlmetatype.cpp | 23 +++++++++++++++++++++++ src/declarative/qml/qmlmetatype.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 5ebe970..091bd1b 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -190,6 +190,21 @@ QmlType::~QmlType() delete d; } +int QmlType::majorVersion() const +{ + return d->m_version_maj; +} + +int QmlType::minMinorVersion() const +{ + return d->m_version_min_from; +} + +int QmlType::maxMinorVersion() const +{ + return d->m_version_min_to; +} + bool QmlType::availableInVersion(int vmajor, int vminor) const { return vmajor == d->m_version_maj && vminor >= d->m_version_min_from && vminor <= d->m_version_min_to; @@ -879,6 +894,14 @@ QList QmlMetaType::qmlTypeNames() return data->nameToType.keys(); } +QList QmlMetaType::qmlTypes() +{ + QReadLocker lock(metaTypeDataLock()); + QmlMetaTypeData *data = metaTypeData(); + + return data->nameToType.values(); +} + /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 94029ce..c388b1a 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -65,6 +65,7 @@ public: static bool copy(int type, void *data, const void *copy = 0); static QList qmlTypeNames(); + static QList qmlTypes(); static QmlType *qmlType(const QByteArray &, int, int); static QmlType *qmlType(const QMetaObject *); @@ -111,6 +112,10 @@ class Q_DECLARATIVE_EXPORT QmlType public: QByteArray typeName() const; QByteArray qmlTypeName() const; + + int majorVersion() const; + int minMinorVersion() const; + int maxMinorVersion() const; bool availableInVersion(int vmajor, int vminor) const; QByteArray hash() const; -- cgit v0.12 From 223746067a9a1b3f5c6195868b5e510311608ca1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 18 Aug 2009 17:59:31 +1000 Subject: Resolve attached property typenames in correct context. The imports of the component containing the reference to the attached property are used to resolve typenames, rather than assuming "Qt" namespace. --- src/declarative/qml/qmlcontext.cpp | 18 ++++++++++++++++++ src/declarative/qml/qmlcontext.h | 3 +++ src/declarative/qml/qmlengine.cpp | 5 ++++- src/declarative/qml/qmlmetaproperty.cpp | 20 +++++++++++++------- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index 451dbcc..b73471a 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -451,4 +451,22 @@ void QmlContext::setBaseUrl(const QUrl &baseUrl) d_func()->url = baseUrl; } +/*! + Returns the base url of the component, or the containing component + if none is set. +*/ +QUrl QmlContext::baseUrl() const +{ + Q_D(const QmlContext); + const QmlContext* p = this; + while (p && p->d_func()->url.isEmpty()) { + p = p->parentContext(); + } + if (p) + return p->d_func()->url; + else + return QUrl(); +} + + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 70a81fc..65d711c 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -56,6 +56,8 @@ class QString; class QmlEngine; class QmlRefCount; class QmlContextPrivate; +class QmlCompositeTypeData; + class Q_DECLARATIVE_EXPORT QmlContext : public QObject { Q_OBJECT @@ -76,6 +78,7 @@ public: QUrl resolvedUrl(const QUrl &); void setBaseUrl(const QUrl &); + QUrl baseUrl() const; private: friend class QmlVME; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 6756642..558bd49 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -191,7 +191,10 @@ QmlEnginePrivate::queryObject(const QString &propName, { QScriptClass::QueryFlags rv = 0; - QmlMetaProperty prop(obj, propName, rootContext); + QmlContext *ctxt = QmlEngine::contextForObject(obj); + if (!ctxt) + ctxt = rootContext; + QmlMetaProperty prop(obj, propName, ctxt); if (prop.type() == QmlMetaProperty::Invalid) { QPair key = qMakePair(obj->metaObject(), propName); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index c1736cb..e69746e 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -41,6 +41,7 @@ #include "qmlmetaproperty.h" #include "qmlmetaproperty_p.h" +#include "qmlcompositetypedata_p.h" #include #include #include @@ -216,14 +217,19 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) if (name.isEmpty() || !obj) return; - if (name.at(0).isUpper()) { + if (enginePrivate && name.at(0).isUpper()) { // Attached property - // XXX name should be resolved with QmlEngine::resolveType(), not like this! - QmlType *t = QmlMetaType::qmlType("Qt/"+name.toLatin1(),-1,-1); - if (t && t->attachedPropertiesFunction()) { - attachedFunc = t->index(); - if (attachedFunc != -1) - type = QmlMetaProperty::Property | QmlMetaProperty::Attached; + QmlCompositeTypeData *typeData = + enginePrivate->typeManager.get(context->baseUrl()); + + if (typeData) { + QmlType *t = 0; + enginePrivate->resolveType(typeData->imports, name.toLatin1(), &t, 0); + if (t && t->attachedPropertiesFunction()) { + attachedFunc = t->index(); + if (attachedFunc != -1) + type = QmlMetaProperty::Property | QmlMetaProperty::Attached; + } } return; -- cgit v0.12 From 42291f03e1a6083dd3459224226a90717299f26e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 Aug 2009 13:17:36 +0200 Subject: Fix documentation for QmlDomObject::className The name of this method is also misleading, maybe rename it to just QmlDomObject::name and QmlDomObject::objectType() to QmlDomObject::qualifiedName() ? --- src/declarative/qml/qmldom.cpp | 4 ++-- src/declarative/qml/qmldom.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index cdd5eef..2000e51 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -761,9 +761,9 @@ QByteArray QmlDomObject::objectType() const } /*! - Returns the fully-qualified type name of this object. + Returns the type name as referenced in the qml file. - For example, the type of this object would be "Qt/4.6/Rect". + For example, the type of this object would be "Rect". \qml Rect { } \endqml diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 1c70206..32ed2da 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -151,8 +151,8 @@ public: QByteArray objectType() const; QByteArray objectClassName() const; - QString objectId() const; + QString objectId() const; void setObjectId(const QByteArray &); QList properties() const; -- cgit v0.12 From 06bef623b0ae135ba539df1e4ae12267abd70784 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 19 Aug 2009 08:51:45 +1000 Subject: BorderImage doc --- src/declarative/fx/qfxborderimage.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/declarative/fx/qfxborderimage.cpp b/src/declarative/fx/qfxborderimage.cpp index 67b05fd..16677e0 100644 --- a/src/declarative/fx/qfxborderimage.cpp +++ b/src/declarative/fx/qfxborderimage.cpp @@ -52,32 +52,20 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,BorderImage,QFxBorderImage) /*! \qmlclass BorderImage QFxBorderImage - \brief The BorderImage element allows you use an image as a border. + \brief The BorderImage element provides an image that can be used as a border. \inherits Item - Example: - \qml - BorderImage { border.left: 20; border.right: 10 - border.top: 14; border.bottom: 14 - width: 160; height: 160 - source: "pics/qtlogo.png" - } - \endqml + \snippet examples/declarative/border-image/example.qml 0 + + \image BorderImage.png + + \sa examples/declarative/border-image */ /*! \internal \class QFxBorderImage BorderImage \brief The QFxBorderImage class provides an image item that you can add to a QFxView. - - \ingroup group_coreitems - - Example: - \qml - BorderImage { source: "pics/star.png" } - \endqml - - A QFxBorderImage object can be instantiated in Qml using the tag \l BorderImage. */ QFxBorderImage::QFxBorderImage(QFxItem *parent) @@ -272,8 +260,6 @@ QFxScaleGrid *QFxBorderImage::border() \o Repeat - Tile the image until there is no more space. May crop the last image. \o Round - Like Repeat, but scales the images down to ensure that the last image is not cropped. \endlist - - \sa examples/declarative/border-image */ QFxBorderImage::TileMode QFxBorderImage::horizontalTileMode() const { -- cgit v0.12 From 5f3ff0080213b09f3edc8faebf5b9eee73e4026a Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 19 Aug 2009 11:30:53 +1000 Subject: more docs --- doc/src/declarative/pics/BorderImage.png | Bin 0 -> 8094 bytes examples/declarative/border-image/example.qml | 31 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 doc/src/declarative/pics/BorderImage.png create mode 100644 examples/declarative/border-image/example.qml diff --git a/doc/src/declarative/pics/BorderImage.png b/doc/src/declarative/pics/BorderImage.png new file mode 100644 index 0000000..651dd8a Binary files /dev/null and b/doc/src/declarative/pics/BorderImage.png differ diff --git a/examples/declarative/border-image/example.qml b/examples/declarative/border-image/example.qml new file mode 100644 index 0000000..10daf47 --- /dev/null +++ b/examples/declarative/border-image/example.qml @@ -0,0 +1,31 @@ +import Qt 4.6 + +Rect { + id: Page + color: "white" + width: 520; height: 280 + + HorizontalPositioner { + anchors.centerIn: parent + spacing: 50 +//! [0] + BorderImage { + width: 180; height: 180 + border.left: 30; border.top: 30 + border.right: 30; border.bottom: 30 + horizontalTileMode: "Stretch" + verticalTileMode: "Stretch" + source: "colors.png" + } + + BorderImage { + width: 180; height: 180 + border.left: 30; border.top: 30 + border.right: 30; border.bottom: 30 + horizontalTileMode: "Round" + verticalTileMode: "Round" + source: "colors.png" + } +//! [0] + } +} -- cgit v0.12 From 26badb44f436329f60193761eaba95d78fb5369d Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 19 Aug 2009 11:32:42 +1000 Subject: doc cleanup --- src/declarative/fx/qfxtext.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index cd34aa0..272102c 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -132,12 +132,6 @@ QFxText::~QFxText() \note \c font.size sets the font's point size (not pixel size). */ - -/*! - \property QFxText::font - \brief the font used to display the text. -*/ - QFont QFxText::font() const { Q_D(const QFxText); @@ -245,16 +239,6 @@ QColor QFxText::color() const \image declarative-textstyle.png */ - -/*! - \property QFxText::style - \brief an additional style of the text to display. - - By default, the text style is Normal. - - \note This property is used to support text styles not natively - handled by QFont or QPainter::drawText(). -*/ QFxText::TextStyle QFxText::style() const { Q_D(const QFxText); @@ -309,13 +293,6 @@ QColor QFxText::styleColor() const \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom and \c AlignVCenter. */ - -/*! - \property QFxText::hAlign - \brief the horizontal alignment of the text. - - Valid values are \c AlignLeft, \c AlignRight, and \c AlignHCenter. The default value is \c AlignLeft. -*/ QFxText::HAlignment QFxText::hAlign() const { Q_D(const QFxText); @@ -328,12 +305,6 @@ void QFxText::setHAlign(HAlignment align) d->hAlign = align; } -/*! - \property QFxText::vAlign - \brief the vertical alignment of the text. - - Valid values are \c AlignTop, \c AlignBottom, and \c AlignVCenter. The default value is \c AlignTop. -*/ QFxText::VAlignment QFxText::vAlign() const { Q_D(const QFxText); -- cgit v0.12 From 4b4015f960ee94a7e244a7ca49297c68446984b0 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 Aug 2009 11:42:54 +1000 Subject: Update Positioner Tests Note that it still doesn't pass tests, due at least partially to an error in the test code. This change also slips in a change to the QLayoutItem example less of a bad example of how to integrate QGraphicsLayouts. --- examples/declarative/layouts/layouts.qml | 40 ++--- .../auto/declarative/layouts/data/grid-margin.qml | 40 ----- .../layouts/data/grid-spacing-margin.qml | 41 ------ .../auto/declarative/layouts/data/grid-spacing.qml | 2 +- tests/auto/declarative/layouts/data/grid.qml | 2 +- .../declarative/layouts/data/horizontal-margin.qml | 27 ---- .../layouts/data/horizontal-spacing-margin.qml | 28 ---- .../layouts/data/horizontal-spacing.qml | 2 +- tests/auto/declarative/layouts/data/horizontal.qml | 2 +- .../declarative/layouts/data/vertical-margin.qml | 27 ---- .../layouts/data/vertical-spacing-margin.qml | 28 ---- .../declarative/layouts/data/vertical-spacing.qml | 2 +- tests/auto/declarative/layouts/data/vertical.qml | 2 +- tests/auto/declarative/layouts/tst_layouts.cpp | 163 --------------------- 14 files changed, 26 insertions(+), 380 deletions(-) delete mode 100644 tests/auto/declarative/layouts/data/grid-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/grid-spacing-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/horizontal-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/vertical-margin.qml delete mode 100644 tests/auto/declarative/layouts/data/vertical-spacing-margin.qml diff --git a/examples/declarative/layouts/layouts.qml b/examples/declarative/layouts/layouts.qml index d049e0a..1f6b956 100644 --- a/examples/declarative/layouts/layouts.qml +++ b/examples/declarative/layouts/layouts.qml @@ -1,25 +1,25 @@ import Qt 4.6 -QGraphicsView{ -QGraphicsScene{ -QGraphicsWidget{ - visible: true - opacity: 1 - geometry: "0,0,400x400" - layout: QGraphicsLinearLayout{ - LayoutItem{ - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - Rect { color: "yellow"; anchors.fill: parent } - } - LayoutItem{ - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "200x200" - Rect { color: "green"; anchors.fill: parent } +Item { id: resizable + width:400; height:400; + GraphicsObjectContainer{ + anchors.fill:parent + QGraphicsWidget{ + geometry:{ "0,0," + parent.width.toString() + "x" + parent.height.toString(); } + layout: QGraphicsLinearLayout{ + LayoutItem{ + minimumSize: "100x100" + maximumSize: "300x300" + preferredSize: "100x100" + Rect { color: "yellow"; anchors.fill: parent } + } + LayoutItem{ + minimumSize: "100x100" + maximumSize: "400x400" + preferredSize: "200x200" + Rect { color: "green"; anchors.fill: parent } + } + } } } } -} -} diff --git a/tests/auto/declarative/layouts/data/grid-margin.qml b/tests/auto/declarative/layouts/data/grid-margin.qml deleted file mode 100644 index a49dc85..0000000 --- a/tests/auto/declarative/layouts/data/grid-margin.qml +++ /dev/null @@ -1,40 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - GridLayout { - columns: 3 - margin: 8 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "green" - width: 20 - height: 50 - } - Rect { - id: three - color: "blue" - width: 50 - height: 20 - } - Rect { - id: four - color: "cyan" - width: 50 - height: 50 - } - Rect { - id: five - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/declarative/layouts/data/grid-spacing-margin.qml b/tests/auto/declarative/layouts/data/grid-spacing-margin.qml deleted file mode 100644 index d2fe4f6..0000000 --- a/tests/auto/declarative/layouts/data/grid-spacing-margin.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - GridLayout { - columns: 3 - spacing: 4 - margin: 8 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "green" - width: 20 - height: 50 - } - Rect { - id: three - color: "blue" - width: 50 - height: 20 - } - Rect { - id: four - color: "cyan" - width: 50 - height: 50 - } - Rect { - id: five - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/declarative/layouts/data/grid-spacing.qml b/tests/auto/declarative/layouts/data/grid-spacing.qml index 704e3f2..f8b5620 100644 --- a/tests/auto/declarative/layouts/data/grid-spacing.qml +++ b/tests/auto/declarative/layouts/data/grid-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - GridLayout { + GridPositioner { columns: 3 spacing: 4 Rect { diff --git a/tests/auto/declarative/layouts/data/grid.qml b/tests/auto/declarative/layouts/data/grid.qml index 2f60f16..2fbc37c 100644 --- a/tests/auto/declarative/layouts/data/grid.qml +++ b/tests/auto/declarative/layouts/data/grid.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - GridLayout { + GridPositioner { columns: 3 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/horizontal-margin.qml b/tests/auto/declarative/layouts/data/horizontal-margin.qml deleted file mode 100644 index a96db02..0000000 --- a/tests/auto/declarative/layouts/data/horizontal-margin.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - HorizontalLayout { - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml b/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml deleted file mode 100644 index 82957be..0000000 --- a/tests/auto/declarative/layouts/data/horizontal-spacing-margin.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - HorizontalLayout { - spacing: 5 - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/horizontal-spacing.qml b/tests/auto/declarative/layouts/data/horizontal-spacing.qml index 8c55ae9..25dad8a 100644 --- a/tests/auto/declarative/layouts/data/horizontal-spacing.qml +++ b/tests/auto/declarative/layouts/data/horizontal-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - HorizontalLayout { + HorizontalPositioner { spacing: 10 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/horizontal.qml b/tests/auto/declarative/layouts/data/horizontal.qml index 286b90b..4bce504 100644 --- a/tests/auto/declarative/layouts/data/horizontal.qml +++ b/tests/auto/declarative/layouts/data/horizontal.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - HorizontalLayout { + HorizontalPositioner { Rect { id: one color: "red" diff --git a/tests/auto/declarative/layouts/data/vertical-margin.qml b/tests/auto/declarative/layouts/data/vertical-margin.qml deleted file mode 100644 index a7e10ea..0000000 --- a/tests/auto/declarative/layouts/data/vertical-margin.qml +++ /dev/null @@ -1,27 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - VerticalLayout { - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml b/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml deleted file mode 100644 index 828ae61..0000000 --- a/tests/auto/declarative/layouts/data/vertical-spacing-margin.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.6 - -Item { - width: 640 - height: 480 - VerticalLayout { - spacing: 5 - margin: 10 - Rect { - id: one - color: "red" - width: 50 - height: 50 - } - Rect { - id: two - color: "red" - width: 20 - height: 10 - } - Rect { - id: three - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/declarative/layouts/data/vertical-spacing.qml b/tests/auto/declarative/layouts/data/vertical-spacing.qml index 8d3e86f..aa704be 100644 --- a/tests/auto/declarative/layouts/data/vertical-spacing.qml +++ b/tests/auto/declarative/layouts/data/vertical-spacing.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - VerticalLayout { + VerticalPositioner { spacing: 10 Rect { id: one diff --git a/tests/auto/declarative/layouts/data/vertical.qml b/tests/auto/declarative/layouts/data/vertical.qml index 960f10a..0a52126 100644 --- a/tests/auto/declarative/layouts/data/vertical.qml +++ b/tests/auto/declarative/layouts/data/vertical.qml @@ -3,7 +3,7 @@ import Qt 4.6 Item { width: 640 height: 480 - VerticalLayout { + VerticalPositioner { Rect { id: one color: "red" diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 732551c..466a7de 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -13,16 +13,10 @@ public: private slots: void test_horizontal(); void test_horizontal_spacing(); - void test_horizontal_margin(); - void test_horizontal_spacing_margin(); void test_vertical(); void test_vertical_spacing(); - void test_vertical_margin(); - void test_vertical_spacing_margin(); void test_grid(); void test_grid_spacing(); - void test_grid_margin(); - void test_grid_spacing_margin(); private: QFxView *createView(const QString &filename); @@ -82,54 +76,6 @@ void tst_QFxLayouts::test_horizontal_spacing() QCOMPARE(three->y(), 0.0); } -void tst_QFxLayouts::test_horizontal_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/horizontal-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 60.0); - QCOMPARE(two->y(), 10.0); - QCOMPARE(three->x(), 80.0); - QCOMPARE(three->y(), 10.0); -} - -void tst_QFxLayouts::test_horizontal_spacing_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/horizontal-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 65.0); - QCOMPARE(two->y(), 10.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 10.0); -} - void tst_QFxLayouts::test_vertical() { QFxView *canvas = createView(SRCDIR "/data/vertical.qml"); @@ -178,54 +124,6 @@ void tst_QFxLayouts::test_vertical_spacing() QCOMPARE(three->y(), 80.0); } -void tst_QFxLayouts::test_vertical_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/vertical-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 10.0); - QCOMPARE(two->y(), 60.0); - QCOMPARE(three->x(), 10.0); - QCOMPARE(three->y(), 70.0); -} - -void tst_QFxLayouts::test_vertical_spacing_margin() -{ - QFxView *canvas = createView(SRCDIR "/data/vertical-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 10.0); - QCOMPARE(one->y(), 10.0); - QCOMPARE(two->x(), 10.0); - QCOMPARE(two->y(), 65.0); - QCOMPARE(three->x(), 10.0); - QCOMPARE(three->y(), 80.0); -} - void tst_QFxLayouts::test_grid() { QFxView *canvas = createView("data/grid.qml"); @@ -286,67 +184,6 @@ void tst_QFxLayouts::test_grid_spacing() QCOMPARE(five->y(), 54.0); } -void tst_QFxLayouts::test_grid_margin() -{ - QFxView *canvas = createView("data/grid-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - QFxRect *four = findItem(canvas->root(), "four"); - QVERIFY(four != 0); - QFxRect *five = findItem(canvas->root(), "five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 8.0); - QCOMPARE(one->y(), 8.0); - QCOMPARE(two->x(), 58.0); - QCOMPARE(two->y(), 8.0); - QCOMPARE(three->x(), 78.0); - QCOMPARE(three->y(), 8.0); - QCOMPARE(four->x(), 8.0); - QCOMPARE(four->y(), 58.0); - QCOMPARE(five->x(), 58.0); - QCOMPARE(five->y(), 58.0); -} - - -void tst_QFxLayouts::test_grid_spacing_margin() -{ - QFxView *canvas = createView("data/grid-spacing-margin.qml"); - - canvas->execute(); - qApp->processEvents(); - - QFxRect *one = findItem(canvas->root(), "one"); - QVERIFY(one != 0); - QFxRect *two = findItem(canvas->root(), "two"); - QVERIFY(two != 0); - QFxRect *three = findItem(canvas->root(), "three"); - QVERIFY(three != 0); - QFxRect *four = findItem(canvas->root(), "four"); - QVERIFY(four != 0); - QFxRect *five = findItem(canvas->root(), "five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 8.0); - QCOMPARE(one->y(), 8.0); - QCOMPARE(two->x(), 62.0); - QCOMPARE(two->y(), 8.0); - QCOMPARE(three->x(), 86.0); - QCOMPARE(three->y(), 8.0); - QCOMPARE(four->x(), 8.0); - QCOMPARE(four->y(), 62.0); - QCOMPARE(five->x(), 62.0); - QCOMPARE(five->y(), 62.0); -} - QFxView *tst_QFxLayouts::createView(const QString &filename) { QFxView *canvas = new QFxView(0); -- cgit v0.12 From 56ccc5fdf6e2136df9c97b3ecdf7d1003549b546 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 19 Aug 2009 11:48:56 +1000 Subject: These docs shouldn't have been removed Still ought to have the docs that explain how to subclass QFxBasePositioner effectively, at least for internal reference. --- src/declarative/fx/qfxpositioners.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp index a164f67..1eb88fe 100644 --- a/src/declarative/fx/qfxpositioners.cpp +++ b/src/declarative/fx/qfxpositioners.cpp @@ -56,6 +56,19 @@ QT_BEGIN_NAMESPACE \internal \class QFxBasePositioner \ingroup group_layouts + \brief The QFxBasePositioner class provides a base for QFx layouts. + + To create a QFx Positioner, simply 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. You can use the applyAdd, applyMove and applyRemove functions + to do this easily. + + Note also that the subclass is responsible for adding the + spacing in between items. */ QFxBasePositioner::QFxBasePositioner(AutoUpdateType at, QFxItem *parent) : QFxItem(*(new QFxBasePositionerPrivate), parent) -- cgit v0.12 From 4f3f840520cb33913bd52618230e51231595a31e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 19 Aug 2009 11:50:55 +1000 Subject: Update with new, more detailed error messages. --- tests/auto/declarative/qmlparser/readOnly.1.errors.txt | 2 +- tests/auto/declarative/qmlparser/readOnly.2.errors.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt index 97219af..b8c3404 100644 --- a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt @@ -1 +1 @@ -3:21:Invalid property assignment: read-only property +3:21:Invalid property assignment: "readOnlyString" is a read-only property diff --git a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt index 471505c..d857a04 100644 --- a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt @@ -1 +1 @@ -3:5:Invalid property assignment: read-only property +3:5:Invalid property assignment: "readOnlyString" is a read-only property -- cgit v0.12