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)
39 #self.labelIcone.setText('<img src="/local00/home/A96028/Install_EficasV1/KarineEficas/InterfaceQT4/loopOff.png">');
44 self.jdc = self.item.object.get_jdc_root()
45 debutTitre=self.editor.titre
47 if self.editor.fichier != None :
48 nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier))
50 nouveauTitre=debutTitre
51 self.editor.appliEficas.setWindowTitle(nouveauTitre)
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)
59 self.editor.labelCommentaire.setText("")
61 self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton)
66 if self.editor.affiche=="alpha" :
67 self.affiche_alpha==1;
68 self.RBalpha.setChecked(True);
70 elif self.editor.affiche=="groupe" :
71 self.affiche_groupe==1;
72 self.RBGroupe.setChecked(True);
74 elif self.editor.affiche=="ordre" :
75 self.affiche_ordre==1;
76 self.RBOrdre.setChecked(True);
79 def afficheAlpha(self):
83 self.AjouteRadioButton()
85 def afficheGroupe(self):
89 self.AjouteRadioButton()
91 def afficheOrdre(self):
95 self.AjouteRadioButton()
97 def mouseDoubleClickEvent(self,event):
98 nodeCourrant=self.node.tree.currentItem()
99 if nodeCourrant==None: nodeCourrant=self.node.tree.racine
100 if self.name != None :
101 plier=self.editor.afficheCommandesPliees
102 if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier)
103 else : nouveau=nodeCourrant.append_brother(self.name,plier=plier)
105 #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
106 if self.editor.afficheApresInsert == True :
107 #if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche()
108 if self.editor.afficheCommandesPliees ==True: nouveau.plieToutEtReaffiche()
109 else : nouveau.deplieToutEtReaffiche()
110 nouveau.fenetre.donnePremier()
111 #nouveau.deplieToutEtReaffiche()
114 self.node.setSelected(False)
115 nouveau.setSelected(True)
116 self.node.tree.setCurrentItem(nouveau)
120 def CreeListeCommande(self,filtre):
121 listeGroupes,dictGroupes=self.jdc.get_groups()
122 if "CACHE" in dictGroupes.keys():
123 aExclure=dictGroupes["CACHE"]
127 for l in self.jdc.get_liste_cmd():
128 if l not in aExclure :
129 if filtre != None and not filtre in l : continue
130 listeACreer.append(l)
133 def AjouteRadioButton(self):
134 filtre=str(self.LEFiltre.text())
135 if filtre==str("") : filtre=None
136 if hasattr(self,'buttonGroup') :
137 for b in self.buttonGroup.buttons():
138 self.buttonGroup.removeButton(b)
141 self.buttonGroup = QButtonGroup()
142 for w in self.listeWidget :
145 if self.affiche_alpha==1 :
146 liste=self.CreeListeCommande(filtre)
148 rbcmd=(QRadioButton(tr(cmd)))
149 self.buttonGroup.addButton(rbcmd)
150 self.commandesLayout.addWidget(rbcmd)
151 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
152 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
153 elif self.affiche_groupe==1 :
154 listeGroupes,dictGroupes=self.jdc.get_groups()
155 for grp in listeGroupes:
156 if grp == "CACHE" : continue
158 text=QString.fromUtf8('<html><head/><body><p><span style=\" font-weight:600;\">Groupe : '+tr(grp)+'</span></p></body></html>')
160 self.listeWidget.append(label)
162 for cmd in dictGroupes[grp]:
163 if filtre != None and not filtre in cmd : continue
165 self.commandesLayout.addWidget(label)
167 rbcmd=(QRadioButton(tr(cmd)))
168 self.buttonGroup.addButton(rbcmd)
169 self.commandesLayout.addWidget(rbcmd)
170 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
171 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
174 self.listeWidget.append(label2)
175 self.commandesLayout.addWidget(label2)
176 elif self.affiche_ordre==1 :
177 listeFiltre=self.CreeListeCommande(filtre)
179 if self.editor.Ordre_Des_Commandes == None : Ordre_Des_Commandes=listeFiltre
180 else : Ordre_Des_Commandes=self.editor.Ordre_Des_Commandes
181 for cmd in Ordre_Des_Commandes :
182 if cmd in listeFiltre :
185 rbcmd=(QRadioButton(tr(cmd)))
186 self.buttonGroup.addButton(rbcmd)
187 self.commandesLayout.addWidget(rbcmd)
188 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
189 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
192 def LEfiltreReturnPressed(self):
193 self.AjouteRadioButton(filtre)
196 def rbClique(self,id):
197 self.name=str(id.text().toLatin1())
198 definitionEtape=getattr(self.jdc.cata[0],self.name)
199 commentaire=getattr(definitionEtape,self.jdc.lang)
201 commentaire=getattr(definitionEtape,self.jdc.lang)
204 commentaire=getattr(definitionEtape,"ang")
207 self.editor.labelCommentaire.setText(commentaire)
212 #PNPN a priori pas d icone mais peut-etre a faire