# Form implementation generated from reading ui file 'c:\Users\aky547\GitHub\Semesterapparate\ui\dialogs\medianadder.ui'
#
# Created by: PySide6 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 PySide6 import QtCore, QtGui, QtWidgets


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(637, 491)
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setGeometry(QtCore.QRect(20, 10, 47, 21))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(Dialog)
        self.label_2.setGeometry(QtCore.QRect(20, 40, 47, 21))
        self.label_2.setObjectName("label_2")
        self.comboBox = QtWidgets.QComboBox(Dialog)
        self.comboBox.setGeometry(QtCore.QRect(70, 40, 69, 22))
        self.comboBox.setObjectName("comboBox")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.comboBox.addItem("")
        self.lineEdit = QtWidgets.QLineEdit(Dialog)
        self.lineEdit.setGeometry(QtCore.QRect(70, 10, 113, 20))
        self.lineEdit.setObjectName("lineEdit")
        self.label_3 = QtWidgets.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(20, 70, 47, 21))
        self.label_3.setObjectName("label_3")
        self.widget = QtWidgets.QWidget(Dialog)
        self.widget.setGeometry(QtCore.QRect(330, 90, 301, 341))
        self.widget.setObjectName("widget")
        self.treeWidget = QtWidgets.QTreeWidget(self.widget)
        self.treeWidget.setEnabled(True)
        self.treeWidget.setGeometry(QtCore.QRect(0, 0, 301, 341))
        self.treeWidget.setAutoFillBackground(False)
        self.treeWidget.setLineWidth(0)
        self.treeWidget.setMidLineWidth(0)
        self.treeWidget.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff
        )
        self.treeWidget.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff
        )
        self.treeWidget.setSizeAdjustPolicy(
            QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents
        )
        self.treeWidget.setEditTriggers(
            QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers
        )
        self.treeWidget.setAlternatingRowColors(True)
        self.treeWidget.setSelectionMode(
            QtWidgets.QAbstractItemView.SelectionMode.NoSelection
        )
        self.treeWidget.setTextElideMode(QtCore.Qt.TextElideMode.ElideMiddle)
        self.treeWidget.setUniformRowHeights(True)
        self.treeWidget.setItemsExpandable(False)
        self.treeWidget.setExpandsOnDoubleClick(False)
        self.treeWidget.setObjectName("treeWidget")
        font = QtGui.QFont()
        font.setPointSize(7)
        self.treeWidget.headerItem().setFont(0, font)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        brush = QtGui.QBrush(QtGui.QColor(255, 0, 0))
        brush.setStyle(QtCore.Qt.BrushStyle.SolidPattern)
        item_0.setBackground(2, brush)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        brush = QtGui.QBrush(QtGui.QColor(0, 255, 0))
        brush.setStyle(QtCore.Qt.BrushStyle.SolidPattern)
        item_0.setBackground(2, brush)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        item_0 = QtWidgets.QTreeWidgetItem(self.treeWidget)
        self.treeWidget.header().setCascadingSectionResizes(False)
        self.treeWidget.header().setDefaultSectionSize(60)
        self.treeWidget.header().setHighlightSections(False)
        self.treeWidget.header().setMinimumSectionSize(20)
        self.listWidget = QtWidgets.QListWidget(Dialog)
        self.listWidget.setGeometry(QtCore.QRect(10, 90, 281, 341))
        self.listWidget.setContextMenuPolicy(
            QtCore.Qt.ContextMenuPolicy.CustomContextMenu
        )
        self.listWidget.setObjectName("listWidget")
        self.label_4 = QtWidgets.QLabel(Dialog)
        self.label_4.setGeometry(QtCore.QRect(330, 50, 181, 21))
        self.label_4.setObjectName("label_4")
        self.label_5 = QtWidgets.QLabel(Dialog)
        self.label_5.setGeometry(QtCore.QRect(200, 70, 41, 21))
        self.label_5.setObjectName("label_5")
        self.list_amount = QtWidgets.QLabel(Dialog)
        self.list_amount.setGeometry(QtCore.QRect(240, 70, 47, 21))
        self.list_amount.setObjectName("list_amount")
        self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(10, 450, 156, 23))
        self.buttonBox.setStandardButtons(
            QtWidgets.QDialogButtonBox.StandardButton.Cancel
            | QtWidgets.QDialogButtonBox.StandardButton.Ok
        )
        self.buttonBox.setCenterButtons(False)
        self.buttonBox.setObjectName("buttonBox")
        self.buttonBox.setFocusPolicy(QtCore.Qt.FocusPolicy.ClickFocus)
        # self.buttonBox.accepted.disconnect()
        # set the activation action for the buttonBox to be shift enter
        self.buttonBox.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus)
        self.buttonBox.accepted.connect(Dialog.accept)  # type: ignore
        self.buttonBox.rejected.connect(Dialog.reject)  # type: ignore

        self.lineEdit.returnPressed.connect(self.add_to_list)
        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", "Signatur"))
        self.label_2.setText(_translate("Dialog", "Modus"))
        self.comboBox.setItemText(0, _translate("Dialog", "ARRAY"))
        self.comboBox.setItemText(1, _translate("Dialog", "BibTeX"))
        self.comboBox.setItemText(2, _translate("Dialog", "COinS"))
        self.comboBox.setItemText(3, _translate("Dialog", "RIS"))
        self.lineEdit.setPlaceholderText(_translate("Dialog", "Signatur / ISBN"))
        self.label_3.setText(_translate("Dialog", "Queue"))
        self.treeWidget.headerItem().setText(
            0, _translate("Dialog", "Datensatz\\Metadata")
        )
        self.treeWidget.headerItem().setText(1, _translate("Dialog", "Array"))
        self.treeWidget.headerItem().setText(2, _translate("Dialog", "BibTeX"))
        self.treeWidget.headerItem().setText(3, _translate("Dialog", "COinS"))
        self.treeWidget.headerItem().setText(4, _translate("Dialog", "RIS"))
        __sortingEnabled = self.treeWidget.isSortingEnabled()
        self.treeWidget.setSortingEnabled(False)
        self.treeWidget.topLevelItem(0).setText(0, _translate("Dialog", "PPN"))
        self.treeWidget.topLevelItem(0).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(0).setText(2, _translate("Dialog", "0"))
        self.treeWidget.topLevelItem(0).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(0).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(1).setText(0, _translate("Dialog", "Signatur"))
        self.treeWidget.topLevelItem(1).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(1).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(1).setText(3, _translate("Dialog", "0"))
        self.treeWidget.topLevelItem(1).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(2).setText(0, _translate("Dialog", "Autor"))
        self.treeWidget.topLevelItem(2).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(2).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(2).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(2).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(3).setText(0, _translate("Dialog", "ISBN"))
        self.treeWidget.topLevelItem(3).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(3).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(3).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(3).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(4).setText(0, _translate("Dialog", "Jahr"))
        self.treeWidget.topLevelItem(4).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(4).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(4).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(4).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(5).setText(0, _translate("Dialog", "Auflage"))
        self.treeWidget.topLevelItem(5).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(5).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(5).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(5).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(6).setText(0, _translate("Dialog", "Sprache"))
        self.treeWidget.topLevelItem(6).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(6).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(6).setText(3, _translate("Dialog", "0"))
        self.treeWidget.topLevelItem(6).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(7).setText(0, _translate("Dialog", "Herausgeber"))
        self.treeWidget.topLevelItem(7).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(7).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(7).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(7).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(8).setText(0, _translate("Dialog", "Seiten"))
        self.treeWidget.topLevelItem(8).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(8).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(8).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(8).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(9).setText(0, _translate("Dialog", "Titel"))
        self.treeWidget.topLevelItem(9).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(9).setText(2, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(9).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(9).setText(4, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(10).setText(0, _translate("Dialog", "Link"))
        self.treeWidget.topLevelItem(10).setText(1, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(10).setText(2, _translate("Dialog", "0"))
        self.treeWidget.topLevelItem(10).setText(3, _translate("Dialog", "1"))
        self.treeWidget.topLevelItem(10).setText(4, _translate("Dialog", "1"))
        self.treeWidget.setSortingEnabled(__sortingEnabled)
        self.label_4.setText(_translate("Dialog", "Belegbare Felder per Anbieter"))
        self.label_5.setText(_translate("Dialog", "Anzahl:"))
        self.list_amount.setText(_translate("Dialog", "0"))
        self.recolorize()
        self.listWidget.customContextMenuRequested.connect(self.custom_context_menu)

    def add_to_list(self):
        text = self.lineEdit.text().strip()
        if text == "":
            return
        else:
            self.listWidget.addItem(text)
            self.list_amount.setText(str(self.listWidget.count()))
            self.lineEdit.clear()

    def recolorize(self):
        # set the color of the cells of the treeWidget to red if the field is not supported by the provider
        # else set it to green
        for i in range(self.treeWidget.topLevelItemCount()):
            for j in range(1, self.treeWidget.columnCount()):
                if self.treeWidget.topLevelItem(i).text(j) == "0":
                    self.treeWidget.topLevelItem(i).setBackground(
                        j, QtGui.QColor(255, 0, 0)
                    )
                else:
                    self.treeWidget.topLevelItem(i).setBackground(
                        j, QtGui.QColor(0, 255, 0)
                    )
                # remove the text from the cells
                self.treeWidget.topLevelItem(i).setText(j, "")

    def custom_context_menu(self):
        menu = QtWidgets.QMenu()
        menu.addAction("Remove")

        action = menu.exec(QtGui.QCursor.pos())
        if action.text() == "Remove":
            self.remove_from_list()

    def remove_from_list(self):
        self.listWidget.takeItem(self.listWidget.currentRow())
        self.list_amount.setText(str(self.listWidget.count()))
