From b0ed5317f5d43760eb56757db0f67ddebfae4f4b Mon Sep 17 00:00:00 2001
From: WorldTeacher <41587052+WorldTeacher@users.noreply.github.com>
Date: Thu, 13 Jun 2024 09:34:53 +0200
Subject: [PATCH] searchpage updates
---
src/ui/widgets/searchPage.py | 60 +++++++++++++++++--
.../Ui_search_statistic_page.py | 4 +-
.../widget_sources/search_statistic_page.ui | 4 +-
3 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/src/ui/widgets/searchPage.py b/src/ui/widgets/searchPage.py
index b6d3915..9a2fd78 100644
--- a/src/ui/widgets/searchPage.py
+++ b/src/ui/widgets/searchPage.py
@@ -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([])
diff --git a/src/ui/widgets/widget_sources/Ui_search_statistic_page.py b/src/ui/widgets/widget_sources/Ui_search_statistic_page.py
index 99aa360..809b3b5 100644
--- a/src/ui/widgets/widget_sources/Ui_search_statistic_page.py
+++ b/src/ui/widgets/widget_sources/Ui_search_statistic_page.py
@@ -205,7 +205,7 @@ class Ui_Dialog(object):
item = QtWidgets.QTableWidgetItem()
self.statistics_table.setHorizontalHeaderItem(2, item)
self.statistics_table.horizontalHeader().setCascadingSectionResizes(True)
- self.statistics_table.horizontalHeader().setDefaultSectionSize(59)
+ self.statistics_table.horizontalHeader().setDefaultSectionSize(80)
self.statistics_table.horizontalHeader().setMinimumSectionSize(40)
self.statistics_table.horizontalHeader().setSortIndicatorShown(True)
self.statistics_table.horizontalHeader().setStretchLastSection(True)
@@ -219,6 +219,8 @@ class Ui_Dialog(object):
self.graph_table.setObjectName("graph_table")
self.tabWidget_3.addTab(self.graph_table, "")
self.horizontalLayout.addWidget(self.tabWidget_3)
+ self.horizontalLayout.setStretch(0, 55)
+ self.horizontalLayout.setStretch(1, 45)
self.stackedWidget_4.addWidget(self.apparatResult)
self.bookresult = QtWidgets.QWidget()
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
diff --git a/src/ui/widgets/widget_sources/search_statistic_page.ui b/src/ui/widgets/widget_sources/search_statistic_page.ui
index 0d160d2..56cd8df 100644
--- a/src/ui/widgets/widget_sources/search_statistic_page.ui
+++ b/src/ui/widgets/widget_sources/search_statistic_page.ui
@@ -305,7 +305,7 @@
0
-
+
-
-
@@ -437,7 +437,7 @@
40
- 59
+ 80
true