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 Groupe.__init__(self,node,editor,None,etape.definition,etape,1)
41 if (etape.get_type_produit()==None): self.LENom.close()
42 elif (hasattr (etape, 'sdnom')) and etape.sdnom != "sansnom" : self.LENom.setText(etape.sdnom)
43 else : self.LENom.setText("")
44 maPolice= QFont("Times", 10,)
45 self.setFont(maPolice)
46 self.repIcon=self.appliEficas.repIcon
47 self.labelNomCommande.setText(self.obj.nom)
48 self.commandesLayout.addStretch()
49 self.commandesLayout.focusInEvent=self.focusInEvent
50 self.scrollAreaCommandes.focusInEvent=self.focusInEvent
51 #self.RBValide.focusInEvent=FacultatifOuOptionnel.focusInEvent
52 self.connect(self.bCatalogue,SIGNAL("clicked()"), self.afficheCatalogue)
53 self.connect(self.LENom,SIGNAL("returnPressed()"),self.nomChange)
54 self.racine=self.node.tree.racine
55 if self.node.item.GetIconName() == "ast-red-square" : self.LENom.setDisabled(True)
57 self.setAcceptDrops(True)
58 from monWidgetOptionnel import MonWidgetOptionnel
59 if hasattr(self.editor,'widgetOptionnel') :
60 self.monOptionnel=self.editor.widgetOptionnel
62 self.monOptionnel=MonWidgetOptionnel(self)
63 self.editor.widgetOptionnel=self.monOptionnel
64 self.editor.splitter.addWidget(self.monOptionnel)
65 self.afficheOptionnel()
69 nom = str(self.LENom.text())
70 nom = string.strip(nom)
71 if nom == '' : return # si pas de nom, on ressort sans rien faire
72 test,mess = self.node.item.nomme_sd(nom)
73 self.editor.affiche_infos(mess)
75 #Notation scientifique
77 from politiquesValidation import Validation
78 validation=Validation(self.node,self.editor)
79 validation.AjoutDsDictReelEtape()
81 def afficheOptionnel(self):
82 # N a pas de parentQt. doit donc etre redefini
83 liste=self.ajouteMCOptionnelDesBlocs()
84 self.monOptionnel.parentMC=self
85 self.monOptionnel.affiche(liste)
87 def focusInEvent(self,event):
88 #print "je mets a jour dans focusInEvent de monWidget Commande "
89 self.afficheOptionnel()
92 def reaffiche(self,nodeAVoir=None):
93 self.node.affichePanneau()
97 self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(f)
99 def afficheCatalogue(self):
100 self.monOptionnel.hide()
101 self.racine.affichePanneau()
102 if self.node : self.node.select()
103 else : self.racine.select()
106 if not(hasattr (self,'RBValide')) : return
109 if self.node.item.object.isvalid() :
110 icon=QIcon(self.repIcon+"/ast-green-ball.png")
112 icon=QIcon(self.repIcon+"/ast-red-ball.png")
113 if self.node.item.GetIconName() == "ast-yellow-square" :
114 icon=QIcon(self.repIcon+"/ast-yel-ball.png")
115 self.RBValide.setIcon(icon)