Salome HOME
onItem=Deplie
[tools/eficas.git] / InterfaceQT4 / browser.py
index ef6657f8b923f87234805d55b810fe11124b195a..7761a6c373863c9713df5f8c11b2bcfa0a6a264c 100644 (file)
@@ -117,47 +117,47 @@ class JDCTree( QTreeWidget,GereRegles ):
         itemParent=item
         item.setPlie()
         item.plieToutEtReaffiche()
+        item.select()
 
     def handleExpandedItem(self,item):
-        #print "dans ExpandItem", self.inhibeExpand  
+        #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
         if self.inhibeExpand == True : return
-        #print "apres if"
         itemParent=item
         while not (hasattr (itemParent,'getPanel')) : 
            if itemParent.plie==True : itemParent.setDeplie()
            itemParent=itemParent.treeParent 
-        #print "apres if"
         if self.tree.node_selected != itemParent : 
              item.setExpanded(True)
-             #print "je suis la"
              return
         item.deplieToutEtReaffiche()
 
 
     def handleOnItem(self,item,int):
-        #if (len(self.selectedIndexes())!=2): return
-        #print "je passe dans handleOnItem pour ", item.item.nom, item, item.item
+        #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
         self.inhibeExpand == True 
         self.itemCourrant=item
         itemParent=item
-        #print self.itemCourrant
         while not (hasattr (itemParent,'getPanel')) : 
            if itemParent.plie==True : itemParent.setDeplie()
            itemParent=itemParent.treeParent 
-        #print itemParent.item.nom
-        #print itemParent.fenetre
-        #print self.editor.afficheCommandesPliees
         if itemParent.fenetre != self.editor.fenetreCentraleAffichee : 
-            if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche()
+             # il faut afficher le parent
+            if self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
             else :                                  itemParent.affichePanneau()
-        if itemParent!=item and item.fenetre != None: item.fenetre.rendVisible()
-        #try :
-        if 1:
+
+
+        from InterfaceQT4 import composimp
+        if (isinstance(item,composimp.Node)) : item.fenetre.rendVisible()
+        elif itemParent!=item:
+             #self.tree.handleExpandedItem(item)
+             #item.fenetre.donnePremier()
+             print 'il faut afficher le 1er'
+        try :
            fr = item.item.get_fr()
            if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
-        #except:
-        else :
+        except:
             pass
+        item.select()
         self.inhibeExpand == False 
         #print "je mets inhibeExpand a false handleOnItem"
 
@@ -186,6 +186,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
                         
         from InterfaceQT4 import compocomm
         from InterfaceQT4 import compoparam
+        from InterfaceQT4 import composimp
         if   (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
         elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
         else:   name  = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
@@ -202,9 +203,10 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         else :
             self.plie        = False
             self.appartientAUnNoeudPlie = False
+
         if ancien and itemExpand     : self.plie = False
         if ancien and not itemExpand : self.plie = True 
-
+        if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
 
         from InterfaceQT4 import compobloc
         from InterfaceQT4 import compomclist
@@ -253,9 +255,10 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         
         self.listeItemExpanded=[]
         self.listeItemPlie=[]
+
         for enfant in self.childrenComplete :
-            if enfant.isExpanded()      : self.listeItemExpanded.append(enfant.item)
-            if not(enfant.isExpanded()) : self.listeItemPlie.append(enfant.item)
+            if enfant.plie : self.listeItemPlie.append(enfant.item)
+            else : self.listeItemExpanded.append(enfant.item)
 
         for enfant in self.childrenComplete :
             p=enfant.vraiParent
@@ -300,18 +303,21 @@ class JDCNode(QTreeWidgetItem,GereRegles):
             from monInactifPanel import PanelInactif
             self.fenetre = PanelInactif(self,self.editor)
          
-        self.editor.widgetCentraleLayout.addWidget(self.fenetre)
+        for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
+            widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
+            self.editor.widgetCentraleLayout.removeItem(widget)
+        # ceinture et bretelle
+        #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
+        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.close()
 
-        self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee
+        self.editor.widgetCentraleLayout.addWidget(self.fenetre)
+        #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
         self.editor.fenetreCentraleAffichee=self.fenetre
         self.tree.node_selected= self
 
-        if self.editor.anciennefenetre != None : 
-           a=self.editor.anciennefenetre.close()
-
-        if self.editor.widgetTree !=None  : index=1
-        else : index=0
-
         if self.editor.first :
            self.editor.splitter.setSizes((400,1400,400))
            if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
@@ -319,7 +325,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         self.tree.expandItem(self)
         self.select()
         self.tree.inhibeExpand=False
-        #print "fin de affichePanneau"
+        #print "fin de affichePanneau", self.item.nom
         #print "______________________________"
           
 
@@ -389,9 +395,7 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         for item in self.tree.selectedItems() :
             item.setSelected(0)
         self.setSelected( True )    
-        #self.setExpanded( True )    
         self.tree.setCurrentItem( self )    
-        self.tree.node_selected= self
                                
     #------------------------------------------------------------------
     # Methodes de creation et destruction de noeuds
@@ -577,14 +581,15 @@ class JDCNode(QTreeWidgetItem,GereRegles):
 
     def onAdd(self,object):
         if self.JESUISOFF==1 : return
+        #print "onAdd pour ", self.item.nom, object.nom
         self.editor.init_modif()
         self.update_nodes()
-
         # PN -- non necessaire si item=jdc
         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
  
     def onSupp(self,object):
         if self.JESUISOFF==1 : return
+        #print "onSup pour ", self.item.nom, object.nom
         self.editor.init_modif()
         self.update_nodes()
         # PN -- non necessaire si item=jdc
@@ -714,6 +719,19 @@ class JDCNode(QTreeWidgetItem,GereRegles):
         child = self.append_child(objet,pos='first')
         return child
 
+    def plieToutEtReafficheSaufItem(self, itemADeplier):
+        #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
+        self.editor.deplier = False
+        for item in self.children :
+            # il ne faut pas plier les blocs 
+            from InterfaceQT4 import compobloc
+            if (isinstance(item,compobloc.Node)) : continue
+            item.setPlie()
+            if item==itemADeplier : 
+                  print itemADeplier.item.nom
+                  itemADeplier.setDeplie()
+        
+        self.affichePanneau()
 
     def plieToutEtReaffiche(self):
         #print "je suis dans plieToutEtReaffiche", self.item.get_nom()