diff --git a/functions/dialog_wrapper.py b/functions/dialog_wrapper.py index 170bbc0..988d380 100644 --- a/functions/dialog_wrapper.py +++ b/functions/dialog_wrapper.py @@ -328,3 +328,53 @@ class ProgressDialog: def create_progress_dialog(total: int, title: str = "Fortschritt", label: str = "Verarbeite...") -> ProgressDialog: return ProgressDialog(total, title, label) + +def ask_bror_kombination( + parent: Any, + kombinationen: list[tuple[str, str]], +) -> Optional[tuple[str, str]]: + """Zeigt Dialog zur Auswahl einer BROR-Kombination (adv_name + bezeichnung). + + Wird aufgerufen, wenn der WFS mehrere verschiedene Kombinationen aus + ``adv_name`` und ``bezeichnung`` zurückliefert, sodass der Nutzer + entscheiden muss, welche Objekte in die Pipeline einfließen sollen. + + Parameters + ---------- + parent : + Eltern-Widget oder None. + kombinationen : + Sortierte Liste von ``(adv_name, bezeichnung)``-Tupeln. + + Returns + ------- + Optional[tuple[str, str]] + Das gewählte ``(adv_name, bezeichnung)``-Tupel oder ``None`` bei + Abbruch bzw. leerer Eingabe. + """ + if not kombinationen: + return None + + if QT_VERSION == 0: # Mock-Modus + print(f"Mock-Modus: ask_bror_kombination → {kombinationen[0]}") + return kombinationen[0] + + items = [f"{adv} | {bez}" for adv, bez in kombinationen] + item, ok = QInputDialog.getItem( + parent, + "BROR-Objekt auswählen", + "Mehrere BauRaumOderBodenordnungsrecht-Objekte gefunden.\n" + "Bitte wählen Sie die gewünschte Kombination\n" + "aus ADV-Name und Bezeichnung:", + items, + 0, + False, + ) + if not ok: + return None + try: + idx = items.index(item) + return kombinationen[idx] + except ValueError: + return None +