]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/monChoixCommande.py
Salome HOME
affichage selon l ordre du catalogue
[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
59       self.editor.labelCommentaire.setText("")
60       self.name=None
61       self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton)
62
63       self.affiche_alpha=0
64       self.affiche_groupe=0
65       self.affiche_ordre=0
66       if self.editor.affiche=="alpha"  : 
67          self.affiche_alpha==1;  
68          self.RBalpha.setChecked(True);
69          self.afficheAlpha()
70       elif self.editor.affiche=="groupe" : 
71          self.affiche_groupe==1; 
72          self.RBGroupe.setChecked(True); 
73          self.afficheGroupe()
74       elif self.editor.affiche=="ordre"  : 
75          self.affiche_ordre==1;  
76          self.RBOrdre.setChecked(True);  
77          self.afficheOrdre()
78
79   def afficheAlpha(self):
80       self.affiche_alpha=1
81       self.affiche_groupe=0
82       self.affiche_ordre=0
83       self.AjouteRadioButton()
84
85   def afficheGroupe(self):
86       self.affiche_alpha=0
87       self.affiche_groupe=1
88       self.affiche_ordre=0
89       self.AjouteRadioButton()
90
91   def afficheOrdre(self):
92       self.affiche_alpha=0
93       self.affiche_groupe=0
94       self.affiche_ordre=1
95       self.AjouteRadioButton()
96
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)
104       nouveau.setDeplie()
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()
112       else :
113            print "je passe la"
114            self.node.setSelected(False)
115            nouveau.setSelected(True)
116            self.node.tree.setCurrentItem(nouveau)
117       event.accept()
118       
119
120   def CreeListeCommande(self,filtre):
121       listeGroupes,dictGroupes=self.jdc.get_groups()
122       if "CACHE" in dictGroupes.keys():
123          aExclure=dictGroupes["CACHE"]
124       else:
125          aExclure=()
126       listeACreer=[]
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)
131       return listeACreer
132
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)
139              b.close()
140       else :
141          self.buttonGroup = QButtonGroup()
142       for w in self.listeWidget :
143          w.close()
144       self.listeWidget=[]
145       if self.affiche_alpha==1 :
146          liste=self.CreeListeCommande(filtre)
147          for cmd in liste :
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
157            label=QLabel(self)
158            text=QString.fromUtf8('<html><head/><body><p><span style=\" font-weight:600;\">Groupe : '+tr(grp)+'</span></p></body></html>')
159            label.setText(text)
160            self.listeWidget.append(label)
161            aAjouter=1
162            for cmd in  dictGroupes[grp]:
163               if filtre != None and not filtre in cmd : continue
164               if aAjouter == 1 :
165                  self.commandesLayout.addWidget(label)
166                  aAjouter=0
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)
172            label2=QLabel(self)
173            label2.setText(" ")
174            self.listeWidget.append(label2)
175            self.commandesLayout.addWidget(label2)
176       elif  self.affiche_ordre==1 :
177          listeFiltre=self.CreeListeCommande(filtre)
178          liste=[]
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 :
183                  liste.append(cmd)
184          for cmd in liste :
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) 
190
191      
192   def LEfiltreReturnPressed(self):
193       self.AjouteRadioButton(filtre)
194
195
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)
200       try :
201         commentaire=getattr(definitionEtape,self.jdc.lang)
202       except :
203         try :
204            commentaire=getattr(definitionEtape,"ang")
205         except :
206            commentaire=""
207       self.editor.labelCommentaire.setText(commentaire)
208
209
210
211   def setValide(self):
212       #PNPN a priori pas d icone mais peut-etre a faire
213       pass