aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/stateseditor/stateslist.qml
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2010-12-08 16:46:25 +0100
committerMarco Bubke <marco.bubke@nokia.com>2010-12-08 17:28:50 +0100
commit562d0c5fbd5a6581a9efe539047d1b8651d421c8 (patch)
tree2c6dd7fb2cfa1dd642fa082025b16864e118f5c2 /src/plugins/qmldesigner/components/stateseditor/stateslist.qml
parentfabf76d202984d1bd93d7e4d82d4a90de27743d0 (diff)
QmlDesigner: Refactor states editor
Reviewed-By: Thomas Hartmann
Diffstat (limited to 'src/plugins/qmldesigner/components/stateseditor/stateslist.qml')
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateslist.qml48
1 files changed, 18 insertions, 30 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml
index 2a552c32bb..19b6bfb068 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateslist.qml
+++ b/src/plugins/qmldesigner/components/stateseditor/stateslist.qml
@@ -3,28 +3,18 @@ import Qt 4.7
Rectangle {
id: root
- property int currentStateIndex : 0
+ property int currentStateInternalId : 0
signal createNewState
- signal deleteState(int index)
+ signal deleteState(int nodeId)
signal duplicateCurrentState
signal startRenaming
color: "#4f4f4f";
property color colorAlpha: "#994f4f4f";
- function adjustCurrentStateIndex() {
- if (currentStateIndex >= statesEditorModel.count)
- currentStateIndex = statesEditorModel.count-1;
- }
-
Connections {
target: statesEditorModel
- onCountChanged: adjustCurrentStateIndex()
- }
-
- Connections {
- target: statesEditorModel
- onChangedToState: root.currentStateIndex = n;
+ onChangedToState: root.currentStateInternalId = n;
}
signal unFocus
@@ -33,9 +23,9 @@ Rectangle {
hoverEnabled:true
onExited: root.unFocus();
}
- onCurrentStateIndexChanged: {
- if (currentStateIndex <= 0)
- currentStateIndex = 0;
+ onCurrentStateInternalIdChanged: {
+ if (currentStateInternalId <= 0)
+ currentStateInternalId = 0;
else
unFocus();
@@ -97,7 +87,7 @@ Rectangle {
height: img.height + txt.height + 29 //(index==0?29:25)
//y:(index==0?0:4)
- property bool isCurrentState: root.currentStateIndex == index;
+ property bool isCurrentState: root.currentStateInternalId == nodeId;
onXChanged: scrollBarAdjuster.adjustScrollBar();
onIsCurrentStateChanged: scrollBarAdjuster.adjustScrollBar();
@@ -115,7 +105,7 @@ Rectangle {
Connections {
target: root
- onStartRenaming: if (root.currentStateIndex == index) startRenaming();
+ onStartRenaming: if (root.currentStateInternalId == index) startRenaming();
}
function startRenaming() {
@@ -160,7 +150,7 @@ Rectangle {
anchors.fill: container
onClicked: {
root.unFocus();
- root.currentStateIndex = index;
+ root.currentStateInternalId = nodeId;
}
}
@@ -184,7 +174,7 @@ Rectangle {
anchors.topMargin: 2
anchors.horizontalCenter: textLimits.horizontalCenter
id: txt
- color: root.currentStateIndex==index ? "white" : "#E1E1E1";
+ color: root.currentStateInternalId==nodeId ? "white" : "#E1E1E1";
text: stateName
width:parent.width
elide:Qt.ElideMiddle
@@ -205,9 +195,9 @@ Rectangle {
id: txtRegion
anchors.fill:parent
onClicked: {
- if (root.currentStateIndex != index)
+ if (root.currentStateInternalId != nodeId)
root.unFocus();
- root.currentStateIndex = index;
+ root.currentStateInternalId = nodeId;
}
onDoubleClicked: if (index!=0) {
startRenaming();
@@ -233,7 +223,7 @@ Rectangle {
function unFocus() {
if (visible) {
visible=false;
- statesEditorModel.renameState(index, stateNameInput.text);
+ statesEditorModel.renameState(nodeId, stateNameInput.text);
}
}
@@ -273,7 +263,7 @@ Rectangle {
onAccepted: {
if (stateNameEditor.visible) {
stateNameEditor.visible = false;
- statesEditorModel.renameState(index,text);
+ statesEditorModel.renameState(nodeId,text);
}
}
}
@@ -285,7 +275,7 @@ Rectangle {
Item {
id: removeState
- visible: (index != 0 && root.currentStateIndex==index)
+ visible: (index != 0 && root.currentStateInternalId==nodeId)
anchors.right: parent.right
anchors.top: parent.top
@@ -372,7 +362,7 @@ Rectangle {
onClicked: {
root.unFocus();
- root.deleteState(index);
+ root.deleteState(nodeId);
horizontalScrollbar.contentSizeDecreased();
}
onPressed: {parent.state="Pressed"}
@@ -569,12 +559,10 @@ Rectangle {
onClicked: {
// force close textinput
root.unFocus();
- if (root.currentStateIndex == 0)
root.createNewState(); //create new state
- else
- root.duplicateCurrentState(); //duplicate current state
+
// select the new state
- root.currentStateIndex = statesEditorModel.count - 1;
+ // root.currentStateInternalId = statesEditorModel.count - 1;
// this should happen automatically
if (floatingNewStateBox.visible)