Salome HOME
linux/windows
[tools/eficas.git] / InterfaceQT4 / feuille.py
index 8f90b305adbdecc3f788c31ca4ed42897265ccb9..8eef0582d88dd587380924139c5193ae3c057b91 100644 (file)
@@ -30,7 +30,7 @@ from gereIcones import ContientIcones
 from gereIcones import FacultatifOuOptionnel
 from qtSaisie    import SaisieValeur
 
-nomMax=26
+nomMax=250
 # ---------------------------------------------------------------------- #
 class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
 # --------------------------------------------------------------------- #
@@ -63,8 +63,9 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
        self.setValeurs()
        self.setNom()
        self.setValide()
-       self.setPoubelle()
-       self.setIcones()
+       self.setIconePoubelle()
+       self.setIconesFichier()
+       self.setIconesSalome()
        self.setCommentaire()
        self.setZoneInfo()
           
@@ -72,13 +73,23 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
    def setNom(self):
        self.debutToolTip=""
        nomTraduit=tr(self.objSimp.nom)
-       if len(nomTraduit) >= nomMax :
-         nom=nomTraduit[0:nomMax]+'...'
-         self.label.setText(nomTraduit)
-         self.debutToolTip=nomTraduit+"\n"
+       #if len(nomTraduit) >= nomMax :
+       #  nom=nomTraduit[0:nomMax]+'...'
+       #  self.label.setText(nomTraduit)
+       #  self.debutToolTip=nomTraduit+"\n"
+       longueur=QFontMetrics(self.label.font()).width(nomTraduit)
+       if longueur >= nomMax :
+         nouveauNom=self.formate(nomTraduit)
+         self.label.setText(nouveauNom)
        else :   
          self.label.setText(nomTraduit)
 
+   def agrandit(self):
+       # inutile pour certains widgets
+       if self.height() < 40 :
+          self.setMinimumHeight(50)
+          self.resize(self.width(),200)
+
                                  
    def setValeurs(self):
       # print "passe dans setValeurs pour ", self.objSimp.nom
@@ -95,45 +106,20 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
 
    def setCommentaire(self):
       c  = self.debutToolTip
-      if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
+      #if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
+      self.aide=c
       if self.objSimp.get_fr() != None and self.objSimp.get_fr() != "":
           c2 = '<html><head/><body><p>'+c+str(self.objSimp.get_fr())+"</p></body></html>"
           self.label.setToolTip(c2)
+          self.aide=str(self.objSimp.get_fr())+" "+c
       else :
          c+=self.finCommentaire()
          if c != "" and c != None :
+            self.aide=c
             #c=str('<html><head/><body><p><span style=" font-size:8pt; ">')+c+"</span></p></body></html>"
             c=str('<html><head/><body><p>')+c+"</p></body></html>"
             self.label.setToolTip(c)
 
-   def setIcones(self):
-
-       mctype = self.monSimpDef.type[0]
-       # selon 
-       if ( hasattr(self,"BFichier")): 
-          if mctype == "Repertoire":
-             self.BRepertoire=self.BFichier
-             self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed)
-          else :
-            #icon = QIcon(self.repIcon+"/visuFichier.png")
-             self.connect(self.BFichier,SIGNAL("clicked()"),self.BFichierPressed)
-             self.connect(self.BVisuFichier,SIGNAL("clicked()"),self.BFichierVisu)
-          return
-
-       if ( hasattr(self,"BSalome")): 
-          enable_salome_selection = self.editor.salome and \
-              (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or ('SalomeEntry' in repr(mctype)) or
-               (hasattr(mctype, "enable_salome_selection") and mctype.enable_salome_selection))
-          if  enable_salome_selection:
-              self.connect(self.BSalome,SIGNAL("pressed()"),self.BSalomePressed)
-
-              if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome):
-                self.BView2D.close()
-              else :
-                self.connect(self.BView2D,SIGNAL("clicked()"),self.BView2DPressed)
-          else:
-              self.BSalome.close()
-              self.BView2D.close()
 
 
    def showEvent(self, event):
@@ -144,10 +130,9 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       QWidget.showEvent(self,event)
 
    def aideALaSaisie(self):
-      return
       mc = self.node.item.get_definition()
       mctype = mc.type[0]
-      d_aide = { 'TXM' : tr(u"chaine de caracteres"),
+      d_aides = { 'TXM' : tr(u"chaine de caracteres"),
                   'R'   : tr("reel"),
                   'I'   : tr("entier"),
                   'C'   : tr("complexe"),
@@ -155,7 +140,8 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
                   'Fichier' : tr(u'fichier'),
                   'FichierNoAbs' : tr(u'fichier existant'),
                   'Repertoire' : tr(u'repertoire')}
-      if mc.min == mc.max: commentaire=tr("Entrez ")+str(mc.min)
+
+      if mc.min == mc.max: commentaire=tr("Entrez ")+" "+str(mc.min)+" "
       else :               commentaire=tr("Entrez entre ")+str(mc.min)+tr(" et ")+str(mc.max)
 
       if type(mctype) == types.ClassType: ctype = getattr(mctype, 'help_message', tr("Type de base inconnu"))
@@ -163,7 +149,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype): ctype=str(mctype)
 
       commentaire+=ctype
-      if self.max!=1 : commentaire+="s" 
+      if mc.max!=1 : commentaire+="s" 
       return commentaire
 
    def setZoneInfo(self):
@@ -174,10 +160,11 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       #self.editor.affiche_infos(info)
 
    def reaffiche(self):
-      print "dans reaffiche de feuille", self.nom
+      #print "dans reaffiche de feuille", self.nom
       if self.editor.jdc.aReafficher==True :
-         print " j appelle le reaffiche de parentQt"
+         #print " j appelle le reaffiche de parentQt"
          self.parentQt.reaffiche()
+
          #PN PN PN pas satisfaisant
          #nodeAVoir=self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
          #print nodeAVoir.fenetre
@@ -185,4 +172,35 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
          #if nodeAVoir.fenetre.isVisible() : return
          #self.editor.fenetreCentraleAffichee.rendVisibleNoeud(nodeAVoir)
          #nodeAVoir.fenetre.setFocus()
-
+         # return  # on est bien postionne
+      if self.objSimp.isvalid() and hasattr(self, 'AAfficher'):
+         self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
+      else :
+         if hasattr(self, 'AAfficher'): self.AAfficher.setFocus(7)
+
+
+   def traiteClicSurLabel(self,texte):
+       #print self.aide 
+       aide=self.aide+"\n"+self.aideALaSaisie()
+       self.editor.affiche_infos(aide)
+
+   def formate(self,t):
+       if t.find('_')==0 :
+          newText=t[0:19]+'\n'+t[19:]
+       else:
+          listeNom=t.split('_')
+          newTexte=""
+          ligne=""
+          for n in listeNom:
+            if len(ligne)+len(n) < 25 : 
+               newTexte=newTexte+"_"+n
+               ligne+="_"+n
+            else :
+               newTexte=newTexte+"\n_"+n
+               ligne=""
+          #newTexte=t[0:t.rfind('_')]+'\n'+ t[t.rfind('_'):]
+          newText=newTexte[1:]
+       return newText
+      
+