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 if self.editor.widgetTree != None:
46 self.connect(self.bFormulaire,SIGNAL("clicked()"),self.bFormulaireReturnPressed)
48 self.bFormulaire.close()
49 debutTitre=self.editor.titre
51 if self.editor.fichier != None :
52 nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier))
54 nouveauTitre=debutTitre
55 self.editor.appliEficas.setWindowTitle(nouveauTitre)
56 self.connect(self.RBalpha,SIGNAL("clicked()"),self.afficheAlpha)
57 self.connect(self.RBGroupe,SIGNAL("clicked()"),self.afficheGroupe)
58 self.editor.labelCommentaire.setText("")
59 self.affiche_alpha=self.editor.affiche_alpha
61 self.AjouteRadioButton()
62 self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton)
63 if self.editor.affiche_alpha==0 : self.afficheGroupe()
65 def afficheAlpha(self):
67 self.editor.affiche_alpha=1
68 self.AjouteRadioButton()
70 def afficheGroupe(self):
72 self.editor.affiche_alpha=0
73 self.AjouteRadioButton()
75 def bFormulaireReturnPressed(self):
76 print "PNPNPNPN a Programmer"
77 self.connect(self.bFormulaire,SIGNAL("clicked()"),self.bFormulaireReturnPressed)
79 def mouseDoubleClickEvent(self,event):
80 nodeCourrant=self.node.tree.currentItem()
81 if nodeCourrant==None: nodeCourrant=self.node.tree.racine
82 if self.name != None :
83 plier=self.editor.afficheCommandesPliees
84 if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier)
85 else : nouveau=nodeCourrant.append_brother(self.name,plier=plier)
87 #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche()
88 if self.editor.afficheApresInsert == True :
89 #if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche()
90 if self.editor.afficheCommandesPliees ==True: nouveau.plieToutEtReaffiche()
91 else : nouveau.deplieToutEtReaffiche()
92 nouveau.fenetre.donnePremier()
93 #nouveau.deplieToutEtReaffiche()
97 def CreeListeCommande(self,filtre):
98 listeGroupes,dictGroupes=self.jdc.get_groups()
99 if "CACHE" in dictGroupes.keys():
100 aExclure=dictGroupes["CACHE"]
104 for l in self.jdc.get_liste_cmd():
105 if l not in aExclure :
106 if filtre != None and not filtre in l : continue
107 listeACreer.append(l)
110 def AjouteRadioButton(self):
111 filtre=str(self.LEFiltre.text())
112 if filtre==str("") : filtre=None
113 if hasattr(self,'buttonGroup') :
114 for b in self.buttonGroup.buttons():
115 self.buttonGroup.removeButton(b)
118 self.buttonGroup = QButtonGroup()
119 for w in self.listeWidget :
122 if self.affiche_alpha==1 :
123 liste=self.CreeListeCommande(filtre)
125 rbcmd=(QRadioButton(tr(cmd)))
126 self.buttonGroup.addButton(rbcmd)
127 self.commandesLayout.addWidget(rbcmd)
128 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
129 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
131 listeGroupes,dictGroupes=self.jdc.get_groups()
132 for grp in listeGroupes:
133 if grp == "CACHE" : continue
135 text=QString.fromUtf8('<html><head/><body><p><span style=\" font-weight:600;\">Groupe : '+tr(grp)+'</span></p></body></html>')
137 self.listeWidget.append(label)
139 for cmd in dictGroupes[grp]:
140 if filtre != None and not filtre in cmd : continue
142 self.commandesLayout.addWidget(label)
144 rbcmd=(QRadioButton(tr(cmd)))
145 self.buttonGroup.addButton(rbcmd)
146 self.commandesLayout.addWidget(rbcmd)
147 rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent
148 self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique)
151 self.listeWidget.append(label2)
152 self.commandesLayout.addWidget(label2)
155 def LEfiltreReturnPressed(self):
156 self.AjouteRadioButton(filtre)
159 def rbClique(self,id):
160 self.name=str(id.text().toLatin1())
161 definitionEtape=getattr(self.jdc.cata[0],self.name)
162 commentaire=getattr(definitionEtape,self.jdc.lang)
164 commentaire=getattr(definitionEtape,self.jdc.lang)
167 commentaire=getattr(definitionEtape,"ang")
170 self.editor.labelCommentaire.setText(commentaire)
175 #PNPN a priori pas d icone mais peut-etre a faire