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

# Form implementation generated from reading ui file 'SearchFlightWidget.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
import sqlite3


class Ui_SEARCHFLIGHTPanel(object):
    def setupUi(self, SEARCHFLIGHTPanel):
        SEARCHFLIGHTPanel.setObjectName("SEARCHFLIGHTPanel")
        SEARCHFLIGHTPanel.resize(1159, 889)
        SEARCHFLIGHTPanel.setMinimumSize(QtCore.QSize(500, 700))
        self.vboxlayout = QtWidgets.QVBoxLayout(SEARCHFLIGHTPanel)
        self.vboxlayout.setContentsMargins(0, 0, 2, 0)
        self.vboxlayout.setSpacing(0)
        self.vboxlayout.setObjectName("vboxlayout")
        self.top = QtWidgets.QFrame(SEARCHFLIGHTPanel)
        self.top.setMaximumSize(QtCore.QSize(16777215, 40))
        self.top.setBaseSize(QtCore.QSize(0, 0))
        self.top.setStyleSheet("background-color: rgb(255, 255, 127);")
        self.top.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.top.setFrameShadow(QtWidgets.QFrame.Raised)
        self.top.setObjectName("top")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.top)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setSpacing(0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.vboxlayout.addWidget(self.top)
        self.content = QtWidgets.QFrame(SEARCHFLIGHTPanel)
        self.content.setStyleSheet("background-color: rgb(143, 143, 143);")
        self.content.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.content.setFrameShadow(QtWidgets.QFrame.Raised)
        self.content.setObjectName("content")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.content)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.main = QtWidgets.QFrame(self.content)
        self.main.setMaximumSize(QtCore.QSize(1000, 750))
        self.main.setStyleSheet("background-color: rgb(57, 57, 57);\n"
"border-radius: 10px;")
        self.main.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.main.setFrameShadow(QtWidgets.QFrame.Plain)
        self.main.setObjectName("main")
        self.PLANEIcon = QtWidgets.QFrame(self.main)
        self.PLANEIcon.setGeometry(QtCore.QRect(370, 180, 261, 161))
        self.PLANEIcon.setStyleSheet("background-image: url(:/newPrefix/img/planeinside.jpg);")
        self.PLANEIcon.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.PLANEIcon.setFrameShadow(QtWidgets.QFrame.Raised)
        self.PLANEIcon.setObjectName("PLANEIcon")
        self.LOGOIcon = QtWidgets.QFrame(self.main)
        self.LOGOIcon.setGeometry(QtCore.QRect(20, 0, 181, 161))
        self.LOGOIcon.setStyleSheet("background-image: url(:/LOGO/img/logo.png);")
        self.LOGOIcon.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.LOGOIcon.setFrameShadow(QtWidgets.QFrame.Raised)
        self.LOGOIcon.setObjectName("LOGOIcon")
        self.Line = QtWidgets.QLabel(self.main)
        self.Line.setGeometry(QtCore.QRect(70, 340, 951, 31))
        self.Line.setStyleSheet("color: rgb(0, 85, 127);")
        self.Line.setObjectName("Line")
        self.TABLEWidget = QtWidgets.QTableWidget(self.main)
        self.TABLEWidget.setGeometry(QtCore.QRect(150, 390, 771, 271))
        self.TABLEWidget.setMinimumSize(QtCore.QSize(0, 0))
        self.TABLEWidget.setAutoFillBackground(False)
        self.TABLEWidget.setStyleSheet("color: rgb(255, 255, 255);\n"
"font: 11pt \"MS Shell Dlg 2\";")
        self.TABLEWidget.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.TABLEWidget.setFrameShadow(QtWidgets.QFrame.Plain)
        self.TABLEWidget.setDragDropMode(QtWidgets.QAbstractItemView.NoDragDrop)
        self.TABLEWidget.setAlternatingRowColors(False)
        self.TABLEWidget.setRowCount(8)
        self.TABLEWidget.setObjectName("TABLEWidget")
        self.TABLEWidget.setColumnCount(7)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        font.setKerning(False)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(8)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(8)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(3, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(4, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(5, item)
        item = QtWidgets.QTableWidgetItem()
        font = QtGui.QFont()
        font.setPointSize(8)
        font.setBold(True)
        font.setWeight(75)
        item.setFont(font)
        brush = QtGui.QBrush(QtGui.QColor(127, 191, 191))
        brush.setStyle(QtCore.Qt.SolidPattern)
        item.setForeground(brush)
        self.TABLEWidget.setHorizontalHeaderItem(6, item)
        self.TABLEWidget.horizontalHeader().setCascadingSectionResizes(False)
        self.TABLEWidget.horizontalHeader().setHighlightSections(True)
        self.TABLEWidget.horizontalHeader().setSortIndicatorShown(False)
        self.TABLEWidget.horizontalHeader().setStretchLastSection(False)
        self.TABLEWidget.verticalHeader().setCascadingSectionResizes(True)
        self.TABLEWidget.verticalHeader().setHighlightSections(True)
        self.TABLEWidget.verticalHeader().setSortIndicatorShown(True)
        self.TABLEWidget.verticalHeader().setStretchLastSection(False)
        self.horizontalLayout.addWidget(self.main)
        self.vboxlayout.addWidget(self.content)
        self.bottom = QtWidgets.QFrame(SEARCHFLIGHTPanel)
        self.bottom.setMaximumSize(QtCore.QSize(16777215, 40))
        self.bottom.setBaseSize(QtCore.QSize(0, 0))
        self.bottom.setStyleSheet("background-color: rgb(255, 255, 127);")
        self.bottom.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.bottom.setFrameShadow(QtWidgets.QFrame.Raised)
        self.bottom.setObjectName("bottom")
        self.vboxlayout.addWidget(self.bottom)

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

    def retranslateUi(self, SEARCHFLIGHTPanel):
        _translate = QtCore.QCoreApplication.translate
        SEARCHFLIGHTPanel.setWindowTitle(_translate("SEARCHFLIGHTPanel", "SEARCH FLIGHT"))
        self.Line.setText(_translate("SEARCHFLIGHTPanel", "______________________________________________________________________________________________________________________________________________"))
        self.TABLEWidget.setSortingEnabled(False)
        item = self.TABLEWidget.horizontalHeaderItem(0)
        item.setText(_translate("SEARCHFLIGHTPanel", "FROM"))
        item = self.TABLEWidget.horizontalHeaderItem(1)
        item.setText(_translate("SEARCHFLIGHTPanel", "TO"))
        item = self.TABLEWidget.horizontalHeaderItem(2)
        item.setText(_translate("SEARCHFLIGHTPanel", "FLIGHT NUMBER"))
        item = self.TABLEWidget.horizontalHeaderItem(3)
        item.setText(_translate("SEARCHFLIGHTPanel", "PLANE NUMBER"))
        item = self.TABLEWidget.horizontalHeaderItem(4)
        item.setText(_translate("SEARCHFLIGHTPanel", "DATE"))
        item = self.TABLEWidget.horizontalHeaderItem(5)
        item.setText(_translate("SEARCHFLIGHTPanel", "PRICE €"))
        item = self.TABLEWidget.horizontalHeaderItem(6)
        item.setText(_translate("SEARCHFLIGHTPanel", "TIME (HOUR)"))

    def setFlight(self, flight):
        con = sqlite3.connect('ticketair.db')
        cur = con.cursor()
        sqlquery = f'SELECT * FROM flights WHERE origin = "{flight.origin}" AND destination = "{flight.destination}"'
        tablerow = 0

        for row in cur.execute(sqlquery):
            self.TABLEWidget.setItem(tablerow, 0, QtWidgets.QTableWidgetItem(row[0]))
            self.TABLEWidget.setItem(tablerow, 1, QtWidgets.QTableWidgetItem(row[1]))
            self.TABLEWidget.setItem(tablerow, 2, QtWidgets.QTableWidgetItem(row[2]))
            self.TABLEWidget.setItem(tablerow, 3, QtWidgets.QTableWidgetItem(row[3]))
            self.TABLEWidget.setItem(tablerow, 4, QtWidgets.QTableWidgetItem(row[4]))
            self.TABLEWidget.setItem(tablerow, 5, QtWidgets.QTableWidgetItem(str(row[5])))
            self.TABLEWidget.setItem(tablerow, 6, QtWidgets.QTableWidgetItem(str(row[6])))
            tablerow = tablerow + 1
import file


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    SEARCHFLIGHTPanel = QtWidgets.QWidget()
    ui = Ui_SEARCHFLIGHTPanel()
    ui.setupUi(SEARCHFLIGHTPanel)
    SEARCHFLIGHTPanel.show()
    sys.exit(app.exec_())
