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


class Ui_Recharge(object):
    
    def setupUi(self, Recharge_window):
        
        # create Recharge window
        Recharge_window.setWindowModality(QtCore.Qt.ApplicationModal)
        Recharge_window.resize(450,450)
        
        # input file
        # create gridLayout
        self.gridLayout1 = QtGui.QGridLayout(Recharge_window)
        self.gridLayout1.setObjectName("gridLayout1")        
        # define a groupbox to specify the input method 1
        self.groupBox0 = QtGui.QGroupBox(Recharge_window)
        self.groupBox0.setObjectName("groupBox0")
        self.groupBox0.setTitle("Base")
        self.gridLayout = QtGui.QGridLayout(self.groupBox0)
        self.gridLayout.setObjectName("gridLayout")
        self.gridLayout1.addWidget(self.groupBox0, 0,0,1,-1)        
        # create label in gridLayout 
        self.label = QtGui.QLabel(Recharge_window)
        self.label.setObjectName("label")
        self.label1 = QtGui.QLabel(Recharge_window)
        self.label1.setObjectName("label1")        
        self.label2 = QtGui.QLabel(Recharge_window)
        self.label2.setObjectName("label2")               
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout.addWidget(self.label,0,0,1,1)
        self.gridLayout.addWidget(self.label1,1,0,1,1)
        self.gridLayout.addWidget(self.label2,2,0,1,1)
        # create select button to input file
        self.selectButton = QtGui.QPushButton(Recharge_window)
        self.selectButton.setObjectName("selectButton")
        self.gridLayout.addWidget(self.selectButton,0,2,1,1)
        self.selectButton1 = QtGui.QPushButton(Recharge_window)
        self.selectButton1.setObjectName("selectButton1")
        self.gridLayout.addWidget(self.selectButton1,1,2,1,1)        
        self.selectButton2 = QtGui.QPushButton(Recharge_window)
        self.selectButton2.setObjectName("selectButton2")
        self.gridLayout.addWidget(self.selectButton2,2,2,1,1)        
        self.inputLayerCombo = QtGui.QComboBox(Recharge_window)
        self.inputLayerCombo.setObjectName("inputLayerCombo")
        self.gridLayout.addWidget(self.inputLayerCombo, 0,1,1,1)
        self.inputLayerCombo1 = QtGui.QComboBox(Recharge_window)
        self.inputLayerCombo1.setObjectName("inputLayerCombo1")
        self.gridLayout.addWidget(self.inputLayerCombo1, 1,1,1,1)        
        self.inputLayerCombo2 = QtGui.QComboBox(Recharge_window)
        self.inputLayerCombo2.setObjectName("inputLayerCombo2")
        self.gridLayout.addWidget(self.inputLayerCombo2, 2,1,1,1)                
        # stretch to extend the widget in column 1
        self.gridLayout.setColumnStretch(1,1)     
        
        # define a groupbox to specify the input method 2
        self.groupBox4 = QtGui.QGroupBox(Recharge_window)
        self.groupBox4.setObjectName("groupBox4")
        self.groupBox4.setTitle("Improvement")
        self.gridLayout4 = QtGui.QGridLayout(self.groupBox4)
        self.gridLayout4.setObjectName("gridLayout4")
        self.gridLayout1.addWidget(self.groupBox4, 2,0,1,-1)   
        self.selectButton4 = QtGui.QPushButton(Recharge_window)
        self.selectButton4.setObjectName("selectButton4")
        self.gridLayout4.addWidget(self.selectButton4,0,2,1,1)   
        self.inputLayerCombo4 = QtGui.QComboBox(Recharge_window)
        self.inputLayerCombo4.setObjectName("inputLayerCombo4")
        self.gridLayout4.addWidget(self.inputLayerCombo4, 0,1,1,1)    
        self.label4 = QtGui.QLabel(Recharge_window)
        self.label4.setObjectName("label4")  
        self.gridLayout4.addWidget(self.label4,0,0,1,1)
        self.gridLayout4.setColumnStretch(1,1) 

        # define a groupbox to specify the cell size and attribute
        self.groupBox1 = QtGui.QGroupBox(Recharge_window)
        self.groupBox1.setObjectName("groupBox1")
        self.gridLayout3 = QtGui.QGridLayout(self.groupBox1)
        self.gridLayout3.setObjectName("gridLayout3")
        self.gridLayout1.addWidget(self.groupBox1, 1,0,1,-1)
        # define attribute "Elevation" for precipitation
        self.labelAttrib = QtGui.QLabel(Recharge_window)
        self.labelAttrib.setObjectName("labelAttrib")
        self.gridLayout3.addWidget(self.labelAttrib,0,0,1,1)
        self.lineAttrib = QtGui.QComboBox(Recharge_window)
        self.lineAttrib.setObjectName("lineAttrib")
        self.gridLayout3.addWidget(self.lineAttrib,0,1,1,1)
        # define attribute for surface runoff
        self.labelAttribRunoff = QtGui.QLabel(Recharge_window)
        self.labelAttribRunoff.setObjectName("labelAttribRunoff")
        self.gridLayout3.addWidget(self.labelAttribRunoff,1,0,1,1)
        self.lineAttribRunoff = QtGui.QComboBox(Recharge_window)
        self.lineAttribRunoff.setObjectName("lineAttribRunoff")
        self.gridLayout3.addWidget(self.lineAttribRunoff,1,1,1,1)  
        # define attribute for evapotranspiration
        self.labelAttribEvap = QtGui.QLabel(Recharge_window)
        self.labelAttribEvap.setObjectName("labelAttribEvap")
        self.gridLayout3.addWidget(self.labelAttribEvap,2,0,1,1)
        self.lineAttribEvap = QtGui.QComboBox(Recharge_window)
        self.lineAttribEvap.setObjectName("lineAttribEvap")
        self.gridLayout3.addWidget(self.lineAttribEvap,2,1,1,1)        
        # define pixel size
        self.labelPix = QtGui.QLabel(Recharge_window)
        self.labelPix.setObjectName("labelPix")
        self.gridLayout3.addWidget(self.labelPix, 0,3,1,1)
        self.linePix = QtGui.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 = QtGui.QGroupBox(Recharge_window)
        self.groupBox.setObjectName("groupBox")
        self.gridLayout2 = QtGui.QGridLayout(self.groupBox)
        self.gridLayout2.setObjectName("gridLayout2")
        self.gridLayout1.addWidget(self.groupBox, 4,0,1,-1)
        # table for classes and indexes
        self.tableWidget = QtGui.QTableWidget(5,3,Recharge_window)
        self.gridLayout2.addWidget(self.tableWidget,0,0,1,1)
        self.newItem = QtGui.QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(0,self.newItem)
        self.newItem = QtGui.QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(1,self.newItem)
        self.newItem = QtGui.QTableWidgetItem()
        self.tableWidget.setHorizontalHeaderItem(2,self.newItem)         
        # set the values (intervals)
        self.line = QtGui.QLineEdit("0")
        self.tableWidget.setItem(0,0,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("51")
        self.tableWidget.setItem(0,1,QtGui.QTableWidgetItem(self.line.text()))
        self.tableWidget.setItem(1,0,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("102")
        self.tableWidget.setItem(1,1,QtGui.QTableWidgetItem(self.line.text()))
        self.tableWidget.setItem(2,0,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("178")
        self.tableWidget.setItem(2,1,QtGui.QTableWidgetItem(self.line.text()))
        self.tableWidget.setItem(3,0,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("254")
        self.tableWidget.setItem(3,1,QtGui.QTableWidgetItem(self.line.text()))
        self.tableWidget.setItem(4,0,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("1000")  
        self.tableWidget.setItem(4,1,QtGui.QTableWidgetItem(self.line.text()))
        # set the indexes values
        self.line = QtGui.QLineEdit("1")
        self.tableWidget.setItem(0,2,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("3")
        self.tableWidget.setItem(1,2,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("6")
        self.tableWidget.setItem(2,2,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("8")
        self.tableWidget.setItem(3,2,QtGui.QTableWidgetItem(self.line.text()))
        self.line = QtGui.QLineEdit("9")
        self.tableWidget.setItem(4,2,QtGui.QTableWidgetItem(self.line.text()))
        # create a box layout to insert the buttons Add and Remove
        self.boxLayout = QtGui.QVBoxLayout()
        self.boxLayout.setObjectName("boxLayout")
        # button Add
        self.buttonAdd = QtGui.QPushButton(Recharge_window)
        self.buttonAdd.setObjectName("buttonAdd")
        self.boxLayout.addWidget(self.buttonAdd)
        # button Remove
        self.buttonRemove = QtGui.QPushButton(Recharge_window)
        self.buttonRemove.setObjectName("buttonRemove") 
        self.boxLayout.addWidget(self.buttonRemove)
        self.gridLayout2.addLayout(self.boxLayout,0,1,-1,1)
        ## button weight
        #self.labelWeight = QtGui.QLabel(Recharge_window)
        #self.labelWeight.setObjectName("labelWeight")
        #self.boxLayout.addWidget(self.labelWeight)
        #self.lineWeight = QtGui.QSpinBox()
        #self.lineWeight.setValue(3)
        #self.lineWeight.stepBy(1)
        #self.lineWeight.setObjectName("lineWeight")
        #self.boxLayout.addWidget(self.lineWeight)
        self.gridLayout2.addLayout(self.boxLayout,0,1,-1,1)         
        
        # output file
        # create label in gridLayout
        self.label3 = QtGui.QLabel(Recharge_window)
        self.label3.setObjectName("label3")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label3,5,0,1,1)
        # create select button to input file
        self.selectButton3 = QtGui.QPushButton(Recharge_window)
        self.selectButton3.setObjectName("selectButton3")
        self.gridLayout1.addWidget(self.selectButton3,5,2,1,1)
        self.inputLayerCombo3 = QtGui.QLineEdit(Recharge_window)
        self.inputLayerCombo3.setObjectName("inputLayerCombo3")
        self.gridLayout1.addWidget(self.inputLayerCombo3, 5,1,1,1)
        # stretch to extend the widget in column 1
        self.gridLayout1.setColumnStretch(1,1)        
        
        # button Ok, Close and Help
        self.buttonBox = QtGui.QDialogButtonBox(Recharge_window)
        #self.buttonBox.setMaximumSize(QtCore.QSize(200, 16777215))
        #self.buttonBox.setBaseSize(QtCore.QSize(110, 0))
        #self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Help|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout1.addWidget(self.buttonBox, 7, 1, 1, 1)             
        
        self.retranslateUi(Recharge_window)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Recharge_window.close)
                
    def retranslateUi(self, Recharge_window):
        Recharge_window.setWindowTitle(QtGui.QApplication.translate('Net Recharge (R)', 'Net Recharge (R)', None, QtGui.QApplication.UnicodeUTF8))
        self.label.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Precipitation (mm/year):', None, QtGui.QApplication.UnicodeUTF8))
        self.label1.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Overland Flow (mm/year):', None, QtGui.QApplication.UnicodeUTF8))
        self.label2.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Evapotranspiration (mm/year):', None, QtGui.QApplication.UnicodeUTF8))
        self.label4.setText(QtGui.QApplication.translate('Net Recharge (R)', 'DEM (m):', None, QtGui.QApplication.UnicodeUTF8))
        self.selectButton.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Browse', None, QtGui.QApplication.UnicodeUTF8)) 
        self.selectButton1.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Browse', None, QtGui.QApplication.UnicodeUTF8))
        self.selectButton2.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Browse', None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox.setTitle(QtGui.QApplication.translate("Net Recharge (R)", "Ratings", None, QtGui.QApplication.UnicodeUTF8))
        self.tableWidget.horizontalHeaderItem(0).setText(QtGui.QApplication.translate("Net Recharge (R)","Net Recharge(mm/year)", None, QtGui.QApplication.UnicodeUTF8))
        self.tableWidget.horizontalHeaderItem(1).setText(QtGui.QApplication.translate("Net Recharge (R)","Net Recharge (mm/year)", None, QtGui.QApplication.UnicodeUTF8))
        self.tableWidget.horizontalHeaderItem(2).setText(QtGui.QApplication.translate("Net Recharge (R)","Ratings", None, QtGui.QApplication.UnicodeUTF8))
        self.buttonAdd.setText(QtGui.QApplication.translate("Net Recharge (R)", "Add", None, QtGui.QApplication.UnicodeUTF8))
        self.buttonRemove.setText(QtGui.QApplication.translate("Net Recharge (R)", "Remove", None, QtGui.QApplication.UnicodeUTF8))        
        self.label3.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Output file:', None, QtGui.QApplication.UnicodeUTF8))
        self.selectButton3.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Browse', None, QtGui.QApplication.UnicodeUTF8))
        self.selectButton4.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Browse', None, QtGui.QApplication.UnicodeUTF8))
        #self.labelWeight.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Weight:', None, QtGui.QApplication.UnicodeUTF8))
        self.labelPix.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Cell size:', None, QtGui.QApplication.UnicodeUTF8))
        self.labelAttrib.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Attribute Precipitation:', None, QtGui.QApplication.UnicodeUTF8))        
        self.labelAttribRunoff.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Attribute Surface Runoff:', None, QtGui.QApplication.UnicodeUTF8))
        self.labelAttribEvap.setText(QtGui.QApplication.translate('Net Recharge (R)', 'Attribute Evapotranspiration:', None, QtGui.QApplication.UnicodeUTF8))