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,135 +29,183 @@ 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 height: 60
color: "#ffff7c"
text: parent.name Text {
wrapMode: Text.WordWrap id: item_name
verticalAlignment: Text.AlignVCenter x: 0
font.pointSize: 34 y: 0
width: 534
height: 60
color: "#ffff7c"
text: page.name
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_name_edit
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: page.state == "name_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "name_edit") page.state = "normal"; else page.state = "name_edit"; }
}
} }
BarButton { Item {
id: item_name_edit id: buyprice_row
x: 599 visible: page.state == "normal" || page.state == "buyprice_edit"
y: 166
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_buyprice_label
x: 65 x: 65
y: 236 y: page.state == "buyprice_edit" ? 166 : 239;
width: 774
height: 60 height: 60
width: 200
color: "#ffffff" Text {
text: "Buy price:" id: item_buyprice_label
verticalAlignment: Text.AlignVCenter x: 0
font.pointSize: 34 y: 0
height: 60
width: 200
color: "#ffffff"
text: "Buy price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_buyprice
x: 200
y: 0
height: 60
width: 248
color: "#ffff7c"
text: info.buy_price
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_buyprice_edit
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: page.state == "buyprice_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "buyprice_edit") page.state = "normal"; else page.state = "buyprice_edit"; }
}
} }
Text { Item {
id: item_buyprice id: sellprice_row
x: 265 visible: page.state == "normal" || page.state == "sellprice_edit"
y: 236
height: 60
width: 248
color: "#ffff7c"
text: info.buy_price
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_buyprice_edit
x: 599
y: 236
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_sellprice_label
x: 65 x: 65
y: 306 y: page.state == "sellprice_edit" ? 166 : 306;
width: 774
height: 60 height: 60
width: 200
color: "#ffffff" Text {
text: "Sell price:" id: item_sellprice_label
verticalAlignment: Text.AlignVCenter x: 0
font.pointSize: 34 y: 0
height: 60
width: 200
color: "#ffffff"
text: "Sell price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_sellprice
x: 200
y: 0
height: 60
width: 248
color: "#ffff7c"
text: info.price
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_sellprice_edit
x: 534
y: 0
width: 240
height: 60
fontSize: 34
text: page.state == "sellprice_edit" ? "Assign" : "Edit"
onButtonClick: { if (page.state == "sellprice_edit") page.state = "normal"; else page.state = "sellprice_edit"; }
}
} }
Text { Item {
id: item_sellprice id: balance_row
x: 265 visible: page.state == "normal" || page.state == "balance_edit"
y: 306
height: 60
width: 248
color: "#ffff7c"
text: info.price
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_sellprice_edit
x: 599
y: 306
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_balance_label
x: 65 x: 65
y: 376 y: page.state == "balance_edit" ? 166 : 376;
width: 774
height: 60 height: 60
width: 200
color: "#ffffff"
text: "Quantity:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text { Text {
id: item_balance id: item_balance_label
x: 265 x: 0
y: 376 y: 0
height: 60 height: 60
width: 248 width: 200
color: "#ffff7c" color: "#ffffff"
text: info.balance text: "Quantity:"
horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter
verticalAlignment: Text.AlignVCenter font.pointSize: 34
font.pointSize: 34 }
}
BarButton { Text {
id: item_balance_restock id: item_balance
x: 599 x: 200
y: 376 y: 0
width: 240 height: 60
height: 60 width: 248
fontSize: 34 color: "#ffff7c"
text: "Restock" text: info.balance
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_balance_restock
x: 534
y: 0
width: 240
height: 60
fontSize: 34
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"
}
]
} }