Salome HOME
numero de version
[tools/eficas.git] / InterfaceQT4 / browser.py
index 3ef56b2c51a02e616ce80a8a942cbf177a97ee3b..400b3ec98c5034c5c23d25eac9678154b7729f40 100644 (file)
@@ -28,6 +28,7 @@ from determine import monEnvQT5
 if monEnvQT5 :
   from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem
   from PyQt5.QtGui import QIcon
+  from PyQt5.QtCore  import Qt
 else :
   from PyQt4.QtGui  import *
   from PyQt4.QtCore  import *
@@ -144,7 +145,7 @@ class JDCTree( QTreeWidget,GereRegles ):
 
 
     def handleOnItem(self,item,int):
-        print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
+        #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
         
         from InterfaceQT4 import composimp
         self.inhibeExpand == True 
@@ -159,8 +160,8 @@ class JDCTree( QTreeWidget,GereRegles ):
               
             estUneFeuille=(isinstance(item,composimp.Node))
              # il faut afficher le parent
-            print "estUneFeuille", estUneFeuille
-            print "afficheCommandesPliees", self.editor.afficheCommandesPliees
+            #print "estUneFeuille", estUneFeuille
+            #print "afficheCommandesPliees", self.editor.afficheCommandesPliees
             if estUneFeuille                        : itemParent.affichePanneau()
             elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
             else                                    : itemParent.affichePanneau()
@@ -171,7 +172,7 @@ class JDCTree( QTreeWidget,GereRegles ):
              #self.tree.handleExpandedItem(item)
              #item.fenetre.donnePremier()
              #item.fenetre.rendActif()
-             print 'il faut afficher le 1er'
+             #print 'il faut afficher le 1er'
         try :
            fr = item.item.get_fr()
            if self.editor: self.editor.affiche_commentaire(unicode(fr))
@@ -225,10 +226,13 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         if self.treeParent.plie==True :
             self.plie        = True
             self.appartientAUnNoeudPlie=True
+            if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie =  self.treeParent.appartientAUnNoeudPlie
         else :
             self.plie        = False
             self.appartientAUnNoeudPlie = False
 
+        #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
+
         if ancien and itemExpand     : self.plie = False
         if ancien and not itemExpand : self.plie = True 
         if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
@@ -242,7 +246,10 @@ class JDCNode(QTreeWidgetItem,GereRegles):
               self.treeParent.childrenComplete.append(self)
               self.treeParent=self.treeParent.vraiParent
         self.treeParent.childrenComplete.append(self)
-        if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) : 
+
+
+        if (isinstance(self,compobloc.Node) or (isinstance(self,compomclist.Node) and self.item.isMCList()) or ( hasattr(self.item.parent,'inhibeValidator') and isinstance(self,compomclist.Node) and self.item.parent.inhibeValidator)) : 
+        # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
            QTreeWidgetItem.__init__(self,None,mesColonnes)
         else :
            QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
@@ -291,7 +298,6 @@ class JDCNode(QTreeWidgetItem,GereRegles):
             else : self.listeItemExpanded.append(enfant.item)
 
         for enfant in self.childrenComplete :
-            p=enfant.vraiParent
             parent=enfant.treeParent
             parent.removeChild(enfant)
             enfant.JESUISOFF=1
@@ -310,7 +316,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
             nouvelItem=item.itemNode(self,item,itemExpand,ancien)
             self.children.append(nouvelItem)
 
-        #print "fin *********** build_children ",self,self.item, self.item.nom
+        #print "fin *********** build_children ",self,self.item, self.item.nom, self.children
 
         
     def chercheNoeudCorrespondant(self,objSimp):
@@ -321,7 +327,6 @@ class JDCNode(QTreeWidgetItem,GereRegles):
 
 
     def affichePanneau(self) :
-        #print " affichePanneau " , self.item.nom 
         #if self.item.isactif(): 
         #if self.editor.code == 'ASTER' and not(self.item.isactif()) : 
         # posera des pb si un code decide d appeler FIN un mot clef
@@ -348,9 +353,9 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         if self.editor.fenetreCentraleAffichee != None : 
             #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
             self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
-
             self.editor.fenetreCentraleAffichee.setParent(None)
             self.editor.fenetreCentraleAffichee.close()
+            self.editor.fenetreCentraleAffichee.deleteLater()
 
         self.editor.widgetCentraleLayout.addWidget(self.fenetre)
         #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
@@ -431,7 +436,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         Rend le noeud courant (self) selectionne et deselectionne
         tous les autres
         """        
-        print "select pour", self.item.nom
+        #print "select pour", self.item.nom
         for item in self.tree.selectedItems() :
             item.setSelected(0)
         self.tree.setCurrentItem( self )    
@@ -520,7 +525,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
            if not verifiePosition : return 0
 
         self.tree.inhibeExpand=True
-        obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
+        obj=self.item.additem(name,index) # emet le signal 'add'
         if obj is None:obj=0
         if obj == 0:return 0
         try :
@@ -613,7 +618,14 @@ class JDCNode(QTreeWidgetItem,GereRegles):
     def onValid(self):        
 
         #print "onValid pour ", self.item.nom
-        if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
+        if self.JESUISOFF==1 : return
+        if hasattr(self,'fenetre') and self.fenetre: 
+           try :
+             self.fenetre.setValide()
+           except :
+            # print "onValid pour ", self.item.nom, self,'pb'
+            pass
+
         if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
            self.item.jdc.recalcule_etat_correlation()
         if hasattr(self.item,'forceRecalcul'):
@@ -642,7 +654,6 @@ class JDCNode(QTreeWidgetItem,GereRegles):
          
 
 
-
     def update_node_valid(self):
         """Cette methode remet a jour la validite du noeud (icone)
            Elle appelle isvalid
@@ -836,6 +847,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
                niveauPere=niveauPere.treeParent
             for c in self.children :
                 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
+                #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie
                 c.setExpanded(False)
 
         # on affiche un niveau de plus