# Form implementation generated from reading ui file 'c:\Users\aky547\GitHub\Semesterapparate\ui\dialogs\fileparser.ui'
#
# Created by: PyQt6 UI code generator 6.3.1
#
# 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

from src.logic.webrequest import BibTextTransformer, WebRequest


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(402, 301)
        self.progressBar = QtWidgets.QProgressBar(Dialog)
        self.progressBar.setGeometry(QtCore.QRect(10, 60, 381, 23))
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName("progressBar")
        self.frame = QtWidgets.QFrame(Dialog)
        self.frame.setGeometry(QtCore.QRect(10, 10, 381, 41))
        self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
        self.frame.setObjectName("frame")
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.frame)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 381, 41))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(self.horizontalLayoutWidget)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.count = QtWidgets.QLabel(self.horizontalLayoutWidget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.count.setFont(font)
        self.count.setTextFormat(QtCore.Qt.TextFormat.PlainText)
        self.count.setObjectName("count")
        self.horizontalLayout.addWidget(self.count)
        self.label_2 = QtWidgets.QLabel(self.horizontalLayoutWidget)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        spacerItem = QtWidgets.QSpacerItem(
            40,
            20,
            QtWidgets.QSizePolicy.Policy.Expanding,
            QtWidgets.QSizePolicy.Policy.Minimum,
        )
        self.horizontalLayout.addItem(spacerItem)
        self.frame_2 = QtWidgets.QFrame(Dialog)
        self.frame_2.setGeometry(QtCore.QRect(10, 100, 381, 201))
        self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
        self.frame_2.setObjectName("frame_2")
        self.listWidget = QtWidgets.QListWidget(self.frame_2)
        self.listWidget.setGeometry(QtCore.QRect(0, 0, 381, 191))
        self.listWidget.setObjectName("listWidget")
        self.signatures = []
        self.returned = []
        # self.data_gathering_complete = QtCore.pyqtSignal()
        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.label.setText(_translate("Dialog", "Es wurden"))
        self.count.setText(_translate("Dialog", "0"))
        self.label_2.setText(_translate("Dialog", "Signaturen gefunden."))

    def moveToThread(self, thread):
        self.progressBar.moveToThread(thread)
        self.frame.moveToThread(thread)
        self.horizontalLayoutWidget.moveToThread(thread)
        self.horizontalLayout.moveToThread(thread)
        self.label.moveToThread(thread)
        self.count.moveToThread(thread)
        self.label_2.moveToThread(thread)
        self.frame_2.moveToThread(thread)
        self.listWidget.moveToThread(thread)

    def run(self):
        for signature in self.signatures:
            self.count.setText(str(self.signatures.index(signature) + 1))
            self.listWidget.addItem(signature)
            webdata = WebRequest().get_ppn(signature).get_data()
            bookdata = BibTextTransformer("ARRAY").get_data(webdata).return_data()
            self.returned.append(bookdata)
            self.progressBar.setValue(self.signatures.index(signature) + 1)
        # self.data_gathering_complete.emit()

    def deleteLater(self):
        self.progressBar.deleteLater()
        self.frame.deleteLater()
        self.horizontalLayoutWidget.deleteLater()
        self.horizontalLayout.deleteLater()
        self.label.deleteLater()
        self.count.deleteLater()
        self.label_2.deleteLater()
        self.frame_2.deleteLater()
        self.listWidget.deleteLater()
        self.signatures = []
        self.returned = []
        self.retranslateUi.deleteLater()
        super().deleteLater()
