move medienadder back into own file
This commit is contained in:
@@ -56,24 +56,10 @@ from src.ui import (
|
||||
SearchStatisticPage,
|
||||
)
|
||||
from src.ui.dialogs.elsa_add_entry import ElsaAddEntry
|
||||
|
||||
config = OmegaConf.load("config.yaml")
|
||||
|
||||
|
||||
class Medien(medienadder_ui):
|
||||
def __init__(self) -> None:
|
||||
self.logger = MyLogger("Medien")
|
||||
super().__init__()
|
||||
self.mode = ""
|
||||
self.data = []
|
||||
|
||||
def get_list_data(self) -> list:
|
||||
signatures = self.listWidget.findItems("*", QtCore.Qt.MatchFlag.MatchWildcard)
|
||||
return [signature.text() for signature in signatures]
|
||||
|
||||
def get_mode(self) -> str:
|
||||
return self.comboBox.currentText()
|
||||
|
||||
|
||||
valid_input = (0, 0, 0, 0, 0, 0)
|
||||
|
||||
|
||||
@@ -280,7 +266,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.update_faculty_member.clicked.connect(self.edit_faculty_member_action)
|
||||
|
||||
# Create instances to be used by the threads in the application
|
||||
self.bookGrabber = None
|
||||
self.bookGrabber = []
|
||||
self.availChecker = None
|
||||
self.mail_thread = None
|
||||
self.autoGrabber = None
|
||||
@@ -375,6 +361,8 @@ class Ui(Ui_Semesterapparat):
|
||||
self.db.createElsaApparat(date, prof, semester)
|
||||
self.cancel_elsa_creation()
|
||||
self.refresh_elsa_table()
|
||||
self.elsa_prof.clear()
|
||||
self.elsa_prof.addItem(prof)
|
||||
|
||||
def refresh_elsa_table(self):
|
||||
self.elsa_table.setRowCount(0)
|
||||
@@ -397,6 +385,7 @@ class Ui(Ui_Semesterapparat):
|
||||
date = self.elsa_table.item(self.elsa_table.currentRow(), 1).text()
|
||||
semester = self.elsa_table.item(self.elsa_table.currentRow(), 2).text()
|
||||
self.elsa_update.setEnabled(True)
|
||||
self.elsa_save.setEnabled(False)
|
||||
if self.elsa_prof.currentText() == prof:
|
||||
self.logger.log_info("Same prof, stopping")
|
||||
return
|
||||
@@ -476,6 +465,7 @@ class Ui(Ui_Semesterapparat):
|
||||
0, 11, QtWidgets.QTableWidgetItem(scan["type"])
|
||||
)
|
||||
self.create_frame_elsa.setEnabled(True)
|
||||
|
||||
def addDokumentElsa(self):
|
||||
print("Add document")
|
||||
picker = FilePicker()
|
||||
@@ -1005,6 +995,7 @@ class Ui(Ui_Semesterapparat):
|
||||
Icon("valid_false", widget)
|
||||
mand.setText("*")
|
||||
self.change_state(index, 0)
|
||||
|
||||
def validate_prof_name(self):
|
||||
if (
|
||||
self.app_group_box.isEnabled()
|
||||
@@ -1013,6 +1004,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.__setValidState(self.valid_check_profname, 1, self.profname_mand, 0)
|
||||
else:
|
||||
self.__setValidState(self.valid_check_profname, 0, self.profname_mand, 0)
|
||||
|
||||
def validate_prof_mail(self):
|
||||
if self.app_group_box.isEnabled():
|
||||
if self.prof_mail.hasAcceptableInput():
|
||||
@@ -1021,6 +1013,7 @@ class Ui(Ui_Semesterapparat):
|
||||
self.__setValidState(self.valid_check_mail, 0, self.mail_mand, 1)
|
||||
else:
|
||||
self.__setValidState(self.valid_check_mail, 0, self.mail_mand, 1)
|
||||
|
||||
def validate_prof_tel(self):
|
||||
if self.app_group_box.isEnabled():
|
||||
if self.prof_tel_nr.text() != "" and self.prof_tel_nr.hasAcceptableInput():
|
||||
@@ -1029,11 +1022,13 @@ class Ui(Ui_Semesterapparat):
|
||||
self.__setValidState(self.valid_check_telnr, 0, self.telnr_mand, 2)
|
||||
else:
|
||||
self.__setValidState(self.valid_check_telnr, 0, self.telnr_mand, 2)
|
||||
|
||||
def validate_app_name(self):
|
||||
if self.app_group_box.isEnabled() and self.app_name.hasAcceptableInput():
|
||||
self.__setValidState(self.valid_check_appname, 1, self.appname_mand, 3)
|
||||
else:
|
||||
self.__setValidState(self.valid_check_appname, 0, self.appname_mand, 3)
|
||||
|
||||
def validate_app_fach(self):
|
||||
if self.app_group_box.isEnabled() and self.app_fach.currentText() != "":
|
||||
self.__setValidState(self.valid_check_app_fach, 1, self.fach_mand, 4)
|
||||
@@ -1198,23 +1193,21 @@ class Ui(Ui_Semesterapparat):
|
||||
self.confirm_popup("Bitte erst einen Apparat auswählen!", title="Fehler")
|
||||
return
|
||||
|
||||
def __new_ui():
|
||||
dialog = QtWidgets.QDialog()
|
||||
frame = Medien()
|
||||
frame.setupUi(dialog)
|
||||
dialog.exec()
|
||||
mode = frame.get_mode()
|
||||
data = frame.get_list_data()
|
||||
return mode, data, dialog.result()
|
||||
media = medienadder_ui()
|
||||
media.exec()
|
||||
mode = media.mode
|
||||
data = media.data
|
||||
result = media.result()
|
||||
|
||||
self.progress_label.show()
|
||||
self.line_2.show()
|
||||
self.label_info.show()
|
||||
self.progress_label.setText("Bitte warten...")
|
||||
mode, data, result = __new_ui()
|
||||
if result == 1:
|
||||
if data == []:
|
||||
self.confirm_popup("Bitte mindestens ein Medium hinzufügen!")
|
||||
self.confirm_popup(
|
||||
"Bitte mindestens ein Medium hinzufügen!", title="Fehler"
|
||||
)
|
||||
|
||||
app_id = self.active_apparat
|
||||
prof_id = self.db.getProfId(self.drpdwn_prof_name.currentText())
|
||||
@@ -1224,18 +1217,18 @@ class Ui(Ui_Semesterapparat):
|
||||
self.btn_save_apparat(False)
|
||||
# create a thread that updates the progress label after each medium
|
||||
|
||||
self.bookGrabber = BookGrabber(
|
||||
mode=mode, prof_id=prof_id, app_id=app_id, data=data
|
||||
)
|
||||
self.bookGrabber.finished.connect(self.bookGrabber.deleteLater)
|
||||
self.bookGrabber.finished.connect(self.hide_progress_label)
|
||||
self.bookGrabber.finished.connect(self.update_app_media_list)
|
||||
self.bookGrabber.updateSignal.connect(self.update_progress_label)
|
||||
# self.bookGrabber = None
|
||||
bookGrabber = BookGrabber()
|
||||
bookGrabber.add_values(mode=mode, prof_id=prof_id, app_id=app_id, data=data)
|
||||
bookGrabber.finished.connect(self.hide_progress_label)
|
||||
bookGrabber.finished.connect(self.update_app_media_list)
|
||||
bookGrabber.updateSignal.connect(self.update_progress_label)
|
||||
|
||||
bookGrabber.start()
|
||||
# while self.bookGrabber[-1].isRunning():
|
||||
# print("waiting for thread to finish")
|
||||
# QtWidgets.QApplication.processEvents()
|
||||
|
||||
self.bookGrabber.start()
|
||||
while self.bookGrabber.isRunning():
|
||||
print("waiting for thread to finish")
|
||||
QtWidgets.QApplication.processEvents()
|
||||
self.__clear_fields()
|
||||
|
||||
else:
|
||||
@@ -1397,15 +1390,18 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
if "http" not in link:
|
||||
link = "https://" + link
|
||||
|
||||
webbrowser.open(link)
|
||||
return link
|
||||
#
|
||||
|
||||
# get the name of the column
|
||||
columnname = self.tableWidget_apparat_media.horizontalHeaderItem(
|
||||
item.column()
|
||||
).text()
|
||||
if columnname == "Link":
|
||||
__openLink(item.text())
|
||||
link = __openLink(item.text())
|
||||
if link is not None:
|
||||
webbrowser.open(link)
|
||||
return
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -1438,7 +1434,7 @@ class Ui(Ui_Semesterapparat):
|
||||
# set tooltip of row 3 to the file path for each row
|
||||
self.dokument_list.item(0, 3).setToolTip(file)
|
||||
|
||||
# self.db.insert_file(files, self.active_apparat, self.db.get_prof_id(self.drpdwn_prof_name.currentText()))
|
||||
# self.add_files()
|
||||
|
||||
def open_document(self):
|
||||
_selected_doc_name = ""
|
||||
@@ -1458,7 +1454,8 @@ class Ui(Ui_Semesterapparat):
|
||||
return
|
||||
if not _selected_doc_location == "Database":
|
||||
path = Path(_selected_doc_location)
|
||||
path: Path = path + "/" + _selected_doc_name
|
||||
path: Path = path.resolve()
|
||||
path = path + "/" + _selected_doc_name
|
||||
if os.getenv("OS") == "Windows_NT":
|
||||
path = path.resolve()
|
||||
os.startfile(path)
|
||||
@@ -1586,6 +1583,7 @@ class Ui(Ui_Semesterapparat):
|
||||
print("Creating apparat")
|
||||
self.btn_save_apparat(False)
|
||||
created = True
|
||||
prof_id = self.db.getProfId(self.drpdwn_prof_name.currentText())
|
||||
if self.dokument_list.rowCount() == 0:
|
||||
print("No file selected")
|
||||
self.tableWidget_apparate.setEnabled(True)
|
||||
@@ -1630,27 +1628,30 @@ class Ui(Ui_Semesterapparat):
|
||||
signatures = [i for i in signatures if i != ""]
|
||||
# ic(signatures)
|
||||
print("starting thread")
|
||||
self.autoGrabber = BookGrabber(
|
||||
|
||||
autoGrabber = BookGrabber()
|
||||
autoGrabber.add_values(
|
||||
mode="ARRAY", app_id=app_id, prof_id=prof_id, data=signatures
|
||||
)
|
||||
self.label_info.show()
|
||||
self.progress_label.show()
|
||||
self.line_2.show()
|
||||
# grabber.finished.connect(thread.quit)
|
||||
self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
||||
self.autoGrabber.finished.connect(self.hide_progress_label)
|
||||
self.autoGrabber.finished.connect(self.unlock_apparate)
|
||||
self.autoGrabber.updateSignal.connect(self.update_progress_label)
|
||||
# self.autoGrabber.finished.connect(self.autoGrabber.deleteLater)
|
||||
autoGrabber.finished.connect(self.hide_progress_label)
|
||||
autoGrabber.finished.connect(self.unlock_apparate)
|
||||
|
||||
autoGrabber.updateSignal.connect(self.update_progress_label)
|
||||
# worker.finished.connect(worker.deleteLater)
|
||||
|
||||
self.autoGrabber.start()
|
||||
while self.autoGrabber.isRunning():
|
||||
autoGrabber.start()
|
||||
while autoGrabber.isRunning():
|
||||
QtWidgets.QApplication.processEvents()
|
||||
# end of thread
|
||||
# self.autoGrabber.exit()
|
||||
self.update_app_media_list()
|
||||
self.__clear_fields()
|
||||
self.btn_cancel_active_selection()
|
||||
# self.__clear_fields()
|
||||
# self.btn_cancel_active_selection()
|
||||
|
||||
def unlock_apparate(self):
|
||||
self.tableWidget_apparate.setEnabled(True)
|
||||
self.tableWidget_apparate.setToolTip("")
|
||||
@@ -1743,6 +1744,7 @@ class Ui(Ui_Semesterapparat):
|
||||
}
|
||||
)
|
||||
self.dokument_list.item(i, 2).setText("")
|
||||
|
||||
self.db.insertFile(
|
||||
files,
|
||||
self.active_apparat,
|
||||
@@ -1808,11 +1810,13 @@ class Ui(Ui_Semesterapparat):
|
||||
row = self.tableWidget_apparate.rowAt(position.y())
|
||||
column = self.tableWidget_apparate.columnAt(position.x())
|
||||
pos = (str(row), str(column))
|
||||
ic(pos)
|
||||
pid = self.__get_table_data_field(self.tableWidget_apparate, pos[0], 2)
|
||||
|
||||
ic(pos, pid)
|
||||
extend_action.triggered.connect(self.extend_apparat)
|
||||
delete_action.triggered.connect(lambda: self.delete_apparat(pos))
|
||||
# pass pos to contact_prof
|
||||
contact_action.triggered.connect(self.contact_prof)
|
||||
contact_action.triggered.connect(lambda: self.contact_prof(pid=pid))
|
||||
remind_action.triggered.connect(self.reminder)
|
||||
menu.exec(self.tableWidget_apparate.mapToGlobal(position))
|
||||
|
||||
@@ -2071,9 +2075,6 @@ class Ui(Ui_Semesterapparat):
|
||||
self.tableWidget_apparate.removeRow(self.tableWidget_apparate.currentRow())
|
||||
# send mail to prof
|
||||
self.contact_prof(mail="deleted", apparat=selected_apparat_id, pid=pid)
|
||||
# if state==QtWidgets.QDialog.DialogCode.Accepted:
|
||||
# self.db.delete_apparat(selected_apparat_id)
|
||||
# pass
|
||||
|
||||
|
||||
def launch_gui():
|
||||
|
||||
Reference in New Issue
Block a user