forked from AG_QGIS/Plugin_SN_Basis
73 lines
2.5 KiB
Python
73 lines
2.5 KiB
Python
from qgis.PyQt.QtWidgets import (
|
|
QWidget, QGridLayout, QLabel, QLineEdit,
|
|
QGroupBox, QVBoxLayout, QPushButton
|
|
)
|
|
from sn_basis.logic.settings_logic import SettingsLogic
|
|
|
|
|
|
class SettingsTab(QWidget):
|
|
tab_title = "Projekteigenschaften" # Titel für den Tab
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.logic = SettingsLogic()
|
|
|
|
main_layout = QVBoxLayout()
|
|
|
|
# Definition der Felder
|
|
self.user_fields = {
|
|
"amt": "Amt:",
|
|
"behoerde": "Behörde:",
|
|
"landkreis_user": "Landkreis:",
|
|
"sachgebiet": "Sachgebiet:"
|
|
}
|
|
self.project_fields = {
|
|
"bezeichnung": "Bezeichnung:",
|
|
"verfahrensnummer": "Verfahrensnummer:",
|
|
"gemeinden": "Gemeinde(n):",
|
|
"landkreise_proj": "Landkreis(e):"
|
|
}
|
|
|
|
# 🟦 Benutzerspezifische Festlegungen
|
|
user_group = QGroupBox("Benutzerspezifische Festlegungen")
|
|
user_layout = QGridLayout()
|
|
self.user_inputs = {}
|
|
for row, (key, label) in enumerate(self.user_fields.items()):
|
|
self.user_inputs[key] = QLineEdit()
|
|
user_layout.addWidget(QLabel(label), row, 0)
|
|
user_layout.addWidget(self.user_inputs[key], row, 1)
|
|
user_group.setLayout(user_layout)
|
|
|
|
# 🟨 Projektspezifische Festlegungen
|
|
project_group = QGroupBox("Projektspezifische Festlegungen")
|
|
project_layout = QGridLayout()
|
|
self.project_inputs = {}
|
|
for row, (key, label) in enumerate(self.project_fields.items()):
|
|
self.project_inputs[key] = QLineEdit()
|
|
project_layout.addWidget(QLabel(label), row, 0)
|
|
project_layout.addWidget(self.project_inputs[key], row, 1)
|
|
project_group.setLayout(project_layout)
|
|
|
|
# 🟩 Speichern-Button
|
|
save_button = QPushButton("Speichern")
|
|
save_button.clicked.connect(self.save_data)
|
|
|
|
# Layout zusammenfügen
|
|
main_layout.addWidget(user_group)
|
|
main_layout.addWidget(project_group)
|
|
main_layout.addStretch()
|
|
main_layout.addWidget(save_button)
|
|
|
|
self.setLayout(main_layout)
|
|
self.load_data()
|
|
|
|
def save_data(self):
|
|
# Alle Felder zusammenführen
|
|
fields = {key: widget.text() for key, widget in {**self.user_inputs, **self.project_inputs}.items()}
|
|
self.logic.save(fields)
|
|
|
|
def load_data(self):
|
|
data = self.logic.load()
|
|
for key, widget in {**self.user_inputs, **self.project_inputs}.items():
|
|
widget.setText(data.get(key, ""))
|