summaryrefslogtreecommitdiff
path: root/tests/auto/controls/data/tableview
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2013-06-18 15:00:52 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-19 17:38:23 +0200
commitd66245f1e8ebee65354a37c30d421a115dd0e383 (patch)
treede900f667c17b9f125340094d4513961bf6c8dd1 /tests/auto/controls/data/tableview
parentb0f3a519289511ad89b99a449176a1aff72d2a99 (diff)
downloadqtquickcontrols-d66245f1e8ebee65354a37c30d421a115dd0e383.tar.gz
TableView: let delegates handle mouse events
Includes auto tests. Task-number: QTBUG-31206 Change-Id: I683363f70f7e360cc70f84fd460cbde5e70a61af Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/auto/controls/data/tableview')
-rw-r--r--tests/auto/controls/data/tableview/table_buttondelegate.qml (renamed from tests/auto/controls/data/tableview/table_delegate.qml)37
-rw-r--r--tests/auto/controls/data/tableview/table_delegate2.qml61
-rw-r--r--tests/auto/controls/data/tableview/table_delegate3.qml77
-rw-r--r--tests/auto/controls/data/tableview/table_mousearea.qml77
4 files changed, 236 insertions, 16 deletions
diff --git a/tests/auto/controls/data/tableview/table_delegate.qml b/tests/auto/controls/data/tableview/table_buttondelegate.qml
index 82b08ba5..d5702524 100644
--- a/tests/auto/controls/data/tableview/table_delegate.qml
+++ b/tests/auto/controls/data/tableview/table_buttondelegate.qml
@@ -43,30 +43,35 @@ import QtQuick.Controls 1.0
TableView {
id: table
- model: [{"text": "text1"}, {"text": "text2"}, {"text": "text3"}]
- property var test: 0
- property bool activatedTest: false
- onActivated: activatedTest = true
+ headerVisible: false
+ model: ["text1", "text2", "text3"]
+
+ property int tableClickCount: 0
+ property int buttonPressCount: 0
+ property int buttonReleaseCount: 0
+ property int buttonClickCount: 0
+
+ onClicked: ++clickCount
TableViewColumn {
- title: "Text"
- role: "text"
width: 100
}
- headerDelegate: Text {
+ rowDelegate: Item {
height: 40
- text: styleData.value
+ width: parent.width
}
- itemDelegate: Text {
+ itemDelegate: Button {
+ height: 40
width: parent.width
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- text: styleData.value !== undefined ? styleData.value : ""
- color: styleData.textColor
- MouseArea {
- anchors.fill: parent
- onClicked: table.test = 1
+ text: styleData.value
+ activeFocusOnPress: true
+ onClicked: ++table.buttonClickCount
+ onPressedChanged: {
+ if (pressed)
+ ++table.buttonPressCount
+ else
+ ++table.buttonReleaseCount
}
}
}
diff --git a/tests/auto/controls/data/tableview/table_delegate2.qml b/tests/auto/controls/data/tableview/table_delegate2.qml
new file mode 100644
index 00000000..b55814ee
--- /dev/null
+++ b/tests/auto/controls/data/tableview/table_delegate2.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+TableView {
+ id: table
+ model: 5
+ property bool test: false
+ headerVisible: false
+
+ TableViewColumn {
+ width: 100
+ title: 'Title'
+ role: "text"
+ delegate: Item {
+ Button {
+ text: 'Click'
+ onClicked: test = true
+ }
+ }
+ }
+}
diff --git a/tests/auto/controls/data/tableview/table_delegate3.qml b/tests/auto/controls/data/tableview/table_delegate3.qml
new file mode 100644
index 00000000..8ff37481
--- /dev/null
+++ b/tests/auto/controls/data/tableview/table_delegate3.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+TableView {
+ id: table
+ model: 5
+ property bool _pressed: false
+ property bool _clicked: false
+ property bool _released: false
+ property bool _doubleClicked: false
+
+ headerVisible: false
+
+ function clearTestData() {
+ _pressed = false
+ _released = false
+ _clicked = false
+ _doubleClicked = false
+ }
+
+ TableViewColumn {
+ id: column1
+ title: 'Title'
+ role: "text"
+ delegate: Text {
+ text: "left"
+ MouseArea {
+ acceptedButtons: Qt.LeftButton
+ anchors.fill: parent
+ onPressed: table._pressed = true
+ onClicked: table._clicked = true
+ onReleased: table._released = true
+ onDoubleClicked: table._doubleClicked = true
+ }
+ }
+ }
+}
diff --git a/tests/auto/controls/data/tableview/table_mousearea.qml b/tests/auto/controls/data/tableview/table_mousearea.qml
new file mode 100644
index 00000000..32f74e04
--- /dev/null
+++ b/tests/auto/controls/data/tableview/table_mousearea.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick Controls module 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 Digia Plc and its Subsidiary(-ies) 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.1
+import QtQuick.Controls 1.0
+
+TableView {
+ width:400
+ id: table
+ model: [{"text": "text1"}, {"text": "text2"}, {"text": "text3"}]
+ property bool _pressed: false
+ property bool _clicked: false
+ property bool _released: false
+ property bool _doubleClicked: false
+
+ headerVisible: false
+
+ function clearTestData() {
+ _pressed = false
+ _released = false
+ _clicked = false
+ _doubleClicked = false
+ }
+
+ TableViewColumn {
+ id: column1
+ title: 'Text'
+ role: "text"
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ acceptedButtons: Qt.RightButton
+ onPressed: table._pressed = true
+ onClicked: table._clicked = true
+ onReleased: table._released = true
+ onDoubleClicked: table._doubleClicked = true
+ }
+}