def setTView(self):
     for idx, val in enumerate(self.dictTblView ['lstquer']):
         View= self.dictTblView ['lstView'][idx]
         Size= self.dictTblView ['size'][idx]
         Hide= self.dictTblView ['toHide'][idx]
         model = mixedModel.setQueryModel(query= val) 
         QT_tblViewUtility.setViewCustom(tblView= View, lstSizeCol=Size)
         QT_tblViewUtility.setModelInView(tblView= View, ViewModel = model, toHide=Hide) 
Exemple #2
0
 def setCombBox(self):
     lstQuer = self.dictCB['quer']
     lstWdg = self.dictCB['widgets']
     for idx, quer in enumerate(lstQuer):
         model = mixedModel.setQueryModel(query=quer)
         lstWdg[idx].setModel(model)
         lstWdg[idx].setModelColumn(1)
         self.CBTextHint(Combox=lstWdg[idx])
Exemple #3
0
    def setTheView(self):
        quer = self.dictFields['quer']
        toHide = self.dictFields['fldToHide']
        toSize = self.dictFields['sizeCol']
        modelOut = mixedModel.setQueryModel(query=quer)

        QT_tblViewUtility.setModelInView(tblView=self.TV,
                                         ViewModel=modelOut,
                                         toHide=toHide)
        QT_tblViewUtility.setViewCustom(tblView=self.TV, lstSizeCol=toSize)
Exemple #4
0
 def configRegistador(self):
     if self.CBProvincia.currentIndex() == 0:
         quer = "select null as id, '-Registador-' as nome union all select id, nome from ref_registador"
     else:
         id_prov = mixedModel.getDataCombox(widg=self.CBProvincia)
         quer = "select null as id, '-Registador-' as nome union all select id, nome from ref_registador where id_centro = '{prov}'".format(
             prov=id_prov)
     model = mixedModel.setQueryModel(query=quer)
     self.CBRegistadores.setModel(model)
     self.CBRegistadores.setModelColumn(1)
 def setCBMes(self, val=-99):
     quer = "select null, '-MES-' UNION all select  cast (data_mes as text), mes_nome from view_ano_mes where data_ano = {inicioAno}".format(inicioAno= val)
     model = mixedModel.setQueryModel(query = quer)
     dictlstWdg= {self.CBAno_inicio.objectName(): self.CBMes_inicio, 
                  self.CBAno_Fim.objectName(): self.CBMes_Fim
                 }
     val = dictlstWdg.get(self.sender().objectName())
     if val is not None:
         val.setModel(model)
         val.setModelColumn(1)
 def configCombox(self):
     '''
     Metodo para configurar o Modelo e Text Hint no Combox.
     '''
     lstWdgt = self.dictCB['widget']
     lstQuer = self.dictCB['quer']
     for idx, val in enumerate(lstWdgt):
         model = mixedModel.setQueryModel(lstQuer[idx])
         val.setModel(model)
         val.setModelColumn(1)
         self.CBTextHint(Combox=val)
 def setCB(self):
     lstquer = ["select null as id, '-ANO-' as nome UNION all (select distinct data_ano, cast (data_ano as text) as d_ano from view_ano_mes order by data_ano)",
                "select null as id, '-ANO-' as nome UNION all (select distinct data_ano, cast (data_ano as text) as d_ano from view_ano_mes order by data_ano)",
                "select null as id, '-Agrupamento-' as nome UNION all (select mes_num, nome from prc_agrupamentos order by mes_num)",
                "select null as id, '-Tipo de Dia-' as nome union all select id, nome from ref_table where id_grupo = 'TPD'",
                "select null as id, '-Periodo do Dia-' as nome union all SELECT id, nome FROM public.prc_periodo_dia;"]
         
     lstWdg = [self.CBAno_inicio, self.CBAno_Fim, self.CBAgrupamento, self.CBTipDia, self.CBPeriodoDia] 
     for idx, val in enumerate (lstWdg):
         model = mixedModel.setQueryModel(query = lstquer[idx])
         val.setModel(model)
         val.setModelColumn(1)    
 def _configCombox(self, index=0):
     '''
     Metodo para configurar o Modelo e Text Hint no Combox.
     '''
     lstWdgt = self.dictCBX['widget']
     lstQuer = self.dictCBX['quer']
     limit = len(lstWdgt)
     for idx in range(index, limit):
         val = lstWdgt[idx]
         model = mixedModel.setQueryModel(lstQuer[idx])
         val.setModel(model)
         val.setModelColumn(1)
         self.CBTextHint(Combox=val)
 def configComboxLocal(self):
     '''
     Configurar o combox e o evento
     '''
     lstWdgt = [self.CBProvincia, self.CBDistrito, self.CBPosto, self.CBCentroPesca]
     for wdg in lstWdgt:
         wdgName = wdg.objectName()
         query= self.dictLocal[wdgName]['query']
         model= mixedModel.setQueryModel(query= query)
         wdg.setModel(model)
         wdg.setModelColumn(1)
         self.CBTextHint(Combox=wdg)
         wdg.currentTextChanged.connect(self.updateNextCombo)
