1 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from desChoixCommandes import Ui_ChoixCommandes
24 from PyQt4.QtCore import *
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
33 class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget):
36 def __init__(self,node, jdc_item, editor):
37 QtGui.QWidget.__init__(self,None)
40 self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons')
41 iconeFile=os.path.join(self.repIcon,'lettreRblanc30.png')
42 icon = QIcon(iconeFile)
43 self.RBRegle.setIcon(icon)
44 self.RBRegle.setIconSize(QtCore.QSize(21, 31))
49 self.jdc = self.item.object.get_jdc_root()
50 debutTitre=self.editor.titre
53 if self.editor.fichier != None :
54 nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier))
56 nouveauTitre=debutTitre
57 self.editor.appliEficas.setWindowTitle(nouveauTitre)
61 self.connect(self.RBalpha,SIGNAL("clicked()"),self.afficheAlpha)
62 self.connect(self.RBGroupe,SIGNAL("clicked()"),self.afficheGroupe)
63 self.connect(self.RBOrdre,SIGNAL("clicked()"),self.afficheOrdre)
64 self.connect(self.RBClear,SIGNAL("clicked()"),self.clearFiltre)
65 self.connect(self.RBCasse,SIGNAL("toggled(bool)"),self.ajouteRadioButtons)
66 if self.node.tree.item.get_regles() == () :
68 self.labelRegle.close()
69 else : self.connect(self.RBRegle,SIGNAL("clicked()"),self.afficheRegle)
71 if self.editor.Ordre_Des_Commandes == None : self.RBOrdre.close()
74 self.editor.labelCommentaire.setText("")
75 if self.editor.widgetOptionnel!= None :
76 self.editor.widgetOptionnel.close()
77 self.editor.widgetOptionnel=None
79 self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.ajouteRadioButtons)
84 if self.editor.affiche=="alpha" :
85 self.affiche_alpha==1;
86 self.RBalpha.setChecked(True);
88 elif self.editor.affiche=="groupe" :
89 self.affiche_groupe==1;
90 self.RBGroupe.setChecked(True);
92 elif self.editor.affiche=="ordre" :
93 self.affiche_ordre==1;
94 self.RBOrdre.setChecked(True);
96 if self.editor.code == "Adao" : self.frameAffichage.close()
98 def afficheRegle(self):
99 self.node.tree.AppelleBuildLBRegles()
101 def afficheAlpha(self):
103 self.affiche_groupe=0
105 self.ajouteRadioButtons()
107 def afficheGroupe(self):
109 self.affiche_groupe=1
111 self.ajouteRadioButtons()
113 def afficheOrdre(self):
115 self.affiche_groupe=0
117 self.ajouteRadioButtons()
119 def mouseDoubleClickEvent(self,event):
120 nodeCourrant=self.node.tree.currentItem()
121 if nodeCourrant==None: nodeCourrant=self.node.tree.racine
122 if self.name != None :
123 plier=self.editor.afficheCommandesPliees
124 if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier)
125 else : nouveau=nodeCourrant.append_brother(self.name,plier=plier)
128 if nouveau == 0 : return # on n a pas insere le noeud
130 #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
131 if self.editor.afficheApresInsert == True :
132 #if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche()
133 if self.editor.afficheCommandesPliees ==True: nouveau.plieToutEtReaffiche()
134 else : nouveau.deplieToutEtReaffiche()
135 nouveau.fenetre.donnePremier()
136 #nouveau.deplieToutEtReaffiche()
138 self.node.setSelected(False)
139 nouveau.setSelected(True)
140 self.node.tree.setCurrentItem(nouveau)
144 def creeListeCommande(self,filtre):
145 listeGroupes,dictGroupes=self.jdc.get_groups()
146 sensibleALaCasse=self.RBCasse.isChecked()
147 if "CACHE" in dictGroupes.keys():
148 aExclure=dictGroupes["CACHE"]
152 for l in self.jdc.get_liste_cmd():
153 if l not in aExclure :
154 if sensibleALaCasse and (filtre != None and not filtre in l) : continue
155 if (not sensibleALaCasse) and filtre != None and (not filtre in l) and (not filtre.upper() in l) : continue
156 listeACreer.append(l)
159 def ajouteRadioButtons(self):
160 filtre=str(self.LEFiltre.text())
161 if filtre==str("") : filtre=None
162 if hasattr(self,'buttonGroup') :
163 for b in self.buttonGroup.buttons():
164 self.buttonGroup.removeButton(b)
167 self.buttonGroup = QButtonGroup()
168 for w in self.listeWidget :
171 if self.affiche_alpha==1 :
172 liste=self.creeListeCommande(filtre)
174 self.dicoCmd[tr(cmd)]=cmd
175 rbcmd=(QRadioButton(tr(cmd)))
176 self.buttonGroup.addButton(rbcmd)
177 self.commandesLayout.addWidget(rbcmd)
178 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
179 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
180 elif self.affiche_groupe==1 :
181 listeGroupes,dictGroupes=self.jdc.get_groups()
182 for grp in listeGroupes:
183 if grp == "CACHE" : continue
185 text=QString.fromUtf8('<html><head/><body><p><span style=\" font-weight:600;\">Groupe : '+tr(grp)+'</span></p></body></html>')
187 self.listeWidget.append(label)
189 sensibleALaCasse=self.RBCasse.isChecked()
190 for cmd in dictGroupes[grp]:
191 if sensibleALaCasse and (filtre != None and not filtre in cmd) : continue
192 if (not sensibleALaCasse) and filtre != None and (not filtre in cmd) and (not filtre.upper() in cmd) : continue
194 self.commandesLayout.addWidget(label)
196 self.dicoCmd[tr(cmd)]=cmd
197 rbcmd=(QRadioButton(tr(cmd)))
198 self.buttonGroup.addButton(rbcmd)
199 self.commandesLayout.addWidget(rbcmd)
200 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
201 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
204 self.listeWidget.append(label2)
205 self.commandesLayout.addWidget(label2)
206 elif self.affiche_ordre==1 :
207 listeFiltre=self.creeListeCommande(filtre)
209 if self.editor.Ordre_Des_Commandes == None : Ordre_Des_Commandes=listeFiltre
210 else : Ordre_Des_Commandes=self.editor.Ordre_Des_Commandes
211 for cmd in Ordre_Des_Commandes :
212 if cmd in listeFiltre :
215 self.dicoCmd[tr(cmd)]=cmd
216 rbcmd=(QRadioButton(tr(cmd)))
217 self.buttonGroup.addButton(rbcmd)
218 self.commandesLayout.addWidget(rbcmd)
219 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
220 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
224 def clearFiltre(self):
225 self.LEFiltre.setText("")
226 self.ajouteRadioButtons()
228 def rbClique(self,id):
229 self.name=self.dicoCmd[str(id.text().toLatin1())]
230 definitionEtape=getattr(self.jdc.cata[0],self.name)
231 commentaire=getattr(definitionEtape,self.jdc.lang)
233 commentaire=getattr(definitionEtape,self.jdc.lang)
236 commentaire=getattr(definitionEtape,"ang")
239 self.editor.labelCommentaire.setText(commentaire)
244 #PNPN a priori pas d icone mais peut-etre a faire