[Pykafe-commits] SF.net SVN: pykafe: [117] trunk/pykafe/server
Status: Pre-Alpha
Brought to you by:
jnmbk
From: <jn...@us...> - 2007-06-10 22:10:57
|
Revision: 117 http://pykafe.svn.sourceforge.net/pykafe/?rev=117&view=rev Author: jnmbk Date: 2007-06-10 15:10:40 -0700 (Sun, 10 Jun 2007) Log Message: ----------- payment dialog, not tested Modified Paths: -------------- trunk/pykafe/server/server.py trunk/pykafe/server/session.py Added Paths: ----------- trunk/pykafe/server/payment.py Added: trunk/pykafe/server/payment.py =================================================================== --- trunk/pykafe/server/payment.py (rev 0) +++ trunk/pykafe/server/payment.py 2007-06-10 22:10:40 UTC (rev 117) @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'payment.ui' +# +# Created: Mon Jun 11 00:40:07 2007 +# by: PyQt4 UI code generator 4.1.1 +# +# WARNING! All changes made in this file will be lost! + +import sys +from PyQt4 import QtCore, QtGui + +class Ui_PaymentDialog(object): + def setupUi(self, PaymentDialog): + PaymentDialog.setObjectName("PaymentDialog") + PaymentDialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(PaymentDialog.minimumSizeHint())) + PaymentDialog.setWindowIcon(QtGui.QIcon("../../data/icons/pyKafe.png")) + + self.gridlayout = QtGui.QGridLayout(PaymentDialog) + self.gridlayout.setMargin(9) + self.gridlayout.setSpacing(6) + self.gridlayout.setObjectName("gridlayout") + + self.groupBox = QtGui.QGroupBox(PaymentDialog) + self.groupBox.setObjectName("groupBox") + + self.gridlayout1 = QtGui.QGridLayout(self.groupBox) + self.gridlayout1.setMargin(9) + self.gridlayout1.setSpacing(6) + self.gridlayout1.setObjectName("gridlayout1") + + self.cafeteriaWidget = QtGui.QTreeWidget(self.groupBox) + self.cafeteriaWidget.setRootIsDecorated(False) + self.cafeteriaWidget.setAllColumnsShowFocus(True) + self.cafeteriaWidget.setObjectName("cafeteriaWidget") + self.gridlayout1.addWidget(self.cafeteriaWidget,0,0,1,1) + self.gridlayout.addWidget(self.groupBox,2,0,1,1) + + self.hboxlayout = QtGui.QHBoxLayout() + self.hboxlayout.setMargin(0) + self.hboxlayout.setSpacing(6) + self.hboxlayout.setObjectName("hboxlayout") + + self.label_2 = QtGui.QLabel(PaymentDialog) + self.label_2.setObjectName("label_2") + self.hboxlayout.addWidget(self.label_2) + + self.totalCost = QtGui.QDoubleSpinBox(PaymentDialog) + self.totalCost.setReadOnly(True) + self.totalCost.setMaximum(1000000000.0) + self.totalCost.setObjectName("totalCost") + self.hboxlayout.addWidget(self.totalCost) + self.gridlayout.addLayout(self.hboxlayout,3,0,1,1) + + self.buttonBox = QtGui.QDialogButtonBox(PaymentDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok) + self.buttonBox.setCenterButtons(True) + self.buttonBox.setObjectName("buttonBox") + self.gridlayout.addWidget(self.buttonBox,5,0,1,1) + + self.hboxlayout1 = QtGui.QHBoxLayout() + self.hboxlayout1.setMargin(0) + self.hboxlayout1.setSpacing(6) + self.hboxlayout1.setObjectName("hboxlayout1") + + self.label = QtGui.QLabel(PaymentDialog) + self.label.setObjectName("label") + self.hboxlayout1.addWidget(self.label) + + self.usedTime = QtGui.QTimeEdit(PaymentDialog) + self.usedTime.setReadOnly(True) + self.usedTime.setObjectName("usedTime") + self.hboxlayout1.addWidget(self.usedTime) + self.gridlayout.addLayout(self.hboxlayout1,1,0,1,1) + + self.label_3 = QtGui.QLabel(PaymentDialog) + self.label_3.setAlignment(QtCore.Qt.AlignCenter) + self.label_3.setObjectName("label_3") + self.gridlayout.addWidget(self.label_3,0,0,1,1) + + self.retranslateUi(PaymentDialog) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),PaymentDialog.accept) + QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("rejected()"),PaymentDialog.) + QtCore.QMetaObject.connectSlotsByName(PaymentDialog) + + def retranslateUi(self, PaymentDialog): + PaymentDialog.setWindowTitle(QtGui.QApplication.translate("PaymentDialog", "Payment", None, QtGui.QApplication.UnicodeUTF8)) + self.groupBox.setTitle(QtGui.QApplication.translate("PaymentDialog", "Cafeteria Costs", None, QtGui.QApplication.UnicodeUTF8)) + self.cafeteriaWidget.headerItem().setText(0,QtGui.QApplication.translate("PaymentDialog", "Date", None, QtGui.QApplication.UnicodeUTF8)) + self.cafeteriaWidget.headerItem().setText(1,QtGui.QApplication.translate("PaymentDialog", "Product", None, QtGui.QApplication.UnicodeUTF8)) + self.cafeteriaWidget.headerItem().setText(2,QtGui.QApplication.translate("PaymentDialog", "Price", None, QtGui.QApplication.UnicodeUTF8)) + self.label_2.setText(QtGui.QApplication.translate("PaymentDialog", "Total Cost:", None, QtGui.QApplication.UnicodeUTF8)) + self.label.setText(QtGui.QApplication.translate("PaymentDialog", "Used Time:", None, QtGui.QApplication.UnicodeUTF8)) + self.label_3.setText(QtGui.QApplication.translate("PaymentDialog", "guest", None, QtGui.QApplication.UnicodeUTF8)) + Modified: trunk/pykafe/server/server.py =================================================================== --- trunk/pykafe/server/server.py 2007-06-10 20:33:58 UTC (rev 116) +++ trunk/pykafe/server/server.py 2007-06-10 22:10:40 UTC (rev 117) @@ -20,6 +20,7 @@ from settingswindow import Ui_SettingsWindow from clientsettingswindow import Ui_ClientSettingsWindow from currencyformat import currency +from payment import Ui_PaymentDialog import logger import base64, sha, os @@ -243,6 +244,14 @@ elif state == ClientSession.notReady: if self.session.state == ClientSession.waitingMoney: total = self.session.calculateTotal(self.config) + self.emit(QtCore.SIGNAL("payment"), self) + #dialog = Ui_PaymentDialog() + #self.parent() + self.paymentDialog = QtGui.QDialog(self.parent()) + QtCore.QObject.connect(self.paymentDialog, QtCore.SIGNAL("accepted()"), self.sendOptions) + settingsUi = Ui_SettingsWindow() + settingsUi.setupUi(self.settingsDialog, self.config) + self.settingsDialog.show() print "will pay", total payingType, credit = Database().runOnce("select paying_type, debt from members where username=?",(self.session.user,))[0] print payingType, credit @@ -364,7 +373,9 @@ self.parent().close() self.clients = [] for clientInformation in self.config.clientList: - self.clients.append(Client(ui.main_treeWidget, clientInformation, self.config, self)) + client = Client(ui.main_treeWidget, clientInformation, self.config, self) + QtCore.QObject.connect(client, QtCore.SIGNAL("payment"), self.payment) + self.clients.append(client) self.ui.orders_idComboBox.addItem(clientInformation.name, QtCore.QVariant(clientInformation.ip)) ui.main_treeWidget.sortItems(0, QtCore.Qt.AscendingOrder) self.initMembers(first = True) @@ -829,7 +840,7 @@ if client.name == order.clientName: logger.add(logger.logTypes.information, _("cafeteria item sold"), order.clientName, client.session.user, order.price()) Database().runOnce("insert into safe values(?,?,?)", (QtCore.QDateTime.currentDateTime().toTime_t(), self.config.last_cashier, order.price())) - client.session.orders.append(order.price()) + client.session.addOrder(order.productName, order.price()) self.orderCancel(question = False) def refreshLogs(self): @@ -849,3 +860,14 @@ elif type == logger.logTypes.error: type = _("error") elif type == logger.logTypes.information: type = _("information") self.logs.append(Log(self.ui.logs_treeWidget, (time, type) + log[2:])) + + def payment(self, client): + paymentDialog = QtGui.QDialog(self.parent()) + paymentUi = Ui_PaymentDialog() + paymentUi.setupUi(paymentDialog) + paymentUi.totalCost.setValue(client.session.calculateTotal()) + time = client.session.startTime.secsTo(QtCore.QDateTime.currentDateTime()) + paymentUi.usedTime.setTime(QtCore.QTime().addSecs(time)) + for order in client.session.orders: + QtGui.QTreeWidgetItem(paymentUi.cafeteriaWidget, order) + paymentDialog.show() Modified: trunk/pykafe/server/session.py =================================================================== --- trunk/pykafe/server/session.py 2007-06-10 20:33:58 UTC (rev 116) +++ trunk/pykafe/server/session.py 2007-06-10 22:10:40 UTC (rev 117) @@ -21,8 +21,11 @@ notConnected, notReady, ready, loggedIn, requestedOpening, waitingMoney = range(6) def __init__(self): self.state = 0 + self.settings = None + self.initialize() + + def initialize(self): self.user = None - self.settings = None self.startTime = None self.endTime = None self.orders = [] @@ -40,8 +43,11 @@ def calculateTotal(self, config): total = self.calculatePrice(config) for i in self.orders: - total += i + total += i[1] return total + + def addOrder(self, productName, price): + self.orders.append([productName, price]) def toString(self): """returns current state as a string""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |