-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditpref.py
179 lines (145 loc) · 7.07 KB
/
editpref.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/python
# -*- coding: utf-8- -*-
from PyQt4 import QtGui,QtCore
import editust,editfee
class beraterLineEdit(QtGui.QLineEdit):
def __init__(self, *args):
QtGui.QLineEdit.__init__(self, *args)
def event(self, event):
if (event.type()== QtCore.QEvent.KeyPress) and ( (event.key()==QtCore.Qt.Key_Return) or (event.key()==QtCore.Qt.Key_Enter) ) :
self.emit(QtCore.SIGNAL("nextElement"));
return True
return QtGui.QLineEdit.event(self, event)
class prefWindow(QtGui.QWidget):
def __init__(self,berater):
super(prefWindow, self).__init__()
self.berater = berater
self.initUI()
def event(self,event):
return QtGui.QWidget.event(self, event)
def initUI(self):
self.setWindowTitle(u"Beraterdaten")
grid = QtGui.QGridLayout() # In Tab Container
maingrid = QtGui.QVBoxLayout() # Main Container
btnSave = QtGui.QPushButton(u"Speichern") # Save-Button
btnSave.clicked.connect(self.save)
btnClose = QtGui.QPushButton(u"Schließen") # Close Button
btnClose.clicked.connect(self.close)
cntButtons = QtGui.QWidget()
cntButtonsLayout = QtGui.QHBoxLayout()
cntButtonsLayout.addWidget(btnSave)
cntButtonsLayout.addWidget(btnClose)
cntButtons.setLayout(cntButtonsLayout)
tabWidget = QtGui.QTabWidget()
generalPrefs = QtGui.QWidget()
self.edtName = beraterLineEdit()
self.edtName.setText(self.berater.name)
lblName = QtGui.QLabel(u"Name")
self.edtFirstName = QtGui.QLineEdit()
self.edtFirstName.setText(self.berater.firstname)
lblFirstName = QtGui.QLabel(u"Vorname")
self.edtId = QtGui.QLineEdit()
self.edtId.setText(self.berater.id)
lblId = QtGui.QLabel(u"Beraternummer")
self.edtUstnr = QtGui.QLineEdit()
self.edtUstnr.setText(self.berater.ustnr)
lblUstnr = QtGui.QLabel(u"Steuernummer")
self.edtBank = QtGui.QLineEdit()
self.edtBank.setText(self.berater.bank)
lblBank = QtGui.QLabel(u"Bank")
self.edtBic = QtGui.QLineEdit()
self.edtBic.setText(self.berater.bic)
lblBic = QtGui.QLabel(u"BIC")
self.edtIban = QtGui.QLineEdit()
self.edtIban.setText(self.berater.iban)
lblIban = QtGui.QLabel(u"IBAN")
self.edtStreet = QtGui.QLineEdit()
self.edtStreet.setText(self.berater.street)
lblStreet = QtGui.QLabel(u"Strasse")
self.edtTown = QtGui.QLineEdit()
self.edtTown.setText(self.berater.town)
lblTown = QtGui.QLabel(u"Ort")
self.edtZip = QtGui.QLineEdit()
self.edtZip.setText(self.berater.zip)
lblZip = QtGui.QLabel(u"Postleitzahl")
self.edtFee = QtGui.QLineEdit()
# self.edtFee.setText(self.berater.fee)
lblFee = QtGui.QLabel(u"Vergütungssatz (in %)")
self.ustwidget = editust.ustWidget(self.berater.ust)
self.feewidget = editfee.feeWidget(self.berater.fee)
self.connect(self,QtCore.SIGNAL("returnPressed"),self.focusNextChild)
grid.addWidget(self.edtName,0,1)
grid.addWidget(lblName,0,0)
grid.addWidget(self.edtFirstName,1,1)
grid.addWidget(lblFirstName,1,0)
grid.addWidget(self.edtId,2,1)
grid.addWidget(lblId,2,0)
grid.addWidget(self.edtUstnr,3,1)
grid.addWidget(lblUstnr,3,0)
grid.addWidget(self.edtStreet,4,1)
grid.addWidget(lblStreet,4,0)
grid.addWidget(self.edtTown,5,1)
grid.addWidget(lblTown,5,0)
grid.addWidget(self.edtZip,6,1)
grid.addWidget(lblZip,6,0)
grid.addWidget(self.edtBank,7,1)
grid.addWidget(lblBank,7,0)
grid.addWidget(self.edtIban,8,1)
grid.addWidget(lblIban,8,0)
grid.addWidget(self.edtBic,9,1)
grid.addWidget(lblBic,9,0)
grid.addWidget(self.edtFee,10,1)
grid.addWidget(lblFee,10,0)
# grid.addWidget(ustgroupBox,11,1)
generalPrefs.setLayout(grid)
tabWidget.insertTab(1,generalPrefs,u"Beratereinstellungen")
tabWidget.insertTab(2,self.ustwidget,u"Umsatzsteuer")
tabWidget.insertTab(3,self.feewidget,u"Vergütung")
maingrid.addWidget(tabWidget)
maingrid.addWidget(cntButtons)
self.setLayout(maingrid) # Grid for Layout
self.show()
# Checking for changes
def closeEvent(self, event):
changed = False
if ((self.berater.name) != (self.edtName.text())) or ((self.berater.firstname) != (self.edtFirstName.text())) or ((self.berater.id) != (self.edtId.text())) or (self.berater.bank) != (self.edtBank.text()) or (self.berater.bic) != (self.edtBic.text()) or (self.berater.iban) != (self.edtIban.text()) or (self.berater.street) != (self.edtStreet.text()) or (self.berater.town) != (self.edtTown.text()) or (self.berater.zip) != (self.edtZip.text()):
changed = True
if (changed == True):
msgBox = QtGui.QMessageBox();
msgBox.setText(u"Ihre Daten wurden verändert..");
msgBox.setInformativeText(u"Möchten Sie die Änderungen Speichern?");
msgBox.setStandardButtons(QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel);
msgBox.setButtonText(QtGui.QMessageBox.Save ,"Speichern");
msgBox.setButtonText(QtGui.QMessageBox.Discard ,"Nicht speichern");
msgBox.setButtonText(QtGui.QMessageBox.Cancel,"Abbrechen");
msgBox.setDefaultButton(QtGui.QMessageBox.Save);
ret = msgBox.exec_();
if ret == QtGui.QMessageBox.Save:
self.save()
event.accept()
else:
if ret == QtGui.QMessageBox.Discard:
event.accept()
else:
event.ignore()
else:
event.accept()
# Saving Personal Data to berater Object, save to file afterwards
def save(self):
self.berater.name = str(self.edtName.text()).rstrip() # Convert Edit-Field to unicode string, remove all trailing whitespaces
self.berater.firstname = str(self.edtFirstName.text()).rstrip()
self.berater.id = str(self.edtId.text()).rstrip()
self.berater.bank = str(self.edtBank.text()).rstrip()
self.berater.bic = str(self.edtBic.text()).rstrip()
self.berater.iban = str(self.edtIban.text()).rstrip()
self.berater.ustnr = str(self.edtUstnr.text()).rstrip()
if (not self.berater.checkiban()): # Check if IBAN is correct
msgBox = QtGui.QMessageBox();
msgBox.setText(u"Die IBAN ist inkorrekt.\nBitte überprüfen Sie Ihre Eingabe.");
msgBox.exec_()
self.berater.street = str(self.edtStreet.text()).rstrip()
self.berater.town = str(self.edtTown.text()).rstrip()
self.berater.zip = str(self.edtZip.text()).rstrip()
self.berater.fee = self.feewidget.returnEntries()
self.berater.ust = self.ustwidget.returnEntries()
self.berater.save()