brmbar-github/brmbar3/brmbar-gui-qt4/ItemEdit.qml

195 lines
3.8 KiB
QML

// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
import QtQuick 1.0
Item {
id: page
anchors.fill: parent
property variant name: ""
property variant dbid: ""
property variant info: ""
property string barcode: ""
BarcodeInput {
color: "#00ff00" /* just for debugging */
onAccepted: {
var acct = shop.barcodeInput(text)
barcode = text
text = ""
if (typeof(acct) != "undefined") {
status_text.setStatus("Existing barcode: " + acct.name, "#ff4444")
/* TODO: Allow override. */
return
}
shop.addBarcode(dbid, barcode)
status_text.setStatus("Barcode added.", "#ffff7c")
}
}
Text {
id: item_name
x: 65
y: 166
width: 537
height: 60
color: "#ffff7c"
text: parent.name
wrapMode: Text.WordWrap
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_name_edit
x: 599
y: 166
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_buyprice_label
x: 65
y: 236
height: 60
width: 200
color: "#ffffff"
text: "Buy price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_buyprice
x: 265
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
y: 306
height: 60
width: 200
color: "#ffffff"
text: "Sell price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_sellprice
x: 265
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
y: 376
height: 60
width: 200
color: "#ffffff"
text: "Quantity:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_balance
x: 265
y: 376
height: 60
width: 248
color: "#ffff7c"
text: info.balance
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
BarButton {
id: item_balance_restock
x: 599
y: 376
width: 240
height: 60
fontSize: 34
text: "Restock"
}
BarTextHint {
x: 65
y: 476
hint_goal: "Add barcode:"
hint_action: "Scan item now"
}
BarButton {
id: save
x: 65
y: 582
width: 360
text: "Save"
onButtonClick: {
info["name"] = name
shop.saveAccount(dbid, info)
status_text.setStatus("Changes saved", "#ffff7c")
loadPage("StockMgmt")
}
}
BarButton {
id: cancel
x: 599
y: 582
width: 360
text: "Cancel"
onButtonClick: {
status_text.setStatus("Edit cancelled", "#ff4444")
loadPage("StockMgmt")
}
}
Component.onCompleted: {
info = shop.loadAccount(dbid)
}
}