From 1d3f6384e2268dad464cf383908062831462c3df Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 24 Feb 2020 17:22:26 +0100 Subject: [PATCH] Little report refactoring. --- report.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/report.py b/report.py index 0c29cf2..faaef27 100644 --- a/report.py +++ b/report.py @@ -53,11 +53,14 @@ class Report(QtWidgets.QDialog): def set_data(self, data): self._report = data - self._report_data = self._report.report() self.refresh_table() self.update_prev_next() + def save(self): + self._report.save(self._report_data) + def refresh_table(self): + self._report_data = self._report.report() self.tableWidget.setRowCount(len(self._report_data)) self._changing_items = True @@ -96,26 +99,25 @@ class Report(QtWidgets.QDialog): if row > len(self._report_data) - 4: return del self._report_data[row] + self.save() self.refresh_table() @QtCore.Slot() def _accept(self): - self._report.save(self._report_data) + self.save() self.accept() @QtCore.Slot() def previous(self): - self._report.save(self._report_data) + self.save() self._report.previous() - self._report_data = self._report.report() self.refresh_table() self.update_prev_next() @QtCore.Slot() def next(self): - self._report.save(self._report_data) + self.save() self._report.next() - self._report_data = self._report.report() self.refresh_table() self.update_prev_next() @@ -130,6 +132,5 @@ class Report(QtWidgets.QDialog): item.setText(self._report_data[row][column]) return self._report_data[row][column] = new_time.strftime("%H:%M") - self._report.save(self._report_data) - self._report_data = self._report.report() + self.save() self.refresh_table()