Exemple #10
0
    def setDB(self):
        self.dbConnection = con_.con_1()
        query = '''select id_gado, data_acontecimento, descricao
                    from tbl_log
                    where
                    id_acontecimento = 2; 
        '''
        list_of_newNames = ['ID Gado', 'Data da Morte', 'Descricao']

        self.model = mx.setQueryModel(query=query,
                                      lstNewNames=list_of_newNames)
        self.tableView.setModel(self.model)
        self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)

        mx.setModel4CombBox(tblName='tbl_log',
                            lstNames='id_gado',
                            widg=self.idComboBox,
                            namePos=0)
 def setModel4Mapper(self):
     fldToMap = [
         None, self.DEData, self.LECentro, self.LERegistador,
         self.LECentroOrigem, self.LEArte, self.SBAmostradas
     ]
     bOK, lstOut = self.getTheData()
     if bOK:
         val = lstOut
         saidaID = val[0]
         quer = '''select 
                 arte.id, DATE(saida.data_amostragem), centro.nome, registador.nome,
                 centro2.nome, artenome.nome, arte.n_amostradas
                 from t_activ_tip_unidade as arte
                 inner join t_saidas as saida on arte.id_saida = saida.id
                 left join ref_geometric as centro2 on arte.id_centro = centro2.id
                 left join ref_unidpescatipo as artenome on arte.id_tip_uni_pesca = artenome.id
                 left join ref_geometric as centro on saida.id_centro = centro.id
                 left join ref_registador as registador on saida.id_registrador = registador.id
                 where saida.id = {id}'''.format(id=saidaID)
         model = mixedModel.setQueryModel(query=quer)
         mixedModel.withWidgets.setMapper(self,
                                          model=model,
                                          fldToMap=fldToMap)
         mixedModel.withWidgets.setMapperToIdx(self, idx=self.mIDx.row())
Exemple #12
0
 def configCbModel(self):
     #Fill the combox (--tipo de documento--)
     quer = sqlMagic.table_query_scrpts['DocTypes']
     model = mixedModel.setQueryModel(query=quer)
     self.CBType.setModel(model)
     self.CBType.setModelColumn(1)
