diff options
| author | matin <matin.kaufmann@gmail.com> | 2025-09-11 16:27:13 +0200 |
|---|---|---|
| committer | matin <matin.kaufmann@gmail.com> | 2025-09-11 16:27:13 +0200 |
| commit | c7fc1d523a80c2eddacadab97b195cbe60ff83e0 (patch) | |
| tree | 587d9d35f9fe95703324dfe58e03c6b7427244ef /calendar_gui.py | |
| parent | 3489736a7ae2c2827452c0c23805becf41e1d2b9 (diff) | |
added commentary field. removed display of corrected start / end dates
Diffstat (limited to 'calendar_gui.py')
| -rw-r--r-- | calendar_gui.py | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/calendar_gui.py b/calendar_gui.py index 67ddaa2..9d89b7e 100644 --- a/calendar_gui.py +++ b/calendar_gui.py @@ -2,7 +2,7 @@ import sys from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QDateEdit, QTableWidget, QTableWidgetItem, QHeaderView, QDialog, QFormLayout, QComboBox, - QMessageBox, QSpinBox, QAction, QFileDialog, QMenuBar) + QMessageBox, QSpinBox, QAction, QFileDialog, QMenuBar, QTextEdit) from PyQt5.QtCore import Qt, QDate, QLocale from PyQt5.QtGui import QFont, QFontDatabase from datetime import datetime, timedelta @@ -83,6 +83,14 @@ class EventDialog(QDialog): self.keyword.currentTextChanged.connect(self.on_keyword_changed) layout.addRow("Art:", self.keyword) + # Commentary input + self.commentary_input = QTextEdit() + self.commentary_input.setFont(font) + self.commentary_input.setFixedHeight(80) + if self.entry and hasattr(self.entry, 'commentary') and self.entry.commentary: + self.commentary_input.setPlainText(self.entry.commentary) + layout.addRow("Kommentar:", self.commentary_input) + # Store layout for later access self.layout = layout self.end_date_row = 1 # Index of end date row in the form layout @@ -133,6 +141,7 @@ class EventDialog(QDialog): def get_data(self): start_date = self.start_date.date().toString("yyyy-MM-dd") keyword = self.keyword.currentText() + commentary = self.commentary_input.toPlainText().strip() if keyword == "EZ pauschal": # For EZ pauschals, calculate end date as start + 4 weeks @@ -141,7 +150,7 @@ class EventDialog(QDialog): end_date = end_dt.strftime("%Y-%m-%d") else: end_date = self.end_date.date().toString("yyyy-MM-dd") - return start_date, end_date, keyword + return start_date, end_date, keyword, commentary class CalendarManagerGUI(QMainWindow): @@ -267,8 +276,8 @@ class CalendarManagerGUI(QMainWindow): # Events table self.events_table = QTableWidget() self.events_table.setFont(self.app_font) - self.events_table.setColumnCount(7) # ID (hidden), Start, End, Keyword, CorrectedStart, CorrectedEnd, Actions - self.events_table.setHorizontalHeaderLabels(["ID", "Anfangsdatum", "Enddatum", "Art", "Korr. Start", "Korr. Ende", "Aktionen"]) + self.events_table.setColumnCount(6) # ID (hidden), Start, End, Keyword, Commentary, Actions + self.events_table.setHorizontalHeaderLabels(["ID", "Anfangsdatum", "Enddatum", "Art", "Kommentar", "Aktionen"]) self.events_table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.events_table.horizontalHeader().setFont(self.app_font) self.events_table.setColumnHidden(0, True) # Hide ID column @@ -306,9 +315,9 @@ class CalendarManagerGUI(QMainWindow): def add_event(self): dialog = EventDialog(self.keyword_list, parent=self, dateformat=self.dateformat) if dialog.exec_(): - start_date, end_date, keyword = dialog.get_data() + start_date, end_date, keyword, commentary = dialog.get_data() try: - self.calendar_manager.add_entry(start_date, end_date, keyword) + self.calendar_manager.add_entry(start_date, end_date, keyword, commentary) self.update_events_table() self.update_prediction() # Auto-update prediction except Exception as e: @@ -319,12 +328,13 @@ class CalendarManagerGUI(QMainWindow): if entry: dialog = EventDialog(self.keyword_list, entry=entry, parent=self, dateformat=self.dateformat) if dialog.exec_(): - start_date, end_date, keyword = dialog.get_data() + start_date, end_date, keyword, commentary = dialog.get_data() try: self.calendar_manager.modify_entry(event_id, datetime.fromisoformat(start_date), datetime.fromisoformat(end_date), - keyword) + keyword, + commentary) self.update_events_table() self.update_prediction() # Auto-update prediction except Exception as e: @@ -364,28 +374,9 @@ class CalendarManagerGUI(QMainWindow): self.events_table.setItem(i, 2, QTableWidgetItem(end_date_text)) self.events_table.setItem(i, 3, QTableWidgetItem(entry.keyword)) - # Corrected dates with unified display format - if entry.corrected_start_date: - corrected_start_qdate = QDate( - entry.corrected_start_date.year, - entry.corrected_start_date.month, - entry.corrected_start_date.day - ) - corrected_start_text = corrected_start_qdate.toString(self.dateformat) - else: - corrected_start_text = "" - - if entry.corrected_end_date: - corrected_end_qdate = QDate( - entry.corrected_end_date.year, - entry.corrected_end_date.month, - entry.corrected_end_date.day - ) - corrected_end_text = corrected_end_qdate.toString(self.dateformat) - else: - corrected_end_text = "" - self.events_table.setItem(i, 4, QTableWidgetItem(corrected_start_text)) - self.events_table.setItem(i, 5, QTableWidgetItem(corrected_end_text)) + # Commentary + commentary_text = getattr(entry, 'commentary', "") or "" + self.events_table.setItem(i, 4, QTableWidgetItem(commentary_text)) # Action buttons actions_widget = QWidget() @@ -405,7 +396,7 @@ class CalendarManagerGUI(QMainWindow): actions_layout.addWidget(delete_button) actions_widget.setLayout(actions_layout) - self.events_table.setCellWidget(i, 6, actions_widget) + self.events_table.setCellWidget(i, 5, actions_widget) def save_file(self): """Save calendar entries to a JSON file""" |
