From 11ff483c564b8a2f5b3ef5e28230fbfc742a2cd2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> Date: Wed, 22 Oct 2014 16:32:59 +0200 Subject: [PATCH] TableViewStyle: Fix and document styleData.hasActiveFocus property The property has been present since 5.1 for rowDelegate and missing for itemDelegate. Also, the property was incorrectly bound to the table having active focus instead of the row. Change-Id: I43a93975dffd849b37cfee6363343f8aef57d11b Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> --- src/controls/Styles/Base/TableViewStyle.qml | 4 ++-- src/controls/Styles/Desktop/TableViewStyle.qml | 4 ++-- src/controls/TableView.qml | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/controls/Styles/Base/TableViewStyle.qml b/src/controls/Styles/Base/TableViewStyle.qml index ca4cc4288..e5e6db2fd 100644 --- a/src/controls/Styles/Base/TableViewStyle.qml +++ b/src/controls/Styles/Base/TableViewStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -110,7 +110,7 @@ ScrollViewStyle { */ property Component rowDelegate: Rectangle { height: Math.round(TextSingleton.implicitHeight * 1.2) - property color selectedColor: styleData.hasActiveFocus ? "#07c" : "#999" + property color selectedColor: control.activeFocus ? "#07c" : "#999" color: styleData.selected ? selectedColor : !styleData.alternate ? alternateBackgroundColor : backgroundColor } diff --git a/src/controls/Styles/Desktop/TableViewStyle.qml b/src/controls/Styles/Desktop/TableViewStyle.qml index 605c62d63..11f8ed54c 100644 --- a/src/controls/Styles/Desktop/TableViewStyle.qml +++ b/src/controls/Styles/Desktop/TableViewStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -82,7 +82,7 @@ ScrollViewStyle { visible: styleData.selected || styleData.alternate source: "image://__tablerow/" + (styleData.alternate ? "alternate_" : "") + (styleData.selected ? "selected_" : "") - + (styleData.hasActiveFocus ? "active" : "") + + (control.activeFocus ? "active" : "") height: Math.max(16, RowItemSingleton.implicitHeight) border.left: 4 ; border.right: 4 } diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index a10972531..df4c941fb 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -149,6 +149,7 @@ ScrollView { \li styleData.elideMode - the elide mode of the column \li styleData.textAlignment - the horizontal text alignment of the column \li styleData.pressed - true when the item is pressed (since QtQuick.Controls 1.3) + \li styleData.hasActiveFocus - true when the row has focus (since QtQuick.Controls 1.3) \endlist Example: @@ -179,6 +180,7 @@ ScrollView { \li styleData.alternate - true when the row uses the alternate background color \li styleData.selected - true when the row is currently selected \li styleData.row - the index of the row + \li styleData.hasActiveFocus - true when the row has focus \li styleData.pressed - true when the row is pressed (since QtQuick.Controls 1.3) \endlist @@ -761,7 +763,7 @@ ScrollView { property QtObject styleData: QtObject { readonly property bool alternate: (index + rowCount) % 2 === 1 readonly property bool selected: false - readonly property bool hasActiveFocus: root.activeFocus + readonly property bool hasActiveFocus: false readonly property bool pressed: false } readonly property var model: listView.model @@ -924,7 +926,7 @@ ScrollView { readonly property int row: rowitem.rowIndex readonly property bool alternate: rowitem.alternate readonly property bool selected: rowitem.itemSelected - readonly property bool hasActiveFocus: root.activeFocus + readonly property bool hasActiveFocus: rowitem.activeFocus readonly property bool pressed: rowitem.rowIndex === mousearea.pressedRow } readonly property var model: listView.model @@ -955,6 +957,7 @@ ScrollView { readonly property int elideMode: columnItem.elideMode readonly property int textAlignment: columnItem.horizontalAlignment readonly property bool selected: rowitem.itemSelected + readonly property bool hasActiveFocus: rowitem.activeFocus readonly property bool pressed: row === mousearea.pressedRow && column === mousearea.pressedColumn readonly property color textColor: rowitem.itemTextColor readonly property string role: columnItem.role -- GitLab