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 desWidgetCommande import Ui_WidgetCommande
23 from groupe import Groupe
24 from gereIcones import FacultatifOuOptionnel
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
35 class MonWidgetCommande(Ui_WidgetCommande,Groupe):
38 def __init__(self,node,editor,etape):
39 #print "MonWidgetCommande ", self
40 self.listeAffichageWidget=[]
42 Groupe.__init__(self,node,editor,None,etape.definition,etape,1,self)
43 if (etape.get_type_produit()==None): self.LENom.close()
44 elif (hasattr (etape, 'sdnom')) and etape.sdnom != "sansnom" : self.LENom.setText(etape.sdnom)
45 else : self.LENom.setText("")
46 maPolice= QFont("Times", 10,)
47 self.setFont(maPolice)
48 self.repIcon=self.appliEficas.repIcon
49 self.labelNomCommande.setText(tr(self.obj.nom))
50 self.commandesLayout.addStretch()
51 self.commandesLayout.focusInEvent=self.focusInEvent
52 self.scrollAreaCommandes.focusInEvent=self.focusInEvent
53 #self.RBValide.focusInEvent=FacultatifOuOptionnel.focusInEvent
54 if self.editor.code in ['MAP','Adao','CARMELCND'] : self.bCatalogue.close()
55 else : self.connect(self.bCatalogue,SIGNAL("clicked()"), self.afficheCatalogue)
56 self.connect(self.LENom,SIGNAL("returnPressed()"),self.nomChange)
57 self.racine=self.node.tree.racine
58 if self.node.item.GetIconName() == "ast-red-square" : self.LENom.setDisabled(True)
60 self.setAcceptDrops(True)
63 if self.editor.code == "CARMELCND" : return #Pas de MC Optionnels pour Carmel
64 from monWidgetOptionnel import MonWidgetOptionnel
65 if hasattr(self.editor,'widgetOptionnel') :
66 self.monOptionnel=self.editor.widgetOptionnel
68 self.monOptionnel=MonWidgetOptionnel(self)
69 self.editor.widgetOptionnel=self.monOptionnel
70 self.editor.splitter.addWidget(self.monOptionnel)
71 self.afficheOptionnel()
74 def focusNextPrevChild(self, next):
75 print "je passe dans focusNextPrevChild"
76 print self.focusWidget().objectName()
78 i= self.listeAffichageWidget.index(self.focusWidget())
81 if (i==len(self.listeAffichageWidget) -1) and next and not self.inhibe:
82 self.listeAffichageWidget[1].setFocus(7)
85 w.focusPreviousChild()
88 if i==0 and next==False and not self.inhibe:
89 if hasattr(self.editor.fenetreCentraleAffichee,'scrollArea'):
90 self.editor.fenetreCentraleAffichee.scrollArea.ensureWidgetVisible(self.listeAffichageWidget[-1])
91 self.listeAffichageWidget[-2].setFocus(7)
97 return QWidget.focusNextPrevChild(self, next)
99 def etablitOrdre(self):
101 for l in self.listeAffichageWidget:
103 while(i +1 < len(self.listeAffichageWidget)):
104 self.setTabOrder(self.listeAffichageWidget[i],self.listeAffichageWidget[i+1])
106 # si on boucle on perd l'ordre
109 nom = str(self.LENom.text())
110 nom = string.strip(nom)
111 if nom == '' : return # si pas de nom, on ressort sans rien faire
112 test,mess = self.node.item.nomme_sd(nom)
113 self.editor.affiche_infos(mess)
115 #Notation scientifique
117 from politiquesValidation import Validation
118 validation=Validation(self.node,self.editor)
119 validation.AjoutDsDictReelEtape()
121 def afficheOptionnel(self):
122 # N a pas de parentQt. doit donc etre redefini
123 liste=self.ajouteMCOptionnelDesBlocs()
124 self.monOptionnel.parentMC=self
125 self.monOptionnel.affiche(liste)
127 def focusInEvent(self,event):
128 #print "je mets a jour dans focusInEvent de monWidget Commande "
129 if self.editor.code == "CARMELCND" : return #Pas de MC Optionnels pour Carmel
130 self.afficheOptionnel()
133 def reaffiche(self,nodeAVoir=None):
134 self.node.affichePanneau()
135 if nodeAVoir != None:
138 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(f)
140 def afficheCatalogue(self):
141 if self.editor.code != "CARMELCND" : self.monOptionnel.hide()
142 self.racine.affichePanneau()
143 if self.node : self.node.select()
144 else : self.racine.select()
147 if not(hasattr (self,'RBValide')) : return
149 if self.node.item.object.isvalid() :
150 icon=QIcon(self.repIcon+"/ast-green-ball.png")
152 icon=QIcon(self.repIcon+"/ast-red-ball.png")
153 if self.node.item.GetIconName() == "ast-yellow-square" :
154 icon=QIcon(self.repIcon+"/ast-yel-ball.png")
155 self.RBValide.setIcon(icon)