1 # Copyright (C) 2007-2017 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 __future__ import absolute_import
24 from builtins import str
29 from desWidgetNiveauFact import Ui_WidgetNiveauFact
30 from InterfaceQT4.monWidgetOptionnel import MonWidgetOptionnel
31 from InterfaceQT4.groupe import Groupe
33 from PyQt5.QtWidgets import QWidget
34 from PyQt5.QtGui import QIcon
37 from Extensions.i18n import tr
44 class MonWidgetNiveauFact(Ui_WidgetNiveauFact,Groupe):
47 def __init__(self,node,editor,definition,obj):
48 self.listeAffichageWidget=[]
49 self.listeBoutonAChanger=[]
50 Groupe.__init__(self,node,editor,None,definition,obj,1,self)
51 from InterfaceQT4 import composimp
52 if isinstance(self.node ,composimp.Node):
53 widget=self.node.getPanelGroupe(self,self.maCommande)
54 self.listeBoutonAChanger.append(widget.RBValide)
55 self.afficheOptionnel()
57 self.labelDoc.setText(self.node.item.getFr())
58 self.labelNomCommande.setText(self.node.item.getLabelText()[0])
60 def reaffiche(self,nodeAVoir=None):
61 self.node.setDeplieChildren()
62 self.node.afficheCeNiveau()
63 self.editor.fenetreCentraleAffichee.labelDoc.setText(self.node.item.getFr())
64 self.editor.fenetreCentraleAffichee.labelNomCommande.setText(self.node.item.getLabelText()[0])
67 # necessaire pour handleOnItem de browser.py
71 def donnePremier(self):
72 #print "dans donnePremier"
73 QApplication.processEvents()
74 if self.listeAffichageWidget != [] :
75 self.listeAffichageWidget[0].setFocus(7)
76 QApplication.processEvents()
77 #print self.focusWidget()
80 def focusNextPrevChild(self, next):
81 # on s assure que ce n est pas un chgt de fenetre
82 #print "je passe dans focusNextPrevChild"
83 if self.editor.fenetreCentraleAffichee != self : return True
86 if f not in self.listeAffichageWidget :
88 while not hasattr (f,'AAfficher') :
89 if f==None :i=-1; break
91 if hasattr(f,'AAfficher') : f=f.AAfficher
92 if i != -1 : i=self.listeAffichageWidget.index(f)
93 else :i=self.listeAffichageWidget.index(f)
94 if (i==len(self.listeAffichageWidget) -1) and next and not self.inhibe:
96 self.listeAffichageWidget[1].setFocus(7)
99 w.focusPreviousChild()
104 if i==0 and next==False and not self.inhibe:
105 if hasattr(self.editor.fenetreCentraleAffichee,'scrollArea'):
106 self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(self.listeAffichageWidget[-1])
107 self.listeAffichageWidget[-2].setFocus(7)
114 if i==0 and next==True and not self.inhibe:
115 self.listeAffichageWidget[0].setFocus(7)
122 if i>0 and next==False and not self.inhibe:
123 if isinstance(self.listeAffichageWidget[i-1],QRadioButton):
124 self.listeAffichageWidget[i-1].setFocus(7)
126 return QWidget.focusNextPrevChild(self, next)
128 def etablitOrdre(self):
129 # si on boucle on perd l'ordre
131 while(i +1 < len(self.listeAffichageWidget)):
132 self.setTabOrder(self.listeAffichageWidget[i],self.listeAffichageWidget[i+1])
135 def afficheSuivant(self,f):
136 #print ('ds afficheSuivant')
138 i=self.listeAffichageWidget.index(f)
142 if (next==len(self.listeAffichageWidget) ): next =0
144 self.listeAffichageWidget[next].setFocus(7)
149 def afficheOptionnel(self):
150 # N a pas de parentQt. doit donc etre redefini
151 #print ('ds afficheOptionnel')
152 if self.editor.widgetOptionnel!= None :
153 self.monOptionnel=self.editor.widgetOptionnel
155 self.editor.inhibeSplitter=1
156 self.monOptionnel=MonWidgetOptionnel(self.editor)
157 self.editor.widgetOptionnel=self.monOptionnel
158 self.editor.splitter.addWidget(self.monOptionnel)
159 self.editor.ajoutOptionnel()
160 self.editor.inhibeSplitter=0
161 self.monOptionnel.vireTous()
164 liste,liste_rouge=self.ajouteMCOptionnelDesBlocs()
165 self.monOptionnel.parentCommande=self
166 self.monOptionnel.titre(self.obj.nom)
167 self.monGroupe=self.monOptionnel.afficheOptionnel(liste,liste_rouge,self)
170 Groupe.setValide(self)
171 for bouton in self.listeBoutonAChanger:
172 couleur=self.node.item.getIconName()
173 monIcone = QIcon(self.repIcon+"/" + couleur + ".png")
174 bouton.setIcon(monIcone)
176 class MonWidgetNiveauFactTableau(MonWidgetNiveauFact):
177 def __init__(self,node,editor,definition,obj):
178 MonWidgetNiveauFact.__init__(self,node,editor,definition,obj)