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
27 from PyQt4.QtGui import *
28 from PyQt4.QtCore import *
29 from Extensions.i18n import tr
30 from gereRegles import GereRegles
31 from monChoixCommande import MonChoixCommande
33 class JDCTree( QTreeWidget,GereRegles ):
34 def __init__( self, jdc_item, QWParent):
35 #if hasattr(QWParent,'widgetTree') :
36 self.editor = QWParent
38 if self.editor.widgetTree !=None :
39 QTreeWidget.__init__(self, self.editor.widgetTree )
40 self.editor.verticalLayout_2.addWidget(self)
41 if self.editor.enteteQTree=='complet':
42 self.headerItem().setText(0, "Commande ")
43 self.headerItem().setText(1, "Concept/Valeur")
45 self.headerItem().setText(0, "Commande ")
46 self.setColumnWidth(0,200)
47 self.setExpandsOnDoubleClick(False)
48 self.setSelectionMode(3)
50 QTreeWidget.__init__(self, None )
53 self.appliEficas = self.editor.appliEficas
54 self.childrenComplete=[]
55 self.racine=self.item.itemNode(self,self.item)
57 self.itemCourrant=None
59 self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
60 self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
61 self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
63 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
64 self.node_selected=self.racine
65 self.inhibeExpand=True
66 self.expandItem(self.racine)
67 self.inhibeExpand=False
68 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
69 if self.racine.children !=[] :
72 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
73 else : self.racine.children[0].deplieToutEtReaffiche()
76 self.racine.children[0].fenetre.donnePremier()
77 else : self.racine.affichePanneau()
81 def contextMenuEvent(self,event) :
82 #print "contextMenuEvent"
83 coord=event.globalPos()
84 item= self.currentItem()
85 self.handleContextMenu(item,coord)
87 def handleContextMenu(self,item,coord):
89 Private slot to show the context menu of the listview.
91 @param itm the selected listview item (QListWidgetItem)
92 @param coord the position of the mouse pointer (QPoint)
93 Attention : existeMenu permet de savoir si un menu est associe a cet item
95 #print "handleContextMenu"
96 if item == None : return
97 if item.existeMenu == 0 : return
99 item.createPopUpMenu()
100 if item.menu != None:
101 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
102 item.Graphe.setEnabled(1)
103 item.menu.exec_(coord)
106 def handleCollapsedItem(self,item):
107 #print "dans CollapsedItem", self.inhibeExpand
108 if self.inhibeExpand == True : return
109 # On traite le cas de l item non selectionne
111 while not (hasattr (itemParent,'getPanel')) :
112 itemParent=itemParent.treeParent
113 if self.tree.node_selected != itemParent :
114 item.setExpanded(False)
119 item.plieToutEtReaffiche()
122 def handleExpandedItem(self,item):
123 #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
124 if self.inhibeExpand == True : return
126 while not (hasattr (itemParent,'getPanel')) :
127 if itemParent.plie==True : itemParent.setDeplie()
128 itemParent=itemParent.treeParent
129 if self.tree.node_selected != itemParent :
130 item.setExpanded(True)
132 item.deplieToutEtReaffiche()
133 self.inhibeExpand == False
136 def handleOnItem(self,item,int):
137 #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
139 self.inhibeExpand == True
140 self.itemCourrant=item
142 while not (hasattr (itemParent,'getPanel')) :
143 if itemParent.plie==True : itemParent.setDeplie()
144 itemParent=itemParent.treeParent
145 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
146 # il faut afficher le parent
147 if self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
148 else : itemParent.affichePanneau()
151 from InterfaceQT4 import composimp
152 if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
153 elif itemParent!=item:
154 #self.tree.handleExpandedItem(item)
155 #item.fenetre.donnePremier()
156 #item.fenetre.rendActif()
157 print 'il faut afficher le 1er'
159 fr = item.item.get_fr()
160 if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
164 self.inhibeExpand == False
165 #print "je mets inhibeExpand a false handleOnItem"
168 def choisitPremier(self,name):
169 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
170 self.racine.fenetre.close()
171 new_node=self.racine.append_brother(name,'after')
174 COMMENT = "COMMENTAIRE"
175 PARAMETERS = "PARAMETRE"
177 class JDCNode(QTreeWidgetItem,GereRegles):
178 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
179 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
182 self.vraiParent = treeParent
183 self.treeParent = treeParent
184 self.tree = self.treeParent.tree
185 self.editor = self.treeParent.editor
186 self.appliEficas = treeParent.appliEficas
188 self.childrenComplete=[]
190 from InterfaceQT4 import compocomm
191 from InterfaceQT4 import compoparam
192 from InterfaceQT4 import composimp
193 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
194 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
195 else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
196 value = self.appliEficas.trUtf8(str( item.GetText() ) )
199 mesColonnes=QStringList()
200 if self.editor.enteteQTree=='complet': mesColonnes << name << value
201 else : mesColonnes << name
203 if self.treeParent.plie==True :
205 self.appartientAUnNoeudPlie=True
208 self.appartientAUnNoeudPlie = False
210 if ancien and itemExpand : self.plie = False
211 if ancien and not itemExpand : self.plie = True
212 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
214 from InterfaceQT4 import compobloc
215 from InterfaceQT4 import compomclist
217 ajoutAuParentduNoeud=0
218 self.treeParent=treeParent
219 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
220 self.treeParent.childrenComplete.append(self)
221 self.treeParent=self.treeParent.vraiParent
222 self.treeParent.childrenComplete.append(self)
223 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
224 QTreeWidgetItem.__init__(self,None,mesColonnes)
226 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
228 self.setToolTip(0,QString(self.item.get_fr()))
229 self.setToolTip(1,QString(self.item.get_fr()))
231 repIcon=QString(self.appliEficas.repIcon)
232 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
233 self.setIcon(0,monIcone)
236 self.build_children()
240 self.item.connect("valid",self.onValid,())
241 self.item.connect("supp" ,self.onSupp,())
242 self.item.connect("add" ,self.onAdd,())
247 if self.item.getObject().isBLOC() :
248 self.setExpanded(True)
254 def build_children(self,posInsertion=10000):
255 """ Construit la liste des enfants de self """
256 """ Se charge de remettre les noeuds Expanded dans le meme etat """
257 #print "*********** build_children ",self,self.item, self.item.nom
259 self.listeItemExpanded=[]
260 self.listeItemPlie=[]
262 for enfant in self.childrenComplete :
263 if enfant.plie : self.listeItemPlie.append(enfant.item)
264 else : self.listeItemExpanded.append(enfant.item)
266 for enfant in self.childrenComplete :
268 parent=enfant.treeParent
269 parent.removeChild(enfant)
274 self.childrenComplete = []
275 sublist = self.item._GetSubList()
278 for item in sublist :
281 if item in self.listeItemExpanded : itemExpand=True; ancien=True
282 if item in self.listeItemPlie : itemExpand=False; ancien=True
283 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
284 self.children.append(nouvelItem)
286 #print "fin *********** build_children ",self,self.item, self.item.nom
289 def chercheNoeudCorrespondant(self,objSimp):
290 sublist = self.item._GetSubList()
291 for node in self.childrenComplete:
292 if node.item.object==objSimp : return node
296 def affichePanneau(self) :
297 #print " affichePanneau " , self.item.nom
298 if self.item.isactif():
300 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
301 if itemParent!=self :
302 itemParent.affichePanneau()
304 self.fenetre=self.getPanel()
306 from monInactifPanel import PanelInactif
307 self.fenetre = PanelInactif(self,self.editor)
309 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
310 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
311 self.editor.widgetCentraleLayout.removeItem(widget)
312 # ceinture et bretelle
313 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
314 if self.editor.fenetreCentraleAffichee != None :
315 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
316 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
317 self.editor.fenetreCentraleAffichee.close()
319 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
320 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
321 self.editor.fenetreCentraleAffichee=self.fenetre
322 self.tree.node_selected= self
324 if self.editor.first :
325 self.editor.splitter.setSizes((400,1400,400))
326 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
327 self.tree.inhibeExpand=True
328 self.tree.expandItem(self)
330 self.tree.inhibeExpand=False
331 #print "fin de affichePanneau", self.item.nom
332 #print "______________________________"
335 def createPopUpMenu(self):
336 #implemente dans les noeuds derives si necessaire
341 Cette methode a pour but de commentariser la commande pointee par self
343 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
344 # (commentariser) un commentaire.
346 pos=self.treeParent.children.index(self)
347 commande_comment = self.item.get_objet_commentarise()
348 # On signale a l editeur du panel (le JDCDisplay) une modification
349 self.editor.init_modif()
350 self.treeParent.build_children()
351 self.treeParent.children[pos].select()
352 self.treeParent.children[pos].affichePanneau()
354 traceback.print_exc()
355 QMessageBox.critical( self.editor, "TOO BAD",str(e))
357 def unCommentIt(self):
359 Realise la decommentarisation de self
362 pos=self.treeParent.children.index(self)
363 commande,nom = self.item.uncomment()
364 self.editor.init_modif()
365 self.treeParent.build_children()
366 self.treeParent.children[pos].select()
367 self.treeParent.children[pos].affichePanneau()
369 QMessageBox.critical( self.editor, "Erreur !",str(e))
371 def addComment( self, after=True ):
373 Ajoute un commentaire a l'interieur du JDC :
375 self.editor.init_modif()
380 return self.append_brother( COMMENT, pos )
382 def addParameters( self, after=True ):
384 Ajoute un parametre a l'interieur du JDC :
386 self.editor.init_modif()
387 if after: pos = 'after'
389 child=self.append_brother( PARAMETERS, pos )
395 Rend le noeud courant (self) selectionne et deselectionne
398 for item in self.tree.selectedItems() :
400 self.setSelected( True )
401 self.tree.setCurrentItem( self )
403 #------------------------------------------------------------------
404 # Methodes de creation et destruction de noeuds
405 # Certaines de ces methodes peuvent etre appelees depuis l'externe
406 #------------------------------------------------------------------
407 def append_brother(self,name,pos='after',plier=False):
409 Permet d'ajouter un objet frere a l'objet associe au noeud self
410 par defaut on l'ajoute immediatement apres
413 self.editor.init_modif()
415 from InterfaceQT4 import compojdc
416 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
418 index = self.treeParent.children.index(self)
419 if pos == 'before': index = index
420 elif pos == 'after': index = index +1
422 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
424 return self.treeParent.append_child(name,pos=index,plier=plier)
426 def verifiePosition(self,name,pos,aLaRacine=False):
427 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
428 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
430 etapes=self.item.get_jdc().etapes
431 if etapes == [] : return True
433 if aLaRacine == False :indexOu=etapes.index(self.item.object)
436 if pos=="after" : indexOu = indexOu+1
437 for e in etapes[:indexOu] :
439 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
440 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
441 if indexEtape > indexName :
442 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
443 QMessageBox.information( None,tr('insertion impossible'),comment, )
445 for e in etapes[indexOu:] :
447 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
448 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
449 if indexEtape < indexName :
450 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
451 QMessageBox.information( None,tr('insertion impossible'),comment, )
455 def append_child(self,name,pos=None,plier=False):
457 Methode pour ajouter un objet fils a l'objet associe au noeud self.
458 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
459 ou en position intermediaire.
460 Si pos vaut None, on le place a la position du catalogue.
462 #print "************** append_child ",self.item.GetLabelText(), plier
465 self.editor.init_modif()
469 index = len(self.children)
470 elif type(pos) == types.IntType :
473 elif type(pos) == types.InstanceType:
474 # pos est un item. Il faut inserer name apres pos
475 index = self.item.get_index(pos) +1
476 elif type(name) == types.InstanceType:
477 index = self.item.get_index_child(name.nom)
479 index = self.item.get_index_child(name)
481 # si on essaye d inserer a la racine
482 if (isinstance(self.treeParent,JDCTree) and index==0) :
483 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
484 if not verifiePosition : return 0
486 self.tree.inhibeExpand=True
487 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
491 child=self.children[index]
492 if plier == True : child.setPlie()
493 else : child.setDeplie()
495 child=self.children[index]
496 self.tree.inhibeExpand=False
497 #print " fin append child"
501 self.editor.init_modif()
502 index = self.treeParent.children.index(self) - 1
503 if index < 0 : index =0
504 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
508 Methode externe pour la destruction de l'objet associe au noeud
510 self.editor.init_modif()
511 index = self.vraiParent.children.index(self) - 1
512 if index < 0 : index =0
514 if self.item.nom == "VARIABLE" :
517 ret,commentaire=self.vraiParent.item.suppitem(self.item)
519 self.editor.affiche_infos(commentaire,Qt.red)
521 self.editor.affiche_infos(commentaire)
522 self.treeParent.build_children()
523 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
524 else: toselect=self.treeParent
525 if recalcule : jdc.recalcule_etat_correlation()
526 from InterfaceQT4 import compojdc
527 # cas ou on detruit dans l arbre sans affichage
528 if isinstance(self.treeParent,compojdc.Node) :
529 toselect.affichePanneau()
531 if self.treeParent.fenetre== None : return
532 #print "J appelle reaffiche de browser apres delete"
533 self.treeParent.fenetre.reaffiche(toselect)
535 def deleteMultiple(self,liste=()):
537 Methode externe pour la destruction d une liste de noeud
539 from InterfaceQT4 import compojdc
540 self.editor.init_modif()
545 while not(isinstance(jdc,compojdc.Node)):
548 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
549 if noeud.item.nom == "VARIABLE" : recalcule=1
550 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
551 if index < 0 : index =0
553 # Cas ou on détruit dans une ETape
555 parentPosition=self.treeParent
556 while not(isinstance(parentPosition, compojdc.Node)):
557 index=parentPosition.treeParent.children.index(parentPosition)
558 parentPosition=parentPosition.treeParent
561 noeud.treeParent.item.suppitem(noeud.item)
564 if recalcule : jdc.recalcule_etat_correlation()
565 try : toselect=parentPosition.children[index]
566 except : toselect=jdc
568 toselect.affichePanneau()
570 # #------------------------------------------------------------------
573 #print "onValid pour ", self.item.nom
574 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
575 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
576 self.item.jdc.recalcule_etat_correlation()
577 if hasattr(self.item,'forceRecalcul'):
578 self.forceRecalculChildren(self.item.forceRecalcul)
579 self.editor.init_modif()
581 self.update_node_valid()
582 self.update_node_label()
583 self.update_node_texte()
585 def onAdd(self,object):
586 if self.JESUISOFF==1 : return
587 #print "onAdd pour ", self.item.nom, object.nom
588 self.editor.init_modif()
590 # PN -- non necessaire si item=jdc
591 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
593 def onSupp(self,object):
594 if self.JESUISOFF==1 : return
595 #print "onSup pour ", self.item.nom, object.nom
596 self.editor.init_modif()
598 # PN -- non necessaire si item=jdc
599 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
604 def update_node_valid(self):
605 """Cette methode remet a jour la validite du noeud (icone)
608 repIcon=QString(self.appliEficas.repIcon)
609 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
610 self.setIcon(0,monIcone)
613 def update_node_label(self):
614 """ Met a jour le label du noeud """
615 #print "NODE update_node_label", self.item.GetLabelText()
616 labeltext,fonte,couleur = self.item.GetLabelText()
618 #self.setText(0, labeltext)
621 def update_node_label_in_blue(self):
622 if hasattr(self.appliEficas,'noeudColore'):
623 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
624 self.appliEficas.noeudColore.update_node_label()
625 self.setTextColor( 0,Qt.blue )
626 labeltext,fonte,couleur = self.item.GetLabelText()
627 self.setText(0, labeltext)
628 self.appliEficas.noeudColore=self
630 def update_plusieurs_node_label_in_blue(self,liste):
631 if hasattr(self.appliEficas,'listeNoeudsColores'):
632 for noeud in self.appliEficas.listeNoeudsColores:
633 noeud.setTextColor( 0,Qt.black)
634 noeud.update_node_label()
635 self.appliEficas.listeNoeudsColores=[]
637 noeud.setTextColor( 0,Qt.blue )
638 labeltext,fonte,couleur = noeud.item.GetLabelText()
639 noeud.setText(0, labeltext)
640 self.appliEficas.listeNoeudsColores.append(noeud)
642 def update_node_texte_in_black(self):
643 """ Met a jour les noms des SD et valeurs des mots-cles """
644 self.setTextColor( 1,Qt.black )
645 value = self.item.GetText()
646 self.setText(1, value)
648 def update_node_texte(self):
649 """ Met a jour les noms des SD et valeurs des mots-cles """
650 value = self.item.GetText()
651 self.setText(1, value)
654 def update_node_texte_in_blue(self):
655 self.setTextColor( 1,Qt.blue )
656 value = self.item.GetText()
657 self.setText(1, value)
659 def update_nodes(self):
660 #print 'NODE update_nodes', self.item.GetLabelText()
661 self.build_children()
663 def update_valid(self) :
664 """Cette methode a pour but de mettre a jour la validite du noeud
665 et de propager la demande de mise a jour a son parent
667 #print "NODE update_valid", self.item.GetLabelText()
668 self.update_node_valid()
670 self.treeParent.update_valid()
674 def update_texte(self):
675 """ Met a jour les noms des SD et valeurs des mots-cles """
676 #print "NODE update_texte", self.item.GetLabelText()
677 self.update_node_texte()
678 if self.isExpanded() :
679 for child in self.children:
680 if child.isHidden() == false : child.update_texte()
683 def forceRecalculChildren(self,niveau):
684 if self.state=='recalcule' :
687 self.state='recalcule'
688 if hasattr(self.item,'object'):
689 self.item.object.state="modified"
690 for child in self.children:
691 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
695 def doPaste(self,node_selected,pos='after'):
697 Déclenche la copie de l'objet item avec pour cible
698 l'objet passé en argument : node_selected
700 #print 'je passe dans doPaste'
701 objet_a_copier = self.item.get_copie_objet()
702 child=node_selected.doPasteCommande(objet_a_copier,pos)
705 def doPasteCommande(self,objet_a_copier,pos='after'):
707 Réalise la copie de l'objet passé en argument qui est nécessairement
712 child = self.append_brother(objet_a_copier,pos)
717 def doPastePremier(self,objet_a_copier):
719 Réalise la copie de l'objet passé en argument (objet_a_copier)
721 objet = objet_a_copier.item.get_copie_objet()
722 child = self.append_child(objet,pos='first')
725 def plieToutEtReafficheSaufItem(self, itemADeplier):
726 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
727 from InterfaceQT4 import compojdc
728 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
729 self.editor.deplier = False
730 for item in self.children :
731 # il ne faut pas plier les blocs
732 from InterfaceQT4 import compobloc
733 if (isinstance(item,compobloc.Node)) : continue
735 if item==itemADeplier :
736 itemADeplier.setDeplie()
738 self.affichePanneau()
740 def plieToutEtReaffiche(self):
741 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
742 from InterfaceQT4 import compojdc
743 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
744 self.editor.deplier = False
745 for item in self.children :
746 # il ne faut pas plier les blocs
747 from InterfaceQT4 import compobloc
748 if (isinstance(item,compobloc.Node)) : continue
750 self.affichePanneau()
752 def deplieToutEtReaffiche(self):
753 self.editor.deplier = True
754 for item in self.children :
756 self.affichePanneau()
759 #print "je mets inhibeExpand a true dans setPlie"
760 #print "je suis dans plieTout", self.item.get_nom()
762 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
764 self.tree.inhibeExpand=True
765 self.tree.collapseItem(self)
766 self.setPlieChildren()
767 self.tree.inhibeExpand=False
768 #print "je mets inhibeExpand a false dans setPlie"
771 # on ne plie pas au niveau 1
773 # for item in self.children :
774 # item.appartientAUnNoeudPlie=False
776 def setPlieChildren(self):
777 #print "dans setPlieChildren pour", self.item.nom
779 for c in self.children :
781 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
782 c.appartientAUnNoeudPlie=True
784 #print "dans setPlieChildren plie", c.item.nom
787 # Pour les blocs et les motcles list
788 # on affiche un niveau de plus
789 from InterfaceQT4 import compobloc
790 from InterfaceQT4 import compomclist
791 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
792 niveauPere=self.treeParent
793 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
794 niveauPere=niveauPere.treeParent
795 for c in self.children :
796 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
799 # on affiche un niveau de plus
800 #if isinstance(self,compomclist.Node) :
801 #if isinstance(self,compobloc.Node) :
802 # niveauPere=self.treeParent
803 # while (isinstance(niveauPere,compobloc.Node)):
804 # niveauPere=niveauPere.treeParent
805 # for c in self.children :
806 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
809 #print "dans setPlieChildren pour", self.item.nom
810 #print "je mets inhibeExpand a true dans setDeplie"
811 self.tree.inhibeExpand=True
813 self.tree.expandItem(self)
814 self.setDeplieChildren()
815 self.tree.inhibeExpand=False
816 #print "je mets inhibeExpand a false dans setDePlie"
818 def setDeplieChildren(self):
819 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
820 for c in self.children :
821 c.setDeplieChildren()
822 #print "dans setDeplieChildren ", c.item.nom
823 c.appartientAUnNoeudPlie=False
827 def selectAvant(self):
828 i=self.item.jdc.etapes.index(self.item.object)
830 cherche=self.item.jdc.etapes[i-1]
832 cherche=self.item.jdc.etapes[-1]
834 for i in self.tree.racine.children :
835 if i.item.object== cherche :
838 if node : node.affichePanneau()
840 def selectApres(self):
841 i=self.item.jdc.etapes.index(self.item.object)
843 cherche=self.item.jdc.etapes[i+1]
845 cherche=self.item.jdc.etapes[0]
847 for i in self.tree.racine.children :
848 if i.item.object== cherche :
851 if node : node.affichePanneau()