From 780395f877caf02a995ffb88074dd0b74b11f67e Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 26 Sep 2012 03:05:01 +0200 Subject: [PATCH] brmbar v3 ItemEdit: New view for editing/restocking items (actual editing not supported yet) --- brmbar3/brmbar-gui-qt4.py | 5 + brmbar3/brmbar-gui-qt4/ItemEdit.qml | 178 ++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 brmbar3/brmbar-gui-qt4/ItemEdit.qml diff --git a/brmbar3/brmbar-gui-qt4.py b/brmbar3/brmbar-gui-qt4.py index 3e46df4..274507f 100755 --- a/brmbar3/brmbar-gui-qt4.py +++ b/brmbar3/brmbar-gui-qt4.py @@ -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) diff --git a/brmbar3/brmbar-gui-qt4/ItemEdit.qml b/brmbar3/brmbar-gui-qt4/ItemEdit.qml new file mode 100644 index 0000000..b652e48 --- /dev/null +++ b/brmbar3/brmbar-gui-qt4/ItemEdit.qml @@ -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) + } +}