From 8b5c355bf11cf7b1810776ac739793791354928e Mon Sep 17 00:00:00 2001 From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:40:02 +0200 Subject: [PATCH] sort profs, add check to enable check_file only if all fields are set correctly --- src/ui/dialogs/elsa_add_entry.py | 5 +++-- src/ui/userInterface.py | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ui/dialogs/elsa_add_entry.py b/src/ui/dialogs/elsa_add_entry.py index 04ed4bf..a6a5dd8 100644 --- a/src/ui/dialogs/elsa_add_entry.py +++ b/src/ui/dialogs/elsa_add_entry.py @@ -66,7 +66,6 @@ class ElsaAddEntry(QtWidgets.QDialog, Ui_Dialog): def copy_to_clipboard(self, field): clipboard = QtWidgets.QApplication.clipboard() - # fields are textedits clipboard.setText(field.toPlainText()) def discard(self): for line in self.findChildren(QtWidgets.QLineEdit): @@ -167,17 +166,19 @@ class ElsaAddEntry(QtWidgets.QDialog, Ui_Dialog): param = self.searchIdent.text() web = WebRequest() web.get_ppn(param) - data = web.get_data() + data = web.get_data_elsa() # if isinstance(data, list): # data = data[0] bib = BibTextTransformer("ARRAY") bib.get_data(data) data = bib.return_data() + print(data) self.setdata(data) def setdata(self, data): # use field to set data in the correct fields fields = self.findChildren(QtWidgets.QLineEdit) + self.source_pages = data.pages # remove all fields from the list if they do not start with the mode and _ fields = [field for field in fields if field.objectName().startswith(self.mode)] for field in fields: diff --git a/src/ui/userInterface.py b/src/ui/userInterface.py index ec44c38..0950fc8 100644 --- a/src/ui/userInterface.py +++ b/src/ui/userInterface.py @@ -2,11 +2,12 @@ import atexit import os -import subprocess import sys import tempfile +import time import webbrowser from pathlib import Path +import threading from icecream import ic from natsort import natsorted @@ -54,7 +55,6 @@ from src.ui import ( UserCreate, EditUser, EditProf - ) config = OmegaConf.load("config.yaml") @@ -237,7 +237,12 @@ class Ui(Ui_Semesterapparat): self.elsatab.setLayout(QtWidgets.QVBoxLayout()) self.search_statistics.setLayout(QtWidgets.QVBoxLayout()) - + #once inputSignal emits, check state + 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 @@ -542,7 +547,7 @@ class Ui(Ui_Semesterapparat): valid_input = list(valid_input) valid_input[index] = state valid_input = tuple(valid_input) - + self.checkValidInput() def set_state(self): # set state of semester and year @@ -559,6 +564,7 @@ class Ui(Ui_Semesterapparat): return all(valid_input) def set_prof_data(self): + self.prof_title.clear() if "," not in self.drpdwn_prof_name.currentText(): self.prof_mail.clear() self.prof_tel_nr.clear() @@ -648,7 +654,7 @@ class Ui(Ui_Semesterapparat): self.drpdwn_app_nr.setEnabled(True) self.app_fach.setEnabled(True) self.check_send_mail.show() - + self.check_file.setEnabled(False) if self.tableWidget_apparat_media.rowCount() > 0: self.tableWidget_apparat_media.setRowCount(0) # clear all fields @@ -908,8 +914,10 @@ class Ui(Ui_Semesterapparat): profs = self.db.getProfs() # add empty entry to dropdown and set it as current self.drpdwn_prof_name.addItem("Kein Name") + profs = [f"{prof.lastname}, {prof.firstname}" for prof in profs] + profs.sort() for prof in profs: - self.drpdwn_prof_name.addItem(f"{prof.lastname}, {prof.firstname}") + self.drpdwn_prof_name.addItem(prof) def add_document(self): # print("Add document")