brmbar v3 ItemEdit: New view for editing/restocking items (actual editing not supported yet)

This commit is contained in:
Petr Baudis 2012-09-26 03:05:01 +02:00
parent db6d2fb372
commit 780395f877
2 changed files with 183 additions and 0 deletions

View file

@ -23,6 +23,7 @@ class ShopAdapter(QtCore.QObject):
def acct_inventory_map(self, acct):
buy, sell = acct.currency.rates(currency)
map = acct.__dict__.copy()
map["balance"] = "{:.0f}".format(acct.balance())
map["buy_price"] = str(buy)
map["price"] = str(sell)
return map
@ -54,6 +55,10 @@ class ShopAdapter(QtCore.QObject):
return { "acctype": "recharge", "amount": str(credit)+".00" }
return self.acct_map(brmbar.Account.load_by_barcode(db, barcode))
@QtCore.Slot('QVariant', result='QVariant')
def loadAccount(self, dbid):
return self.acct_map(brmbar.Account.load(db, id = dbid))
@QtCore.Slot('QVariant', 'QVariant', result='QVariant')
def sellItem(self, itemid, userid):
user = brmbar.Account.load(db, id = userid)

View file

@ -0,0 +1,178 @@
// 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: ""
Text {
id: item_name
x: 65
y: 156
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: 156
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_buyprice_label
x: 65
y: 226
height: 60
width: 200
color: "#ffffff"
text: "Buy price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_buyprice
x: 265
y: 226
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: 226
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_sellprice_label
x: 65
y: 296
height: 60
width: 200
color: "#ffffff"
text: "Sell price:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_sellprice
x: 265
y: 296
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: 296
width: 240
height: 60
fontSize: 34
text: "Edit"
}
Text {
id: item_balance_label
x: 65
y: 366
height: 60
width: 200
color: "#ffffff"
text: "Quantity:"
verticalAlignment: Text.AlignVCenter
font.pointSize: 34
}
Text {
id: item_balance
x: 265
y: 366
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: 366
width: 240
height: 60
fontSize: 34
text: "Restock"
}
BarButton {
id: add_barcode
x: 65
y: 476
width: 360
text: "Add Barcode"
}
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)
}
}