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=[]
191 from InterfaceQT4 import compocomm
192 from InterfaceQT4 import compoparam
193 from InterfaceQT4 import composimp
194 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
195 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
196 else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
197 value = self.appliEficas.trUtf8(str( item.GetText() ) )
200 mesColonnes=QStringList()
201 if self.editor.enteteQTree=='complet': mesColonnes << name << value
202 else : mesColonnes << name
204 if self.treeParent.plie==True :
206 self.appartientAUnNoeudPlie=True
209 self.appartientAUnNoeudPlie = False
211 if ancien and itemExpand : self.plie = False
212 if ancien and not itemExpand : self.plie = True
213 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
215 from InterfaceQT4 import compobloc
216 from InterfaceQT4 import compomclist
218 ajoutAuParentduNoeud=0
219 self.treeParent=treeParent
220 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
221 self.treeParent.childrenComplete.append(self)
222 self.treeParent=self.treeParent.vraiParent
223 self.treeParent.childrenComplete.append(self)
224 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
225 QTreeWidgetItem.__init__(self,None,mesColonnes)
227 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
229 self.setToolTip(0,QString(self.item.get_fr()))
230 self.setToolTip(1,QString(self.item.get_fr()))
232 repIcon=QString(self.appliEficas.repIcon)
233 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
234 self.setIcon(0,monIcone)
237 self.build_children()
241 self.item.connect("valid",self.onValid,())
242 self.item.connect("supp" ,self.onSupp,())
243 self.item.connect("add" ,self.onAdd,())
248 if self.item.getObject().isBLOC() :
249 self.setExpanded(True)
255 def build_children(self,posInsertion=10000):
256 """ Construit la liste des enfants de self """
257 """ Se charge de remettre les noeuds Expanded dans le meme etat """
258 #print "*********** build_children ",self,self.item, self.item.nom
260 self.listeItemExpanded=[]
261 self.listeItemPlie=[]
263 for enfant in self.childrenComplete :
264 if enfant.plie : self.listeItemPlie.append(enfant.item)
265 else : self.listeItemExpanded.append(enfant.item)
267 for enfant in self.childrenComplete :
269 parent=enfant.treeParent
270 parent.removeChild(enfant)
275 self.childrenComplete = []
276 sublist = self.item._GetSubList()
279 for item in sublist :
282 if item in self.listeItemExpanded : itemExpand=True; ancien=True
283 if item in self.listeItemPlie : itemExpand=False; ancien=True
284 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
285 self.children.append(nouvelItem)
287 #print "fin *********** build_children ",self,self.item, self.item.nom
290 def chercheNoeudCorrespondant(self,objSimp):
291 sublist = self.item._GetSubList()
292 for node in self.childrenComplete:
293 if node.item.object==objSimp : return node
297 def affichePanneau(self) :
298 #print " affichePanneau " , self.item.nom
299 if self.item.isactif():
301 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
302 if itemParent!=self :
303 itemParent.affichePanneau()
305 self.fenetre=self.getPanel()
307 from monInactifPanel import PanelInactif
308 self.fenetre = PanelInactif(self,self.editor)
310 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
311 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
312 self.editor.widgetCentraleLayout.removeItem(widget)
313 # ceinture et bretelle
314 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
315 if self.editor.fenetreCentraleAffichee != None :
316 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
317 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
318 self.editor.fenetreCentraleAffichee.close()
320 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
321 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
322 self.editor.fenetreCentraleAffichee=self.fenetre
323 self.tree.node_selected= self
325 if self.editor.first :
326 self.editor.splitter.setSizes((400,1400,400))
327 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
328 self.tree.inhibeExpand=True
329 self.tree.expandItem(self)
331 self.tree.inhibeExpand=False
332 #print "fin de affichePanneau", self.item.nom
333 #print "______________________________"
336 def createPopUpMenu(self):
337 #implemente dans les noeuds derives si necessaire
342 Cette methode a pour but de commentariser la commande pointee par self
344 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
345 # (commentariser) un commentaire.
347 pos=self.treeParent.children.index(self)
348 commande_comment = self.item.get_objet_commentarise()
349 # On signale a l editeur du panel (le JDCDisplay) une modification
350 self.editor.init_modif()
351 self.treeParent.build_children()
352 self.treeParent.children[pos].select()
353 self.treeParent.children[pos].affichePanneau()
355 traceback.print_exc()
356 QMessageBox.critical( self.editor, "TOO BAD",str(e))
358 def unCommentIt(self):
360 Realise la decommentarisation de self
363 pos=self.treeParent.children.index(self)
364 commande,nom = self.item.uncomment()
365 self.editor.init_modif()
366 self.treeParent.build_children()
367 self.treeParent.children[pos].select()
368 self.treeParent.children[pos].affichePanneau()
370 QMessageBox.critical( self.editor, "Erreur !",str(e))
372 def addComment( self, after=True ):
374 Ajoute un commentaire a l'interieur du JDC :
376 self.editor.init_modif()
381 return self.append_brother( COMMENT, pos )
383 def addParameters( self, after=True ):
385 Ajoute un parametre a l'interieur du JDC :
387 self.editor.init_modif()
388 if after: pos = 'after'
390 child=self.append_brother( PARAMETERS, pos )
396 Rend le noeud courant (self) selectionne et deselectionne
399 for item in self.tree.selectedItems() :
401 self.setSelected( True )
402 self.tree.setCurrentItem( self )
404 #------------------------------------------------------------------
405 # Methodes de creation et destruction de noeuds
406 # Certaines de ces methodes peuvent etre appelees depuis l'externe
407 #------------------------------------------------------------------
408 def append_brother(self,name,pos='after',plier=False):
410 Permet d'ajouter un objet frere a l'objet associe au noeud self
411 par defaut on l'ajoute immediatement apres
414 self.editor.init_modif()
416 from InterfaceQT4 import compojdc
417 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
419 index = self.treeParent.children.index(self)
420 if pos == 'before': index = index
421 elif pos == 'after': index = index +1
423 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
425 return self.treeParent.append_child(name,pos=index,plier=plier)
427 def verifiePosition(self,name,pos,aLaRacine=False):
428 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
429 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
431 etapes=self.item.get_jdc().etapes
432 if etapes == [] : return True
434 if aLaRacine == False :indexOu=etapes.index(self.item.object)
437 if pos=="after" : indexOu = indexOu+1
438 for e in etapes[:indexOu] :
440 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
441 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
442 if indexEtape > indexName :
443 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
444 QMessageBox.information( None,tr('insertion impossible'),comment, )
446 for e in etapes[indexOu:] :
448 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
449 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
450 if indexEtape < indexName :
451 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
452 QMessageBox.information( None,tr('insertion impossible'),comment, )
456 def append_child(self,name,pos=None,plier=False):
458 Methode pour ajouter un objet fils a l'objet associe au noeud self.
459 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
460 ou en position intermediaire.
461 Si pos vaut None, on le place a la position du catalogue.
463 #print "************** append_child ",self.item.GetLabelText(), plier
466 self.editor.init_modif()
470 index = len(self.children)
471 elif type(pos) == types.IntType :
474 elif type(pos) == types.InstanceType:
475 # pos est un item. Il faut inserer name apres pos
476 index = self.item.get_index(pos) +1
477 elif type(name) == types.InstanceType:
478 index = self.item.get_index_child(name.nom)
480 index = self.item.get_index_child(name)
482 # si on essaye d inserer a la racine
483 if (isinstance(self.treeParent,JDCTree) and index==0) :
484 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
485 if not verifiePosition : return 0
487 self.tree.inhibeExpand=True
488 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
492 child=self.children[index]
493 if plier == True : child.setPlie()
494 else : child.setDeplie()
496 child=self.children[index]
497 self.tree.inhibeExpand=False
498 #print " fin append child"
502 self.editor.init_modif()
503 index = self.treeParent.children.index(self) - 1
504 if index < 0 : index =0
505 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
509 Methode externe pour la destruction de l'objet associe au noeud
511 self.editor.init_modif()
512 index = self.vraiParent.children.index(self) - 1
513 if index < 0 : index =0
515 if self.item.nom == "VARIABLE" :
518 ret,commentaire=self.vraiParent.item.suppitem(self.item)
520 self.editor.affiche_infos(commentaire,Qt.red)
522 self.editor.affiche_infos(commentaire)
523 self.treeParent.build_children()
524 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
525 else: toselect=self.treeParent
526 if recalcule : jdc.recalcule_etat_correlation()
527 from InterfaceQT4 import compojdc
528 # cas ou on detruit dans l arbre sans affichage
529 if isinstance(self.treeParent,compojdc.Node) :
530 toselect.affichePanneau()
532 if self.treeParent.fenetre== None : return
533 #print "J appelle reaffiche de browser apres delete"
534 self.treeParent.fenetre.reaffiche(toselect)
536 def deleteMultiple(self,liste=()):
538 Methode externe pour la destruction d une liste de noeud
540 from InterfaceQT4 import compojdc
541 self.editor.init_modif()
546 while not(isinstance(jdc,compojdc.Node)):
549 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
550 if noeud.item.nom == "VARIABLE" : recalcule=1
551 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
552 if index < 0 : index =0
554 # Cas ou on détruit dans une ETape
556 parentPosition=self.treeParent
557 while not(isinstance(parentPosition, compojdc.Node)):
558 index=parentPosition.treeParent.children.index(parentPosition)
559 parentPosition=parentPosition.treeParent
562 noeud.treeParent.item.suppitem(noeud.item)
565 if recalcule : jdc.recalcule_etat_correlation()
566 try : toselect=parentPosition.children[index]
567 except : toselect=jdc
569 toselect.affichePanneau()
571 # #------------------------------------------------------------------
574 #print "onValid pour ", self.item.nom
575 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
576 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
577 self.item.jdc.recalcule_etat_correlation()
578 if hasattr(self.item,'forceRecalcul'):
579 self.forceRecalculChildren(self.item.forceRecalcul)
580 self.editor.init_modif()
582 self.update_node_valid()
583 self.update_node_label()
584 self.update_node_texte()
586 def onAdd(self,object):
587 if self.JESUISOFF==1 : return
588 #print "onAdd pour ", self.item.nom, object.nom
589 self.editor.init_modif()
591 # PN -- non necessaire si item=jdc
592 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
594 def onSupp(self,object):
595 if self.JESUISOFF==1 : return
596 #print "onSup pour ", self.item.nom, object.nom
597 self.editor.init_modif()
599 # PN -- non necessaire si item=jdc
600 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
605 def update_node_valid(self):
606 """Cette methode remet a jour la validite du noeud (icone)
609 repIcon=QString(self.appliEficas.repIcon)
610 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
611 self.setIcon(0,monIcone)
614 def update_node_label(self):
615 """ Met a jour le label du noeud """
616 #print "NODE update_node_label", self.item.GetLabelText()
617 labeltext,fonte,couleur = self.item.GetLabelText()
619 #self.setText(0, labeltext)
622 def update_node_label_in_blue(self):
623 if hasattr(self.appliEficas,'noeudColore'):
624 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
625 self.appliEficas.noeudColore.update_node_label()
626 self.setTextColor( 0,Qt.blue )
627 labeltext,fonte,couleur = self.item.GetLabelText()
628 self.setText(0, labeltext)
629 self.appliEficas.noeudColore=self
631 def update_plusieurs_node_label_in_blue(self,liste):
632 if hasattr(self.appliEficas,'listeNoeudsColores'):
633 for noeud in self.appliEficas.listeNoeudsColores:
634 noeud.setTextColor( 0,Qt.black)
635 noeud.update_node_label()
636 self.appliEficas.listeNoeudsColores=[]
638 noeud.setTextColor( 0,Qt.blue )
639 labeltext,fonte,couleur = noeud.item.GetLabelText()
640 noeud.setText(0, labeltext)
641 self.appliEficas.listeNoeudsColores.append(noeud)
643 def update_node_texte_in_black(self):
644 """ Met a jour les noms des SD et valeurs des mots-cles """
645 self.setTextColor( 1,Qt.black )
646 value = self.item.GetText()
647 self.setText(1, value)
649 def update_node_texte(self):
650 """ Met a jour les noms des SD et valeurs des mots-cles """
651 value = self.item.GetText()
652 self.setText(1, value)
655 def update_node_texte_in_blue(self):
656 self.setTextColor( 1,Qt.blue )
657 value = self.item.GetText()
658 self.setText(1, value)
660 def update_nodes(self):
661 #print 'NODE update_nodes', self.item.GetLabelText()
662 self.build_children()
664 def update_valid(self) :
665 """Cette methode a pour but de mettre a jour la validite du noeud
666 et de propager la demande de mise a jour a son parent
668 #print "NODE update_valid", self.item.GetLabelText()
669 self.update_node_valid()
671 self.treeParent.update_valid()
675 def update_texte(self):
676 """ Met a jour les noms des SD et valeurs des mots-cles """
677 #print "NODE update_texte", self.item.GetLabelText()
678 self.update_node_texte()
679 if self.isExpanded() :
680 for child in self.children:
681 if child.isHidden() == false : child.update_texte()
684 def forceRecalculChildren(self,niveau):
685 if self.state=='recalcule' :
688 self.state='recalcule'
689 if hasattr(self.item,'object'):
690 self.item.object.state="modified"
691 for child in self.children:
692 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
696 def doPaste(self,node_selected,pos='after'):
698 Déclenche la copie de l'objet item avec pour cible
699 l'objet passé en argument : node_selected
701 #print 'je passe dans doPaste'
702 objet_a_copier = self.item.get_copie_objet()
703 child=node_selected.doPasteCommande(objet_a_copier,pos)
706 def doPasteCommande(self,objet_a_copier,pos='after'):
708 Réalise la copie de l'objet passé en argument qui est nécessairement
713 child = self.append_brother(objet_a_copier,pos)
718 def doPastePremier(self,objet_a_copier):
720 Réalise la copie de l'objet passé en argument (objet_a_copier)
722 objet = objet_a_copier.item.get_copie_objet()
723 child = self.append_child(objet,pos='first')
726 def plieToutEtReafficheSaufItem(self, itemADeplier):
727 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
728 from InterfaceQT4 import compojdc
729 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
730 self.editor.deplier = False
731 for item in self.children :
732 # il ne faut pas plier les blocs
733 from InterfaceQT4 import compobloc
734 if (isinstance(item,compobloc.Node)) : continue
736 if item==itemADeplier :
737 itemADeplier.setDeplie()
739 self.affichePanneau()
741 def plieToutEtReaffiche(self):
742 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
743 from InterfaceQT4 import compojdc
744 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
745 self.editor.deplier = False
746 for item in self.children :
747 # il ne faut pas plier les blocs
748 from InterfaceQT4 import compobloc
749 if (isinstance(item,compobloc.Node)) : continue
751 self.affichePanneau()
753 def deplieToutEtReaffiche(self):
754 self.editor.deplier = True
755 for item in self.children :
757 self.affichePanneau()
760 #print "je mets inhibeExpand a true dans setPlie"
761 #print "je suis dans plieTout", self.item.get_nom()
763 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
765 self.tree.inhibeExpand=True
766 self.tree.collapseItem(self)
767 self.setPlieChildren()
768 self.tree.inhibeExpand=False
769 #print "je mets inhibeExpand a false dans setPlie"
772 # on ne plie pas au niveau 1
774 # for item in self.children :
775 # item.appartientAUnNoeudPlie=False
777 def setPlieChildren(self):
778 #print "dans setPlieChildren pour", self.item.nom
780 for c in self.children :
782 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
783 c.appartientAUnNoeudPlie=True
785 #print "dans setPlieChildren plie", c.item.nom
788 # Pour les blocs et les motcles list
789 # on affiche un niveau de plus
790 from InterfaceQT4 import compobloc
791 from InterfaceQT4 import compomclist
792 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
793 niveauPere=self.treeParent
794 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
795 niveauPere=niveauPere.treeParent
796 for c in self.children :
797 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
800 # on affiche un niveau de plus
801 #if isinstance(self,compomclist.Node) :
802 #if isinstance(self,compobloc.Node) :
803 # niveauPere=self.treeParent
804 # while (isinstance(niveauPere,compobloc.Node)):
805 # niveauPere=niveauPere.treeParent
806 # for c in self.children :
807 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
810 #print "dans setPlieChildren pour", self.item.nom
811 #print "je mets inhibeExpand a true dans setDeplie"
812 self.tree.inhibeExpand=True
814 self.tree.expandItem(self)
815 self.setDeplieChildren()
816 self.tree.inhibeExpand=False
817 #print "je mets inhibeExpand a false dans setDePlie"
819 def setDeplieChildren(self):
820 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
821 for c in self.children :
822 c.setDeplieChildren()
823 #print "dans setDeplieChildren ", c.item.nom
824 c.appartientAUnNoeudPlie=False
828 def selectAvant(self):
829 i=self.item.jdc.etapes.index(self.item.object)
831 cherche=self.item.jdc.etapes[i-1]
833 cherche=self.item.jdc.etapes[-1]
835 for i in self.tree.racine.children :
836 if i.item.object== cherche :
839 if node : node.affichePanneau()
841 def selectApres(self):
842 i=self.item.jdc.etapes.index(self.item.object)
844 cherche=self.item.jdc.etapes[i+1]
846 cherche=self.item.jdc.etapes[0]
848 for i in self.tree.racine.children :
849 if i.item.object== cherche :
852 if node : node.affichePanneau()