From ab936c26d8246a1e8d1e80ec6be737449fb9770b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 3 May 2013 19:04:41 +0200 Subject: SplitView: rename 'expanding' to 'fillWidth' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename variables to the new Layout terminology, to ease future maintenance/understanding of the code. Change-Id: I619f62a0280238fafefe261fae3f00eb575bb699 Reviewed-by: Jan Arve Sæther --- src/controls/SplitView.qml | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/controls/SplitView.qml') diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index 7d013bdd..f1251399 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -53,29 +53,29 @@ import QtQuick.Controls.Private 1.0 as Private SplitView is a control that lays out items horizontally or vertically with a draggable splitter between each item. - There will always be one (and only one) item in the SplitView that is 'expanding'. - Being expanding means that the item will get all the remaining space when other - items have been laid out according to their own width and height. - By default, the last visible child of the SplitView will be expanding, but - this can be changed by setting Layout.fillWidth to \c true. - As the expanding item will automatically be resized to fit the extra space, it - will ignore explicit assignments to width and height. + There will always be one (and only one) item in the SplitView that has \l {Layout}{Layout.fillWidth} + set to \c true (or Layout.fillHeight, if orientation is Qt.Vertical). This means that the + item will get all leftover space when other items have been laid out. + By default, the last visible child of the SplitView will have this set, but + it can be changed by explicitly setting fillWidth to \c true on another item. + As the fillWidth item will automatically be resized to fit the extra space, explicit assignments + to width and height will be ignored (but Layout.minimumWidth and Layout.maximumWidth will still be respected). A handle can belong to the item either on the left or top side, or on the right or bottom side: \list - \li If the expanding item is to the right: the handle belongs to the left item. - \li if the expanding item is on the left: the handle belongs to the right item. + \li If the fillWidth item is to the right: the handle belongs to the left item. + \li if the fillWidth item is on the left: the handle belongs to the right item. \endlist This will again control which item gets resized when the user drags a handle, and which handle gets hidden when an item is told to hide. - SplitView supports setting attached Layout properties on child items, which means that you + SplitView supports setting attached \l Layout properties on child items, which means that you can control minimumWidth, minimumHeight, maximumWidth and maximumHeight (in addition to fillWidth/fillHeight) for each child. Example: - To create a SplitView with three items, and let the center item be expanding, one + To create a SplitView with three items, and let the center item get superfluous space, one could do the following: \qml @@ -165,7 +165,7 @@ Item { readonly property string implicitSize: horizontal ? "implicitWidth" : "implicitHeight" readonly property string implicitOtherSize: horizontal ? "implicitHeight" : "implicitWidth" - property int expandingIndex: -1 + property int fillIndex: -1 property bool updateLayoutGuard: true function init() @@ -185,17 +185,17 @@ Item { item.Layout.minimumWidthChanged.connect(d.updateLayout) item.Layout.maximumHeightChanged.connect(d.updateLayout) item.Layout.minimumHeightChanged.connect(d.updateLayout) - item.visibleChanged.connect(d.updateExpandingIndex) - item.Layout.fillWidthChanged.connect(d.updateExpandingIndex) - item.Layout.fillHeightChanged.connect(d.updateExpandingIndex) + item.visibleChanged.connect(d.updateFillIndex) + item.Layout.fillWidthChanged.connect(d.updateFillIndex) + item.Layout.fillHeightChanged.connect(d.updateFillIndex) } d.calculateImplicitSize() d.updateLayoutGuard = false - d.updateExpandingIndex() + d.updateFillIndex() } - function updateExpandingIndex() + function updateFillIndex() { if (!lastItem.visible) return @@ -205,7 +205,7 @@ Item { break; } - d.expandingIndex = i + d.fillIndex = i d.updateLayout() } @@ -238,7 +238,7 @@ Item { return value } - function accumulatedSize(firstIndex, lastIndex, includeExpandingMinimum) + function accumulatedSize(firstIndex, lastIndex, includeFillItemMinimum) { // Go through items and handles, and // calculate their acummulated width. @@ -246,9 +246,9 @@ Item { for (var i=firstIndex; i= handleIndex) ? 0 : 1)].visible + visible: __items[handleIndex + ((d.fillIndex >= handleIndex) ? 0 : 1)].visible sourceComponent: handleDelegate onWidthChanged: d.updateLayout() onHeightChanged: d.updateLayout() @@ -345,7 +345,7 @@ Item { function moveHandle() { // Moving the handle means resizing an item. Which one, - // left or right, depends on where the expanding item is. + // left or right, depends on where the fillItem is. // 'updateLayout' will be overridden in case new width violates max/min. // 'updateLayout' will be triggered when an item changes width. if (d.updateLayoutGuard) @@ -355,7 +355,7 @@ Item { var leftEdge, rightEdge, newWidth, leftStopX, rightStopX var i - if (d.expandingIndex > handleIndex) { + if (d.fillIndex > handleIndex) { // Resize item to the left. // Ensure that the handle is not crossing other handles. So // find the first visible handle to the left to determine the left edge: @@ -422,15 +422,15 @@ Item { Item { id: lastItem - onVisibleChanged: d.updateExpandingIndex() + onVisibleChanged: d.updateFillIndex() } Component.onDestruction: { for (var i=0; i