1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 import string,types,os
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
29 from gereIcones import ContientIcones
30 from gereIcones import FacultatifOuOptionnel
31 from qtSaisie import SaisieValeur
33 # ---------------------------------------------------------------------- #
34 class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
35 # --------------------------------------------------------------------- #
38 def __init__(self,node,monSimpDef,nom,objSimp,parentQt):
39 #print "Feuille", monSimpDef,nom,objSimp
40 QWidget.__init__(self,None)
42 self.node.fenetre=self
46 maPolice= QFont("Times", 10)
47 self.setFont(maPolice)
49 self.parentQt=parentQt
50 self.editor=self.node.editor
51 self.appliEficas=self.editor.appliEficas
52 self.repIcon=self.appliEficas.repIcon
53 self.monSimpDef=monSimpDef
56 self.node.fenetre=self
58 self.aRedimensionner=0
71 if len(self.objSimp.nom) >= 17 :
72 nom=self.objSimp.nom[0:15]+'...'
73 self.label.setText(nom)
74 self.debutToolTip=self.objSimp.nom+"\n"
76 self.label.setText(self.objSimp.nom)
80 # print "passe dans setValeurs pour ", self.objSimp.nom
81 # print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
84 def finCommentaire(self):
87 def setSuggestion(self):
88 if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "":
89 suggere=str('<html><head/><body><p><span style=" font-size:8pt;">suggestion : ')+str(self.monSimpDef.get_sug())+"</span></p></body></html>"
90 if hasattr(self,'lineEditVal'): self.lineEditVal.setToolTip(suggere)
92 def setCommentaire(self):
93 #print "dans setCommentaire"
96 if self.objSimp.get_fr() != None and self.objSimp.get_fr() != "":
97 c2 = '<html><head/><body><p><span style=" font-size:8pt;">'+c+str(self.objSimp.get_fr())+"</span></p></body></html>"
98 self.label.setToolTip(c2)
100 c+=self.finCommentaire()
101 if c != "" and c != None :
102 c=str('<html><head/><body><p><span style=" font-size:8pt; ">')+c+"</span></p></body></html>"
103 self.label.setToolTip(c)
107 mctype = self.monSimpDef.type[0]
109 if ( hasattr(self,"BFichier")):
110 if mctype == "Repertoire":
111 self.BRepertoire=self.BFichier
112 #icon = QIcon(self.repIcon+"/fichier.png")
113 #self.BRepertoire.setIcon(icon)
114 self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed)
115 #self.BVisuFichier.close()
117 #icon = QIcon(self.repIcon+"/visuFichier.png")
118 #self.BVisuFichier.setIcon(icon)
119 self.connect(self.BFichier,SIGNAL("clicked()"),self.BFichierPressed)
120 self.connect(self.BVisuFichier,SIGNAL("clicked()"),self.BFichierVisu)
123 if ( hasattr(self,"BSalome")):
124 enable_salome_selection = self.editor.salome and \
125 (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or ('SalomeEntry' in repr(mctype)) or
126 (hasattr(mctype, "enable_salome_selection") and mctype.enable_salome_selection))
127 if enable_salome_selection:
128 self.connect(self.BSalome,SIGNAL("pressed()"),self.BSalomePressed)
129 #icon = QIcon(self.repIcon+"/flecheSalome.png")
130 #self.BSalome.setIcon(icon)
132 if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome):
135 #icon = QIcon(self.repIcon+"/salomeLoupe.png")
136 #self.BView2D.setIcon(icon)
137 self.connect(self.BView2D,SIGNAL("clicked()"),self.BView2DPressed)
143 def showEvent(self, event):
144 if self.prendLeFocus==1 :
145 self.activateWindow()
146 "il faut deriver le showEvent pour" , self.nom
148 QWidget.showEvent(self,event)
150 def aideALaSaisie(self):
152 mc = self.node.item.get_definition()
154 d_aide = { 'TXM' : tr(u"chaine de caracteres"),
157 'C' : tr("complexe"),
158 'Matrice' : tr(u'Matrice'),
159 'Fichier' : tr(u'fichier'),
160 'FichierNoAbs' : tr(u'fichier existant'),
161 'Repertoire' : tr(u'repertoire')}
162 if mc.min == mc.max: commentaire=tr("Entrez ")+str(mc.min)
163 else : commentaire=tr("Entrez entre ")+str(mc.min)+tr(" et ")+str(mc.max)
165 if type(mctype) == types.ClassType: ctype = getattr(mctype, 'help_message', tr("Type de base inconnu"))
166 else: ctype = d_aides.get(mctype, tr("Type de base inconnu"))
167 if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype): ctype=str(mctype)
170 if self.max!=1 : commentaire+="s"
176 def setZoneInfo(self):
177 # info=str(self.nom)+' '
178 # if self.monSimpDef.get_fr() != None and self.monSimpDef.get_fr() != "": info+=self.monSimpDef.get_sug() +" "
179 # if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "": info+="Valeur suggérée : "self.monSimpDef.get_sug()
181 #self.editor.affiche_infos(info)