diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-11 05:14:00 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-11 05:14:00 (GMT) |
commit | b90283fd887898a3eda62e856bec7f8a34e242ac (patch) | |
tree | a0384dd4359384f4ef87d9df1909b6723f687a80 | |
parent | db414f8db1cca5d811416eb1ecec0536c379e107 (diff) | |
parent | 5e99815f85c953760d027be50caea5a386b6b710 (diff) | |
download | Qt-b90283fd887898a3eda62e856bec7f8a34e242ac.zip Qt-b90283fd887898a3eda62e856bec7f8a34e242ac.tar.gz Qt-b90283fd887898a3eda62e856bec7f8a34e242ac.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
24 files changed, 318 insertions, 248 deletions
diff --git a/doc/src/declarative/pics/repeater-simple.png b/doc/src/declarative/pics/repeater-simple.png Binary files differnew file mode 100644 index 0000000..6da6295 --- /dev/null +++ b/doc/src/declarative/pics/repeater-simple.png diff --git a/doc/src/snippets/declarative/repeater-modeldata.qml b/doc/src/snippets/declarative/repeater-modeldata.qml deleted file mode 100644 index 3b4cc6d..0000000 --- a/doc/src/snippets/declarative/repeater-modeldata.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the 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 Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt 4.7 - -//! [0] -Column { - Repeater { - model: ["apples", "oranges", "pears"] - Text { text: "Data: " + modelData } - } -} -//! [0] - diff --git a/doc/src/snippets/declarative/repeater.qml b/doc/src/snippets/declarative/repeater.qml index 8b4d9cb..be5d62d 100644 --- a/doc/src/snippets/declarative/repeater.qml +++ b/doc/src/snippets/declarative/repeater.qml @@ -39,19 +39,52 @@ ** ****************************************************************************/ +//! [import] import Qt 4.7 +//! [import] -Rectangle { - width: 220; height: 20; color: "white" +Row { -//! [0] - Row { - Rectangle { width: 10; height: 20; color: "red" } - Repeater { - model: 10 - Rectangle { width: 20; height: 20; radius: 10; color: "green" } +//! [simple] +Row { + Repeater { + model: 3 + Rectangle { + width: 100; height: 40 + border.width: 1 + color: "yellow" } - Rectangle { width: 10; height: 20; color: "blue" } } -//! [0] +} +//! [simple] + +//! [index] +Column { + Repeater { + model: 10 + Text { text: "I'm item " + index } + } +} +//! [index] + +//! [modeldata] +Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { text: "Data: " + modelData } + } +} +//! [modeldata] + +//! [layout] +Row { + Rectangle { width: 10; height: 20; color: "red" } + Repeater { + model: 10 + Rectangle { width: 20; height: 20; radius: 10; color: "green" } + } + Rectangle { width: 10; height: 20; color: "blue" } +} +//! [layout] + } diff --git a/doc/src/snippets/declarative/rotation.qml b/doc/src/snippets/declarative/rotation.qml index 0fb9a61..5437292 100644 --- a/doc/src/snippets/declarative/rotation.qml +++ b/doc/src/snippets/declarative/rotation.qml @@ -38,37 +38,33 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//! [0] import Qt 4.7 -Rectangle { - width: 360; height: 80 - color: "white" -//! [0] - Row { - x: 10; y: 10 - spacing: 10 - Image { source: "pics/qt.png" } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } - smooth: true - } +Row { + x: 10; y: 10 + spacing: 10 + + Image { source: "pics/qt.png" } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } + smooth: true + } + Image { + source: "pics/qt.png" + transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } + smooth: true } -//! [0] } +//! [0] diff --git a/doc/src/snippets/declarative/repeater-index.qml b/doc/src/snippets/declarative/systempalette.qml index 3eee742..98b333e 100644 --- a/doc/src/snippets/declarative/repeater-index.qml +++ b/doc/src/snippets/declarative/systempalette.qml @@ -38,19 +38,18 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +//![0] import Qt 4.7 Rectangle { - width: 50; height: childrenRect.height; color: "white" + SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } + + width: 640; height: 480 + color: myPalette.window -//! [0] - Column { - Repeater { - model: 10 - Text { text: "I'm item " + index } - } + Text { + anchors.fill: parent + text: "Hello!"; color: myPalette.windowText } -//! [0] } - +//![0] diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp index 261cc5c..d8527d3 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp @@ -63,9 +63,10 @@ QT_BEGIN_NAMESPACE \inherits Image \since 4.7 - This item provides for playing animations stored as images containing a series of frames, - such as GIF files. The full list of supported formats can be determined with - QMovie::supportedFormats(). + The AnimatedImage element provides for playing animations stored as images containing a series of frames, + such as GIF files. + + The full list of supported formats can be determined with QMovie::supportedFormats(). \table \row diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 1f1e453..cf458da 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -138,7 +138,7 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() BorderImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. - It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies + It can also handle .sci files, which are a QML-specific format. A .sci file uses a simple text-based format that specifies the borders, the image file and the tile rules. The following .sci file sets the borders to 10 on each side for the image \c picture.png: diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 10dc0f8..fdc1444 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -351,6 +351,8 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() Flickable places its children on a surface that can be dragged and flicked. \code + import Qt 4.7 + Flickable { width: 200; height: 200 contentWidth: image.width; contentHeight: image.height @@ -1039,11 +1041,11 @@ QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildr The \c boundsBehavior can be one of: \list - \o \e Flickable.StopAtBounds - the contents can not be dragged beyond the boundary + \o Flickable.StopAtBounds - the contents can not be dragged beyond the boundary of the flickable, and flicks will not overshoot. - \o \e Flickable.DragOverBounds - the contents can be dragged beyond the boundary + \o Flickable.DragOverBounds - the contents can be dragged beyond the boundary of the Flickable, but flicks will not overshoot. - \o \e Flickable.DragAndOvershootBounds (default) - the contents can be dragged + \o Flickable.DragAndOvershootBounds (default) - the contents can be dragged beyond the boundary of the Flickable, and can overshoot the boundary when flicked. \endlist diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 94240c2..ec08517 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -83,6 +83,8 @@ QT_BEGIN_NAMESPACE that images which do not form part of the user interface have their size bounded via the \l sourceSize property. This is especially important for content that is loaded from external sources or provided by the user. + + \sa {declarative/imageelements/image}{Image example} */ /*! @@ -95,7 +97,7 @@ QT_BEGIN_NAMESPACE Image { source: "pics/star.png" } \endqml - A QDeclarativeImage object can be instantiated in Qml using the tag \l Image. + A QDeclarativeImage object can be instantiated in QML using the tag \l Image. */ QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 7ab280e..18806e7 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -86,8 +86,8 @@ QT_BEGIN_NAMESPACE The Transform elements let you create and control advanced transformations that can be configured independently using specialized properties. - You can assign any number of Transform elements to an Item. Each Transform is applied in order, - one at a time, to the Item it's assigned to. + You can assign any number of Transform elements to an \l Item. Each Transform is applied in order, + one at a time. */ /*! @@ -134,9 +134,9 @@ QT_BEGIN_NAMESPACE /*! \qmlclass Scale QGraphicsScale \since 4.7 - \brief The Scale object provides a way to scale an Item. + \brief The Scale element provides a way to scale an Item. - The Scale object gives more control over scaling than using Item's scale property. Specifically, + The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically, it allows a different scale for the x and y axes, and allows the scale to be relative to an arbitrary point. @@ -148,6 +148,8 @@ QT_BEGIN_NAMESPACE transform: Scale { origin.x: 25; origin.y: 25; xScale: 3} } \endqml + + \sa Rotate, Translate */ /*! @@ -175,7 +177,7 @@ QT_BEGIN_NAMESPACE \since 4.7 \brief The Rotation object provides a way to rotate an Item. - The Rotation object gives more control over rotation than using Item's rotation property. + The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property. Specifically, it allows (z axis) rotation to be relative to an arbitrary point. The following example rotates a Rectangle around its interior point 25, 25: diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 72be670..d8d317c 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1378,6 +1378,8 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m is not clipped by another item or the screen, it will be necessary to set \e {clip: true} in order to have the out of view items clipped nicely. + + \sa ListModel, GridView */ QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 898c5a5..25b1119 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -112,27 +112,35 @@ void QDeclarativeLoaderPrivate::initResize() \inherits Item \brief The Loader item allows dynamically loading an Item-based - subtree from a QML URL or Component. + subtree from a URL or Component. - Loader instantiates an item from a component. The component to - instantiate may be specified directly by the \l sourceComponent + The Loader element instantiates an item from a component. The component to + be instantiated may be specified directly by the \l sourceComponent property, or loaded from a URL via the \l source property. - It is also an effective means of delaying the creation of a component - until it is required: + Loader can be used to delay the creation of a component until it is required. + For example, this loads "Page1.qml" as a component into the \l Loader element + when the \l MouseArea is clicked: + \code import Qt 4.7 - Loader { id: pageLoader } + Item { + width: 200; height: 200 - Rectangle { MouseArea { anchors.fill: parent onClicked: pageLoader.source = "Page1.qml" } + + Loader { id: pageLoader } } \endcode + Note that Loader is like any other graphical Item and needs to be positioned + and sized accordingly to become visible. When a component is loaded, the + Loader is automatically resized to the size of the component. + If the Loader source is changed, any previous items instantiated will be destroyed. Setting \l source to an empty string, or setting sourceComponent to \e undefined @@ -225,7 +233,7 @@ void QDeclarativeLoader::setSource(const QUrl &url) /*! \qmlproperty Component Loader::sourceComponent - The sourceComponent property holds the \l{Component} to instantiate. + This property holds the \l{Component} to instantiate. \qml Item { @@ -239,6 +247,8 @@ void QDeclarativeLoader::setSource(const QUrl &url) } \endqml + Note this value must hold a \l Component object; it cannot be a \l Item. + \sa source, progress */ @@ -401,7 +411,7 @@ void QDeclarativeLoader::componentComplete() /*! \qmlsignal Loader::onLoaded() - This handler is called when the \l status becomes Loader.Ready, or on successful + This handler is called when the \l status becomes \c Loader.Ready, or on successful initial load. */ diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index a68e664..c4956df 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -305,12 +305,12 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() /*! \internal \class QDeclarativeMouseArea - \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within Qml. + \brief The QDeclarativeMouseArea class provides a simple mouse handling abstraction for use within QML. All QDeclarativeItem derived classes can do mouse handling but the QDeclarativeMouseArea class exposes mouse handling data as properties and tracks flicking and dragging of the mouse. - A QDeclarativeMouseArea object can be instantiated in Qml using the tag \l MouseArea. + A QDeclarativeMouseArea object can be instantiated in QML using the tag \l MouseArea. */ QDeclarativeMouseArea::QDeclarativeMouseArea(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeMouseAreaPrivate), parent) diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index 18618ab..ad61bab 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -358,6 +358,7 @@ Column { positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Column. + \sa Row, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Column::add @@ -500,6 +501,8 @@ Row { width of a child depend on the position of a child, then the positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Row. + + \sa Column, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Row::add @@ -653,6 +656,8 @@ Grid { width or height of a child depend on the position of a child, then the positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Grid. + + \sa Flow, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Grid::add @@ -908,6 +913,7 @@ void QDeclarativeGrid::reportConflictingAnchors() positioner may exhibit strange behaviour. If you need to perform any of these actions, consider positioning the items without the use of a Flow. + \sa Grid, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition Flow::add diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 691cfa2..995e22a 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -65,55 +65,75 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \since 4.7 \inherits Item - \brief The Repeater item allows you to repeat an Item-based component using a model. + \brief The Repeater element allows you to repeat an Item-based component using a model. - The Repeater item is used to create a large number of - similar items. For each entry in the model, an item is instantiated - in a context seeded with data from the model. If the repeater will - be instantiating a large number of instances, it may be more efficient to - use one of Qt Declarative's \l {xmlViews}{view items}. + The Repeater element is used to create a large number of + similar items. Like other view elements, a Repeater has a \l model and a \l delegate: + for each entry in the model, the delegate is instantiated + in a context seeded with data from the model. A Repeater item is usually + enclosed in a positioner element such as \l Row or \l Column to visually + position the multiple delegate items created by the Repeater. - The model may be either an object list, a string list, a number or a Qt model. - In each case, the data element and the index is exposed to each instantiated - component. - - The index is always exposed as an accessible \c index property. - In the case of an object or string list, the data element (of type string - 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. + The following Repeater creates three instances of a \l Rectangle item within + a \l Row: + + \snippet doc/src/snippets/declarative/repeater.qml import + \codeline + \snippet doc/src/snippets/declarative/repeater.qml simple + + \image repeater-simple.png + + The \l model of a Repeater can be specified as a model object, a number, a string list + or an object list. If a model object is used, the + \l delegate can access the model roles as named properties, just as for view elements like + ListView and GridView. - The following example shows how to use the \c index property inside the instantiated - items: + The \l delegate can also access two additional properties: - \snippet doc/src/snippets/declarative/repeater-index.qml 0 - \image repeater-index.png + \list + \o \c index - the index of the delegate's item + \o \c modelData - the data element for the delegate, which is useful where the \l model is a string or object list + \endlist - The repeater could also use the \c modelData property to reference the data for a + Here is a Repeater that uses the \c index property inside the instantiated items: + + \table + \row + \o \snippet doc/src/snippets/declarative/repeater.qml index + \o \image repeater-index.png + \endtable + + Here is another Repeater that uses the \c modelData property to reference the data for a particular index: - \snippet doc/src/snippets/declarative/repeater-modeldata.qml 0 - \image repeater-modeldata.png + \table + \row + \o \snippet doc/src/snippets/declarative/repeater.qml modeldata + \o \image repeater-modeldata.png + \endtable 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 - blue rectangles. - - \snippet doc/src/snippets/declarative/repeater.qml 0 + the repeater's position in its parent stacking list. This allows + a Repeater to be used inside a layout. For example, the following Repeater's + items are stacked between a red rectangle and a blue rectangle: + + \snippet doc/src/snippets/declarative/repeater.qml layout \image repeater.png - The repeater instance continues to own all items it instantiates, even - if they are otherwise manipulated. It is illegal to manually remove an item - created by the Repeater. + A Repeater item owns all items it instantiates. Removing or dynamically destroying + an item created by a Repeater results in unpredictable behavior. - \note Repeater is Item-based, and cannot be used to repeat non-Item-derived objects. + Note that if a repeater is + required to instantiate a large number of items, it may be more efficient to + use other view elements such as ListView. + + \note Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. For example, it cannot be used to repeat QtObjects. \badcode Item { - //XXX illegal. Can't repeat QtObject as it doesn't derive from Item. + //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. Repeater { model: 10 QtObject {} @@ -149,7 +169,15 @@ QDeclarativeRepeater::~QDeclarativeRepeater() The model providing data for the repeater. - The model may be either an object list, a string list, a number or a Qt model. + This property can be set to any of the following: + + \list + \o A number that indicates the number of delegates to be created + \o A model (e.g. a ListModel item, or a QAbstractItemModel subclass) + \o A string list + \o An object list + \endlist + In each case, the data element and the index is exposed to each instantiated component. The index is always exposed as an accessible \c index property. In the case of an object or string list, the data element (of type string diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3b89ad9..c2e0d67 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -119,8 +119,6 @@ QSet<QUrl> QTextDocumentWithImageResources::errors; A Text item can display both plain and rich text. For example: \qml - import Qt 4.7 - Text { text: "Hello World!"; font.family: "Helvetica"; font.pointSize: 24; color: "red" } Text { text: "<b>Hello</b> <i>World!</i>" } \endqml @@ -128,10 +126,10 @@ QSet<QUrl> QTextDocumentWithImageResources::errors; \image declarative-text.png If height and width are not explicitly set, Text will attempt to determine how - much room is needed and set it accordingly. Unless \c wrapMode is set, it will always + much room is needed and set it accordingly. Unless \l wrapMode is set, it will always prefer width to height (all text will be placed on a single line). - The \c elide property can alternatively be used to fit a single line of + The \l elide property can alternatively be used to fit a single line of plain text to a set width. Note that the \l{Supported HTML Subset} is limited. Also, if the text contains @@ -163,7 +161,7 @@ QSet<QUrl> QTextDocumentWithImageResources::errors; The \c elide property can alternatively be used to fit a line of plain text to a set width. - A QDeclarativeText object can be instantiated in Qml using the tag \c Text. + A QDeclarativeText object can be instantiated in QML using the tag \c Text. */ QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent) : QDeclarativeItem(*(new QDeclarativeTextPrivate), parent) @@ -507,13 +505,11 @@ void QDeclarativeText::setVAlign(VAlignment align) wrap if an explicit width has been set. wrapMode can be one of: \list - \o Text.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width. - \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width. + \o Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l paintedWidth will exceed a set width. + \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l paintedWidth will exceed a set width. \o Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. \endlist - - The default is Text.NoWrap. */ QDeclarativeText::WrapMode QDeclarativeText::wrapMode() const { @@ -543,13 +539,13 @@ void QDeclarativeText::setWrapMode(WrapMode mode) Supported text formats are: \list - \o Text.AutoText + \o Text.AutoText (default) \o Text.PlainText \o Text.RichText \o Text.StyledText \endlist - The default is Text.AutoText. If the text format is Text.AutoText the text element + If the text format is \c Text.AutoText the text element will automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText(). diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index c086851..3b4f2a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -62,25 +62,28 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextEdit QDeclarativeTextEdit \since 4.7 - \brief The TextEdit item allows you to add editable formatted text to a scene. + \brief The TextEdit item displays multiple lines of editable formatted text. \inherits Item + The TextEdit item displays a block of editable, formatted text. + It can display both plain and rich text. For example: \qml TextEdit { - id: edit + width: 240 text: "<b>Hello</b> <i>World!</i>" - focus: true font.family: "Helvetica" font.pointSize: 20 color: "blue" - width: 240 + focus: true } \endqml \image declarative-textedit.gif + Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus. + Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific to a look-and-feel. For example, to add flickable scrolling that follows the cursor: @@ -96,7 +99,7 @@ TextEdit { You can translate between cursor positions (characters from the start of the document) and pixel points using positionAt() and positionToRectangle(). - \sa Text + \sa Text, TextInput */ /*! @@ -110,7 +113,7 @@ TextEdit { \image declarative-textedit.png - A QDeclarativeTextEdit object can be instantiated in Qml using the tag \c <TextEdit>. + A QDeclarativeTextEdit object can be instantiated in QML using the tag \c <TextEdit>. */ /*! @@ -206,7 +209,7 @@ QString QDeclarativeTextEdit::text() const Sets the font size in pixels. Using this function makes the font device dependent. - Use \c pointSize to set the size of the font in a device independent manner. + Use \l pointSize to set the size of the font in a device independent manner. */ /*! @@ -453,12 +456,22 @@ void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color) \qmlproperty enumeration TextEdit::horizontalAlignment \qmlproperty enumeration TextEdit::verticalAlignment - Sets the horizontal and vertical alignment of the text within the TextEdit items + Sets the horizontal and vertical alignment of the text within the TextEdit item's width and height. By default, the text is top-left aligned. - The valid values for \c horizontalAlignment are \c TextEdit.AlignLeft, \c TextEdit.AlignRight and - \c TextEdit.AlignHCenter. The valid values for \c verticalAlignment are \c TextEdit.AlignTop, \c TextEdit.AlignBottom - and \c TextEdit.AlignVCenter. + Valid values for \c horizontalAlignment are: + \list + \o TextEdit.AlignLeft (default) + \o TextEdit.AlignRight + \o TextEdit.AlignHCenter + \endlist + + Valid values for \c verticalAlignment are: + \list + \o TextEdit.AlignTop (default) + \o TextEdit.AlignBottom + \c TextEdit.AlignVCenter + \endlist */ QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::hAlign() const { @@ -529,8 +542,8 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode) /*! \qmlproperty real TextEdit::paintedWidth - Returns the width of the text, including width past the width - which is covered due to insufficient wrapping if WrapMode is set. + Returns the width of the text, including the width past the width + which is covered due to insufficient wrapping if \l wrapMode is set. */ qreal QDeclarativeTextEdit::paintedWidth() const { @@ -540,8 +553,8 @@ qreal QDeclarativeTextEdit::paintedWidth() const /*! \qmlproperty real TextEdit::paintedHeight - Returns the height of the text, including height past the height - which is covered due to there being more text than fits in the set height. + Returns the height of the text, including the height past the height + that is covered if the text does not fit within the set height. */ qreal QDeclarativeTextEdit::paintedHeight() const { @@ -567,10 +580,10 @@ QRectF QDeclarativeTextEdit::positionToRectangle(int pos) const /*! \qmlmethod int TextEdit::positionAt(x,y) - Returns the text position closest to pixel position (\a x,\a y). + Returns the text position closest to pixel position (\a x, \a y). Position 0 is before the first character, position 1 is after the first character - but before the second, and so on until position text.length, which is after all characters. + but before the second, and so on until position \l {text}.length, which is after all characters. */ int QDeclarativeTextEdit::positionAt(int x, int y) const { @@ -1082,7 +1095,7 @@ void QDeclarativeTextEdit::copy() /*! \qmlmethod TextEdit::paste() - Relaces the currently selected text by the contents of the system clipboard. + Replaces the currently selected text by the contents of the system clipboard. */ void QDeclarativeTextEdit::paste() { @@ -1395,7 +1408,7 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() the panels are automatically opened when TextEdit element gains focus. Input panels are always closed if no editor owns focus. - . You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. @@ -1446,7 +1459,7 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() the panels are automatically opened when TextEdit element gains focus. Input panels are always closed if no editor owns focus. - . You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c focusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 01b1447..ad7a3a7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -56,17 +56,20 @@ QT_BEGIN_NAMESPACE /*! \qmlclass TextInput QDeclarativeTextInput \since 4.7 - \brief The TextInput item allows you to add an editable line of text to a scene. + \brief The TextInput item displays an editable line of text. \inherits Item - TextInput can only display a single line of text, and can only display - plain text. However it can provide addition input constraints on the text. + The TextInput element displays a single line of editable plain text. - Input constraints include setting a QValidator, an input mask, or a - maximum input length. + TextInput is used to accept a line of text input. Input constraints + can be placed on a TextInput item (for example, through a \l validator or \l inputMask), + and setting \l echoMode to an appropriate value enables TextInput to be used for + a password input field. On Mac OS X, the Up/Down key bindings for Home/End are explicitly disabled. If you want such bindings (on any platform), you will need to construct them in QML. + + \sa TextEdit, Text */ QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent) : QDeclarativePaintedItem(*(new QDeclarativeTextInputPrivate), parent) @@ -558,7 +561,7 @@ void QDeclarativeTextInput::setAutoScroll(bool b) /*! \qmlclass IntValidator QIntValidator - This element provides a validator for integer values + This element provides a validator for integer values. */ /*! \qmlproperty int IntValidator::top @@ -601,10 +604,14 @@ void QDeclarativeTextInput::setAutoScroll(bool b) \qmlproperty enumeration DoubleValidator::notation This property holds the notation of how a string can describe a number. - The values for this property are DoubleValidator.StandardNotation or DoubleValidator.ScientificNotation. - If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part(i.e. 1.5E-2). + The possible values for this property are: + + \list + \o DoubleValidator.StandardNotation + \o DoubleValidator.ScientificNotation (default) + \endlist - By default, this property is set to DoubleValidator.ScientificNotation. + If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part (e.g. 1.5E-2). */ /*! diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index e0ee84f..aec84a6 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -523,7 +523,7 @@ void QDeclarativeWorkerScriptEngine::run() Messages can be passed between the new thread and the parent thread using \l sendMessage() and the \l {WorkerScript::onMessage}{onMessage()} handler. - Here is an example: + An example: \snippet doc/src/snippets/declarative/workerscript.qml 0 @@ -541,6 +541,9 @@ void QDeclarativeWorkerScriptEngine::run() called, triggering the \tt WorkerScript.onMessage() handler in \tt script.js. This in turn sends a reply message that is then received by the \tt onMessage() handler of \tt myWorker. + + \sa {declarative/threading/workerscript}{WorkerScript example}, + {declarative/threading/threadedlistmodel}{Threaded ListModel example} */ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) : QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true) diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 3c2e239..83bdb17 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -79,18 +79,27 @@ public: /*! \qmlclass FontLoader QDeclarativeFontLoader \since 4.7 - \brief This item allows using fonts by name or url. + \brief The FontLoader element allows fonts to be loaded by name or URL. - Example: + The FontLoader element is used to load fonts by name or URL. + + The \l status indicates when the font has been loaded, which is useful + for fonts loaded from remote sources. + + For example: \qml import Qt 4.7 - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } + Column { + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } - Text { text: "Fixed-size font"; font.family: fixedFont.name } - Text { text: "Fancy font"; font.family: webFont.name } + Text { text: "Fixed-size font"; font.family: fixedFont.name } + Text { text: "Fancy font"; font.family: webFont.name } + } \endqml + + \sa {declarative/text/fonts}{Fonts example} */ QDeclarativeFontLoader::QDeclarativeFontLoader(QObject *parent) : QObject(*(new QDeclarativeFontLoaderPrivate), parent) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 78a3207..ff83227 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -160,7 +160,7 @@ QDeclarativeListModelParser::ListInstruction *QDeclarativeListModelParser::ListM In addition, the WorkerScript cannot add any list data to the model. - \sa {qmlmodels}{Data Models}, WorkerScript, QtDeclarative + \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative */ diff --git a/src/declarative/util/qdeclarativesystempalette.cpp b/src/declarative/util/qdeclarativesystempalette.cpp index 6c62446..c334859 100644 --- a/src/declarative/util/qdeclarativesystempalette.cpp +++ b/src/declarative/util/qdeclarativesystempalette.cpp @@ -59,22 +59,25 @@ public: /*! \qmlclass SystemPalette QDeclarativeSystemPalette \since 4.7 - \brief The SystemPalette item gives access to the Qt palettes. - \sa QPalette + \brief The SystemPalette element provides access to the Qt palettes. - Example: - \qml - SystemPalette { id: myPalette; colorGroup: Qt.Active } + The SystemPalette element provides access to the Qt application + palettes. This provides information about the standard colors used + for application windows, buttons and other features. These colors + are grouped into three \e {color groups}: \c Active, \c Inactive, + and \c Disabled. See the QPalette documentation for details about + color groups and the properties provided by SystemPalette. - Rectangle { - width: 640; height: 480 - color: myPalette.window - Text { - anchors.fill: parent - text: "Hello!"; color: myPalette.windowText - } - } - \endqml + This can be used to color items in a way that provides a more + native look and feel. + + The following example creates a palette from the \c Active color + group and uses this to color the window and text items + appropriately: + + \snippet doc/src/snippets/declarative/systempalette.qml 0 + + \sa QPalette */ QDeclarativeSystemPalette::QDeclarativeSystemPalette(QObject *parent) : QObject(*(new QDeclarativeSystemPalettePrivate), parent) @@ -258,10 +261,15 @@ QColor QDeclarativeSystemPalette::highlightedText() const } /*! - \qmlproperty QDeclarativeSystemPalette::ColorGroup SystemPalette::colorGroup + \qmlproperty enumeration SystemPalette::colorGroup + + The color group of the palette. This can be one of: - The color group of the palette. It can be Active, Inactive or Disabled. - Active is the default. + \list + \o SystemPalette.Active (default) + \o SystemPalette.Inactive + \o SystemPalette.Disabled + \endlist \sa QPalette::ColorGroup */ diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 7a6a73f..ca21a0c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -196,9 +196,10 @@ public: static QPixmapCache::KeyData* getKeyData(QPixmapCache::Key *key); QList< QPair<QString,QPixmap> > allPixmaps() const; - void flushDetachedPixmaps(bool nt); + bool flushDetachedPixmaps(bool nt); private: + enum { soon_time = 10000, flush_time = 30000 }; int *keyArray; int theid; int ps; @@ -236,38 +237,44 @@ QPMCache::~QPMCache() cleaning-up, and to not cut down the size of the cache while the cache is in active use. - When the last pixmap has been deleted from the cache, kill the - timer so Qt won't keep the CPU from going into sleep mode. + When the last detached pixmap has been deleted from the cache, kill the + timer so Qt won't keep the CPU from going into sleep mode. Currently + the timer is not restarted when the pixmap becomes unused, but it does + restart once something else is added (i.e. the cache space is actually needed). + + Returns true if any were removed. */ -void QPMCache::flushDetachedPixmaps(bool nt) +bool QPMCache::flushDetachedPixmaps(bool nt) { int mc = maxCost(); setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); + bool any = false; QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin(); while (it != cacheKeys.end()) { if (!contains(it.value())) { releaseKey(it.value()); it = cacheKeys.erase(it); + any = true; } else { ++it; } } + + return any; } void QPMCache::timerEvent(QTimerEvent *) { bool nt = totalCost() == ps; - flushDetachedPixmaps(nt); - - if (!size()) { + if (!flushDetachedPixmaps(nt)) { killTimer(theid); theid = 0; } else if (nt != t) { killTimer(theid); - theid = startTimer(nt ? 10000 : 30000); + theid = startTimer(nt ? soon_time : flush_time); t = nt; } } @@ -315,7 +322,7 @@ bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) if (success) { cacheKeys.insert(key, cacheKey); if (!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } } else { @@ -331,7 +338,7 @@ QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if (!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } } else { @@ -352,7 +359,7 @@ bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if(!theid) { - theid = startTimer(30000); + theid = startTimer(flush_time); t = false; } const_cast<QPixmapCache::Key&>(key) = cacheKey; diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index ef99173..f30f758 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -93,7 +93,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -103,7 +103,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 300.0); QCOMPARE(rootItem->height(), 200.0); - QCOMPARE(viewer->view()->size(), QSize(300, 200)); + QTRY_COMPARE(viewer->view()->size(), QSize(300, 200)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -113,7 +113,7 @@ void tst_QDeclarativeViewer::orientation() QCOMPARE(rootItem->width(), 200.0); QCOMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); + QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height())); QCOMPARE(viewer->size(), viewer->sizeHint()); @@ -255,21 +255,20 @@ void tst_QDeclarativeViewer::resizing() viewer->setSizeToView(false); // size view to root object - rootItem->setWidth(100); + rootItem->setWidth(150); rootItem->setHeight(200); qApp->processEvents(); - QCOMPARE(rootItem->width(), 100.0); + QCOMPARE(rootItem->width(), 150.0); QCOMPARE(rootItem->height(), 200.0); - QCOMPARE(viewer->view()->size(), QSize(100, 200)); + QCOMPARE(viewer->view()->size(), QSize(150, 200)); QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(100, 200)); - QCOMPARE(viewer->size(), QSize(100, 200+viewer->menuBar()->height())); - QCOMPARE(viewer->size(), viewer->sizeHint()); + QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); + QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height())); // do not size root object to view - viewer->resize(QSize(150,250)); - QCOMPARE(rootItem->width(), 100.0); + viewer->resize(QSize(180,250)); + QCOMPARE(rootItem->width(), 150.0); QCOMPARE(rootItem->height(), 200.0); viewer->setSizeToView(true); @@ -284,10 +283,9 @@ void tst_QDeclarativeViewer::resizing() QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height())); QCOMPARE(viewer->size(), QSize(250, 350)); - QCOMPARE(viewer->size(), viewer->sizeHint()); // do not size view to root object - rootItem->setWidth(100); + rootItem->setWidth(150); rootItem->setHeight(200); QTRY_COMPARE(viewer->size(), QSize(250, 350)); } |