diff -r 09f25e6d99ee -r 702f47d3f794 TimeTracker/TimeTrackerEntryDialog.py --- a/TimeTracker/TimeTrackerEntryDialog.py Thu Dec 30 12:38:13 2021 +0100 +++ b/TimeTracker/TimeTrackerEntryDialog.py Tue Sep 20 19:10:20 2022 +0200 @@ -17,10 +17,11 @@ """ Class implementing the time tracker edit dialog. """ + def __init__(self, tracker, entry, taskItems, commentItems, parent=None): """ Constructor - + @param tracker reference to the time tracker @type TimeTracker @param entry reference to the time tracker entry @@ -36,21 +37,18 @@ """ super().__init__(parent) self.setupUi(self) - - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(False) - + + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) + self.taskCombo.addItems(taskItems) self.commentCombo.addItems(commentItems) - + # The allowed end time (i.e. start date and time plus duration must be # earlier or equal to the start date and time of the current entry. - self.__endDateTime = QDateTime( - tracker.getCurrentEntry().getStartDateTime()) - - self.durationSpinBox.setMinimum( - tracker.getPreferences("MinimumDuration")) - + self.__endDateTime = QDateTime(tracker.getCurrentEntry().getStartDateTime()) + + self.durationSpinBox.setMinimum(tracker.getPreferences("MinimumDuration")) + if entry is None: self.setWindowTitle(self.tr("Add Tracker Entry")) self.startDateTimeEdit.setDate(QDate.currentDate()) @@ -58,46 +56,47 @@ self.startDateTimeEdit.setDateTime(entry.getStartDateTime()) self.durationSpinBox.setValue(entry.getDuration()) self.durationSpinBox.setMaximum( - entry.getStartDateTime().secsTo(self.__endDateTime) // 60) + entry.getStartDateTime().secsTo(self.__endDateTime) // 60 + ) self.taskCombo.setEditText(entry.getTask()) self.commentCombo.setEditText(entry.getComment()) - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + def __checkOk(self): """ Private slot to set the enabled state of the OK button. """ dt = self.startDateTimeEdit.dateTime() self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - dt.addSecs(self.durationSpinBox.value() * 60) <= - self.__endDateTime) - + dt.addSecs(self.durationSpinBox.value() * 60) <= self.__endDateTime + ) + @pyqtSlot(QDateTime) def on_startDateTimeEdit_dateTimeChanged(self, date): """ Private slot handling a change of the start date and time. - + @param date start date and time @type QDateTime """ self.__checkOk() - + @pyqtSlot(int) def on_durationSpinBox_valueChanged(self, value): """ Private slot handling a change of the duration. - + @param value value of the duration spin box @type int """ self.__checkOk() - + def getData(self): """ Public method to get the data. - + @return tuple with start date and time, duration, task description and comment @rtype tuple of (QDateTime, int, str, str)