diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-03-30 16:34:15 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-04-01 12:23:03 +0000 |
commit | 335b1fff26ef0c13e1cd1fe697c70d7b8f1a8139 (patch) | |
tree | 3f890be1b88ff1ca4383a3fcd6472cf985d61df0 | |
parent | cb3b2d7dab2f99a559c8dd6d89d43bb81978805d (diff) |
Improve documentation for delegate controls
- Add "Delegate Controls" doc page. This will list future delegate
controls, such as CheckDelegate, RadioDelegate and SwitchDelegate.
- Add GIF for ItemDelegate.
Change-Id: If8c66ab2178185f96d190f29ef7815beaa6e8d68
Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r-- | src/imports/controls/doc/images/qtquickcontrols-itemdelegate.gif | bin | 0 -> 12468 bytes | |||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-delegates.qdoc | 48 | ||||
-rw-r--r-- | src/templates/qquickitemdelegate.cpp | 4 | ||||
-rw-r--r-- | tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml | 64 | ||||
-rw-r--r-- | tests/manual/gifs/tst_gifs.cpp | 35 |
5 files changed, 150 insertions, 1 deletions
diff --git a/src/imports/controls/doc/images/qtquickcontrols-itemdelegate.gif b/src/imports/controls/doc/images/qtquickcontrols-itemdelegate.gif Binary files differnew file mode 100644 index 00000000..7f8a2af8 --- /dev/null +++ b/src/imports/controls/doc/images/qtquickcontrols-itemdelegate.gif diff --git a/src/imports/controls/doc/src/qtquickcontrols2-delegates.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-delegates.qdoc new file mode 100644 index 00000000..40c52996 --- /dev/null +++ b/src/imports/controls/doc/src/qtquickcontrols2-delegates.qdoc @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtquickcontrols2-delegates.html + \title Delegate Controls + + Qt Quick Controls 2 offers a selection of controls that are used as + delegates in views. + + \annotatedlist qtlabscontrols-delegates + + Each type of delegate has its own specific target use case. The following + sections offer guidelines for choosing the appropriate type of delegate, + depending on the use case. + + \section1 ItemDelegate Control + + \image qtquickcontrols-itemdelegate.gif + + \l ItemDelegate presents a checkable control that can be pressed and + clicked by the user. +*/ + diff --git a/src/templates/qquickitemdelegate.cpp b/src/templates/qquickitemdelegate.cpp index 8ae9b535..32efca9a 100644 --- a/src/templates/qquickitemdelegate.cpp +++ b/src/templates/qquickitemdelegate.cpp @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE \inqmlmodule Qt.labs.controls \brief A standard view item that can be used in various views and controls. + \image qtquickcontrols-itemdelegate.gif + ItemDelegate presents a standard view item. It can be used as a delegate in various views and controls, such as \l ListView and \l ComboBox. @@ -59,7 +61,7 @@ QT_BEGIN_NAMESPACE \labs - \sa {Customizing ItemDelegate} + \sa {Customizing ItemDelegate}, {Delegate Controls} */ QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent) : QQuickAbstractButton(parent) diff --git a/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml b/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml new file mode 100644 index 00000000..413cd085 --- /dev/null +++ b/tests/manual/gifs/data/qtquickcontrols-itemdelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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.6 +import QtQuick.Window 2.0 +import Qt.labs.controls 1.0 + +Window { + width: column.implicitWidth + height: column.implicitHeight + visible: true + + property var delegate: repeater.count > 0 ? repeater.itemAt(0) : null + + Column { + id: column + + Repeater { + id: repeater + model: ["Option 1", "Option 2", "Option 3"] + delegate: ItemDelegate { + checkable: true + text: modelData + } + } + } +} diff --git a/tests/manual/gifs/tst_gifs.cpp b/tests/manual/gifs/tst_gifs.cpp index ed5d2956..bc096ccb 100644 --- a/tests/manual/gifs/tst_gifs.cpp +++ b/tests/manual/gifs/tst_gifs.cpp @@ -60,6 +60,8 @@ private slots: void swipeDelegate_data(); void swipeDelegate(); void swipeDelegateBehind(); + void delegates_data(); + void delegates(); private: void moveSmoothly(QQuickWindow *window, const QPoint &from, const QPoint &to, int movements, @@ -466,6 +468,39 @@ void tst_Gifs::swipeDelegateBehind() gifRecorder.waitForFinish(); } +void tst_Gifs::delegates_data() +{ + QTest::addColumn<QString>("name"); + QTest::newRow("ItemDelegate") << "itemdelegate"; +} + +void tst_Gifs::delegates() +{ + QFETCH(QString, name); + + GifRecorder gifRecorder; + gifRecorder.setDataDirPath(dataDirPath); + gifRecorder.setOutputDir(outputDir); + gifRecorder.setRecordingDuration(5); + gifRecorder.setQmlFileName(QString::fromLatin1("qtquickcontrols-%1.qml").arg(name)); + gifRecorder.setHighQuality(true); + + gifRecorder.start(); + + QQuickWindow *window = gifRecorder.window(); + QQuickItem *delegate = window->property("delegate").value<QQuickItem*>(); + QVERIFY(delegate); + + const QPoint delegateCenter(delegate->mapToScene(QPointF(delegate->width() / 2, delegate->height() / 2)).toPoint()); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 200); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 1000); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, delegateCenter, 400); + + gifRecorder.waitForFinish(); +} + QTEST_MAIN(tst_Gifs) #include "tst_gifs.moc" |