Exemple #13
0
 def buldingTheQuery(self):
     startQuery = """SELECT tbl1.id, date(data_amostragem) as "Data da Amostra", tbl2.nome as "Centro", tbl3.nome as "Registador",
                     hora_inicioamo, hor_fimamo, tbl4.nome as "Dia da Semana", tbl5.nome as "Forca do Vento", tbl6.nome as "Nivel da Mare", 
                     tbl7.nome as "Direcao do Vento", hora_vento, tbl8.nome as "Tipo de Mare", altura_preamar, hora_preamar, altura_baimar, 
                     hora_baixamar, tbl9.nome as "Fase da Lua", tbl10.nome as "Nebulosidade", hora_nebulosidade, actividade_pesq, 
                     total_artes_amos, total_artes_act, total_artes_n_activas, total_artes_prov_outo_cent, observacoes
                     FROM public.t_saidas as tbl1
                     left join ref_geometric as tbl2
                     on tbl1.id_centro = tbl2.id and tbl2.id_tiplocal = 'CTP'
                     left join ref_registador as tbl3
                     on tbl1.id_registrador = tbl3.id
                     left join ref_diasemana as tbl4
                     on tbl1.id_diasemana = tbl4.id  
                     left join ref_table as tbl5
                     on tbl1.id_forcavento = tbl5.id and tbl5.id_grupo = 'FCV'
                     left join ref_table as tbl6
                     on tbl1.id_estadomare = tbl6.id and tbl6.id_grupo = 'NVM'
                     left join ref_table as tbl7 
                     on tbl1.id_direccao = tbl7.id and tbl7.id_grupo = 'DDV'
                     left join ref_table as tbl8
                     on tbl1.id_tipomare = tbl8.id and tbl8.id_grupo = 'TPM'
                     left join ref_table as tbl9
                     on tbl1.id_faselua = tbl9.id and tbl9.id_grupo = 'FLD'
                     left join ref_table as tbl10
                     on tbl1.id_nebulosidade = tbl10.id and tbl10.id_grupo = 'NBL' """#BigQuery and start Where
     #
     #
     if self.CBProvincia.currentIndex() != 0:
         startQuery += " where "
         if self.CBDistrito.currentIndex() != 0:
             if self.CBPosto.currentIndex() != 0:
                 if self.CBCentroPesca.currentIndex() != 0:
                     ctp = mixedModel.getDataCombox(widg=self.CBCentroPesca)
                     startQuery += "tbl1.id_centro in (select tbl1.id from ref_geometric as tbl1 where tbl1.id = '{ctp}')".format(
                         ctp=ctp)
                 else:
                     psd = mixedModel.getDataCombox(widg=self.CBPosto)
                     startQuery += """ tbl1.id_centro in (select tbl1.id from ref_geometric as tbl1 
                                         inner join ref_geometric as tbl2
                                         on tbl1.id_parent = tbl2.id
                                         where tbl2.id like '{psd}') """.format(
                         psd=psd)
             else:
                 dst = mixedModel.getDataCombox(widg=self.CBDistrito)
                 startQuery += """ tbl1.id_centro in (select tbl1.id from ref_geometric as tbl1 
                                         inner join ref_geometric as tbl2
                                         on tbl1.id_parent = tbl2.id
                                         inner join ref_geometric as tbl3 
                                         on tbl2.id_parent = tbl3.id
                                         where tbl3.id like '{dst}') """.format(
                     dst=dst)
         else:
             prv = mixedModel.getDataCombox(widg=self.CBProvincia)
             startQuery += """ tbl1.id_centro in (select tbl1.id from ref_geometric as tbl1 
                                         inner join ref_geometric as tbl2
                                         on tbl1.id_parent = tbl2.id
                                         inner join ref_geometric as tbl3 
                                         on tbl2.id_parent = tbl3.id
                                         inner join ref_geometric as tbl4
                                         on tbl3.id_parent = tbl4.id
                                         where tbl4.id like '{prv}') """.format(
                 prv=prv)
     #
     #
     if self.GBData.isChecked():
         if self.CBProvincia.currentIndex(
         ):  #!= 0 or self.CBRegistador.currentIndex() != 0 or self.CBDiaSemana.currentIndex() != 0 or self.CBActividadePesqueria.currentIndex() != 0:
             startQuery += ' and '
         else:
             startQuery += " where "
         inicio = rscForm.getText(widg=self.DEInicio)
         fim = rscForm.getText(widg=self.DEFim)
         startQuery += "data_amostragem  between '{inicio}' and '{fim}' ".format(
             inicio=inicio, fim=fim)
     #
     #
     if self.CBRegistador.currentIndex() != 0:
         if self.CBProvincia.currentIndex() != 0 or self.GBData.isChecked(
         ):  #or self.CBDiaSemana.currentIndex() != 0 or self.CBActividadePesqueria.currentIndex() != 0:
             startQuery += ' and '
         else:
             startQuery += " where "
         rgt = mixedModel.getDataCombox(widg=self.CBRegistador)
         startQuery += "tbl3.id = '{rgt}' ".format(rgt=rgt)
     #
     #
     if self.CBDiaSemana.currentIndex() != 0:
         if self.CBProvincia.currentIndex() != 0 or self.GBData.isChecked(
         ) or self.CBRegistador.currentIndex(
         ) != 0:  # or self.CBActividadePesqueria.currentIndex() != 0:
             startQuery += ' and '
         else:
             startQuery += " where "
         dsm = mixedModel.getDataCombox(widg=self.CBDiaSemana)
         startQuery += "tbl4.id = '{dsm}' ".format(dsm=dsm)
     #
     #
     if self.CBActividadePesqueria.currentIndex() != 0:
         if self.CBProvincia.currentIndex() != 0 or self.GBData.isChecked(
         ) or self.CBRegistador.currentIndex(
         ) != 0 or self.CBDiaSemana.currentIndex() != 0:
             startQuery += ' and '
         else:
             startQuery += " where "
         quer = mixedModel.getDataCombox(widg=self.CBActividadePesqueria)
         startQuery += quer
     #
     #
     try:
         if self.endQuery != " ":
             startQuery += "order by "
             startQuery += self.endQuery
     except AttributeError:
         startQuery += " order by data_amostragem "
     lstName = self.dictSaidas['newNames']
     model = mixedModel.setQueryModel(query=startQuery, lstNewNames=lstName)
     toHide = self.dictSaidas['toHide']
     lstSizeCol = self.dictSaidas['sizeCol']
     QT_tblViewUtility.setModelInView(tblView=self.TVSaidas,
                                      ViewModel=model,
                                      toHide=toHide)
     QT_tblViewUtility.setViewCustom(tblView=self.TVSaidas,
                                     lstSizeCol=lstSizeCol)