From e0c8035c3db5c3c68602a90a5addbb2d48c0733f Mon Sep 17 00:00:00 2001
From: J-P Nurmi <jpnurmi@digia.com>
Date: Mon, 27 May 2013 18:34:37 +0200
Subject: [PATCH] Rename controlState to styleData

Change-Id: I06c9f4b0d9b6eef7d2ca608827eee982d8d97027
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
---
 examples/quick/controls/tableview/main.qml |   8 +-
 src/controls/SpinBox.qml                   |   2 +-
 src/private/Control.qml                    |   4 +-
 src/private/ScrollBar.qml                  |   2 +-
 src/styles/Base/ProgressBarStyle.qml       |   2 +-
 src/styles/Base/ScrollViewStyle.qml        | 127 ++++++++++++---------
 src/styles/Base/SpinBoxStyle.qml           |   2 +-
 src/styles/Desktop/ScrollViewStyle.qml     |   4 +-
 src/styles/Desktop/SpinBoxStyle.qml        |  16 +--
 tests/auto/controls/data/tst_spinbox.qml   |  20 ++--
 10 files changed, 100 insertions(+), 87 deletions(-)

diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml
index 02c7e6f02..3ecf5ddb3 100644
--- a/examples/quick/controls/tableview/main.qml
+++ b/examples/quick/controls/tableview/main.qml
@@ -104,9 +104,9 @@ Window {
 
     ListModel {
         id: nestedModel
-        ListElement{controlState:  ListElement { description: "Core" ; color:"#ffaacc"}}
-        ListElement{controlState: ListElement { description: "Second" ; color:"#ffccaa"}}
-        ListElement{controlState: ListElement { description: "Third" ; color:"#ffffaa"}}
+        ListElement{content: ListElement { description: "Core" ; color:"#ffaacc"}}
+        ListElement{content: ListElement { description: "Second" ; color:"#ffccaa"}}
+        ListElement{content: ListElement { description: "Third" ; color:"#ffffaa"}}
     }
 
     ListModel {
@@ -176,7 +176,7 @@ Window {
                     anchors.margins: 12
 
                     TableViewColumn {
-                        role: "controlState"
+                        role: "content"
                         title: "Text and Color"
                         width: 220
                     }
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index ec563afca..4db67c8d2 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -148,7 +148,7 @@ Control {
     /*! \internal */
     property alias __text: input.text
 
-    __controlState: QtObject {
+    __styleData: QtObject {
         readonly property bool upEnabled: value != maximumValue;
         readonly property alias upHovered: mouseUp.containsMouse
         readonly property alias upPressed: mouseUp.pressed
diff --git a/src/private/Control.qml b/src/private/Control.qml
index d518adb25..109e37ed7 100644
--- a/src/private/Control.qml
+++ b/src/private/Control.qml
@@ -71,7 +71,7 @@ FocusScope {
     activeFocusOnTab: false
 
     /*! \internal */
-    property alias __controlState: styleLoader.controlState
+    property alias __styleData: styleLoader.styleData
 
     Loader {
         id: panelLoader
@@ -82,7 +82,7 @@ FocusScope {
             id: styleLoader
             sourceComponent: style
             property Item __control: root
-            property QtObject controlState: null
+            property QtObject styleData: null
             onStatusChanged: {
                 if (status === Loader.Error)
                     console.error("Failed to load Style for", root)
diff --git a/src/private/ScrollBar.qml b/src/private/ScrollBar.qml
index ad26d249a..2f8e80bc5 100644
--- a/src/private/ScrollBar.qml
+++ b/src/private/ScrollBar.qml
@@ -75,7 +75,7 @@ Item {
         sourceComponent: __style ? __style.__scrollbar : null
         onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root)
         property alias __control: scrollbar
-        property QtObject controlState: QtObject {
+        property QtObject __styleData: QtObject {
             readonly property alias horizontal: internal.horizontal
             readonly property alias upPressed: scrollbar.upPressed
             readonly property alias downPressed: scrollbar.downPressed
diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml
index 1d7c98a81..c93a63565 100644
--- a/src/styles/Base/ProgressBarStyle.qml
+++ b/src/styles/Base/ProgressBarStyle.qml
@@ -89,7 +89,7 @@ PaddedStyle {
     /*! This property holds the visible contents of the progress bar
         You can access the Slider through the \c control property.
 
-        For convenience, you can also access the readonly property \c controlState.progress
+        For convenience, you can also access the readonly property \c styleData.progress
         which provides the current progress as a \c real in the range [0-1]
     */
     padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 }
diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml
index 8bf5a120c..b1fe789f1 100644
--- a/src/styles/Base/ScrollViewStyle.qml
+++ b/src/styles/Base/ScrollViewStyle.qml
@@ -95,9 +95,11 @@ PaddedStyle {
     /*! This component controls the appearance of the
         scroll bar background.
 
+        You can access the following state properties:
+
         \list
-        \li property bool hovered
-        \li property bool horizontal
+        \li property bool styleData.hovered
+        \li property bool styleData.horizontal
         \endlist
     */
 
@@ -109,26 +111,28 @@ PaddedStyle {
             anchors.fill: parent
             color: "#ddd"
             border.color: "#aaa"
-            anchors.rightMargin: horizontal ? -2 : -1
-            anchors.leftMargin: horizontal ? -2 : 0
-            anchors.topMargin: horizontal ? 0 : -2
-            anchors.bottomMargin: horizontal ? -1 : -2
+            anchors.rightMargin: styleData.horizontal ? -2 : -1
+            anchors.leftMargin: styleData.horizontal ? -2 : 0
+            anchors.topMargin: styleData.horizontal ? 0 : -2
+            anchors.bottomMargin: styleData.horizontal ? -1 : -2
         }
     }
 
     /*! This component controls the appearance of the
         scroll bar handle.
 
+        You can access the following state properties:
+
         \list
-        \li property bool hovered
-        \li property bool pressed
-        \li property bool horizontal
+        \li property bool styleData.hovered
+        \li property bool styleData.pressed
+        \li property bool styleData.horizontal
         \endlist
     */
 
     property Component handle: BorderImage{
-        opacity: pressed ? 0.5 : hovered ? 1 : 0.8
-        source: "images/scrollbar-handle-" + (horizontal ? "horizontal" : "vertical") + ".png"
+        opacity: styleData.pressed ? 0.5 : styleData.hovered ? 1 : 0.8
+        source: "images/scrollbar-handle-" + (styleData.horizontal ? "horizontal" : "vertical") + ".png"
         border.left: 2
         border.top: 2
         border.right: 2
@@ -141,9 +145,9 @@ PaddedStyle {
         You can access the following state properties:
 
         \list
-        \li property bool hovered
-        \li property bool pressed
-        \li property bool horizontal
+        \li property bool styleData.hovered
+        \li property bool styleData.pressed
+        \li property bool styleData.horizontal
         \endlist
     */
     property Component incrementControl: Rectangle {
@@ -161,13 +165,13 @@ PaddedStyle {
                 border.color: "#88ffffff"
             }
             Image {
-                source: horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
+                source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png"
                 anchors.centerIn: parent
                 opacity: control.enabled ? 0.7 : 0.5
             }
             gradient: Gradient {
-                GradientStop {color: pressed ? "lightgray" : "white" ; position: 0}
-                GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1}
+                GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
+                GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
             }
         }
     }
@@ -175,10 +179,12 @@ PaddedStyle {
     /*! This component controls the appearance of the
         scroll bar decrement button.
 
+        You can access the following state properties:
+
         \list
-        \li property bool hovered
-        \li property bool pressed
-        \li property bool horizontal
+        \li property bool styleData.hovered
+        \li property bool styleData.pressed
+        \li property bool styleData.horizontal
         \endlist
     */
     property Component decrementControl: Rectangle {
@@ -186,10 +192,10 @@ PaddedStyle {
         implicitHeight: 16
         Rectangle {
             anchors.fill: parent
-            anchors.topMargin: horizontal ? 0 : -1
-            anchors.leftMargin:  horizontal ? -1 : 0
-            anchors.bottomMargin: horizontal ? -1 : 0
-            anchors.rightMargin: horizontal ? 0 : -1
+            anchors.topMargin: styleData.horizontal ? 0 : -1
+            anchors.leftMargin:  styleData.horizontal ? -1 : 0
+            anchors.bottomMargin: styleData.horizontal ? -1 : 0
+            anchors.rightMargin: styleData.horizontal ? 0 : -1
             color: "lightgray"
             Rectangle {
                 anchors.fill: parent
@@ -198,15 +204,15 @@ PaddedStyle {
                 border.color: "#88ffffff"
             }
             Image {
-                source: horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
+                source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png"
                 anchors.centerIn: parent
-                anchors.verticalCenterOffset: horizontal ? 0 : -1
-                anchors.horizontalCenterOffset: horizontal ? -1 : 0
+                anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1
+                anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0
                 opacity: control.enabled ? 0.7 : 0.5
             }
             gradient: Gradient {
-                GradientStop {color: pressed ? "lightgray" : "white" ; position: 0}
-                GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1}
+                GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0}
+                GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1}
             }
             border.color: "#aaa"
         }
@@ -217,14 +223,13 @@ PaddedStyle {
         id: panel
         property string activeControl: ""
         property bool scrollToClickPosition: true
-        property var controlStateRef: controlState
 
-        implicitWidth: controlState.horizontal ? 200 : bg.implicitWidth
-        implicitHeight: controlState.horizontal ? bg.implicitHeight : 200
+        implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth
+        implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200
 
         function pixelMetric(arg) {
             if (arg === "scrollbarExtent")
-                return (controlState.horizontal ? bg.height : bg.width);
+                return (__styleData.horizontal ? bg.height : bg.width);
             return 0;
         }
 
@@ -240,7 +245,7 @@ PaddedStyle {
             else if (itemIsHit(decrementLoader, argX, argY))
                 return "down";
             else if (itemIsHit(bg, argX, argY)) {
-                if (controlState.horizontal && argX < handleControl.x || !controlState.horizontal && argY < handleControl.y)
+                if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y)
                     return "upPage"
                 else
                     return "downPage"
@@ -253,7 +258,7 @@ PaddedStyle {
             if (arg === "handle") {
                 return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height);
             } else if (arg === "groove") {
-                if (controlState.horizontal) {
+                if (__styleData.horizontal) {
                     return Qt.rect(incrementLoader.width - handleOverlap,
                                    0,
                                    __control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2),
@@ -278,49 +283,57 @@ PaddedStyle {
             anchors.top: parent.top
             anchors.left: parent.left
             sourceComponent: decrementControl
-            property bool hovered: activeControl === "up"
-            property bool pressed: controlState.upPressed
-            property bool horizontal: controlState.horizontal
+            property QtObject styleData: QtObject {
+                readonly property bool hovered: activeControl === "up"
+                readonly property bool pressed: __styleData.upPressed
+                readonly property bool horizontal: __styleData.horizontal
+            }
         }
 
         Loader {
             id: bg
-            anchors.top: controlState.horizontal ? undefined : incrementLoader.bottom
-            anchors.bottom: controlState.horizontal ? undefined : decrementLoader.top
-            anchors.left:  controlState.horizontal ? incrementLoader.right : undefined
-            anchors.right: controlState.horizontal ? decrementLoader.left : undefined
+            anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom
+            anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top
+            anchors.left:  __styleData.horizontal ? incrementLoader.right : undefined
+            anchors.right: __styleData.horizontal ? decrementLoader.left : undefined
             sourceComponent: scrollBarBackground
-            property bool horizontal: controlState.horizontal
-            property bool hovered: activeControl !== "none"
+            property QtObject styleData: QtObject {
+                readonly property bool horizontal: __styleData.horizontal
+                readonly property bool hovered: activeControl !== "none"
+            }
         }
 
         Loader {
             id: decrementLoader
-            anchors.bottom: controlState.horizontal ? undefined : parent.bottom
-            anchors.right: controlState.horizontal ? parent.right : undefined
+            anchors.bottom: __styleData.horizontal ? undefined : parent.bottom
+            anchors.right: __styleData.horizontal ? parent.right : undefined
             sourceComponent: incrementControl
-            property bool hovered: activeControl === "down"
-            property bool pressed: controlState.downPressed
-            property bool horizontal: controlState.horizontal
+            property QtObject styleData: QtObject {
+                readonly property bool hovered: activeControl === "down"
+                readonly property bool pressed: __styleData.downPressed
+                readonly property bool horizontal: __styleData.horizontal
+            }
         }
 
         property var flickableItem: control.flickableItem
-        property int extent: Math.max(minimumHandleLength, controlState.horizontal ?
+        property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
                                           (flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width :
                                           (flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height)
 
         Loader {
             id: handleControl
-            height: controlState.horizontal ? implicitHeight : extent
-            width: controlState.horizontal ? extent : implicitWidth
+            height: __styleData.horizontal ? implicitHeight : extent
+            width: __styleData.horizontal ? extent : implicitWidth
             anchors.top: bg.top
             anchors.left: bg.left
-            anchors.topMargin: controlState.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
-            anchors.leftMargin: controlState.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
+            anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height)
+            anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0
             sourceComponent: handle
-            property bool hovered: activeControl === "handle"
-            property bool pressed: controlState.handlePressed
-            property bool horizontal: controlState.horizontal
+            property QtObject styleData: QtObject {
+                readonly property bool hovered: activeControl === "handle"
+                readonly property bool pressed: __styleData.handlePressed
+                readonly property bool horizontal: __styleData.horizontal
+            }
         }
     }
 
diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml
index 9b37fe5bb..6280ea93e 100644
--- a/src/styles/Base/SpinBoxStyle.qml
+++ b/src/styles/Base/SpinBoxStyle.qml
@@ -129,7 +129,7 @@ PaddedStyle {
     /*! \internal */
     property Component panel: Item {
         id: styleitem
-        implicitWidth: controlState.contentWidth + 26
+        implicitWidth: styleData.contentWidth + 26
         implicitHeight: backgroundLoader.implicitHeight
 
         property color foregroundColor: spinboxStyle.textColor
diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml
index 42c9fc3e2..d504c59b6 100644
--- a/src/styles/Desktop/ScrollViewStyle.qml
+++ b/src/styles/Desktop/ScrollViewStyle.qml
@@ -74,11 +74,11 @@ PaddedStyle {
         elementType: "scrollbar"
         hover: activeControl != "none"
         activeControl: "none"
-        sunken: __control.upPressed | __control.downPressed | __control.handlePressed
+        sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed
         minimum: __control.minimumValue
         maximum: __control.maximumValue
         value: __control.value
-        horizontal: __control.orientation === Qt.Horizontal
+        horizontal: __styleData.horizontal
         enabled: __control.enabled
 
         implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent")
diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml
index 2da3db1f2..e8012a690 100644
--- a/src/styles/Desktop/SpinBoxStyle.qml
+++ b/src/styles/Desktop/SpinBoxStyle.qml
@@ -114,17 +114,17 @@ PaddedStyle {
             id: styleitem
             elementType: "spinbox"
             anchors.fill: parent
-            sunken: (controlState.downEnabled && controlState.downPressed) || (controlState.upEnabled && controlState.upPressed)
-            hover: controlState.containsMouse
+            sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed)
+            hover: styleData.containsMouse
             hints: control.styleHints
             hasFocus: control.activeFocus
             enabled: control.enabled
-            value: (controlState.upPressed ? 1 : 0)           |
-                   (controlState.downPressed ? 1<<1 : 0) |
-                   (controlState.upEnabled ? (1<<2) : 0)      |
-                   (controlState.downEnabled ? (1<<3) : 0)
-            contentWidth: controlState.contentWidth
-            contentHeight: controlState.contentHeight
+            value: (styleData.upPressed ? 1 : 0)           |
+                   (styleData.downPressed ? 1<<1 : 0) |
+                   (styleData.upEnabled ? (1<<2) : 0)      |
+                   (styleData.downEnabled ? (1<<3) : 0)
+            contentWidth: styleData.contentWidth
+            contentHeight: styleData.contentHeight
         }
     }
 }
diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml
index 9cc0662e7..4e701cc06 100644
--- a/tests/auto/controls/data/tst_spinbox.qml
+++ b/tests/auto/controls/data/tst_spinbox.qml
@@ -178,22 +178,22 @@ Item {
             setCoordinates(spinbox)
 
             mouseMove(spinbox, mainCoord.x, mainCoord.y)
-            compare(spinbox.__controlState.containsMouse, true)
-            compare(spinbox.__controlState.upHovered, false)
-            compare(spinbox.__controlState.downHovered, false)
+            compare(spinbox.__styleData.containsMouse, true)
+            compare(spinbox.__styleData.upHovered, false)
+            compare(spinbox.__styleData.downHovered, false)
 
             mouseMove(spinbox.parent, upCoord.x, upCoord.y)
-            compare(spinbox.__controlState.upHovered, true)
-            compare(spinbox.__controlState.downHovered, false)
+            compare(spinbox.__styleData.upHovered, true)
+            compare(spinbox.__styleData.downHovered, false)
 
             mouseMove(spinbox, downCoord.x, downCoord.y)
-            compare(spinbox.__controlState.upHovered, false)
-            compare(spinbox.__controlState.downHovered, true)
+            compare(spinbox.__styleData.upHovered, false)
+            compare(spinbox.__styleData.downHovered, true)
 
             mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2)
-            compare(spinbox.__controlState.containsMouse, false)
-            compare(spinbox.__controlState.upHovered, false)
-            compare(spinbox.__controlState.downHovered, false)
+            compare(spinbox.__styleData.containsMouse, false)
+            compare(spinbox.__styleData.upHovered, false)
+            compare(spinbox.__styleData.downHovered, false)
             spinbox.destroy()
         }
 
-- 
GitLab