diff options
author | Liang Qi <liang.qi@qt.io> | 2016-06-16 07:09:47 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-16 07:09:47 +0200 |
commit | bbec66f60ce8d1828c4f08b8975a031212009beb (patch) | |
tree | 81ccbac5a0dd2527d305f8242f72e1bce4952c41 /src | |
parent | 4593f43a932aa513c16c793e23bc3309ea52b2d5 (diff) | |
parent | 6b0fc95d094258d968b57f48c03f10be2fe8ac26 (diff) |
Merge remote-tracking branch 'origin/5.7.0' into 5.7
Change-Id: I5954150d06519d7058716124580ee7fe73afb810
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/plugins.qmltypes | 168 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontainer.cpp | 120 |
2 files changed, 117 insertions, 171 deletions
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index 95f5aa15..e661056c 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // 'qmlplugindump -nonrelocatable QtQuick.Controls 2.0 -merge ..\templates\plugins.qmltypes -dependencies dep.json' Module { - dependencies: ["QtQuick.Templates 2.0", "QtQuick.Window 2.2"] + dependencies: ["QtQuick.Templates 2.0", "QtQuick.Window 2.2", "QtQuick 2.7"] Component { name: "QQuickAbstractAnimation" prototype: "QObject" @@ -750,172 +750,6 @@ Module { Signal { name: "implicitHeightChanged2"; revision: 1 } } Component { - name: "QQuickItem" - defaultProperty: "data" - prototype: "QObject" - Enum { - name: "TransformOrigin" - values: { - "TopLeft": 0, - "Top": 1, - "TopRight": 2, - "Left": 3, - "Center": 4, - "Right": 5, - "BottomLeft": 6, - "Bottom": 7, - "BottomRight": 8 - } - } - Property { name: "parent"; type: "QQuickItem"; isPointer: true } - Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } - Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } - Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } - Property { name: "x"; type: "double" } - Property { name: "y"; type: "double" } - Property { name: "z"; type: "double" } - Property { name: "width"; type: "double" } - Property { name: "height"; type: "double" } - Property { name: "opacity"; type: "double" } - Property { name: "enabled"; type: "bool" } - Property { name: "visible"; type: "bool" } - Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } - Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } - Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } - Property { name: "state"; type: "string" } - Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } - Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } - Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "baselineOffset"; type: "double" } - Property { name: "clip"; type: "bool" } - Property { name: "focus"; type: "bool" } - Property { name: "activeFocus"; type: "bool"; isReadonly: true } - Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } - Property { name: "rotation"; type: "double" } - Property { name: "scale"; type: "double" } - Property { name: "transformOrigin"; type: "TransformOrigin" } - Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } - Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } - Property { name: "smooth"; type: "bool" } - Property { name: "antialiasing"; type: "bool" } - Property { name: "implicitWidth"; type: "double" } - Property { name: "implicitHeight"; type: "double" } - Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } - Signal { - name: "childrenRectChanged" - Parameter { type: "QRectF" } - } - Signal { - name: "baselineOffsetChanged" - Parameter { type: "double" } - } - Signal { - name: "stateChanged" - Parameter { type: "string" } - } - Signal { - name: "focusChanged" - Parameter { type: "bool" } - } - Signal { - name: "activeFocusChanged" - Parameter { type: "bool" } - } - Signal { - name: "activeFocusOnTabChanged" - revision: 1 - Parameter { type: "bool" } - } - Signal { - name: "parentChanged" - Parameter { type: "QQuickItem"; isPointer: true } - } - Signal { - name: "transformOriginChanged" - Parameter { type: "TransformOrigin" } - } - Signal { - name: "smoothChanged" - Parameter { type: "bool" } - } - Signal { - name: "antialiasingChanged" - Parameter { type: "bool" } - } - Signal { - name: "clipChanged" - Parameter { type: "bool" } - } - Signal { - name: "windowChanged" - revision: 1 - Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } - } - Method { name: "update" } - Method { - name: "grabToImage" - revision: 2 - type: "bool" - Parameter { name: "callback"; type: "QJSValue" } - Parameter { name: "targetSize"; type: "QSize" } - } - Method { - name: "grabToImage" - revision: 2 - type: "bool" - Parameter { name: "callback"; type: "QJSValue" } - } - Method { - name: "contains" - type: "bool" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapToGlobal" - revision: 7 - type: "QPointF" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapFromGlobal" - revision: 7 - type: "QPointF" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapFromItem" - Parameter { type: "QQmlV4Function"; isPointer: true } - } - Method { - name: "mapToItem" - Parameter { type: "QQmlV4Function"; isPointer: true } - } - Method { name: "forceActiveFocus" } - Method { - name: "forceActiveFocus" - Parameter { name: "reason"; type: "Qt::FocusReason" } - } - Method { - name: "nextItemInFocusChain" - revision: 1 - type: "QQuickItem*" - Parameter { name: "forward"; type: "bool" } - } - Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } - Method { - name: "childAt" - type: "QQuickItem*" - Parameter { name: "x"; type: "double" } - Parameter { name: "y"; type: "double" } - } - } - Component { name: "QQuickItemDelegate" defaultProperty: "data" prototype: "QQuickAbstractButton" diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index ff5b694b..bbb56e4b 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -50,7 +50,86 @@ QT_BEGIN_NAMESPACE \ingroup qtquickcontrols2-containers \brief A container control base type. - Container is the base type of container-like user interface controls. + Container is the base type of container-like user interface controls that + allow dynamic insertion and removal of items. + + \section2 Using Containers + + Container provides API to \l {addItem}{add}, \l {insertItem}{insert}, + \l {moveItem}{move} and \l {removeItem}{remove} items dynamically. The + items in a container can be accessed using \l itemAt() or \l contentChildren. + + Most containers have a concept of a "current" item. The current item is + specified via the \l currentIndex property, and can be accessed using the + read-only \l currentItem property. + + The following example illustrates dynamic insertion of items to a \l TabBar, + which is one of the concrete implementations of Container. + + \code + Row { + TabBar { + id: tabBar + + currentIndex: 0 + width: parent.width - addButton.width + + TabButton { text: "TabButton" } + } + + Component { + id: tabButton + TabButton { text: "TabButton" } + } + + Button { + id: addButton + text: "+" + flat: true + onClicked: { + tabBar.addItem(tabButton.createObject(tabBar)) + console.log("added:", tabBar.itemAt(tabBar.count - 1)) + } + } + } + \endcode + + \section2 Implementing Containers + + Container does not provide any default visualization. It is used to implement + such containers as \l SwipeView and \l TabBar. When implementing a custom + container, the most important part of the API is \l contentModel, which provides + the contained items in a way that it can be used as a delegate model for item + views and repeaters. + + \code + Container { + id: container + + contentItem: ListView { + model: container.contentModel + snapMode: ListView.SnapOneItem + orientation: ListView.Horizontal + } + + Text { + text: "Page 1" + width: container.width + height: container.height + } + + Text { + text: "Page 2" + width: container.width + height: container.height + } + } + \endcode + + Notice how the sizes of the page items are set by hand. This is because the + example uses a plain Container, which does not make any assumptions on the + visual layout. It is typically not necessary to specify sizes for items in + concrete Container implementations, such as \l SwipeView and \l TabBar. \sa {Container Controls} */ @@ -391,6 +470,20 @@ void QQuickContainer::removeItem(int index) \readonly This property holds the content model of items. + + The content model is provided for visualization purposes. It can be assigned + as a model to a content item that presents the contents of the container. + + \code + Container { + id: container + contentItem: ListView { + model: container.contentModel + } + } + \endcode + + \sa contentData, contentChildren */ QVariant QQuickContainer::contentModel() const { @@ -404,7 +497,14 @@ QVariant QQuickContainer::contentModel() const This property holds the list of content data. - \sa Item::data + The list contains all objects that have been declared in QML as children + of the container, and also items that have been dynamically added or + inserted using the \l addItem() and \l insertItem() methods, respectively. + + \note Unlike \c contentChildren, \c contentData does include non-visual QML + objects. It is not re-ordered when items are inserted or moved. + + \sa Item::data, contentChildren */ QQmlListProperty<QObject> QQuickContainer::contentData() { @@ -421,7 +521,14 @@ QQmlListProperty<QObject> QQuickContainer::contentData() This property holds the list of content children. - \sa Item::children + The list contains all items that have been declared in QML as children + of the container, and also items that have been dynamically added or + inserted using the \l addItem() and \l insertItem() methods, respectively. + + \note Unlike \c contentData, \c contentChildren does not include non-visual + QML objects. It is re-ordered when items are inserted or moved. + + \sa Item::children, contentData */ QQmlListProperty<QQuickItem> QQuickContainer::contentChildren() { @@ -436,7 +543,9 @@ QQmlListProperty<QQuickItem> QQuickContainer::contentChildren() /*! \qmlproperty int QtQuick.Controls::Container::currentIndex - This property holds the index of the current item in the container. + This property holds the index of the current item. + + \sa currentItem */ int QQuickContainer::currentIndex() const { @@ -457,8 +566,11 @@ void QQuickContainer::setCurrentIndex(int index) /*! \qmlproperty Item QtQuick.Controls::Container::currentItem + \readonly This property holds the current item. + + \sa currentIndex */ QQuickItem *QQuickContainer::currentItem() const { |