update logging, update docuprint add new ui for generating documents
This commit is contained in:
233
src/ui/dialogs/dialog_sources/documentprint.ui
Normal file
233
src/ui/dialogs/dialog_sources/documentprint.ui
Normal file
@@ -0,0 +1,233 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>725</width>
|
||||
<height>623</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>707</width>
|
||||
<height>545</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Semesterapparatsübersicht</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mit dem Klick auf Okay wird eine Übersicht aller aktiven Semesterapparate erstellt und an den FollowME Drucker gesendet. Es kann bis zu 5 Minuten dauern, bis das Dokument im Drucker angezeigt wird.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Dokument erstellen und drucken</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>707</width>
|
||||
<height>545</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Semesterapparatsschilder</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hier kann das Dokument für die Semesterapparatsschilder erstellt werden. Hierfür müssen die entsprechenden Apparate ausgewählt werden. Mithilfe dieser wird das Dokument erstellt.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Dokument erstellen und drucken</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_load_current_apparats">
|
||||
<property name="text">
|
||||
<string>Aktuelle Apparate laden</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="expertMode">
|
||||
<property name="text">
|
||||
<string>Expertenmodus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
hr { height: 1px; border-width: 0; }
|
||||
li.unchecked::marker { content: "\2610"; }
|
||||
li.checked::marker { content: "\2612"; }
|
||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:700; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">SELECT</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> semesterapparat.name,</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> prof.lname</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">from</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> semesterapparat</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> INNER JOIN prof ON semesterapparat.prof_id = prof.id</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">WHERE</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> (erstellsemester = 'SoSe 25'</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> OR erstellsemester = 'WiSe 24/25')</p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> and semesterapparat.deletion_status = 0</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="manualCheck">
|
||||
<property name="text">
|
||||
<string>Anfragen und anzeigen</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="font">
|
||||
<font>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignLeading|AlignVCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
143
src/ui/dialogs/dialog_sources/documentprint_ui.py
Normal file
143
src/ui/dialogs/dialog_sources/documentprint_ui.py
Normal file
@@ -0,0 +1,143 @@
|
||||
# Form implementation generated from reading ui file 'c:\Users\aky547\GitHub\SemesterapparatsManager\src\ui\dialogs\dialog_sources\documentprint.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.8.0
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_Dialog(object):
|
||||
def setupUi(self, Dialog):
|
||||
Dialog.setObjectName("Dialog")
|
||||
Dialog.resize(725, 623)
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.toolBox = QtWidgets.QToolBox(parent=Dialog)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
self.toolBox.setFont(font)
|
||||
self.toolBox.setObjectName("toolBox")
|
||||
self.page = QtWidgets.QWidget()
|
||||
self.page.setGeometry(QtCore.QRect(0, 0, 707, 545))
|
||||
self.page.setObjectName("page")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(self.page)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.label = QtWidgets.QLabel(parent=self.page)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.label.setFont(font)
|
||||
self.label.setWordWrap(True)
|
||||
self.label.setObjectName("label")
|
||||
self.horizontalLayout.addWidget(self.label)
|
||||
self.pushButton = QtWidgets.QPushButton(parent=self.page)
|
||||
self.pushButton.setObjectName("pushButton")
|
||||
self.horizontalLayout.addWidget(self.pushButton)
|
||||
self.toolBox.addItem(self.page, "")
|
||||
self.page_2 = QtWidgets.QWidget()
|
||||
self.page_2.setGeometry(QtCore.QRect(0, 0, 707, 545))
|
||||
self.page_2.setObjectName("page_2")
|
||||
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.page_2)
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
|
||||
self.label_2 = QtWidgets.QLabel(parent=self.page_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.label_2.setFont(font)
|
||||
self.label_2.setWordWrap(True)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.horizontalLayout_2.addWidget(self.label_2)
|
||||
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_3.setObjectName("verticalLayout_3")
|
||||
self.pushButton_2 = QtWidgets.QPushButton(parent=self.page_2)
|
||||
self.pushButton_2.setObjectName("pushButton_2")
|
||||
self.verticalLayout_3.addWidget(self.pushButton_2)
|
||||
self.btn_load_current_apparats = QtWidgets.QPushButton(parent=self.page_2)
|
||||
self.btn_load_current_apparats.setObjectName("btn_load_current_apparats")
|
||||
self.verticalLayout_3.addWidget(self.btn_load_current_apparats)
|
||||
self.expertMode = QtWidgets.QCheckBox(parent=self.page_2)
|
||||
self.expertMode.setObjectName("expertMode")
|
||||
self.verticalLayout_3.addWidget(self.expertMode)
|
||||
self.horizontalLayout_2.addLayout(self.verticalLayout_3)
|
||||
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
|
||||
self.frame = QtWidgets.QFrame(parent=self.page_2)
|
||||
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||
self.frame.setObjectName("frame")
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.frame)
|
||||
self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout_3.setSpacing(0)
|
||||
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
|
||||
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_4.setObjectName("verticalLayout_4")
|
||||
self.textBrowser = QtWidgets.QTextBrowser(parent=self.frame)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.textBrowser.sizePolicy().hasHeightForWidth())
|
||||
self.textBrowser.setSizePolicy(sizePolicy)
|
||||
self.textBrowser.setReadOnly(False)
|
||||
self.textBrowser.setObjectName("textBrowser")
|
||||
self.verticalLayout_4.addWidget(self.textBrowser)
|
||||
self.manualCheck = QtWidgets.QPushButton(parent=self.frame)
|
||||
self.manualCheck.setObjectName("manualCheck")
|
||||
self.verticalLayout_4.addWidget(self.manualCheck)
|
||||
self.horizontalLayout_3.addLayout(self.verticalLayout_4)
|
||||
self.verticalLayout_2.addWidget(self.frame)
|
||||
self.tableWidget = QtWidgets.QTableWidget(parent=self.page_2)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(False)
|
||||
self.tableWidget.setFont(font)
|
||||
self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.tableWidget.setObjectName("tableWidget")
|
||||
self.tableWidget.setColumnCount(2)
|
||||
self.tableWidget.setRowCount(0)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
item.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignVCenter)
|
||||
self.tableWidget.setHorizontalHeaderItem(0, item)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.tableWidget.setHorizontalHeaderItem(1, item)
|
||||
self.tableWidget.horizontalHeader().setSortIndicatorShown(True)
|
||||
self.tableWidget.horizontalHeader().setStretchLastSection(True)
|
||||
self.verticalLayout_2.addWidget(self.tableWidget)
|
||||
self.toolBox.addItem(self.page_2, "")
|
||||
self.verticalLayout.addWidget(self.toolBox)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
self.toolBox.setCurrentIndex(1)
|
||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.label.setText(_translate("Dialog", "Mit dem Klick auf Okay wird eine Übersicht aller aktiven Semesterapparate erstellt und an den FollowME Drucker gesendet. Es kann bis zu 5 Minuten dauern, bis das Dokument im Drucker angezeigt wird."))
|
||||
self.pushButton.setText(_translate("Dialog", "Dokument erstellen und drucken"))
|
||||
self.toolBox.setItemText(self.toolBox.indexOf(self.page), _translate("Dialog", "Semesterapparatsübersicht"))
|
||||
self.label_2.setText(_translate("Dialog", "Hier kann das Dokument für die Semesterapparatsschilder erstellt werden. Hierfür müssen die entsprechenden Apparate ausgewählt werden. Mithilfe dieser wird das Dokument erstellt."))
|
||||
self.pushButton_2.setText(_translate("Dialog", "Dokument erstellen und drucken"))
|
||||
self.btn_load_current_apparats.setText(_translate("Dialog", "Aktuelle Apparate laden"))
|
||||
self.expertMode.setText(_translate("Dialog", "Expertenmodus"))
|
||||
self.textBrowser.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><meta charset=\"utf-8\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"hr { height: 1px; border-width: 0; }\n"
|
||||
"li.unchecked::marker { content: \"\\2610\"; }\n"
|
||||
"li.checked::marker { content: \"\\2612\"; }\n"
|
||||
"</style></head><body style=\" font-family:\'Segoe UI\'; font-size:9pt; font-weight:700; font-style:normal;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">SELECT</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> semesterapparat.name,</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> prof.lname</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">from</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> semesterapparat</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> INNER JOIN prof ON semesterapparat.prof_id = prof.id</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">WHERE</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> (erstellsemester = \'SoSe 25\'</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> OR erstellsemester = \'WiSe 24/25\')</p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> and semesterapparat.deletion_status = 0</p></body></html>"))
|
||||
self.manualCheck.setText(_translate("Dialog", "Anfragen und anzeigen"))
|
||||
item = self.tableWidget.horizontalHeaderItem(1)
|
||||
item.setText(_translate("Dialog", "Name"))
|
||||
self.toolBox.setItemText(self.toolBox.indexOf(self.page_2), _translate("Dialog", "Semesterapparatsschilder"))
|
||||
152
src/ui/dialogs/docuprint.py
Normal file
152
src/ui/dialogs/docuprint.py
Normal file
@@ -0,0 +1,152 @@
|
||||
from .dialog_sources.documentprint_ui import Ui_Dialog
|
||||
from PyQt6 import QtWidgets, QtCore
|
||||
from src import Icon
|
||||
|
||||
from src.utils.richtext import SemapSchilder, SemesterDocument
|
||||
from src.backend import Semester, Database
|
||||
from natsort import natsorted
|
||||
|
||||
|
||||
class DocumentPrintDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setWindowIcon(Icon("print").icon)
|
||||
self.frame.hide()
|
||||
|
||||
self.semester = Semester()
|
||||
|
||||
self.db = Database()
|
||||
|
||||
self.insert_table_data()
|
||||
self.expertMode.clicked.connect(self.enable_expert_mode)
|
||||
# Ensure the signal is connected only once
|
||||
try:
|
||||
self.pushButton_2.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass # Signal was not connected before
|
||||
self.pushButton_2.clicked.connect(self.on_pushButton_2_clicked)
|
||||
|
||||
try:
|
||||
self.pushButton.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass
|
||||
self.pushButton.clicked.connect(self.on_pushButton_clicked)
|
||||
|
||||
try:
|
||||
self.btn_load_current_apparats.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass
|
||||
self.btn_load_current_apparats.clicked.connect(self.load_current_clicked)
|
||||
|
||||
try:
|
||||
self.manualCheck.clicked.disconnect()
|
||||
except TypeError:
|
||||
pass
|
||||
self.manualCheck.clicked.connect(self.manual_request)
|
||||
|
||||
def manual_request(self):
|
||||
self.tableWidget.setRowCount(0)
|
||||
request_text = self.textBrowser.toPlainText()
|
||||
data = self.db.query_db(request_text)
|
||||
apparats: list[str] = []
|
||||
if not data:
|
||||
self.tableWidget.setRowCount(0)
|
||||
return
|
||||
for row in data:
|
||||
apparats.append(f"{row[1]} ({row[0]})")
|
||||
|
||||
self.tableWidget.setHorizontalHeaderLabels(["", "Semesterapparat"])
|
||||
self.tableWidget.setColumnWidth(0, 50)
|
||||
for entry in apparats:
|
||||
# insert the entry, column 1 should be a checkbox, column 2 the data
|
||||
self.tableWidget.insertRow(0)
|
||||
self.tableWidget.setItem(0, 0, QtWidgets.QTableWidgetItem(""))
|
||||
checkbox = QtWidgets.QCheckBox()
|
||||
|
||||
self.tableWidget.setCellWidget(0, 0, checkbox)
|
||||
|
||||
self.tableWidget.setItem(0, 1, QtWidgets.QTableWidgetItem(entry))
|
||||
# align row 0 column 0 to center
|
||||
|
||||
def load_current_clicked(self):
|
||||
entries = self.get_valid_apparats_for_signs()
|
||||
self.tableWidget.setHorizontalHeaderLabels(["", "Semesterapparat"])
|
||||
self.tableWidget.setColumnWidth(0, 50)
|
||||
self.tableWidget.setRowCount(0)
|
||||
for entry in entries:
|
||||
# insert the entry, column 1 should be a checkbox, column 2 the data
|
||||
self.tableWidget.insertRow(0)
|
||||
self.tableWidget.setItem(0, 0, QtWidgets.QTableWidgetItem(""))
|
||||
checkbox = QtWidgets.QCheckBox()
|
||||
|
||||
self.tableWidget.setCellWidget(0, 0, checkbox)
|
||||
|
||||
self.tableWidget.setItem(0, 1, QtWidgets.QTableWidgetItem(entry))
|
||||
|
||||
def enable_expert_mode(self):
|
||||
# if self.exportMode.
|
||||
if self.expertMode.isChecked():
|
||||
self.frame.show()
|
||||
self.expertMode.setText("Expertenmodus deaktivieren")
|
||||
else:
|
||||
self.frame.hide()
|
||||
self.expertMode.setText("Expertenmodus aktivieren")
|
||||
|
||||
def on_pushButton_2_clicked(self):
|
||||
# get the checked items from the table
|
||||
checked_items = []
|
||||
for i in range(self.tableWidget.rowCount()):
|
||||
checkbox = self.tableWidget.cellWidget(i, 0)
|
||||
if isinstance(checkbox, QtWidgets.QCheckBox) and checkbox.isChecked():
|
||||
item = self.tableWidget.item(i, 1)
|
||||
if item is not None:
|
||||
checked_items.append(item.text())
|
||||
document = SemapSchilder(checked_items)
|
||||
|
||||
def on_pushButton_clicked(self):
|
||||
apparats: list[tuple[int, str]] = []
|
||||
apps = self.db.getAllAparats(0)
|
||||
apps = natsorted(apps, key=lambda x: x[4], reverse=True)
|
||||
for app in apps:
|
||||
prof = self.db.getProfById(app[2])
|
||||
data = (app[4], f"{prof.lastname} ({app[1]})")
|
||||
apparats.append(data)
|
||||
semapDocument = SemesterDocument(
|
||||
semester=self.semester.value,
|
||||
filename="Semesterapparat",
|
||||
full=True,
|
||||
apparats=apparats,
|
||||
)
|
||||
|
||||
def insert_table_data(self):
|
||||
entries = self.get_valid_apparats_for_signs()
|
||||
self.tableWidget.setHorizontalHeaderLabels(["", "Semesterapparat"])
|
||||
self.tableWidget.setColumnWidth(0, 50)
|
||||
for entry in entries:
|
||||
# insert the entry, column 1 should be a checkbox, column 2 the data
|
||||
self.tableWidget.insertRow(0)
|
||||
self.tableWidget.setItem(0, 0, QtWidgets.QTableWidgetItem(""))
|
||||
checkbox = QtWidgets.QCheckBox()
|
||||
|
||||
self.tableWidget.setCellWidget(0, 0, checkbox)
|
||||
|
||||
self.tableWidget.setItem(0, 1, QtWidgets.QTableWidgetItem(entry))
|
||||
# align row 0 column 0 to center
|
||||
|
||||
def get_valid_apparats_for_signs(self):
|
||||
this_sem = self.db.query_db(
|
||||
query="SELECT prof.lname, semesterapparat.name from semesterapparat INNER JOIN prof ON semesterapparat.prof_id = prof.id WHERE (erstellsemester = ? OR erstellsemester = ?) AND semesterapparat.deletion_status=0",
|
||||
args=(str(self.semester.value), str(self.semester.previous)),
|
||||
)
|
||||
apparats: list[str] = []
|
||||
for row in this_sem:
|
||||
apparats.append(f"{row[0]} ({row[1]})")
|
||||
return apparats
|
||||
|
||||
|
||||
def launch():
|
||||
app = QtWidgets.QApplication([])
|
||||
dialog = DocumentPrintDialog()
|
||||
dialog.show()
|
||||
app.exec()
|
||||
Reference in New Issue
Block a user