Little report refactoring.
This commit is contained in:
parent
5b62e8684d
commit
1d3f6384e2
17
report.py
17
report.py
@ -53,11 +53,14 @@ class Report(QtWidgets.QDialog):
|
|||||||
|
|
||||||
def set_data(self, data):
|
def set_data(self, data):
|
||||||
self._report = data
|
self._report = data
|
||||||
self._report_data = self._report.report()
|
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
self.update_prev_next()
|
self.update_prev_next()
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
self._report.save(self._report_data)
|
||||||
|
|
||||||
def refresh_table(self):
|
def refresh_table(self):
|
||||||
|
self._report_data = self._report.report()
|
||||||
self.tableWidget.setRowCount(len(self._report_data))
|
self.tableWidget.setRowCount(len(self._report_data))
|
||||||
|
|
||||||
self._changing_items = True
|
self._changing_items = True
|
||||||
@ -96,26 +99,25 @@ class Report(QtWidgets.QDialog):
|
|||||||
if row > len(self._report_data) - 4:
|
if row > len(self._report_data) - 4:
|
||||||
return
|
return
|
||||||
del self._report_data[row]
|
del self._report_data[row]
|
||||||
|
self.save()
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def _accept(self):
|
def _accept(self):
|
||||||
self._report.save(self._report_data)
|
self.save()
|
||||||
self.accept()
|
self.accept()
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def previous(self):
|
def previous(self):
|
||||||
self._report.save(self._report_data)
|
self.save()
|
||||||
self._report.previous()
|
self._report.previous()
|
||||||
self._report_data = self._report.report()
|
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
self.update_prev_next()
|
self.update_prev_next()
|
||||||
|
|
||||||
@QtCore.Slot()
|
@QtCore.Slot()
|
||||||
def next(self):
|
def next(self):
|
||||||
self._report.save(self._report_data)
|
self.save()
|
||||||
self._report.next()
|
self._report.next()
|
||||||
self._report_data = self._report.report()
|
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
self.update_prev_next()
|
self.update_prev_next()
|
||||||
|
|
||||||
@ -130,6 +132,5 @@ class Report(QtWidgets.QDialog):
|
|||||||
item.setText(self._report_data[row][column])
|
item.setText(self._report_data[row][column])
|
||||||
return
|
return
|
||||||
self._report_data[row][column] = new_time.strftime("%H:%M")
|
self._report_data[row][column] = new_time.strftime("%H:%M")
|
||||||
self._report.save(self._report_data)
|
self.save()
|
||||||
self._report_data = self._report.report()
|
|
||||||
self.refresh_table()
|
self.refresh_table()
|
||||||
|
Loading…
Reference in New Issue
Block a user