if self.inhibeExpand == True : return
# On traite le cas de l item non selectionne
itemParent=item
- while not (hasattr (itemParent,'getPanel2')) :
+ while not (hasattr (itemParent,'getPanel')) :
itemParent=itemParent.treeParent
if self.tree.node_selected != itemParent :
item.setExpanded(False)
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,'getPanel2')) :
+ 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,'getPanel2')) :
+ 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"
PARAMETERS = "PARAMETRE"
class JDCNode(QTreeWidgetItem,GereRegles):
- def __init__( self, treeParent, item):
+ def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
#print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
- self.a=0
+ #self.a=0
self.item = item
self.vraiParent = treeParent
self.treeParent = treeParent
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))+" :")
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
""" Se charge de remettre les noeuds Expanded dans le meme etat """
#print "*********** build_children ",self,self.item, self.item.nom
- listeExpanded=[]
- for enfant in self.childrenComplete :
- #if enfant.isExpanded():
- # if self.childrenComplete.index(item) < posInsertion :
- # listeExpanded.append(self.childrenComplete.index(item))
- # print dir(item.item )
- # else :
- # listeExpanded.append( self.childrenComplete.index(item) +1)
+ self.listeItemExpanded=[]
+ self.listeItemPlie=[]
+ for enfant in self.childrenComplete :
+ if enfant.plie : self.listeItemPlie.append(enfant.item)
+ else : self.listeItemExpanded.append(enfant.item)
+ for enfant in self.childrenComplete :
p=enfant.vraiParent
parent=enfant.treeParent
parent.removeChild(enfant)
-
enfant.JESUISOFF=1
+
- #print listeExpanded
self.children = []
self.childrenComplete = []
sublist = self.item._GetSubList()
ind=0
+
for item in sublist :
- nouvelItem=item.itemNode(self,item)
+ itemExpand=False
+ ancien=False
+ if item in self.listeItemExpanded : itemExpand=True; ancien=True
+ if item in self.listeItemPlie : itemExpand=False; ancien=True
+ nouvelItem=item.itemNode(self,item,itemExpand,ancien)
self.children.append(nouvelItem)
+ #print "fin *********** build_children ",self,self.item, self.item.nom
+
def chercheNoeudCorrespondant(self,objSimp):
sublist = self.item._GetSubList()
def affichePanneau(self) :
+ #print " affichePanneau " , self.item.nom
if self.item.isactif():
itemParent=self
- while not (hasattr (itemParent,'getPanel2')) :
- itemParent=itemParent.treeParent
+ while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
if itemParent!=self :
itemParent.affichePanneau()
return
- self.fenetre=self.getPanel2()
+ self.fenetre=self.getPanel()
else:
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
self.tree.expandItem(self)
self.select()
self.tree.inhibeExpand=False
- #print "fin de affichePanneau"
+ #print "fin de affichePanneau", self.item.nom
#print "______________________________"
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
obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
if obj is None:obj=0
if obj == 0:return 0
- #try :
- # old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
- # child=old_obj[-1]
- # if plier : child.plieToutEtReaffiche()
- # else : child.affichePanneau()
- # print "dans le 1er Try"
- #else :
- #except:
- # Souci pour gerer les copies des AFFE d'une commande à l autre
- # try :
- # child=self.children[index]
- # if plier == True : child.setPlie()
- # else : child.setDeplie()
- # print "dans le 2nd Try"
- # except :
- # child=self.children[index]
- # print "dans le except"
try :
- #if 1:
child=self.children[index]
if plier == True : child.setPlie()
else : child.setDeplie()
except :
child=self.children[index]
- #print "dans le except"
self.tree.inhibeExpand=False
+ #print " fin append child"
return child
def deplace(self):
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
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()
# item.appartientAUnNoeudPlie=False
def setPlieChildren(self):
+ #print "dans setPlieChildren pour", self.item.nom
self.plie=True
for c in self.children :
c.setPlieChildren()
#print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
c.appartientAUnNoeudPlie=True
c.plie=True
+ #print "dans setPlieChildren plie", c.item.nom
c.setExpanded(False)
# Pour les blocs et les motcles list
# c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
def setDeplie(self):
+ #print "dans setPlieChildren pour", self.item.nom
#print "je mets inhibeExpand a true dans setDeplie"
self.tree.inhibeExpand=True
self.plie=False
#print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
for c in self.children :
c.setDeplieChildren()
- #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText()
+ #print "dans setDeplieChildren ", c.item.nom
c.appartientAUnNoeudPlie=False
c.setExpanded(True)
c.plie=False