brmbar v3 ItemEdit: Split to row items, add basic state machine

This commit is contained in:
Petr Baudis 2012-09-28 20:12:50 +02:00
parent a69a1e171b
commit 592211bb51

View file

@ -11,6 +11,7 @@ Item {
property variant info: ""
property string barcode: ""
state: "normal"
BarcodeInput {
color: "#00ff00" /* just for debugging */
@ -28,14 +29,22 @@ Item {
}
}
Text {
id: item_name
Item {
id: name_row
visible: page.state == "normal" || page.state == "name_edit"
x: 65
y: 166
width: 537
width: 774
height: 60
Text {
id: item_name
x: 0
y: 0
width: 534
height: 60
color: "#ffff7c"
text: parent.name
text: page.name
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
@ -43,18 +52,28 @@ Item {
BarButton {
id: item_name_edit
x: 599
y: 166
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: "Edit"
text: page.state == "name_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "name_edit") page.state = "normal"; else page.state = "name_edit"; }
}
}
Item {
id: buyprice_row
visible: page.state == "normal" || page.state == "buyprice_edit"
x: 65
y: page.state == "buyprice_edit" ? 166 : 239;
width: 774
height: 60
Text {
id: item_buyprice_label
x: 65
y: 236
x: 0
y: 0
height: 60
width: 200
color: "#ffffff"
@ -65,8 +84,8 @@ Item {
Text {
id: item_buyprice
x: 265
y: 236
x: 200
y: 0
height: 60
width: 248
color: "#ffff7c"
@ -78,18 +97,28 @@ Item {
BarButton {
id: item_buyprice_edit
x: 599
y: 236
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: "Edit"
text: page.state == "buyprice_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "buyprice_edit") page.state = "normal"; else page.state = "buyprice_edit"; }
}
}
Item {
id: sellprice_row
visible: page.state == "normal" || page.state == "sellprice_edit"
x: 65
y: page.state == "sellprice_edit" ? 166 : 306;
width: 774
height: 60
Text {
id: item_sellprice_label
x: 65
y: 306
x: 0
y: 0
height: 60
width: 200
color: "#ffffff"
@ -100,8 +129,8 @@ Item {
Text {
id: item_sellprice
x: 265
y: 306
x: 200
y: 0
height: 60
width: 248
color: "#ffff7c"
@ -113,18 +142,28 @@ Item {
BarButton {
id: item_sellprice_edit
x: 599
y: 306
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: "Edit"
text: page.state == "sellprice_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "sellprice_edit") page.state = "normal"; else page.state = "sellprice_edit"; }
}
}
Item {
id: balance_row
visible: page.state == "normal" || page.state == "balance_edit"
x: 65
y: page.state == "balance_edit" ? 166 : 376;
width: 774
height: 60
Text {
id: item_balance_label
x: 65
y: 376
x: 0
y: 0
height: 60
width: 200
color: "#ffffff"
@ -135,8 +174,8 @@ Item {
Text {
id: item_balance
x: 265
y: 376
x: 200
y: 0
height: 60
width: 248
color: "#ffff7c"
@ -148,15 +187,25 @@ Item {
BarButton {
id: item_balance_restock
x: 599
y: 376
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: "Restock"
text: page.state == "balance_edit" ? "Add qty" : "Restock"
onButtonClick: {
if (page.state == "balance_edit") {
/* TODO: Add... */
page.state = "normal";
} else
page.state = "balance_edit";
}
}
}
BarTextHint {
id: barcode_row
visible: page.state == "normal"
x: 65
y: 476
hint_goal: "Add barcode:"
@ -192,4 +241,22 @@ Item {
Component.onCompleted: {
info = shop.loadAccount(dbid)
}
states: [
State {
name: "normal"
},
State {
name: "name_edit"
},
State {
name: "buyprice_edit"
},
State {
name: "sellprice_edit"
},
State {
name: "balance_edit"
}
]
}