Salome HOME
premiere version
[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
31     
32 # Import des panels
33
34 class MonWidgetCommande(Ui_WidgetCommande,Groupe):
35   """
36   """
37   def __init__(self,node,editor,etape):
38       print "MonWidgetCommande ", self
39       Groupe.__init__(self,node,editor,None,etape.definition,etape,1)
40       if (etape.get_type_produit()==None): self.LENom.close()
41       elif (hasattr (etape, 'sdnom')) : self.LENom.setText(etape.sdnom) 
42       maPolice= QFont("Times", 10,)
43       self.setFont(maPolice)
44       self.repIcon=self.appliEficas.repIcon
45       self.labelNomCommande.setText(self.obj.nom)
46       self.commandesLayout.addStretch()
47       self.commandesLayout.focusInEvent=self.focusInEvent
48       self.scrollAreaCommandes.focusInEvent=self.focusInEvent
49       #self.RBValide.focusInEvent=FacultatifOuOptionnel.focusInEvent
50       self.connect(self.bCatalogue,SIGNAL("clicked()"), self.afficheCatalogue)
51       self.racine=self.node.tree.racine
52        
53
54       self.setAcceptDrops(True)
55       from monWidgetOptionnel import MonWidgetOptionnel
56       if hasattr(self.editor,'widgetOptionnel') : 
57         self.monOptionnel=self.editor.widgetOptionnel
58       else :
59         self.monOptionnel=MonWidgetOptionnel(self)
60         self.editor.widgetOptionnel=self.monOptionnel
61         self.editor.splitter.addWidget(self.monOptionnel)
62       self.afficheOptionnel()
63
64
65   def afficheOptionnel(self):
66       # N a pas de parentQt. doit donc etre redefini
67       liste=self.ajouteMCOptionnelDesBlocs()
68       self.monOptionnel.parentMC=self
69       self.monOptionnel.affiche(liste)
70
71   def focusInEvent(self,event):
72       #print "je mets a jour dans focusInEvent de monWidget Commande "
73       self.afficheOptionnel()
74
75
76   def reaffiche(self,nodeAVoir=None):
77       self.node.affichePanneau()
78       if nodeAVoir != None:
79         f=nodeAVoir.fenetre
80         qApp.processEvents()
81         self.editor.fenetreCentraleAffichee.scrollAreaCommandes.ensureWidgetVisible(f)
82
83   def afficheCatalogue(self):
84       self.monOptionnel.hide()
85       self.racine.affichePanneau()
86       if self.node : self.node.select()
87       else : self.racine.select()
88