Salome HOME
PourLaura
[tools/eficas.git] / InterfaceQT4 / monChoixCommande.py
index 674ceaeb6b77c9e0b314ce8a2a5b76d26a8e3dd5..3fdab859e6e1decdb66cbf7a77ec08e8132916fa 100644 (file)
@@ -36,7 +36,12 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
   def __init__(self,node, jdc_item, editor):
       QtGui.QWidget.__init__(self,None)
       self.setupUi(self)
-      #self.labelIcone.setText('<img src="/local00/home/A96028/Install_EficasV1/KarineEficas/InterfaceQT4/loopOff.png">');
+
+      self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
+      iconeFile=os.path.join(self.repIcon,'lettreRblanc30.png')
+      icon = QIcon(iconeFile)
+      self.RBRegle.setIcon(icon)
+      self.RBRegle.setIconSize(QtCore.QSize(21, 31))
 
       self.item = jdc_item
       self.node = node
@@ -44,23 +49,34 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
       self.jdc  = self.item.object.get_jdc_root()
       debutTitre=self.editor.titre
       self.listeWidget=[]
+      self.dicoCmd={}
       if self.editor.fichier != None : 
           nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier))
       else :
           nouveauTitre=debutTitre
       self.editor.appliEficas.setWindowTitle(nouveauTitre)
 
+      #print self.node.tree
 
       self.connect(self.RBalpha,SIGNAL("clicked()"),self.afficheAlpha)
       self.connect(self.RBGroupe,SIGNAL("clicked()"),self.afficheGroupe)
       self.connect(self.RBOrdre,SIGNAL("clicked()"),self.afficheOrdre)
+      self.connect(self.RBClear,SIGNAL("clicked()"),self.clearFiltre)
+      self.connect(self.RBCasse,SIGNAL("toggled(bool)"),self.ajouteRadioButtons)
+      if self.node.tree.item.get_regles() == () :
+         self.RBRegle.close()
+         self.labelRegle.close()
+      else : self.connect(self.RBRegle,SIGNAL("clicked()"),self.afficheRegle)
 
       if self.editor.Ordre_Des_Commandes == None : self.RBOrdre.close()
 
        
       self.editor.labelCommentaire.setText("")
+      if self.editor.widgetOptionnel!= None : 
+         self.editor.widgetOptionnel.close()
+         self.editor.widgetOptionnel=None
       self.name=None
-      self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton)
+      self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.ajouteRadioButtons)
 
       self.affiche_alpha=0
       self.affiche_groupe=0
@@ -77,24 +93,28 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
          self.affiche_ordre==1;  
          self.RBOrdre.setChecked(True);  
          self.afficheOrdre()
+      if self.editor.code == "Adao" : self.frameAffichage.close()
+
+  def afficheRegle(self):
+      self.node.tree.AppelleBuildLBRegles()
 
   def afficheAlpha(self):
       self.affiche_alpha=1
       self.affiche_groupe=0
       self.affiche_ordre=0
-      self.AjouteRadioButton()
+      self.ajouteRadioButtons()
 
   def afficheGroupe(self):
       self.affiche_alpha=0
       self.affiche_groupe=1
       self.affiche_ordre=0
-      self.AjouteRadioButton()
+      self.ajouteRadioButtons()
 
   def afficheOrdre(self):
       self.affiche_alpha=0
       self.affiche_groupe=0
       self.affiche_ordre=1
-      self.AjouteRadioButton()
+      self.ajouteRadioButtons()
 
   def mouseDoubleClickEvent(self,event):
       nodeCourrant=self.node.tree.currentItem()
@@ -103,6 +123,9 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
          plier=self.editor.afficheCommandesPliees
          if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier)
          else : nouveau=nodeCourrant.append_brother(self.name,plier=plier)
+      else :
+         nouveau = 0
+      if nouveau == 0 : return # on n a pas insere le noeud
       nouveau.setDeplie()
       #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
       if self.editor.afficheApresInsert == True :
