mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-07 21:04:00 +02:00
brmbar v3 StockMgmt: New view listing inventory with edit buttons (non-functional yet)
This commit is contained in:
parent
d897edd6ed
commit
42ce11de32
3 changed files with 114 additions and 0 deletions
|
@ -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["buy_price"] = str(buy)
|
||||
map["price"] = str(sell)
|
||||
return map
|
||||
|
||||
|
@ -90,6 +91,10 @@ class ShopAdapter(QtCore.QObject):
|
|||
def userList(self):
|
||||
return [ self.acct_debt_map(a) for a in shop.account_list("debt") ]
|
||||
|
||||
@QtCore.Slot(result='QVariant')
|
||||
def itemList(self):
|
||||
return [ self.acct_inventory_map(a) for a in shop.account_list("inventory") ]
|
||||
|
||||
db = psycopg2.connect("dbname=brmbar")
|
||||
shop = brmbar.Shop.new_with_defaults(db)
|
||||
currency = shop.currency
|
||||
|
|
|
@ -121,6 +121,9 @@ Item {
|
|||
y: 430
|
||||
width: 360
|
||||
text: "Stock Mgmt"
|
||||
onButtonClick: {
|
||||
loadPage("StockMgmt")
|
||||
}
|
||||
}
|
||||
|
||||
BarButton {
|
||||
|
|
106
brmbar3/brmbar-gui-qt4/StockMgmt.qml
Normal file
106
brmbar3/brmbar-gui-qt4/StockMgmt.qml
Normal file
|
@ -0,0 +1,106 @@
|
|||
// 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 item_list_model
|
||||
|
||||
BarcodeInput {
|
||||
color: "#00ff00" /* just for debugging */
|
||||
onAccepted: {
|
||||
var acct = shop.barcodeInput(text)
|
||||
text = ""
|
||||
if (typeof(acct) == "undefined") {
|
||||
status_text.setStatus("Unknown barcode", "#ff4444")
|
||||
return
|
||||
}
|
||||
if (acct.acctype != "inventory") {
|
||||
loadPageByAcct(acct)
|
||||
return
|
||||
}
|
||||
loadPage("ItemEdit", { name: acct["name"], dbid: acct["id"] })
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: item_list_container
|
||||
x: 65
|
||||
y: 166
|
||||
width: 899
|
||||
height: 250
|
||||
|
||||
ListView {
|
||||
id: item_list
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
delegate: Item {
|
||||
x: 5
|
||||
height: 80
|
||||
|
||||
Text {
|
||||
text: modelData.name
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: "#ffffff"
|
||||
font.pointSize: 34
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: 300
|
||||
width: 254
|
||||
color: "#ffff7c"
|
||||
text: modelData.price
|
||||
horizontalAlignment: Text.AlignRight
|
||||
font.pointSize: 34
|
||||
}
|
||||
|
||||
BarButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: 600
|
||||
width: 240
|
||||
height: 68
|
||||
text: "Edit"
|
||||
fontSize: 34
|
||||
onButtonClick: {
|
||||
loadPage("ItemEdit", { name: modelData.name, dbid: modelData.id })
|
||||
}
|
||||
}
|
||||
}
|
||||
model: item_list_model
|
||||
}
|
||||
|
||||
BarScrollBar {
|
||||
id: item_list_scrollbar
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
flickableItem: item_list
|
||||
}
|
||||
}
|
||||
|
||||
BarButton {
|
||||
id: add_item
|
||||
x: 65
|
||||
y: 582
|
||||
width: 360
|
||||
text: "Add Item"
|
||||
fontSize: 44
|
||||
}
|
||||
|
||||
BarButton {
|
||||
id: cancel
|
||||
x: 599
|
||||
y: 582
|
||||
width: 360
|
||||
text: "Main Screen"
|
||||
onButtonClick: {
|
||||
loadPage("MainPage")
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
item_list_model = shop.itemList()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue