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