from PyQt import QtGui, QtCore
from qgis.core import *
from qgis.gui import *

class Ui_RUSLE_cover(object):
    def setupUi(self, RUSLE_cover):
        
        # create main window
        RUSLE_cover.setWindowModality(QtCore.Qt.ApplicationModal)
        RUSLE_cover.resize(300,400)  
        
        # input file corine land cover map
        # create gridLayout
        self.gridLayout1 = QGridLayout(RUSLE_cover)
        self.gridLayout1.setObjectName("gridLayout1")
        # create label in gridLayout 
        self.label_geo = QLabel(RUSLE_cover)
        self.label_geo.setObjectName("label_geo")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_geo,0,0,1,1)
        # create select button to input file
        self.selectButton_geo = QPushButton(RUSLE_cover)
        self.selectButton_geo.setObjectName("selectButton_geo")
        self.gridLayout1.addWidget(self.selectButton_geo,0,2,1,1)
        self.inputLayerCombo_geo = QComboBox(RUSLE_cover)
        self.inputLayerCombo_geo.setObjectName("inputLayerCombo_geo")
        self.gridLayout1.addWidget(self.inputLayerCombo_geo, 0,1,1,1)
        
        
        # input file soil map
        self.label_soil = QLabel(RUSLE_cover)
        self.label_soil.setObjectName("label_soil")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_soil,1,0,1,1)
        # create select button to input file
        self.selectButton_soil = QPushButton(RUSLE_cover)
        self.selectButton_soil.setObjectName("selectButton_soil")
        self.gridLayout1.addWidget(self.selectButton_soil,1,2,1,1)
        self.inputLayerCombo_soil = QComboBox(RUSLE_cover)
        self.inputLayerCombo_soil.setObjectName("inputLayerCombo_soil")
        self.gridLayout1.addWidget(self.inputLayerCombo_soil,1,1,1,1)
        
        # define a groupbox to specify the cell size and attribute
        self.groupBox1 = QGroupBox(RUSLE_cover)
        self.groupBox1.setObjectName("groupBox1")
        self.gridLayout3 = QGridLayout(self.groupBox1)
        self.gridLayout3.setObjectName("gridLayout3")
        self.gridLayout1.addWidget(self.groupBox1, 2,0,1,-1)
        # define attribute "Elevation"
        self.labelAttrib = QLabel(RUSLE_cover)
        self.labelAttrib.setObjectName("labelAttrib")
        self.gridLayout3.addWidget(self.labelAttrib,0,0,-1,1)
        self.lineAttrib = QComboBox(RUSLE_cover)
        self.lineAttrib.setObjectName("lineAttrib")
        self.gridLayout3.addWidget(self.lineAttrib,0,1,-1,1)
        # define pixel size
        self.labelPix = QLabel(RUSLE_cover)
        self.labelPix.setObjectName("labelPix")
        self.gridLayout3.addWidget(self.labelPix, 0,3,-1,1)
        self.linePix = QSpinBox()
        self.linePix.setValue(29)
        self.linePix.stepBy(1)
        self.linePix.setObjectName("linePix")
        self.gridLayout3.addWidget(self.linePix,0,4,-1,1)           
        
        # define the indexs
        # create a group box
        self.groupBox = QGroupBox(RUSLE_cover)
        self.groupBox.setObjectName("groupBox")
        self.gridLayout2 = QGridLayout(self.groupBox)
        self.gridLayout2.setObjectName("gridLayout2")
        self.gridLayout1.addWidget(self.groupBox, 3,0,1,-1)
        # table for classes and indexes
        self.tableWidget = QTableWidget(15,2,RUSLE_cover)
        self.gridLayout2.addWidget(self.tableWidget,0,0,1,1)
        self.newItem = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0,self.newItem)
        self.newItem = QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1,self.newItem)         
        # set the description CLC or COS
        self.line = QLineEdit("")
        self.tableWidget.setItem(0,0,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(1,0,QTableWidgetItem(self.line.text()))        
        self.line = QLineEdit("")
        self.tableWidget.setItem(2,0,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(3,0,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(4,0,QTableWidgetItem(self.line.text()))  
        self.line = QLineEdit("")
        self.tableWidget.setItem(5,0,QTableWidgetItem(self.line.text()))   
        self.line = QLineEdit("")
        self.tableWidget.setItem(6,0,QTableWidgetItem(self.line.text()))  
        self.line = QLineEdit("")
        self.tableWidget.setItem(7,0,QTableWidgetItem(self.line.text()))   
        self.line = QLineEdit("")
        self.tableWidget.setItem(8,0,QTableWidgetItem(self.line.text()))   
        self.line = QLineEdit("")
        self.tableWidget.setItem(9,0,QTableWidgetItem(self.line.text()))  
        self.line = QLineEdit("")
        self.tableWidget.setItem(10,0,QTableWidgetItem(self.line.text()))          
        self.line = QLineEdit("")
        self.tableWidget.setItem(11,0,QTableWidgetItem(self.line.text())) 
        self.line = QLineEdit("")
        self.tableWidget.setItem(12,0,QTableWidgetItem(self.line.text()))      
        self.line = QLineEdit("")
        self.tableWidget.setItem(13,0,QTableWidgetItem(self.line.text()))  
        self.line = QLineEdit("")
        self.tableWidget.setItem(14,0,QTableWidgetItem(self.line.text()))         
        # set the factor C  
        self.line = QLineEdit("")
        self.tableWidget.setItem(0,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(1,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(2,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(3,1,QTableWidgetItem(self.line.text()))        
        self.line = QLineEdit("")
        self.tableWidget.setItem(4,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("") 
        self.tableWidget.setItem(5,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")     
        self.tableWidget.setItem(6,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")    
        self.tableWidget.setItem(7,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")      
        self.tableWidget.setItem(8,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("") 
        self.tableWidget.setItem(9,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("") 
        self.tableWidget.setItem(10,1,QTableWidgetItem(self.line.text()))
        self.line = QLineEdit("")
        self.tableWidget.setItem(11,1,QTableWidgetItem(self.line.text())) 
        self.line = QLineEdit("")
        self.tableWidget.setItem(12,1,QTableWidgetItem(self.line.text()))      
        self.line = QLineEdit("")
        self.tableWidget.setItem(13,1,QTableWidgetItem(self.line.text()))  
        self.line = QLineEdit("")
        self.tableWidget.setItem(14,1,QTableWidgetItem(self.line.text()))             
        # create a box layout to insert the buttons Add and Remove
        self.boxLayout = QVBoxLayout()
        self.boxLayout.setObjectName("boxLayout")
        # button Add
        self.buttonAdd = QPushButton(RUSLE_cover)
        self.buttonAdd.setObjectName("buttonAdd")
        self.boxLayout.addWidget(self.buttonAdd)
        # button Remove
        self.buttonRemove = QPushButton(RUSLE_cover)
        self.buttonRemove.setObjectName("buttonRemove") 
        self.boxLayout.addWidget(self.buttonRemove)        
        # connection to pdf files with codes button
        self.buttonPDF = QPushButton(RUSLE_cover)
        self.buttonPDF.setObjectName("buttonPDF")
        self.boxLayout.addWidget(self.buttonPDF)
        # attribute table button
        self.buttonAttribute = QPushButton(RUSLE_cover)
        self.buttonAttribute.setObjectName("buttonAttribute")
        self.boxLayout.addWidget(self.buttonAttribute)       
        self.gridLayout2.addLayout(self.boxLayout,0,1,-1,1)        
       
        # output file
        # create label in gridLayout
        self.label_out = QLabel(RUSLE_cover)
        self.label_out.setObjectName("label_out")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_out,4,0,1,1)
        # create select button to output file
        self.selectButton_out = QPushButton(RUSLE_cover)
        self.selectButton_out.setObjectName("selectButton_out")
        self.gridLayout1.addWidget(self.selectButton_out,4,2,1,1)
        self.inputLayerCombo_out = QLineEdit(RUSLE_cover)
        self.inputLayerCombo_out.setObjectName("inputLayerCombo_out")
        self.gridLayout1.addWidget(self.inputLayerCombo_out, 4,1,1,1)
        # stretch to extend the widget in column 1
        self.gridLayout1.setColumnStretch(1,1)                   
 
    
        # button Ok, Close and Help
        self.buttonBox = QDialogButtonBox(RUSLE_cover)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Help|QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout1.addWidget(self.buttonBox, 5, 1, 1, 1)           
                  
    
        self.retranslateUi(RUSLE_cover)
        self.buttonBox.rejected.connect(RUSLE_cover.close)
            
    def retranslateUi(self, RUSLE_cover):
        RUSLE_cover.setWindowTitle("RUSLE", "RUSLE Cover Management")
        self.label_geo.setText('RUSLE', 'Input CLC map:')    
        self.label_soil.setText('RUSLE', 'Input COS map:')    
        self.label_out.setText('RUSLE', 'Output C:')    
        self.selectButton_geo.setText('RUSLE', 'Browse')
        self.selectButton_soil.setText('RUSLE', 'Browse')
        self.selectButton_out.setText('RUSLE', 'Browse')
        self.tableWidget.horizontalHeaderItem(0).setText("RUSLE","CLC/COS")
        self.tableWidget.horizontalHeaderItem(1).setText("RUSLE","Fator C")
        self.buttonPDF.setText("RUSLE", "CLC and COS codes")  
        self.buttonAttribute.setText("RUSLE", "Import attribute table")  
        self.labelAttrib.setText('RUSLE', 'Attribute:') 
        self.labelPix.setText('RUSLE', 'Cell size:')        
        self.buttonAdd.setText("RUSLE", "Add")
        self.buttonRemove.setText("RUSLE", "Remove")         