diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-03-18 15:40:52 +0100 |
---|---|---|
committer | Jari-Pekka Nurmi <jpnurmi@theqtcompany.com> | 2015-03-23 17:23:15 +0200 |
commit | 28a38f2b17c10fd3f62e769607e0ebbc73bfc8d4 (patch) | |
tree | 74a857cc8c9b022f99028edd75c5276fd850092d | |
parent | 86c80a68567a7019c151f830155fe0ac1560e03e (diff) |
Remove SplitView
SplitView is a very centric control. It won't be provided in Qt Quick
Controls 2.0, but maybe later when desktop support is re-considered.
Qt Quick Controls 2.0 will focus on embedded and mobile. SplitView is
still available in 1.x
Change-Id: I3bc1c7a525d4e1e75153205ca806dc4dcee7e601
Reviewed-by: Jari-Pekka Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/extras/extras.pri | 6 | ||||
-rw-r--r-- | src/extras/qquickabstractsplitview.cpp | 97 | ||||
-rw-r--r-- | src/extras/qquickabstractsplitview_p.h | 90 | ||||
-rw-r--r-- | src/imports/extras/SplitView.qml | 556 | ||||
-rw-r--r-- | src/imports/extras/extras.pro | 3 | ||||
-rw-r--r-- | src/imports/extras/qmldir | 1 | ||||
-rw-r--r-- | src/imports/extras/qtquickextras2plugin.cpp | 2 | ||||
-rw-r--r-- | tests/auto/extras/data/tst_splitview.qml | 332 |
8 files changed, 3 insertions, 1084 deletions
diff --git a/src/extras/extras.pri b/src/extras/extras.pri index 6b97f98c..6d82cdd0 100644 --- a/src/extras/extras.pri +++ b/src/extras/extras.pri @@ -1,9 +1,7 @@ INCLUDEPATH += $$PWD HEADERS += \ - $$PWD/qquickabstractdrawer_p.h \ - $$PWD/qquickabstractsplitview_p.h + $$PWD/qquickabstractdrawer_p.h SOURCES += \ - $$PWD/qquickabstractdrawer.cpp \ - $$PWD/qquickabstractsplitview.cpp + $$PWD/qquickabstractdrawer.cpp diff --git a/src/extras/qquickabstractsplitview.cpp b/src/extras/qquickabstractsplitview.cpp deleted file mode 100644 index cf20945e..00000000 --- a/src/extras/qquickabstractsplitview.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Extras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickabstractsplitview_p.h" - -#include <QtQuickControls/private/qquickabstractcontainer_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickAbstractSplitViewPrivate : public QQuickAbstractContainerPrivate -{ -public: - QQuickAbstractSplitViewPrivate() : orientation(Qt::Horizontal) { } - - bool resizing; - Qt::Orientation orientation; -}; - -QQuickAbstractSplitView::QQuickAbstractSplitView(QQuickItem *parent) : - QQuickAbstractContainer(*(new QQuickAbstractSplitViewPrivate), parent) -{ -} - -Qt::Orientation QQuickAbstractSplitView::orientation() const -{ - Q_D(const QQuickAbstractSplitView); - return d->orientation; -} - -void QQuickAbstractSplitView::setOrientation(Qt::Orientation orientation) -{ - Q_D(QQuickAbstractSplitView); - if (d->orientation != orientation) { - d->orientation = orientation; - emit orientationChanged(); - } -} - -bool QQuickAbstractSplitView::isResizing() const -{ - Q_D(const QQuickAbstractSplitView); - return d->resizing; -} - -void QQuickAbstractSplitView::setResizing(bool resizing) -{ - Q_D(QQuickAbstractSplitView); - if (d->resizing != resizing) { - d->resizing = resizing; - emit resizingChanged(); - } -} - -void QQuickAbstractSplitView::addItem(QQuickItem *item) -{ - // TODO - Q_UNUSED(item); -} - -void QQuickAbstractSplitView::componentComplete() -{ -} - -QT_END_NAMESPACE diff --git a/src/extras/qquickabstractsplitview_p.h b/src/extras/qquickabstractsplitview_p.h deleted file mode 100644 index 09d511fc..00000000 --- a/src/extras/qquickabstractsplitview_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Extras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKABSTRACTSPLITVIEW_P_H -#define QQUICKABSTRACTSPLITVIEW_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickExtras/private/qtquickextrasglobal_p.h> -#include <QtQuickControls/private/qquickabstractcontainer_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickAbstractSplitViewPrivate; - -class Q_QUICKEXTRAS_EXPORT QQuickAbstractSplitView : public QQuickAbstractContainer -{ - Q_OBJECT - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) - Q_PROPERTY(bool resizing READ isResizing NOTIFY resizingChanged FINAL) - -public: - explicit QQuickAbstractSplitView(QQuickItem *parent = Q_NULLPTR); - - Qt::Orientation orientation() const; - void setOrientation(Qt::Orientation orientation); - - bool isResizing() const; - void setResizing(bool resizing); - -public Q_SLOTS: - void addItem(QQuickItem *item); - -Q_SIGNALS: - void orientationChanged(); - void resizingChanged(); - -protected: - void componentComplete() Q_DECL_OVERRIDE; - -private: - Q_DISABLE_COPY(QQuickAbstractSplitView) - Q_DECLARE_PRIVATE(QQuickAbstractSplitView) -}; - -QT_END_NAMESPACE - -#endif // QQUICKABSTRACTSPLITVIEW_P_H diff --git a/src/imports/extras/SplitView.qml b/src/imports/extras/SplitView.qml deleted file mode 100644 index 56eb56f4..00000000 --- a/src/imports/extras/SplitView.qml +++ /dev/null @@ -1,556 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Extras module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 -import QtQuick.Controls.Private 1.0 as Private -import QtQuick.Window 2.1 - -/*! - \qmltype SplitView - \inqmlmodule QtQuick.Controls - \since 5.1 - \ingroup views - \brief Lays out items with a draggable splitter between each item. - - \image splitview.png - - 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 has \l{Layout::fillWidth}{Layout.fillWidth} - set to \c true (or \l{Layout::fillHeight}{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 \l{Layout::minimumWidth}{Layout.minimumWidth} and - \l{Layout::maximumWidth}{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 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 can set the following attached properties for each child: - \list - \li \l{Layout::minimumWidth}{Layout.minimumWidth} - \li \l{Layout::minimumHeight}{Layout.minimumHeight} - \li \l{Layout::maximumWidth}{Layout.maximumWidth} - \li \l{Layout::maximumHeight}{Layout.maximumHeight} - \li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child) - \li \l{Layout::fillHeight}{Layout.fillHeight} (\c true for only one child) - \endlist - - \note Please import QtQuick.Layout 1.0 in your QML file in order to use the Layout - attached properties inside SplitView. - - Example: - - To create a SplitView with three items, and let the center item get superfluous space, one - could do the following: - - \qml - SplitView { - anchors.fill: parent - orientation: Qt.Horizontal - - Rectangle { - width: 200 - Layout.maximumWidth: 400 - color: "lightblue" - Text { - text: "View 1" - anchors.centerIn: parent - } - } - Rectangle { - id: centerItem - Layout.minimumWidth: 50 - Layout.fillWidth: true - color: "lightgray" - Text { - text: "View 2" - anchors.centerIn: parent - } - } - Rectangle { - width: 200 - color: "lightgreen" - Text { - text: "View 3" - anchors.centerIn: parent - } - } - } - - \endqml -*/ - -Item { - id: root - - /*! - \qmlproperty enumeration SplitView::orientation - - This property holds the orientation of the SplitView. - The value can be either \c Qt.Horizontal or \c Qt.Vertical. - The default value is \c Qt.Horizontal. - */ - property int orientation: Qt.Horizontal - - /*! - This property holds the delegate that will be instantiated between each - child item. Inside the delegate the following properties are available: - - \table - \row \li readonly property bool styleData.index \li Specifies the index of the splitter handle. The handle - between the first and the second item will get index 0, - the next handle index 1 etc. - \row \li readonly property bool styleData.hovered \li The handle is being hovered. - \row \li readonly property bool styleData.pressed \li The handle is being pressed. - \row \li readonly property bool styleData.resizing \li The handle is being dragged. - \endtable - -*/ - property Component handleDelegate: Rectangle { - width: 1 - height: 1 - color: Qt.darker(pal.window, 1.5) - } - - /*! - This property is \c true when the user is resizing any of the items by - dragging on the splitter handles. - */ - property bool resizing: false - - /*! \internal */ - default property alias __contents: contents.data - /*! \internal */ - property alias __items: splitterItems.children - /*! \internal */ - property alias __handles: splitterHandles.children - - clip: true - Component.onCompleted: d.init() - onWidthChanged: d.updateLayout() - onHeightChanged: d.updateLayout() - onOrientationChanged: d.changeOrientation() - - /*! Add an item to the end of the view. - \since QtQuick.Controls 1.3 */ - function addItem(item) { - d.updateLayoutGuard = true - - d.addItem_impl(item) - - d.calculateImplicitSize() - d.updateLayoutGuard = false - d.updateFillIndex() - } - - SystemPalette { id: pal } - - QtObject { - id: d - - readonly property string leftMargin: horizontal ? "leftMargin" : "topMargin" - readonly property string topMargin: horizontal ? "topMargin" : "leftMargin" - readonly property string rightMargin: horizontal ? "rightMargin" : "bottomMargin" - - property bool horizontal: orientation == Qt.Horizontal - readonly property string minimum: horizontal ? "minimumWidth" : "minimumHeight" - readonly property string maximum: horizontal ? "maximumWidth" : "maximumHeight" - readonly property string otherMinimum: horizontal ? "minimumHeight" : "minimumWidth" - readonly property string otherMaximum: horizontal ? "maximumHeight" : "maximumWidth" - readonly property string offset: horizontal ? "x" : "y" - readonly property string otherOffset: horizontal ? "y" : "x" - readonly property string size: horizontal ? "width" : "height" - readonly property string otherSize: horizontal ? "height" : "width" - readonly property string implicitSize: horizontal ? "implicitWidth" : "implicitHeight" - readonly property string implicitOtherSize: horizontal ? "implicitHeight" : "implicitWidth" - - property int fillIndex: -1 - property bool updateLayoutGuard: true - - function extraMarginSize(item, other) { - if (typeof(other) === 'undefined') - other = false; - if (other === horizontal) - // vertical - return item.Layout.topMargin + item.Layout.bottomMargin - return item.Layout.leftMargin + item.Layout.rightMargin - } - - function addItem_impl(item) - { - // temporarily set fillIndex to new item - fillIndex = __items.length - if (splitterItems.children.length > 0) - handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1}) - - item.parent = splitterItems - - // should match disconnections in Component.onDestruction - item.widthChanged.connect(d.updateLayout) - item.heightChanged.connect(d.updateLayout) - item.Layout.maximumWidthChanged.connect(d.updateLayout) - item.Layout.minimumWidthChanged.connect(d.updateLayout) - item.Layout.maximumHeightChanged.connect(d.updateLayout) - item.Layout.minimumHeightChanged.connect(d.updateLayout) - item.Layout.leftMarginChanged.connect(d.updateLayout) - item.Layout.topMarginChanged.connect(d.updateLayout) - item.Layout.rightMarginChanged.connect(d.updateLayout) - item.Layout.bottomMarginChanged.connect(d.updateLayout) - item.visibleChanged.connect(d.updateFillIndex) - item.Layout.fillWidthChanged.connect(d.updateFillIndex) - item.Layout.fillHeightChanged.connect(d.updateFillIndex) - } - - function init() - { - for (var i=0; i<__contents.length; ++i) { - var item = __contents[i]; - if (!item.hasOwnProperty("x")) - continue - addItem_impl(item) - i-- // item was removed from list - } - - d.calculateImplicitSize() - d.updateLayoutGuard = false - d.updateFillIndex() - } - - function updateFillIndex() - { - if (lastItem.visible !== root.visible) - return - var policy = (root.orientation === Qt.Horizontal) ? "fillWidth" : "fillHeight" - for (var i=0; i<__items.length-1; ++i) { - if (__items[i].Layout[policy] === true) - break; - } - - d.fillIndex = i - d.updateLayout() - } - - function changeOrientation() - { - if (__items.length == 0) - return; - d.updateLayoutGuard = true - - // Swap width/height for items and handles: - for (var i=0; i<__items.length; ++i) { - var item = __items[i] - var tmp = item.x - item.x = item.y - item.y = tmp - tmp = item.width - item.width = item.height - item.height = tmp - - var handle = __handles[i] - if (handle) { - tmp = handle.x - handle.x = handle.y - handle.y = handle.x - tmp = handle.width - handle.width = handle.height - handle.height = tmp - } - } - - // Change d.horizontal explicit, since the binding will change too late: - d.horizontal = orientation == Qt.Horizontal - d.updateLayoutGuard = false - d.updateFillIndex() - } - - function calculateImplicitSize() - { - var implicitSize = 0 - var implicitOtherSize = 0 - - for (var i=0; i<__items.length; ++i) { - var item = __items[i]; - implicitSize += clampedMinMax(item[d.size], item.Layout[minimum], item.Layout[maximum]) + extraMarginSize(item) - var os = clampedMinMax(item[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum]) - implicitOtherSize = Math.max(implicitOtherSize, os) - - var handle = __handles[i] - if (handle) - implicitSize += handle[d.size] //### Can handles have margins?? - } - - root[d.implicitSize] = implicitSize - root[d.implicitOtherSize] = implicitOtherSize + extraMarginSize(item, true) - } - - function clampedMinMax(value, minimum, maximum) - { - if (value < minimum) - value = minimum - if (value > maximum) - value = maximum - return value - } - - function accumulatedSize(firstIndex, lastIndex, includeFillItemMinimum) - { - // Go through items and handles, and - // calculate their accummulated width. - var w = 0 - for (var i=firstIndex; i<lastIndex; ++i) { - - var item = __items[i] - if (item.visible || i == d.fillIndex) { - if (i !== d.fillIndex) - w += item[d.size] + extraMarginSize(item) - else if (includeFillItemMinimum && item.Layout[minimum] !== undefined) - w += item.Layout[minimum] + extraMarginSize(item) - } - - var handle = __handles[i] - if (handle && handle.visible) - w += handle[d.size] - } - return w - } - - function updateLayout() - { - // This function will reposition both handles and - // items according to the their width/height: - if (__items.length === 0) - return; - if (!lastItem.visible) - return; - if (d.updateLayoutGuard === true) - return - d.updateLayoutGuard = true - - // Ensure all items within their min/max: - for (var i=0; i<__items.length; ++i) { - if (i !== d.fillIndex) { - var item = __items[i]; - var clampedSize = clampedMinMax(item[d.size], item.Layout[d.minimum], item.Layout[d.maximum]) - if (clampedSize != item[d.size]) - item[d.size] = clampedSize - } - } - - // Set size of fillItem to remaining available space. - // Special case: If SplitView size is zero, we leave fillItem with the size - // it already got, and assume that SplitView ends up with implicit size as size: - if (root[d.size] != 0) { - var fillItem = __items[fillIndex] - var superfluous = root[d.size] - d.accumulatedSize(0, __items.length, false) - fillItem[d.size] = clampedMinMax(superfluous - extraMarginSize(fillItem), fillItem.Layout[minimum], fillItem.Layout[maximum]); - } - - // Position items and handles according to their width: - var lastVisibleItem, lastVisibleHandle, handle - var pos = 0; - for (i=0; i<__items.length; ++i) { - // Position item to the right of the previous visible handle: - item = __items[i]; - if (item.visible || i == d.fillIndex) { - pos += item.Layout[leftMargin] - item[d.offset] = pos - item[d.otherOffset] = item.Layout[topMargin] - item[d.otherSize] = clampedMinMax(root[otherSize], item.Layout[otherMinimum], item.Layout[otherMaximum]) - extraMarginSize(item, true) - lastVisibleItem = item - pos += Math.max(0, item[d.size]) + item.Layout[rightMargin] - } - - handle = __handles[i] - if (handle && handle.visible) { - handle[d.offset] = pos - handle[d.otherOffset] = 0 //### can handles have margins? - handle[d.otherSize] = root[d.otherSize] - lastVisibleHandle = handle - pos += handle[d.size] - } - } - - d.updateLayoutGuard = false - } - } - - Component { - id: handleLoader - Loader { - id: itemHandle - - property int __handleIndex: -1 - property QtObject styleData: QtObject { - readonly property int index: __handleIndex - readonly property alias hovered: mouseArea.containsMouse - readonly property alias pressed: mouseArea.pressed - readonly property bool resizing: mouseArea.drag.active - onResizingChanged: root.resizing = resizing - } - property bool resizeLeftItem: (d.fillIndex > __handleIndex) - visible: __items[__handleIndex + (resizeLeftItem ? 0 : 1)].visible - sourceComponent: handleDelegate - onWidthChanged: d.updateLayout() - onHeightChanged: d.updateLayout() - onXChanged: moveHandle() - onYChanged: moveHandle() - - MouseArea { - id: mouseArea - anchors.fill: parent - property real defaultMargin: Private.Settings.hasTouchScreen ? Screen.pixelDensity * 3.5 : 2 - anchors.leftMargin: (parent.width <= 1) ? -defaultMargin : 0 - anchors.rightMargin: (parent.width <= 1) ? -defaultMargin : 0 - anchors.topMargin: (parent.height <= 1) ? -defaultMargin : 0 - anchors.bottomMargin: (parent.height <= 1) ? -defaultMargin : 0 - hoverEnabled: true - drag.threshold: 0 - drag.target: parent - drag.axis: root.orientation === Qt.Horizontal ? Drag.XAxis : Drag.YAxis - cursorShape: root.orientation === Qt.Horizontal ? Qt.SplitHCursor : Qt.SplitVCursor - } - - function moveHandle() { - // Moving the handle means resizing an item. Which one, - // 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) - return - - var leftHandle, leftItem, rightItem, rightHandle - var leftEdge, rightEdge, newWidth, leftStopX, rightStopX - var i - - if (resizeLeftItem) { - // Ensure that the handle is not crossing other handles. So - // find the first visible handle to the left to determine the left edge: - leftEdge = 0 - for (i=__handleIndex-1; i>=0; --i) { - leftHandle = __handles[i] - if (leftHandle.visible) { - leftEdge = leftHandle[d.offset] + leftHandle[d.size] - break; - } - } - - // Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX - var min = d.accumulatedSize(__handleIndex+1, __items.length, true) - rightStopX = root[d.size] - min - itemHandle[d.size] - leftStopX = Math.max(leftEdge, itemHandle[d.offset]) - itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset])) - - newWidth = itemHandle[d.offset] - leftEdge - leftItem = __items[__handleIndex] - // The next line will trigger 'updateLayout': - leftItem[d.size] = newWidth - } else { - // Resize item to the right. - // Ensure that the handle is not crossing other handles. So - // find the first visible handle to the right to determine the right edge: - rightEdge = root[d.size] - for (i=__handleIndex+1; i<__handles.length; ++i) { - rightHandle = __handles[i] - if (rightHandle.visible) { - rightEdge = rightHandle[d.offset] - break; - } - } - - // Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX - min = d.accumulatedSize(0, __handleIndex+1, true) - leftStopX = min - itemHandle[d.size] - rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset]) - itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX)) - - newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size]) - rightItem = __items[__handleIndex+1] - // The next line will trigger 'updateLayout': - rightItem[d.size] = newWidth - } - } - } - } - - Item { - id: contents - visible: false - anchors.fill: parent - } - Item { - id: splitterItems - anchors.fill: parent - } - Item { - id: splitterHandles - anchors.fill: parent - } - - Item { - id: lastItem - onVisibleChanged: d.updateFillIndex() - } - - Component.onDestruction: { - for (var i=0; i<splitterItems.children.length; ++i) { - var item = splitterItems.children[i]; - - // should match connections in init() - item.widthChanged.disconnect(d.updateLayout) - item.heightChanged.disconnect(d.updateLayout) - item.Layout.maximumWidthChanged.disconnect(d.updateLayout) - item.Layout.minimumWidthChanged.disconnect(d.updateLayout) - item.Layout.maximumHeightChanged.disconnect(d.updateLayout) - item.Layout.minimumHeightChanged.disconnect(d.updateLayout) - item.visibleChanged.disconnect(d.updateFillIndex) - item.Layout.fillWidthChanged.disconnect(d.updateFillIndex) - item.Layout.fillHeightChanged.disconnect(d.updateFillIndex) - } - } -} diff --git a/src/imports/extras/extras.pro b/src/imports/extras/extras.pro index 18a2da18..b2615353 100644 --- a/src/imports/extras/extras.pro +++ b/src/imports/extras/extras.pro @@ -9,8 +9,7 @@ OTHER_FILES += \ qmldir QML_FILES = \ - Drawer.qml \ - SplitView.qml + Drawer.qml SOURCES += \ $$PWD/qtquickextras2plugin.cpp diff --git a/src/imports/extras/qmldir b/src/imports/extras/qmldir index 850e5a72..ec2bc05a 100644 --- a/src/imports/extras/qmldir +++ b/src/imports/extras/qmldir @@ -2,4 +2,3 @@ module QtQuick.Extras plugin qtquickextras2plugin classname QtQuickExtras2Plugin Drawer 2.0 Drawer.qml -SplitView 2.0 SplitView.qml diff --git a/src/imports/extras/qtquickextras2plugin.cpp b/src/imports/extras/qtquickextras2plugin.cpp index 08c62dc3..42f0d48e 100644 --- a/src/imports/extras/qtquickextras2plugin.cpp +++ b/src/imports/extras/qtquickextras2plugin.cpp @@ -37,7 +37,6 @@ #include <QtQml/qqmlextensionplugin.h> #include <QtQuickExtras/private/qquickabstractdrawer_p.h> -#include <QtQuickExtras/private/qquickabstractsplitview_p.h> QT_BEGIN_NAMESPACE @@ -53,7 +52,6 @@ public: void QtQuickExtras2Plugin::registerTypes(const char *uri) { qmlRegisterType<QQuickAbstractDrawer>(uri, 2, 0, "AbstractDrawer"); - qmlRegisterType<QQuickAbstractSplitView>(uri, 2, 0, "AbstractSplitView"); } QT_END_NAMESPACE diff --git a/tests/auto/extras/data/tst_splitview.qml b/tests/auto/extras/data/tst_splitview.qml deleted file mode 100644 index 23b8ae07..00000000 --- a/tests/auto/extras/data/tst_splitview.qml +++ /dev/null @@ -1,332 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.2 -import QtTest 1.0 -import QtQuick.Extras 2.0 -import QtQuick.Layouts 1.0 - -TestCase { - id: testCase - name: "Tests_SplitView" - when: windowShown - width: 400 - height: 500 - visible: true - property int handleWidth: 1 - property int handleHeight: 5 - - Component { - id: splitView - SplitView { - anchors.fill: parent - property alias item1: item1 - property alias item2: item2 - handleDelegate: Rectangle { width: handleWidth; height: handleHeight; color: "black" } - - Rectangle { - id: item1 - width: 100 - height: 80 - color: "red" - } - Rectangle { - id: item2 - width: 200 - height: 90 - color: "blue" - } - } - } - - Component { - id: splitView_hide_item_after_fillWidth - SplitView { - anchors.fill: parent - property alias item3: item3 - handleDelegate: Rectangle { width: handleWidth; height: handleHeight; color: "black" } - Rectangle { - color: "yellow" - Layout.fillWidth: true - } - Rectangle { - color: "green" - Layout.minimumWidth: 100 - visible: false - } - Rectangle { - id: item3 - color: "blue" - Layout.minimumWidth: 100 - } - } - } - - function test_01_splitView() { - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - waitForRendering(view) - verify (view.orientation === Qt.Horizontal) - compare (view.__items.length, 2) - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) - compare (view.item2.y, 0) - compare (view.item2.width, testCase.width - view.item1.width - handleWidth) - compare (view.item2.height, 500) - view.destroy() - } - - function test_02_splitView_initial_orientation_vertical() { - var view = splitView.createObject(testCase, {orientation:Qt.Vertical}); - verify (view !== null, "splitview created is null") - waitForRendering(view) - compare (view.orientation, Qt.Vertical) - compare (view.__items.length, 2) - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 400) - compare (view.item1.height, 80) - compare (view.item2.x, 0) - compare (view.item2.y, view.item1.y + view.item1.height + handleHeight) - compare (view.item2.width, 400) - compare (view.item2.height, testCase.height - view.item1.height - handleHeight) - view.destroy() - } - - function test_03_orientation_change() { - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - waitForRendering(view) - verify (view.orientation === Qt.Horizontal) - - view.orientation = Qt.Vertical - verify (view.orientation === Qt.Vertical) - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 400) - compare (view.item1.height, 100) - compare (view.item2.x, 0) - // We use handleWidth rather than handleHeight, since the layout is just flipped: - compare (view.item2.y, view.item1.y + view.item1.height + handleWidth) - compare (view.item2.width, 400) - compare (view.item2.height, testCase.height - view.item1.height - handleWidth) - - view.orientation = Qt.Horizontal - verify (view.orientation === Qt.Horizontal) - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) - compare (view.item2.y, 0) - compare (view.item2.width, testCase.width - view.item1.width - handleWidth) - compare (view.item2.height, 500) - view.destroy() - } - - function test_04_hide_item() { - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - waitForRendering(view) - verify (view.item1.visible) - verify (view.item2.visible) - view.item1.visible = false - verify (view.item1.visible === false) - - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - compare (view.item2.x, 0) - compare (view.item2.y, 0) - compare (view.item2.width, testCase.width) - compare (view.item2.height, 500) - view.destroy() - } - - function test_05_hide_fillWidth_item() { - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - waitForRendering(view) - verify (view.item1.visible) - verify (view.item2.visible) - view.item2.visible = false - verify (view.item2.visible === false) - - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) - compare (view.item2.y, 0) - compare (view.item2.width, testCase.width - view.item1.width - handleWidth) - compare (view.item2.height, 500) - view.destroy() - } - - function test_hide_item_after_fillWidth() { - // QTBUG-33448 - var view = splitView_hide_item_after_fillWidth.createObject(testCase); - verify (view !== null, "splitview created is null") - waitForRendering(view) - compare (view.item3.x, view.width - view.item3.width) - view.destroy() - } - - Component { - id: item_to_add_dynamically - Rectangle { - width: 50 - height: 100 - color: "yellow" - } - } - - function test_dynamic_item_add() { - // QTBUG-35281 - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - verify (view.orientation === Qt.Horizontal) - waitForRendering(view) - - var item3 = item_to_add_dynamically.createObject() - view.addItem(item3) - // reset item2 width - view.item2.width = 200 - waitForRendering(view) - - compare (view.__items.length, 3) - - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - - compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) - compare (view.item2.y, 0) - compare (view.item2.width, 200) - compare (view.item2.height, 500) - - compare (item3.x, view.item2.x + view.item2.width + handleWidth) - compare (item3.y, 0) - compare (item3.width, testCase.width - view.item2.width - view.item1.width - (handleWidth*2)) - compare (item3.height, 500) - - view.destroy() - } - - function test_dynamic_item_add_fillWidth() { - var view = splitView.createObject(testCase); - verify (view !== null, "splitview created is null") - verify (view.orientation === Qt.Horizontal) - view.item2.Layout.fillWidth = true - waitForRendering(view) - - var item3 = item_to_add_dynamically.createObject() - view.addItem(item3) - waitForRendering(view) - - compare (view.__items.length, 3) - - compare (view.item1.x, 0) - compare (view.item1.y, 0) - compare (view.item1.width, 100) - compare (view.item1.height, 500) - - compare (view.item2.x, view.item1.x + view.item1.width + handleWidth) - compare (view.item2.y, 0) - compare (view.item2.width, testCase.width - view.item1.width - item3.width - (handleWidth*2)) - compare (view.item2.height, 500) - - compare (item3.x, view.item2.x + view.item2.width + handleWidth) - compare (item3.y, 0) - compare (item3.width, 50) - compare (item3.height, 500) - - view.destroy() - } - - Component { - id: splitViewMargins - SplitView { - anchors.fill: parent - property alias item1: item1 - property alias item2: item2 - handleDelegate: Rectangle { width: handleWidth; height: handleHeight; color: "black" } - - Rectangle { - id: item1 - width: 100 - height: 80 - color: "red" - Layout.margins: 3 - } - Rectangle { - id: item2 - width: 200 - height: 90 - color: "blue" - Layout.margins: 7 - Layout.fillWidth: true - } - } - } - - function test_item_margins() { - var view = splitViewMargins.createObject(testCase); - verify (view !== null, "splitview created is null") - verify (view.orientation === Qt.Horizontal) - compare(view.implicitWidth, 100 + 3*2 + 1 + 200 + 7*2) - waitForRendering(view) - - compare(view.item1.width, 100) - - compare(view.item2.width, testCase.width - 100 - (3*2) - handleWidth - (7*2)) - compare(view.item2.height, testCase.height - 7*2) - - view.item2.Layout.rightMargin = 0 - compare(view.item2.width, testCase.width - 100 - 3*2 - handleWidth - 7) - - view.destroy() - } -} |