ui changes

This commit is contained in:
WorldTeacher
2024-06-03 15:18:02 +02:00
parent ecf7ac1fea
commit a19dc12c18
11 changed files with 743 additions and 227 deletions

View File

@@ -42,6 +42,7 @@ from src.ui import (
reminder_ui,
settings_ui,
)
from src.utils import Icon
config = OmegaConf.load("config.yaml")
@@ -114,13 +115,7 @@ class Ui(Ui_Semesterapparat):
self.MainWindow = MainWindow
# set the window title
MainWindow.setWindowTitle("Semesterapparatsmanagement")
icon = QtGui.QIcon()
icon.addPixmap(
QtGui.QPixmap("icons/logo.ico"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.Off,
)
MainWindow.setWindowIcon(icon)
MainWindow.setWindowIcon(Icon("logo", "ico").icon)
self.db = Database()
# self.show()
@@ -298,6 +293,7 @@ class Ui(Ui_Semesterapparat):
self.elsa_save.clicked.connect(self.save_elsa)
self.elsa_date_today.clicked.connect(self.generateTodayDateElsa)
self.active_semester.clicked.connect(self.addSemester)
Icon("semap", "png").set_icon(self.active_semester)
self.elsa_table.doubleClicked.connect(self.open_elsa)
self.btn_add_document_elsa.clicked.connect(self.addDokumentElsa)
self.check_file_elsa.clicked.connect(self.parseDokumentElsa)
@@ -408,12 +404,8 @@ class Ui(Ui_Semesterapparat):
)
scans = self.db.getElsaMedia(elsa_id)
if scans == []:
self.MainWindow.setStatusTip("ELSA-Apparat hat noch keine Daten")
self.create_frame_elsa.setEnabled(True)
else:
self.MainWindow.setStatusTip(
"ELSA-Apparat hat bereits alle benötigten Daten"
)
for scan in scans:
self.table_elsa_list.insertRow(0)
self.table_elsa_list.setItem(0, 0, QtWidgets.QTableWidgetItem(scan[1]))
@@ -549,6 +541,19 @@ class Ui(Ui_Semesterapparat):
self.btn_notify_for_deletion.setEnabled(False)
def setStatisticTableSize(self):
print(self.statistics_table.size(), self.statistics_table.rowCount())
size = self.statistics_table.size()
h = size.height()
w = size.width()
rows = self.statistics_table.rowCount()
rowheight = round(h / rows) - 5
header_width = round(w / 3) - 5
for i in range(3):
self.statistics_table.setColumnWidth(i, header_width)
for i in range(rows):
self.statistics_table.setRowHeight(i, rowheight)
def get_apparats(self):
alist = self.db.getAllAparats(deleted=0)
alist = natsorted(alist, key=lambda x: x[4], reverse=True)
@@ -572,6 +577,7 @@ class Ui(Ui_Semesterapparat):
# self.tabWidget.setCurrentIndex(1)
self.tabWidget_2.setCurrentIndex(1)
self.tabWidget_2.setCurrentIndex(0)
self.populate_tab()
if self.tabWidget.currentIndex() == 0: # Apparate
# clear all entries from the table
self.tableWidget_apparate.setRowCount(0)
@@ -585,17 +591,20 @@ class Ui(Ui_Semesterapparat):
self.elsa_table.setRowCount(0)
elsa_apparats = self.db.getElsaApparats()
elsa_apparats = natsorted(elsa_apparats, key=lambda x: x[2], reverse=True)
graph_data = {}
graph_data = {"x": [], "y": []} # x = semester, y = number of apparats
for apparat in elsa_apparats:
print(apparat)
data = self.insert_elsa_into_table(apparat)
if data[0] in graph_data.keys():
graph_data["x"].append(data[0])
graph_data["y"].append(data[1])
semester = data[0]
number = data[1]
if semester not in graph_data["x"]:
graph_data["x"].append(semester)
graph_data["y"].append(number)
else:
graph_data["x"] = [data[0]]
graph_data["y"] = [data[1]]
index = graph_data["x"].index(semester)
graph_data["y"][index] += number
generateMissing = True if len(graph_data["x"]) > 1 else False
graph = DataGraph(
"ELSA Apparate pro Semester",
@@ -603,7 +612,16 @@ class Ui(Ui_Semesterapparat):
generateMissing,
"Anzahl der Apparate",
)
ic(graph_data)
self.elsa_statistics_table.setRowCount(0)
for i in range(len(graph_data["x"])):
self.elsa_statistics_table.insertRow(0)
self.elsa_statistics_table.setItem(
0, 0, QtWidgets.QTableWidgetItem(graph_data["x"][i])
)
self.elsa_statistics_table.setItem(
0, 1, QtWidgets.QTableWidgetItem(str(graph_data["y"][i]))
)
self.elsa_statistics.addTab(graph, "Graph")
def search_book(self):
@@ -895,8 +913,12 @@ class Ui(Ui_Semesterapparat):
# add them to the gridLayout_4
self.gridLayout_4.addWidget(created_status, 1, 0)
self.gridLayout_4.addWidget(deleted_status, 1, 1)
# self.setStatisticTableSize()
created_status.person_double_clicked.connect(self.open_apparat)
deleted_status.person_double_clicked.connect(self.open_apparat)
created_status.setToolTip("Doppelklick um den Semesterapparat zu öffnen")
deleted_status.setToolTip("Nur zur Übersicht")
# set deleted_status background to slightly gray
deleted_status.setStyleSheet("background-color: #f0f0f0")
def open_apparat(self, header: str, apparat: str, parent_depth: int):
print(header)
@@ -1013,6 +1035,9 @@ class Ui(Ui_Semesterapparat):
)
self.statistics_table.resizeColumnsToContents()
self.statistics_table.resizeRowsToContents()
# self.setStatisticTableSize()
# get height of the table
# create graph
graph_data = {
@@ -1252,7 +1277,8 @@ class Ui(Ui_Semesterapparat):
self.profname_mand.setText("*")
self.change_state(0, 0)
else:
self.drpdwn_prof_name.setStyleSheet("border: 1px solid black;")
pass
# self.drpdwn_prof_name.setStyleSheet("border: 1px solid black;")
def validate_prof_mail(self):
if self.frame.isEnabled():
@@ -1308,9 +1334,11 @@ class Ui(Ui_Semesterapparat):
) or self.check_eternal_app.isChecked():
self._mand.setText("")
self.change_state(5, 1)
self.check_eternal_app.setEnabled(True)
else:
self._mand.setText("*")
self.change_state(5, 0)
self.check_eternal_app.setEnabled(False)
def change_state(self, index, state):
global valid_input
@@ -1593,6 +1621,11 @@ class Ui(Ui_Semesterapparat):
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)
self.sem_winter.setChecked(False)
for child in self.frame.findChildren(QtWidgets.QLineEdit):
child.clear()
@@ -2315,13 +2348,11 @@ class Ui(Ui_Semesterapparat):
if apparat is None:
self.confirm_popup("Bitte erst einen Apparat auswählen!")
return
active_apparat_id = (
self.tableWidget_apparate.item(
self.tableWidget_apparate.currentRow(), 0
).text()
if apparat is None
else apparat
)
if apparat:
active_apparat_id = apparat
else:
active_apparat_id = self.drpdwn_app_nr.currentText()
print(active_apparat_id)
profname = self.drpdwn_prof_name.currentText().replace(",", "").split(" ")
profname = f"{profname[1]} {profname[0]}"
prof_id = self.db.getProfId(self.drpdwn_prof_name.currentText())