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