X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FgereListe.py;h=f08adac3b21b98ee0d86001a12781016aed31d9a;hb=3b2aa4435996023b38c1c749799a956909684b7c;hp=1645b1d09a9800293b6165860c1e909cd3f2b8c3;hpb=df0e1a1f57e70d3d99dd7fb381845500c3d3c6dd;p=tools%2Feficas.git diff --git a/InterfaceQT4/gereListe.py b/InterfaceQT4/gereListe.py index 1645b1d0..f08adac3 100644 --- a/InterfaceQT4/gereListe.py +++ b/InterfaceQT4/gereListe.py @@ -18,14 +18,27 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # # Modules Python -import string,types,os + +from __future__ import absolute_import +try : + from builtins import str + from builtins import range + from builtins import object +except : pass + +import types,os import traceback -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * + +import six +from six.moves import range +from PyQt5.QtWidgets import QLineEdit, QLabel, QFileDialog +from PyQt5.QtCore import QEvent, Qt +from PyQt5.QtGui import QIcon, QPalette + from Extensions.i18n import tr -from monViewTexte import ViewText +from InterfaceQT4.monViewTexte import ViewText + # ---------------------- # class LECustom(QLineEdit): @@ -34,38 +47,135 @@ class LECustom(QLineEdit): """ Constructor """ - QMainWindow.__init__(self,parent) + QLineEdit.__init__(self,parent) + self.parentQt=parentQt self.num=i + self.dansUnTuple=False + self.numDsLaListe=-1 def focusInEvent(self,event): + #print "dans focusInEvent de LECustom" self.parentQt.LineEditEnCours=self self.parentQt.NumLineEditEnCours=self.num + self.parentQt.textSelected=self.text() + self.setStyleSheet("border: 2px solid gray") + QLineEdit.focusInEvent(self,event) + + def focusOutEvent(self,event): + self.setStyleSheet("border: 0px") + if self.dansUnTuple : self.setStyleSheet("background:rgb(235,235,235); border: 0px;") + elif self.num % 2 == 1 : self.setStyleSheet("background:rgb(210,210,210)") + else : self.setStyleSheet("background:rgb(235,235,235)") + + + if isinstance(self,LECustomTuple) and not self.tupleCustomParent.inFocusOutEvent: + self.tupleCustomParent.inFocusOutEvent=True + self.tupleCustomParent.valueChange() + self.tupleCustomParent.inFocusOutEvent=False + QLineEdit.focusOutEvent(self,event) + + def clean(self): + self.setText("") + + def getValeur(self): + return self.text() + + def setValeur(self,valeur): + self.setText(valeur) + + + +# --------------------------- # +class LECustomTuple(LECustom): +# --------------------------- # + def __init__(self,parent): + # index sera mis a jour par TupleCustom + parentQt=parent.parent().parent().parent() + LECustom. __init__(self,parent,parentQt,0) + #print (dir(self)) + +# ---------------------------- # +class MonLabelListeClic(QLabel): +# ---------------------------- # + def __init__(self,parent): + QLabel.__init__(self,parent) + self.parent=parent + + def event(self,event) : + if event.type() == QEvent.MouseButtonRelease: + self.texte=self.text() + self.parent.traiteClicSurLabelListe(self.texte) + return QLabel.event(self,event) # ------------- # -class GereListe: +class GereListe(object): # ------------- # def __init__(self): - print "GereListe" self.connecterSignaux() + def connecterSignauxQT4(self): + if hasattr(self,'RBHaut'): + self.connect(self.RBHaut,SIGNAL("clicked()"),self.hautPushed) + self.connect(self.RBBas,SIGNAL("clicked()"),self.basPushed) + self.connect(self.RBMoins,SIGNAL("clicked()"),self.moinsPushed) + self.connect(self.RBPlus,SIGNAL("clicked()"),self.plusPushed) + self.connect(self.RBVoisListe,SIGNAL("clicked()"),self.voisListePushed) + if hasattr(self,'PBAlpha'): + self.connect(self.PBAlpha,SIGNAL("clicked()"),self.alphaPushed) + self.connect(self.PBCata,SIGNAL("clicked()"),self.cataPushed) + self.connect(self.PBFind,SIGNAL("clicked()"),self.findPushed) + self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.LEFiltreReturnPressed) + def connecterSignaux(self): - self.connect(self.RBHaut,SIGNAL("clicked()"),self.hautPushed) - self.connect(self.RBBas,SIGNAL("clicked()"),self.basPushed) - self.connect(self.RBMoins,SIGNAL("clicked()"),self.moinsPushed) - self.connect(self.RBPlus,SIGNAL("clicked()"),self.plusPushed) - self.connect(self.RBVoisListe,SIGNAL("clicked()"),self.voisListePushed) - self.connect(self.RBSalome,SIGNAL("clicked()"),self.salomePushed) - self.connect(self.RBSalomeVue,SIGNAL("clicked()"),self.salomeVuePushed) + if hasattr(self,'RBHaut'): + self.RBHaut.clicked.connect(self.hautPushed) + self.RBBas.clicked.connect(self.basPushed) + self.RBMoins.clicked.connect(self.moinsPushed) + self.RBPlus.clicked.connect(self.plusPushed) + self.RBVoisListe.clicked.connect(self.voisListePushed) + if hasattr(self,'PBAlpha'): + self.PBCata.clicked.connect(self.cataPushed) + self.PBAlpha.clicked.connect(self.alphaPushed) + self.PBFind.clicked.connect(self.findPushed) + self.LEFiltre.returnPressed.connect(self.LEFiltreReturnPressed) + + def filtreListe(self): + l=[] + if self.filtre != "" : + for i in self.listeAAfficher : + if i.find(self.filtre) == 0 :l.append(i) + self.listeAAfficher=l + if self.alpha : self.listeAAfficher.sort() + + def LEFiltreReturnPressed(self): + self.filtre= self.LEFiltre.text() + self.prepareListeResultatFiltre() + + def findPushed(self): + self.filtre= self.LEFiltre.text() + self.prepareListeResultatFiltre() + + def alphaPushed(self): + #print "alphaPushed" ,self.alpha + if self.alpha == 1 : return + self.alpha=1 + self.prepareListeResultat() + + def cataPushed(self): + if self.alpha == 0 : return + self.alpha=0 + self.prepareListeResultat() def hautPushed(self): if self.NumLineEditEnCours == 1 : return else : numEchange=self.NumLineEditEnCours-1 self.echange(self.NumLineEditEnCours,numEchange) + self.LineEditEnCours.setFocus(True) self.scrollArea.ensureWidgetVisible(self.LineEditEnCours) @@ -73,16 +183,17 @@ class GereListe: if self.NumLineEditEnCours == self.indexDernierLabel : return else : numEchange=self.NumLineEditEnCours+1 self.echange(self.NumLineEditEnCours,numEchange) + self.LineEditEnCours.setFocus(True) self.scrollArea.ensureWidgetVisible(self.LineEditEnCours) def echange(self,num1,num2): # on donne le focus au a celui ou on a bouge # par convention le 2 - nomLineEdit="lineEditVal"+str(num1) + nomLineEdit=self.nomLine+str(num1) #print nomLineEdit courant=getattr(self,nomLineEdit) valeurAGarder=courant.text() - nomLineEdit2="lineEditVal"+str(num2) + nomLineEdit2=self.nomLine+str(num2) #print nomLineEdit2 courant2=getattr(self,nomLineEdit2) courant.setText(courant2.text()) @@ -90,50 +201,64 @@ class GereListe: self.changeValeur(changeDePlace=False) self.NumLineEditEnCours=num2 self.LineEditEnCours=courant2 + self.LineEditEnCours.setFocus(True) def moinsPushed(self): - if self.indexDernierLabel < self.monSimpDef.min: - self.editor.affiche_infos('nb min de valeurs : '+str(self.monSimpDef.min)+' atteint') - return # on supprime le dernier + if self.NumLineEditEnCours == 0 : return if self.NumLineEditEnCours==self.indexDernierLabel : - self.setText("") + nomLineEdit=self.nomLine+str(self.indexDernierLabel) + courant=getattr(self,nomLineEdit) + courant.clean() else : for i in range (self.NumLineEditEnCours, self.indexDernierLabel): aRemonter=i+1 - nomLineEdit="lineEditVal"+str(aRemonter) + nomLineEdit=self.nomLine+str(aRemonter) courant=getattr(self,nomLineEdit) - valeurARemonter=courant.text() - nomLineEdit="lineEditVal"+str(i) + valeurARemonter=courant.getValeur() + nomLineEdit=self.nomLine+str(i) courant=getattr(self,nomLineEdit) - courant.setText(valeurARemonter) - nomLineEdit="lineEditVal"+str(self.indexDernierLabel) + if valeurARemonter != None : courant.setValeur(valeurARemonter) + else : courant.clean() + nomLineEdit=self.nomLine+str(self.indexDernierLabel) courant=getattr(self,nomLineEdit) - courant.setText("") - self.changeValeur(changeDePlace=False) + courant.clean() + self.changeValeur(changeDePlace=False,oblige=True) + self.setValide() def plusPushed(self): if self.indexDernierLabel == self.monSimpDef.max: - self.editor.affiche_infos('nb max de valeurs : '+str(self.monSimpDef.max)+' atteint') + if len(self.listeValeursCourantes) < self.monSimpDef.max : self.chercheLigneVide() + else : self.editor.affiche_infos('nb max de valeurs : '+str(self.monSimpDef.max)+' atteint',Qt.red) return self.ajoutLineEdit() + self.descendLesLignes() + + def chercheLigneVide(self): + for i in range(self.indexDernierLabel) : + nomLineEdit=self.nomLine+str(i+1) + courant=getattr(self,nomLineEdit) + valeur=courant.getValeur() + if valeur=="" : courant.setFocus(7);return + + + def descendLesLignes(self): if self.NumLineEditEnCours==self.indexDernierLabel : return - nomLineEdit="lineEditVal"+str(self.NumLineEditEnCours+1) + nomLineEdit=self.nomLine+str(self.NumLineEditEnCours+1) courant=getattr(self,nomLineEdit) - valeurADescendre=courant.text() - courant.setText("") + valeurADescendre=courant.getValeur() + courant.clean() for i in range (self.NumLineEditEnCours+1, self.indexDernierLabel): aDescendre=i+1 - nomLineEdit="lineEditVal"+str(aDescendre) + nomLineEdit=self.nomLine+str(aDescendre) courant=getattr(self,nomLineEdit) - valeurAGarder=courant.text() - courant.setText(valeurADescendre) + valeurAGarder=courant.getValeur() + courant.setValeur(valeurADescendre) valeurADescendre=valeurAGarder self.changeValeur(changeDePlace=False) self.scrollArea.ensureWidgetVisible(self.LineEditEnCours) def voisListePushed(self): - print "voisListePushed" texteValeurs="" for v in self.node.item.GetListeValeurs(): texteValeurs+=str(v)+", " @@ -141,9 +266,55 @@ class GereListe: f=ViewText(self,self.editor,entete,texteValeurs[0:-2]) f.show() - def salomePushed(self): - print "salomePushed" - def salomeVuePushed(self): - print "salomeVuePushed" + def selectInFile(self): + init=str( self.editor.CONFIGURATION.savedir) + fn = QFileDialog.getOpenFileName(self.node.appliEficas, + tr("Fichier de donnees"), + init, + tr('Tous les Fichiers (*)',)) + fn=fn[0] + if fn == None : return + if fn == "" : return + ulfile = os.path.abspath(six.text_type(fn)) + self.editor.CONFIGURATION.savedir=os.path.split(ulfile)[0] + + from .monSelectVal import MonSelectVal + MonSelectVal(file=fn,parent=self).show() + + def noircirResultatFiltre(self): + filtre=str(self.LEFiltre.text()) + for cb in self.listeCbRouge: + palette = QPalette(Qt.red) + palette.setColor(QPalette.WindowText,Qt.black) + cb.setPalette(palette) + t=cb.text() + cb.setText(t) + self.LEFiltre.setText("") + self.listeCbRouge = [] + + +# ----------- # +class GerePlie(object): +# ----------- # + + def gereIconePlier(self): + if not(hasattr(self,'BFermeListe')) : return + self.editor.listeDesListesOuvertes.add(self.node.item) + repIcon=self.node.editor.appliEficas.repIcon + if not (self.editor.afficheListesPliees): + fichier=os.path.join(repIcon, 'empty.png') + icon = QIcon(fichier) + self.BFermeListe.setIcon(icon) + return + fichier=os.path.join(repIcon, 'minusnode.png') + icon = QIcon(fichier) + self.BFermeListe.setIcon(icon) + self.BFermeListe.clicked.connect( self.selectWidgetPlie) + + def selectWidgetPlie(self): + self.editor.listeDesListesOuvertes.remove(self.node.item) + self.reaffichePourDeplier() + +