remove whitespaces, fix bug where steps frame was not shown correctly

This commit is contained in:
2024-11-27 13:52:30 +01:00
parent 88a641d13d
commit 28bcbdd97c

View File

@@ -53,8 +53,6 @@ from src.ui import (
EditProf
)
valid_input = (0, 0, 0, 0, 0, 0)
@@ -99,6 +97,7 @@ class Ui(Ui_Semesterapparat):
QtWidgets.QHeaderView.ResizeMode.Stretch
)
self.tableWidget_apparate.setSortingEnabled(True)
self.saveandcreate.hide()
# Actions
self.actionEinstellungen.triggered.connect(self.open_settings)
@@ -179,15 +178,10 @@ class Ui(Ui_Semesterapparat):
self.line_3.hide()
self.avail_status.hide()
self.chkbx_show_del_media.hide()
self.groupBox_2.hide()
self.groupBox.hide()
# self.btn_del_select_apparats.setEnabled(False)
self.tabWidget.currentChanged.connect(self.tabW1_changed)
# create a thread, that continually checks the validity of the inputs
self.validate_thread = QThread()
self.validate_thread.started.connect(self.thread_check)
@@ -201,7 +195,6 @@ class Ui(Ui_Semesterapparat):
# if length of apparats changes, update box_apparats
# if tab is changed, gather data needed
# Context Menus
self.tableWidget_apparate.setContextMenuPolicy(
QtCore.Qt.ContextMenuPolicy.CustomContextMenu
@@ -216,7 +209,6 @@ class Ui(Ui_Semesterapparat):
self.media_context_menu
)
# admin buttons
self.select_action_box.currentTextChanged.connect(self.adminActions)
self.select_action_box.addItem("")
@@ -233,11 +225,15 @@ class Ui(Ui_Semesterapparat):
self.elsatab.setLayout(QtWidgets.QVBoxLayout())
self.search_statistics.setLayout(QtWidgets.QVBoxLayout())
# once inputSignal emits, check state
self.steps.hide()
def checkValidInput(self):
if valid_input == (1, 1, 1, 1, 1, 1):
self.check_file.setEnabled(True)
else:
self.check_file.setEnabled(False)
def setWidget(self, widget):
# remove all widgets from localwidget
@@ -247,7 +243,10 @@ class Ui(Ui_Semesterapparat):
def hideWidget(self):
try:
widgets = [self.admin_action.layout().itemAt(i).widget() for i in range(self.admin_action.layout().count())]
widgets = [
self.admin_action.layout().itemAt(i).widget()
for i in range(self.admin_action.layout().count())
]
except AttributeError:
return
for widget in widgets:
@@ -307,7 +306,9 @@ class Ui(Ui_Semesterapparat):
stats_layout = self.search_statistics.layout()
if stats_layout is not None:
# delete tabpage, re-add with same name at same position
for widget in [stats_layout.itemAt(i).widget() for i in range(stats_layout.count())]:
for widget in [
stats_layout.itemAt(i).widget() for i in range(stats_layout.count())
]:
stats_layout.removeWidget(widget)
widget.deleteLater()
statistics = SearchStatisticPage()
@@ -325,12 +326,14 @@ class Ui(Ui_Semesterapparat):
elsa_layout = self.elsatab.layout()
if elsa_layout is not None:
# delete tabpage, re-add with same name at same position
widgets = [self.elsatab.layout().itemAt(i).widget() for i in range(self.elsatab.layout().count())]
widgets = [
self.elsatab.layout().itemAt(i).widget()
for i in range(self.elsatab.layout().count())
]
for widget in widgets:
self.elsatab.layout().removeWidget(widget)
widget.deleteLater()
elsa_layout.addWidget(ElsaDialog())
print("added")
pass
@@ -405,8 +408,6 @@ class Ui(Ui_Semesterapparat):
self.prof_id_adis.setText(str(appdata.prof_adis_id))
self.apparat_id_adis.setText(str(appdata.apparat_adis_id))
self.app_group_box.setEnabled(True)
self.groupBox_2.hide()
self.groupBox.hide()
self.validateLoadedData()
def validateLoadedData(self):
@@ -609,8 +610,6 @@ class Ui(Ui_Semesterapparat):
self.btn_apparat_save.hide()
self.btn_reserve.show()
self.chkbx_show_del_media.show()
self.groupBox_2.show()
self.groupBox.show()
self.drpdwn_app_nr.setDisabled(True)
self.update_app_media_list()
@@ -632,10 +631,8 @@ class Ui(Ui_Semesterapparat):
self.dokument_list.item(0, 0).setToolTip(file[0])
def btn_create_new_apparat(self):
self.frame_creation_progress.show()
self.groupBox.show()
self.groupBox_2.show()
global valid_input
self.steps.show()
# *create a new apparat
self.btn_apparat_save.show() if self.btn_apparat_save.isHidden() else None
# clear dokumemt_list
@@ -687,6 +684,8 @@ class Ui(Ui_Semesterapparat):
media.exec()
mode = media.mode
data = media.data
use_any = media.use_any
use_exact = media.use_exact
result = media.result()
if result == 1:
@@ -710,7 +709,14 @@ class Ui(Ui_Semesterapparat):
# self.bookGrabber = None
bookGrabber = BookGrabber(self.active_apparat)
bookGrabber.add_values(mode=mode, prof_id=prof_id, app_id=app_id, data=data)
bookGrabber.add_values(
mode=mode,
prof_id=prof_id,
app_id=app_id,
data=data,
any_book=use_any,
exact=use_exact,
)
bookGrabber.finished.connect(self.hide_progress_label)
bookGrabber.finished.connect(self.update_app_media_list)
bookGrabber.updateSignal.connect(self.update_progress_label)
@@ -779,6 +785,7 @@ class Ui(Ui_Semesterapparat):
# self.grabbers.append(availcheck)
def btn_cancel_active_selection(self):
self.steps.hide()
# clear the rows of the table
self.tableWidget_apparat_media.setRowCount(0)
self.dokument_list.setRowCount(0)
@@ -787,8 +794,6 @@ class Ui(Ui_Semesterapparat):
self.chkbx_show_del_media.hide()
self.check_send_mail.hide()
self.btn_reserve.hide()
self.groupBox_2.hide()
self.groupBox.hide()
self.check_eternal_app.setEnabled(False)
# set all radio buttons to unchecked
self.sem_sommer.setChecked(False)
@@ -965,6 +970,7 @@ class Ui(Ui_Semesterapparat):
def add_media_from_file(self):
app_id = self.active_apparat
prof_id = self.db.getProfId(self.profdata)
def __open_dialog(signatures):
dialog = QtWidgets.QDialog()
frame = parsed_titles_ui()
@@ -1167,14 +1173,12 @@ class Ui(Ui_Semesterapparat):
self.drpdwn_prof_name.clear()
self.tableWidget_apparat_media.setRowCount(0)
self.app_group_box.setEnabled(False)
self.groupBox_2.hide()
self.groupBox.hide()
self.check_send_mail.setChecked(False)
self.cancel_active_selection.setEnabled(False)
# check if sem_sommer, sem_winter and check_eternal_app are checked. if yes, set them to unchecked
def btn_save_apparat(self, clear_fields=True):
self.steps.hide()
if not self.validate_fields():
self.confirm_popup("Bitte alle Pflichtfelder ausfüllen!", title="Fehler")
return False
@@ -1206,6 +1210,7 @@ class Ui(Ui_Semesterapparat):
# merge self.appdata and appdata, remove duplicates
self.apparats = list(set(self.apparats + appdata))
self.apparats = natsorted(self.apparats, key=lambda x: x[4], reverse=True)
self.update_apparat_list()
# self.btn_load_apparat()
@@ -1405,12 +1410,26 @@ class Ui(Ui_Semesterapparat):
menu = QtWidgets.QMenu()
delete_action = menu.addAction("Löschen")
edit_action = menu.addAction("Bearbeiten")
apparat_add_action = menu.addAction("Zum Apparat hinzufügen")
menu.addAction(delete_action)
menu.addAction(edit_action)
menu.addAction(apparat_add_action)
delete_action.triggered.connect(self.delete_medium)
edit_action.triggered.connect(self.edit_medium)
apparat_add_action.triggered.connect(self.add_to_apparat)
menu.exec(self.tableWidget_apparat_media.mapToGlobal(position))
def add_to_apparat(self):
"""use playwright in background to add medium to apparat"""
signature = self.tableWidget_apparat_media.item(
self.tableWidget_apparat_media.currentRow(), 1
).text()
medium = self.db.getBookBasedOnSignature(
self.drpdwn_app_nr.currentText(),
signature=signature,
prof_id=self.db.getProfId(self.profdata),
)
print(medium.adis_idn, medium.signature)
def edit_medium(self):
book = self.tableWidget_apparat_media.item(
self.tableWidget_apparat_media.currentRow(), 1
@@ -1629,12 +1648,6 @@ def launch_gui():
warning_dialog.setText("Invalid username or password. Please try again.")
warning_dialog.setWindowTitle("Login Failed")
warning_dialog.exec()
elif ui.lresult == 2:
# TODO: implement admin functionality here
"""change passwords for apparats, change passwords for users, list users, create and delete users etc"""
# open a console window
# console = ""
# print("admin")
atexit.register(tempdelete)