Salome HOME
f4dc44c58c35237eed15c9f37163037eb0539b10
[tools/eficas.git] / InterfaceQT4 / monWidgetCommande.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 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
28 import Accas 
29 import os
30 import string
31
32     
33 # Import des panels
34
35 class MonWidgetCommande(Ui_WidgetCommande,Groupe):
36   """
37   """
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)
56
57       self.setAcceptDrops(True)
58       from monWidgetOptionnel import MonWidgetOptionnel
59       if hasattr(self.editor,'widgetOptionnel') : 
60         self.monOptionnel=self.editor.widgetOptionnel
61       else :
62         self.monOptionnel=MonWidgetOptionnel(self)
63         self.editor.widgetOptionnel=self.monOptionnel
64         self.editor.splitter.addWidget(self.monOptionnel)
65       self.afficheOptionnel()
66
67
68   def nomChange(self):
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)
74
75       #Notation scientifique
76       if test :
77         from politiquesValidation import Validation
78         validation=Validation(self.node,self.editor)
79         validation.AjoutDsDictReelEtape()
80
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)
86
87   def focusInEvent(self,event):
88       #print "je mets a jour dans focusInEvent de monWidget Commande "
89       self.afficheOptionnel()
90
91
92   def reaffiche(self,nodeAVoir=None):
93       self.node.affichePanneau()
94       if nodeAVoir != None:
95         f=nodeAVoir.fenetre
96         qApp.processEvents()
97         self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(f)
98
99   def afficheCatalogue(self):
100       self.monOptionnel.hide()
101       self.racine.affichePanneau()
102       if self.node : self.node.select()
103       else : self.racine.select()
104
105   def setValide(self):
106       if not(hasattr (self,'RBValide')) : return
107       icon = QIcon()
108       print self.repIcon
109       if self.node.item.object.isvalid() :
110          icon=QIcon(self.repIcon+"/ast-green-ball.png")
111       else :
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)