]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/monChoixCommande.py
Salome HOME
correction bugs adao + commentaire
[tools/eficas.git] / InterfaceQT4 / monChoixCommande.py
1 # Copyright (C) 2007-2013   EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Modules Python
20 # Modules Eficas
21
22 from desChoixCommandes import Ui_ChoixCommandes
23 from PyQt4  import *
24 from PyQt4.QtCore import *
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
28 import os
29
30     
31 # Import des panels
32
33 class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
34   """
35   """
36   def __init__(self,node, jdc_item, editor):
37       QtGui.QWidget.__init__(self,None)
38       self.setupUi(self)
39       #self.labelIcone.setText('<img src="/local00/home/A96028/Install_EficasV1/KarineEficas/InterfaceQT4/loopOff.png">');
40
41       self.item = jdc_item
42       self.node = node
43       self.editor = editor
44       self.jdc  = self.item.object.get_jdc_root()
45       debutTitre=self.editor.titre
46       self.listeWidget=[]
47       if self.editor.fichier != None : 
48           nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier))
49       else :
50           nouveauTitre=debutTitre
51       self.editor.appliEficas.setWindowTitle(nouveauTitre)
52
53
54       self.connect(self.RBalpha,SIGNAL("clicked()"),self.afficheAlpha)
55       self.connect(self.RBGroupe,SIGNAL("clicked()"),self.afficheGroupe)
56       self.connect(self.RBOrdre,SIGNAL("clicked()"),self.afficheOrdre)
57
58       if self.editor.Ordre_Des_Commandes == None : self.RBOrdre.close()
59
60        
61       self.editor.labelCommentaire.setText("")
62       if self.editor.widgetOptionnel!= None : self.editor.widgetOptionnel.close()
63       self.name=None
64       self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton)
65
66       self.affiche_alpha=0
67       self.affiche_groupe=0
68       self.affiche_ordre=0
69       if self.editor.affiche=="alpha"  : 
70          self.affiche_alpha==1;  
71          self.RBalpha.setChecked(True);
72          self.afficheAlpha()
73       elif self.editor.affiche=="groupe" : 
74          self.affiche_groupe==1; 
75          self.RBGroupe.setChecked(True); 
76          self.afficheGroupe()
77       elif self.editor.affiche=="ordre"  : 
78          self.affiche_ordre==1;  
79          self.RBOrdre.setChecked(True);  
80          self.afficheOrdre()
81       if self.editor.code == "Adao" : self.frameAffichage.close()
82
83   def afficheAlpha(self):
84       self.affiche_alpha=1
85       self.affiche_groupe=0
86       self.affiche_ordre=0
87       self.AjouteRadioButton()
88
89   def afficheGroupe(self):
90       self.affiche_alpha=0
91       self.affiche_groupe=1
92       self.affiche_ordre=0
93       self.AjouteRadioButton()
94
95   def afficheOrdre(self):
96       self.affiche_alpha=0
97       self.affiche_groupe=0
98       self.affiche_ordre=1
99       self.AjouteRadioButton()
100
101   def mouseDoubleClickEvent(self,event):
102       nodeCourrant=self.node.tree.currentItem()
103       if nodeCourrant==None: nodeCourrant=self.node.tree.racine
104       if self.name != None :
105          plier=self.editor.afficheCommandesPliees
106          if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier)
107          else : nouveau=nodeCourrant.append_brother(self.name,plier=plier)
108       if nouveau == 0 : return # on n a pas insere le noeud
109       nouveau.setDeplie()
110       #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
111       if self.editor.afficheApresInsert == True :
112            #if self.editor.affichePlie==True:  nouveau.plieToutEtReaffiche()
113            if self.editor.afficheCommandesPliees ==True:  nouveau.plieToutEtReaffiche()
114            else : nouveau.deplieToutEtReaffiche()
115            nouveau.fenetre.donnePremier()
116            #nouveau.deplieToutEtReaffiche()
117       else :
118            self.node.setSelected(False)
119            nouveau.setSelected(True)
120            self.node.tree.setCurrentItem(nouveau)
121       event.accept()
122       
123
124   def CreeListeCommande(self,filtre):
125       listeGroupes,dictGroupes=self.jdc.get_groups()
126       if "CACHE" in dictGroupes.keys():
127          aExclure=dictGroupes["CACHE"]
128       else:
129          aExclure=()
130       listeACreer=[]
131       for l in self.jdc.get_liste_cmd():
132          if l not in aExclure : 
133             if filtre != None and not filtre in l : continue
134             listeACreer.append(l)
135       return listeACreer
136
137   def AjouteRadioButton(self):
138       filtre=str(self.LEFiltre.text())
139       if filtre==str("") : filtre=None
140       if hasattr(self,'buttonGroup') :
141          for b in self.buttonGroup.buttons():
142              self.buttonGroup.removeButton(b)
143              b.close()
144       else :
145          self.buttonGroup = QButtonGroup()
146       for w in self.listeWidget :
147          w.close()
148       self.listeWidget=[]
149       if self.affiche_alpha==1 :
150          liste=self.CreeListeCommande(filtre)
151          for cmd in liste :
152            rbcmd=(QRadioButton(tr(cmd)))
153            self.buttonGroup.addButton(rbcmd)
154            self.commandesLayout.addWidget(rbcmd)
155            rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
156            self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique) 
157       elif  self.affiche_groupe==1 :
158          listeGroupes,dictGroupes=self.jdc.get_groups()
159          for grp in listeGroupes:
160            if grp == "CACHE" : continue
161            label=QLabel(self)
162            text=QString.fromUtf8('<html><head/><body><p><span style=\" font-weight:600;\">Groupe : '+tr(grp)+'</span></p></body></html>')
163            label.setText(text)
164            self.listeWidget.append(label)
165            aAjouter=1
166            for cmd in  dictGroupes[grp]:
167               if filtre != None and not filtre in cmd : continue
168               if aAjouter == 1 :
169                  self.commandesLayout.addWidget(label)
170                  aAjouter=0
171               rbcmd=(QRadioButton(tr(cmd)))
172               self.buttonGroup.addButton(rbcmd)
173               self.commandesLayout.addWidget(rbcmd)
174               rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
175               self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
176            label2=QLabel(self)
177            label2.setText(" ")
178            self.listeWidget.append(label2)
179            self.commandesLayout.addWidget(label2)
180       elif  self.affiche_ordre==1 :
181          listeFiltre=self.CreeListeCommande(filtre)
182          liste=[]
183          if self.editor.Ordre_Des_Commandes == None : Ordre_Des_Commandes=listeFiltre
184          else : Ordre_Des_Commandes=self.editor.Ordre_Des_Commandes
185          for cmd in Ordre_Des_Commandes :
186             if cmd in listeFiltre :
187                  liste.append(cmd)
188          for cmd in liste :
189            rbcmd=(QRadioButton(tr(cmd)))
190            self.buttonGroup.addButton(rbcmd)
191            self.commandesLayout.addWidget(rbcmd)
192            rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
193            self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique) 
194
195      
196   def LEfiltreReturnPressed(self):
197       self.AjouteRadioButton(filtre)
198
199
200   def rbClique(self,id):
201       self.name=str(id.text().toLatin1())
202       definitionEtape=getattr(self.jdc.cata[0],self.name)
203       commentaire=getattr(definitionEtape,self.jdc.lang)
204       try :
205         commentaire=getattr(definitionEtape,self.jdc.lang)
206       except :
207         try :
208            commentaire=getattr(definitionEtape,"ang")
209         except :
210            commentaire=""
211       self.editor.labelCommentaire.setText(commentaire)
212
213
214
215   def setValide(self):
216       #PNPN a priori pas d icone mais peut-etre a faire
217       pass