searchpage updates

This commit is contained in:
WorldTeacher
2024-06-13 09:34:53 +02:00
parent 45b611fe83
commit b0ed5317f5
3 changed files with 60 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
reloadSignal = pyqtSignal()
def __init__(self):
self.logger = MyLogger("search_statistic_page")
self.logger = MyLogger("SearchStatisticPage")
super().__init__()
self.setupUi(self)
self.book_search_result.horizontalHeader().setSectionResizeMode(
@@ -42,6 +42,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
# statistic side buttons
self.btn_notify_for_deletion.clicked.connect(self.notify_for_deletion)
self.btn_notify_for_deletion.setEnabled(False)
self.btn_del_select_apparats.setEnabled(False)
self.tableWidget.resizeColumnsToContents()
self.tableWidget.resizeRowsToContents()
self.db = Database()
@@ -170,7 +171,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
self.box_erstellsemester.setEnabled(True)
self.box_dauerapp.setEnabled(True)
def populate_tab(self):
def populate_tab(self, table_or_graph=0):
# add default values to the dropdowns
self.box_appnrs.clear()
self.box_appnrs.addItem("")
@@ -231,9 +232,10 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
# place the graph into tabWidget_3
self.tabWidget_3.addTab(graph, "Graph")
self.tabWidget_3.setCurrentIndex(0)
self.tabWidget_3.setCurrentIndex(table_or_graph)
def delete_selected_apparats(self):
table_or_graph = self.tabWidget_3.currentIndex()
# get all selected apparats
selected_apparats = []
selected_apparat_rows = []
@@ -250,7 +252,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
for j in range(5):
self.tableWidget.item(row, j).setBackground(QtGui.QColor(235, 74, 71))
# refresh the table
self.populate_tab()
self.populate_tab(table_or_graph)
self.btn_del_select_apparats.setEnabled(False)
def statistics(self):
@@ -357,11 +359,59 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
self.dataLayout.addWidget(deleted_status)
# self.setStatisticTableSize()
created_status.person_double_clicked.emit(self.apparat_open)
created_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
def open_apparat(self, *args):
header = "created"
# in *args
parent_depth = args[2]
apparat = args[1]
if header == "deleted" and parent_depth == 2:
# TODO: warn message here
print("warning")
if parent_depth == 1:
# person selected case - open all apparats from this person in the tableWidget
self.tableWidget.setRowCount(0)
prof_id = self.db.getProfId(apparat.split("(")[0].strip())
apparats = self.db.getApparatsByProf(prof_id)
for app in apparats:
# set the items 0 = clickable checkbox, 1 = appname, 2 = profname, 3 = fach
# insert new row
self.tableWidget.insertRow(0)
self.tableWidget.setItem(0, 0, QtWidgets.QTableWidgetItem(""))
self.tableWidget.setItem(0, 1, QtWidgets.QTableWidgetItem(app[1]))
self.tableWidget.setItem(0, 2, QtWidgets.QTableWidgetItem(str(app[4])))
self.tableWidget.setItem(0, 3, QtWidgets.QTableWidgetItem(app[2]))
self.tableWidget.setItem(0, 4, QtWidgets.QTableWidgetItem(app[3]))
# replace the 0 with a checkbox
checkbox = QtWidgets.QCheckBox()
checkbox.setChecked(False)
self.tableWidget.setCellWidget(0, 0, checkbox)
# if i[9] is 1, set the background of the row to red
if int(app[9]) == 1:
for j in range(5):
self.tableWidget.item(0, j).setBackground(
QtGui.QColor(235, 74, 71)
)
# disable the checkbox
self.tableWidget.cellWidget(0, 0).setEnabled(False)
# set the tooltip
self.tableWidget.cellWidget(0, 0).setToolTip(
"Dieser Semesterapparat kann nicht gelöscht werden, da er bereits gelöscht wurde"
)
elif parent_depth == 2:
print("depth", parent_depth)
# apparat selected case - open the apparat in the frame
self.apparat_open.emit(apparat)
return
def emit_signal(self, *args):
print("emit_signal", *args)
self.apparat_open.emit(args[1])
def show_ui():
app = QtWidgets.QApplication([])