@@ -112,15 +135,15 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
            nouveau.fenetre.donnePremier()
            #nouveau.deplieToutEtReaffiche()
       else :
-           print "je passe la"
            self.node.setSelected(False)
            nouveau.setSelected(True)
            self.node.tree.setCurrentItem(nouveau)
       event.accept()
       
 
-  def CreeListeCommande(self,filtre):
+  def creeListeCommande(self,filtre):
       listeGroupes,dictGroupes=self.jdc.get_groups()
+      sensibleALaCasse=self.RBCasse.isChecked()
       if "CACHE" in dictGroupes.keys():
          aExclure=dictGroupes["CACHE"]
       else:
@@ -128,11 +151,12 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
       listeACreer=[]
       for l in self.jdc.get_liste_cmd():
          if l not in aExclure : 
-            if filtre != None and not filtre in l : continue
+            if sensibleALaCasse and (filtre != None and not filtre in l) : continue
+            if (not sensibleALaCasse) and filtre != None and (not filtre in l) and (not filtre.upper() in l) : continue
             listeACreer.append(l)
       return listeACreer
 
-  def AjouteRadioButton(self):
+  def ajouteRadioButtons(self):
       filtre=str(self.LEFiltre.text())
       if filtre==str("") : filtre=None
       if hasattr(self,'buttonGroup') :
@@ -145,8 +169,9 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
          w.close()
       self.listeWidget=[]
       if self.affiche_alpha==1 :
-         liste=self.CreeListeCommande(filtre)
+         liste=self.creeListeCommande(filtre)
          for cmd in liste :
+           self.dicoCmd[tr(cmd)]=cmd
            rbcmd=(QRadioButton(tr(cmd)))
            self.buttonGroup.addButton(rbcmd)
            self.commandesLayout.addWidget(rbcmd)
@@ -161,11 +186,14 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
            label.setText(text)
            self.listeWidget.append(label)
            aAjouter=1
+           sensibleALaCasse=self.RBCasse.isChecked()
            for cmd in  dictGroupes[grp]:
-              if filtre != None and not filtre in cmd : continue
+              if sensibleALaCasse and (filtre != None and not filtre in cmd) : continue
+              if (not sensibleALaCasse) and filtre != None and (not filtre in cmd) and (not filtre.upper() in cmd) : continue
               if aAjouter == 1 :
                  self.commandesLayout.addWidget(label)
                  aAjouter=0
+              self.dicoCmd[tr(cmd)]=cmd
               rbcmd=(QRadioButton(tr(cmd)))
               self.buttonGroup.addButton(rbcmd)
               self.commandesLayout.addWidget(rbcmd)
@@ -176,7 +204,7 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
            self.listeWidget.append(label2)
            self.commandesLayout.addWidget(label2)
       elif  self.affiche_ordre==1 :
-         listeFiltre=self.CreeListeCommande(filtre)
+         listeFiltre=self.creeListeCommande(filtre)
          liste=[]
          if self.editor.Ordre_Des_Commandes == None : Ordre_Des_Commandes=listeFiltre
          else : Ordre_Des_Commandes=self.editor.Ordre_Des_Commandes
@@ -184,6 +212,7 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
             if cmd in listeFiltre :
                  liste.append(cmd)
          for cmd in liste :
+           self.dicoCmd[tr(cmd)]=cmd
            rbcmd=(QRadioButton(tr(cmd)))
            self.buttonGroup.addButton(rbcmd)
            self.commandesLayout.addWidget(rbcmd)
@@ -191,12 +220,13 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
            self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique) 
 
      
-  def LEfiltreReturnPressed(self):
-      self.AjouteRadioButton(filtre)
 
+  def clearFiltre(self):
+      self.LEFiltre.setText("")
+      self.ajouteRadioButtons()
 
   def rbClique(self,id):
-      self.name=str(id.text().toLatin1())
+      self.name=self.dicoCmd[str(id.text().toLatin1())]
       definitionEtape=getattr(self.jdc.cata[0],self.name)
       commentaire=getattr(definitionEtape,self.jdc.lang)
       try :