diff --git a/gui.py b/gui.py index 10c010d..9af0f89 100644 --- a/gui.py +++ b/gui.py @@ -47,6 +47,9 @@ class PDFtoICSGUI: # Letztes PDF-Verzeichnis merken self.last_pdf_dir = self.config.get('last_pdf_dir', str(Path.home())) + # Exportoptionen + self.exclude_rest = tk.BooleanVar(value=self.config.get('exclude_rest', False)) + # UI erstellen self.create_widgets() @@ -190,6 +193,18 @@ class PDFtoICSGUI: ) browse_btn.pack(side=tk.LEFT) + # Exportoptionen + options_frame = tk.Frame(content_frame) + options_frame.pack(fill=tk.X, pady=(10, 5)) + + exclude_rest_check = tk.Checkbutton( + options_frame, + text="🧘 Ruhetage ausschließen - (Ruhe, R56, R36, vRWF48, RWE, vR48)", + variable=self.exclude_rest, + font=("Arial", 10) + ) + exclude_rest_check.pack(anchor=tk.W) + # Log-Bereich log_label = tk.Label( content_frame, @@ -231,7 +246,8 @@ class PDFtoICSGUI: try: config = { 'last_output_dir': self.output_dir.get(), - 'last_pdf_dir': self.last_pdf_dir + 'last_pdf_dir': self.last_pdf_dir, + 'exclude_rest': self.exclude_rest.get() } with open(CONFIG_FILE, 'w') as f: json.dump(config, f, indent=2) @@ -406,7 +422,7 @@ class PDFtoICSGUI: ics_filename = Path(pdf_path).stem + '.ics' ics_path = output_dir / ics_filename - create_ics_from_dienstplan(dienstplan, str(ics_path)) + create_ics_from_dienstplan(dienstplan, str(ics_path), exclude_rest=self.exclude_rest.get()) self.log(f" ✓ ICS erstellt: {ics_filename}") success_count += 1 diff --git a/pdf_to_ics.py b/pdf_to_ics.py index acc2ec4..95d9962 100644 --- a/pdf_to_ics.py +++ b/pdf_to_ics.py @@ -154,9 +154,14 @@ def parse_dienstplan_table(table, month_start_str): return events -def create_ics_from_dienstplan(dienstplan, output_path=None): +def create_ics_from_dienstplan(dienstplan, output_path=None, exclude_rest=False): """ Erstellt eine ICS-Datei aus den Dienstplan-Daten + + Args: + dienstplan: Dictionary mit Dienstplan-Daten + output_path: Pfad für Output-Datei + exclude_rest: Wenn True, werden Ruhepausen nicht exportiert """ # Erstelle Calendar cal = Calendar() @@ -168,16 +173,30 @@ def create_ics_from_dienstplan(dienstplan, output_path=None): # Timezone tz = pytz.timezone('Europe/Berlin') + # Service-Typen die als "Ruhe" angezeigt werden + rest_types = ['R56', 'R36', 'vRWF48', 'RWE', 'vR48'] + # Füge Events hinzu for event_data in dienstplan['events']: if not event_data['service']: continue + service_type = event_data['service'] + event = Event() # Titel - nur den Dienstart - service_type = event_data['service'] - title = f"Dienst: {service_type}" + # Spezielle Service-Typen mit aussagekräftigen Namen + if service_type == '0060': + title = "Urlaub" + elif service_type in rest_types: + title = "Ruhe" + else: + title = service_type + + # Überspringe Ruhepausen wenn gewünscht (nach Titel-Erstellung) + if exclude_rest and title == "Ruhe": + continue event.add('summary', title)