# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'genericListViewWidget.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
from EquationConstants import DB_HOST, DB_NAME, DB_PASS, DB_USER
import psycopg2
import psycopg2.extras


class Ui_unitForm(object):
    def setupUi(self, unitForm):
        unitForm.setObjectName("unitForm")
        unitForm.resize(1748, 1359)

        bFont = QtGui.QFont()  # Button Font
        bFont.setPointSize(14)

        lFont = QtGui.QFont()  # Label Font
        lFont.setPointSize(10)

        font = QtGui.QFont()   # Widget Font
        font.setPointSize(14)

        self.mainWindow_vLayout = QtWidgets.QVBoxLayout(unitForm)
        self.mainWindow_vLayout.setObjectName("mainWindow_vLayout")

        self.listForm_vSplitter = QtWidgets.QSplitter(unitForm)
        self.listForm_vSplitter.setOrientation(QtCore.Qt.Horizontal)
        self.listForm_vSplitter.setObjectName("listForm_vSplitter")

        self.layoutWidget = QtWidgets.QWidget(self.listForm_vSplitter)
        self.layoutWidget.setFont(font)
        self.layoutWidget.setObjectName("layoutWidget")

        self.list_vLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.list_vLayout.setContentsMargins(0, 0, 0, 0)
        self.list_vLayout.setObjectName("list_vLayout")

        self.list_label = QtWidgets.QLabel(self.layoutWidget)


        self.list_label.setFont(lFont)
        self.list_label.setObjectName("list_label")
        self.list_vLayout.addWidget(self.list_label)

        self.list_listView = QtWidgets.QListView(self.layoutWidget)


        self.list_listView.setFont(font)
        self.list_listView.setObjectName("list_listView")
        self.list_vLayout.addWidget(self.list_listView)

        self.addRemove_hLayout = QtWidgets.QHBoxLayout()
        self.addRemove_hLayout.setObjectName("addRemove_hLayout")

        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.addRemove_hLayout.addItem(spacerItem)

        self.remove_btn = QtWidgets.QPushButton(self.layoutWidget)


        self.remove_btn.setFont(bFont)
        self.remove_btn.setObjectName("remove_btn")
        self.addRemove_hLayout.addWidget(self.remove_btn)

        self.add_btn = QtWidgets.QPushButton(self.layoutWidget)


        self.add_btn.setFont(bFont)
        self.add_btn.setObjectName("add_btn")
        self.addRemove_hLayout.addWidget(self.add_btn)
        self.list_vLayout.addLayout(self.addRemove_hLayout)

        self.layoutWidget1 = QtWidgets.QWidget(self.listForm_vSplitter)
        self.layoutWidget1.setObjectName("layoutWidget1")

        self.form_vLayout = QtWidgets.QVBoxLayout(self.layoutWidget1)
        self.form_vLayout.setContentsMargins(0, 0, 0, 0)
        self.form_vLayout.setObjectName("form_vLayout")

        self.formLayout = QtWidgets.QFormLayout()
        self.formLayout.setObjectName("formLayout")

        self.name_label = QtWidgets.QLabel(self.layoutWidget1)


        self.name_label.setFont(lFont)
        self.name_label.setObjectName("name_label")

        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.name_label)

        self.name_lineEdit = QtWidgets.QLineEdit(self.layoutWidget1)


        self.name_lineEdit.setFont(font)
        self.name_lineEdit.setObjectName("name_lineEdit")

        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.name_lineEdit)

        self.type_label = QtWidgets.QLabel(self.layoutWidget1)

        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.type_label.sizePolicy().hasHeightForWidth())
        self.type_label.setSizePolicy(sizePolicy)


        self.type_label.setFont(lFont)
        self.type_label.setObjectName("type_label")

        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.type_label)

        self.type_comboBox = QtWidgets.QComboBox(self.layoutWidget1)


        self.type_comboBox.setFont(font)
        self.type_comboBox.setObjectName("type_comboBox")

        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.type_comboBox)
        self.form_vLayout.addLayout(self.formLayout)

        self.latex_label = QtWidgets.QLabel(self.layoutWidget1)


        self.latex_label.setFont(lFont)
        self.latex_label.setAlignment(QtCore.Qt.AlignCenter)
        self.latex_label.setObjectName("latex_label")
        self.form_vLayout.addWidget(self.latex_label)

        self.textBrowser = QtWidgets.QTextBrowser(self.layoutWidget1)


        self.textBrowser.setFont(font)
        self.textBrowser.setObjectName("textBrowser")
        self.form_vLayout.addWidget(self.textBrowser)

        self.latexBtns_hLayout = QtWidgets.QHBoxLayout()
        self.latexBtns_hLayout.setObjectName("latexBtns_hLayout")

        self.latexTemplate_btn = QtWidgets.QPushButton(self.layoutWidget1)

        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.latexTemplate_btn.sizePolicy().hasHeightForWidth())
        self.latexTemplate_btn.setSizePolicy(sizePolicy)


        self.latexTemplate_btn.setFont(bFont)
        self.latexTemplate_btn.setObjectName("latexTemplate_btn")
        self.latexBtns_hLayout.addWidget(self.latexTemplate_btn)

        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.latexBtns_hLayout.addItem(spacerItem1)

        self.generate_btn = QtWidgets.QPushButton(self.layoutWidget1)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.generate_btn.sizePolicy().hasHeightForWidth())
        self.generate_btn.setSizePolicy(sizePolicy)
        self.generate_btn.setFont(bFont)
        self.generate_btn.setObjectName("generate_btn")
        self.latexBtns_hLayout.addWidget(self.generate_btn)
        self.form_vLayout.addLayout(self.latexBtns_hLayout)

        self.image_vLayout = QtWidgets.QVBoxLayout()
        self.image_vLayout.setObjectName("image_vLayout")

        self.image_label = QtWidgets.QLabel(self.layoutWidget1)


        self.image_label.setFont(lFont)
        self.image_label.setAlignment(QtCore.Qt.AlignCenter)
        self.image_label.setObjectName("image_label")
        self.image_vLayout.addWidget(self.image_label)

        self.image_gView = QtWidgets.QGraphicsView(self.layoutWidget1)


        self.image_gView.setFont(font)
        self.image_gView.setObjectName("image_gView")
        self.image_vLayout.addWidget(self.image_gView)
        self.form_vLayout.addLayout(self.image_vLayout)

        self.update_hLayout = QtWidgets.QHBoxLayout()
        self.update_hLayout.setObjectName("update_hLayout")

        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.update_hLayout.addItem(spacerItem2)

        self.update_btn = QtWidgets.QPushButton(self.layoutWidget1)


        self.update_btn.setFont(bFont)
        self.update_btn.setObjectName("update_btn")
        self.update_hLayout.addWidget(self.update_btn)
        self.form_vLayout.addLayout(self.update_hLayout)
        self.mainWindow_vLayout.addWidget(self.listForm_vSplitter)
        self.list_label.setBuddy(self.list_listView)
        self.name_label.setBuddy(self.name_lineEdit)
        self.type_label.setBuddy(self.type_comboBox)
        self.latex_label.setBuddy(self.textBrowser)
        self.image_label.setBuddy(self.image_gView)

        self.retranslateUi(unitForm)
        QtCore.QMetaObject.connectSlotsByName(unitForm)

    def retranslateUi(self, unitForm):
        _translate = QtCore.QCoreApplication.translate
        unitForm.setWindowTitle(_translate("unitForm", "Unit"))
        self.list_label.setText(_translate("unitForm", "Available Units"))
        self.remove_btn.setText(_translate("unitForm", "Remove"))
        self.add_btn.setText(_translate("unitForm", "Add"))
        self.name_label.setText(_translate("unitForm", "Name"))
        self.type_label.setText(_translate("unitForm", "System"))
        self.latex_label.setText(_translate("unitForm", "LaTeX"))
        self.latexTemplate_btn.setText(_translate("unitForm", "LaTex Template"))
        self.generate_btn.setText(_translate("unitForm", "Generate"))
        self.image_label.setText(_translate("unitForm", "Image"))
        self.update_btn.setText(_translate("unitForm", "Update"))

    def loadListData(self):
        # connection = psycopg2.connect(dbname=DB_NAME, user=DB_USER, password=DB_PASS, host=DB_HOST)
        # cursor = connection.cursor()
        #
        # myTable = 'math_object'
        #
        # template_query = """SELECT (id, name) FROM {aTable}""".format(aTable=myTable)
        # cursor.execute(template_query)
        #
        # myData = cursor.fetchall()
        # self.tableWidget.setRowCount(0)
        #
        # for row_number, row_data in enumerate(myData):
        #     self.tableWidget.insertRow(row_number)
        #     for column_number, data in enumerate(row_data):
        #         self.tableWidget.setItem(row_number, column_number, QtWidgets.QTableWidgetItem(str(data)))
        #
        # cursor.close()
        # connection.close()

        self.listWidget.addItems(["{:03d}".format(x) for x in range(100)])

    def initializeUnitData(self):
        pass


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    unitForm = QtWidgets.QWidget()
    ui = Ui_unitForm()
    ui.setupUi(unitForm)
    unitForm.show()
    sys.exit(app.exec_())
