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()
135 def handleOnItem(self,item,int):
136 #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
137 self.inhibeExpand == True
138 self.itemCourrant=item
140 while not (hasattr (itemParent,'getPanel')) :
141 if itemParent.plie==True : itemParent.setDeplie()
142 itemParent=itemParent.treeParent
143 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
144 # il faut afficher le parent
145 if self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
146 else : itemParent.affichePanneau()
149 from InterfaceQT4 import composimp
150 if (isinstance(item,composimp.Node)) : item.fenetre.rendVisible()
151 elif itemParent!=item:
152 #self.tree.handleExpandedItem(item)
153 #item.fenetre.donnePremier()
154 print 'il faut afficher le 1er'
156 fr = item.item.get_fr()
157 if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
161 self.inhibeExpand == False
162 #print "je mets inhibeExpand a false handleOnItem"
165 def choisitPremier(self,name):
166 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
167 self.racine.fenetre.close()
168 new_node=self.racine.append_brother(name,'after')
171 COMMENT = "COMMENTAIRE"
172 PARAMETERS = "PARAMETRE"
174 class JDCNode(QTreeWidgetItem,GereRegles):
175 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
176 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
179 self.vraiParent = treeParent
180 self.treeParent = treeParent
181 self.tree = self.treeParent.tree
182 self.editor = self.treeParent.editor
183 self.appliEficas = treeParent.appliEficas
185 self.childrenComplete=[]
187 from InterfaceQT4 import compocomm
188 from InterfaceQT4 import compoparam
189 from InterfaceQT4 import composimp
190 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
191 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
192 else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
193 value = self.appliEficas.trUtf8(str( item.GetText() ) )
196 mesColonnes=QStringList()
197 if self.editor.enteteQTree=='complet': mesColonnes << name << value
198 else : mesColonnes << name
200 if self.treeParent.plie==True :
202 self.appartientAUnNoeudPlie=True
205 self.appartientAUnNoeudPlie = False
207 if ancien and itemExpand : self.plie = False
208 if ancien and not itemExpand : self.plie = True
209 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
211 from InterfaceQT4 import compobloc
212 from InterfaceQT4 import compomclist
214 ajoutAuParentduNoeud=0
215 self.treeParent=treeParent
216 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
217 self.treeParent.childrenComplete.append(self)
218 self.treeParent=self.treeParent.vraiParent
219 self.treeParent.childrenComplete.append(self)
220 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
221 QTreeWidgetItem.__init__(self,None,mesColonnes)
223 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
225 self.setToolTip(0,QString(self.item.get_fr()))
226 self.setToolTip(1,QString(self.item.get_fr()))
228 repIcon=QString(self.appliEficas.repIcon)
229 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
230 self.setIcon(0,monIcone)
233 self.build_children()
237 self.item.connect("valid",self.onValid,())
238 self.item.connect("supp" ,self.onSupp,())
239 self.item.connect("add" ,self.onAdd,())
244 if self.item.getObject().isBLOC() :
245 self.setExpanded(True)
251 def build_children(self,posInsertion=10000):
252 """ Construit la liste des enfants de self """
253 """ Se charge de remettre les noeuds Expanded dans le meme etat """
254 #print "*********** build_children ",self,self.item, self.item.nom
256 self.listeItemExpanded=[]
257 self.listeItemPlie=[]
259 for enfant in self.childrenComplete :
260 if enfant.plie : self.listeItemPlie.append(enfant.item)
261 else : self.listeItemExpanded.append(enfant.item)
263 for enfant in self.childrenComplete :
265 parent=enfant.treeParent
266 parent.removeChild(enfant)
271 self.childrenComplete = []
272 sublist = self.item._GetSubList()
275 for item in sublist :
278 if item in self.listeItemExpanded : itemExpand=True; ancien=True
279 if item in self.listeItemPlie : itemExpand=False; ancien=True
280 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
281 self.children.append(nouvelItem)
283 #print "fin *********** build_children ",self,self.item, self.item.nom
286 def chercheNoeudCorrespondant(self,objSimp):
287 sublist = self.item._GetSubList()
288 for node in self.childrenComplete:
289 if node.item.object==objSimp : return node
293 def affichePanneau(self) :
294 #print " affichePanneau " , self.item.nom
295 if self.item.isactif():
297 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
298 if itemParent!=self :
299 itemParent.affichePanneau()
301 self.fenetre=self.getPanel()
303 from monInactifPanel import PanelInactif
304 self.fenetre = PanelInactif(self,self.editor)
306 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
307 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
308 self.editor.widgetCentraleLayout.removeItem(widget)
309 # ceinture et bretelle
310 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
311 if self.editor.fenetreCentraleAffichee != None :
312 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
313 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
314 self.editor.fenetreCentraleAffichee.close()
316 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
317 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
318 self.editor.fenetreCentraleAffichee=self.fenetre
319 self.tree.node_selected= self
321 if self.editor.first :
322 self.editor.splitter.setSizes((400,1400,400))
323 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
324 self.tree.inhibeExpand=True
325 self.tree.expandItem(self)
327 self.tree.inhibeExpand=False
328 #print "fin de affichePanneau", self.item.nom
329 #print "______________________________"
332 def createPopUpMenu(self):
333 #implemente dans les noeuds derives si necessaire
338 Cette methode a pour but de commentariser la commande pointee par self
340 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
341 # (commentariser) un commentaire.
343 pos=self.treeParent.children.index(self)
344 commande_comment = self.item.get_objet_commentarise()
345 # On signale a l editeur du panel (le JDCDisplay) une modification
346 self.editor.init_modif()
347 self.treeParent.build_children()
348 self.treeParent.children[pos].select()
349 self.treeParent.children[pos].affichePanneau()
351 traceback.print_exc()
352 QMessageBox.critical( self.editor, "TOO BAD",str(e))
354 def unCommentIt(self):
356 Realise la decommentarisation de self
359 pos=self.treeParent.children.index(self)
360 commande,nom = self.item.uncomment()
361 self.editor.init_modif()
362 self.treeParent.build_children()
363 self.treeParent.children[pos].select()
364 self.treeParent.children[pos].affichePanneau()
366 QMessageBox.critical( self.editor, "Erreur !",str(e))
368 def addComment( self, after=True ):
370 Ajoute un commentaire a l'interieur du JDC :
372 self.editor.init_modif()
377 return self.append_brother( COMMENT, pos )
379 def addParameters( self, after=True ):
381 Ajoute un parametre a l'interieur du JDC :
383 self.editor.init_modif()
384 if after: pos = 'after'
386 child=self.append_brother( PARAMETERS, pos )
392 Rend le noeud courant (self) selectionne et deselectionne
395 for item in self.tree.selectedItems() :
397 self.setSelected( True )
398 self.tree.setCurrentItem( self )
400 #------------------------------------------------------------------
401 # Methodes de creation et destruction de noeuds
402 # Certaines de ces methodes peuvent etre appelees depuis l'externe
403 #------------------------------------------------------------------
404 def append_brother(self,name,pos='after',plier=False):
406 Permet d'ajouter un objet frere a l'objet associe au noeud self
407 par defaut on l'ajoute immediatement apres
410 self.editor.init_modif()
412 from InterfaceQT4 import compojdc
413 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
415 index = self.treeParent.children.index(self)
416 if pos == 'before': index = index
417 elif pos == 'after': index = index +1
419 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
421 return self.treeParent.append_child(name,pos=index,plier=plier)
423 def verifiePosition(self,name,pos,aLaRacine=False):
424 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
425 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
427 etapes=self.item.get_jdc().etapes
428 if etapes == [] : return True
430 if aLaRacine == False :indexOu=etapes.index(self.item.object)
433 if pos=="after" : indexOu = indexOu+1
434 for e in etapes[:indexOu] :
436 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
437 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
438 if indexEtape > indexName :
439 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
440 QMessageBox.information( None,tr('insertion impossible'),comment, )
442 for e in etapes[indexOu:] :
444 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
445 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
446 if indexEtape < indexName :
447 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
448 QMessageBox.information( None,tr('insertion impossible'),comment, )
452 def append_child(self,name,pos=None,plier=False):
454 Methode pour ajouter un objet fils a l'objet associe au noeud self.
455 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
456 ou en position intermediaire.
457 Si pos vaut None, on le place a la position du catalogue.
459 #print "************** append_child ",self.item.GetLabelText(), plier
462 self.editor.init_modif()
466 index = len(self.children)
467 elif type(pos) == types.IntType :
470 elif type(pos) == types.InstanceType:
471 # pos est un item. Il faut inserer name apres pos
472 index = self.item.get_index(pos) +1
473 elif type(name) == types.InstanceType:
474 index = self.item.get_index_child(name.nom)
476 index = self.item.get_index_child(name)
478 # si on essaye d inserer a la racine
479 if (isinstance(self.treeParent,JDCTree) and index==0) :
480 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
481 if not verifiePosition : return 0
483 self.tree.inhibeExpand=True
484 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
488 child=self.children[index]
489 if plier == True : child.setPlie()
490 else : child.setDeplie()
492 child=self.children[index]
493 self.tree.inhibeExpand=False
494 #print " fin append child"
498 self.editor.init_modif()
499 index = self.treeParent.children.index(self) - 1
500 if index < 0 : index =0
501 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
505 Methode externe pour la destruction de l'objet associe au noeud
507 self.editor.init_modif()
508 index = self.vraiParent.children.index(self) - 1
509 if index < 0 : index =0
511 if self.item.nom == "VARIABLE" :
514 ret,commentaire=self.vraiParent.item.suppitem(self.item)
516 self.editor.affiche_infos(commentaire,Qt.red)
518 self.editor.affiche_infos(commentaire)
519 self.treeParent.build_children()
520 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
521 else: toselect=self.treeParent
522 if recalcule : jdc.recalcule_etat_correlation()
523 from InterfaceQT4 import compojdc
524 # cas ou on detruit dans l arbre sans affichage
525 if isinstance(self.treeParent,compojdc.Node) :
526 toselect.affichePanneau()
528 if self.treeParent.fenetre== None : return
529 #print "J appelle reaffiche de browser apres delete"
530 self.treeParent.fenetre.reaffiche(toselect)
532 def deleteMultiple(self,liste=()):
534 Methode externe pour la destruction d une liste de noeud
536 from InterfaceQT4 import compojdc
537 self.editor.init_modif()
542 while not(isinstance(jdc,compojdc.Node)):
545 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
546 if noeud.item.nom == "VARIABLE" : recalcule=1
547 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
548 if index < 0 : index =0
550 # Cas ou on détruit dans une ETape
552 parentPosition=self.treeParent
553 while not(isinstance(parentPosition, compojdc.Node)):
554 index=parentPosition.treeParent.children.index(parentPosition)
555 parentPosition=parentPosition.treeParent
558 noeud.treeParent.item.suppitem(noeud.item)
561 if recalcule : jdc.recalcule_etat_correlation()
562 try : toselect=parentPosition.children[index]
563 except : toselect=jdc
565 toselect.affichePanneau()
567 # #------------------------------------------------------------------
570 #print "onValid pour ", self.item.nom
571 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
572 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
573 self.item.jdc.recalcule_etat_correlation()
574 if hasattr(self.item,'forceRecalcul'):
575 self.forceRecalculChildren(self.item.forceRecalcul)
576 self.editor.init_modif()
578 self.update_node_valid()
579 self.update_node_label()
580 self.update_node_texte()
582 def onAdd(self,object):
583 if self.JESUISOFF==1 : return
584 #print "onAdd pour ", self.item.nom, object.nom
585 self.editor.init_modif()
587 # PN -- non necessaire si item=jdc
588 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
590 def onSupp(self,object):
591 if self.JESUISOFF==1 : return
592 #print "onSup pour ", self.item.nom, object.nom
593 self.editor.init_modif()
595 # PN -- non necessaire si item=jdc
596 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
601 def update_node_valid(self):
602 """Cette methode remet a jour la validite du noeud (icone)
605 repIcon=QString(self.appliEficas.repIcon)
606 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
607 self.setIcon(0,monIcone)
610 def update_node_label(self):
611 """ Met a jour le label du noeud """
612 #print "NODE update_node_label", self.item.GetLabelText()
613 labeltext,fonte,couleur = self.item.GetLabelText()
615 #self.setText(0, labeltext)
618 def update_node_label_in_blue(self):
619 if hasattr(self.appliEficas,'noeudColore'):
620 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
621 self.appliEficas.noeudColore.update_node_label()
622 self.setTextColor( 0,Qt.blue )
623 labeltext,fonte,couleur = self.item.GetLabelText()
624 self.setText(0, labeltext)
625 self.appliEficas.noeudColore=self
627 def update_plusieurs_node_label_in_blue(self,liste):
628 if hasattr(self.appliEficas,'listeNoeudsColores'):
629 for noeud in self.appliEficas.listeNoeudsColores:
630 noeud.setTextColor( 0,Qt.black)
631 noeud.update_node_label()
632 self.appliEficas.listeNoeudsColores=[]
634 noeud.setTextColor( 0,Qt.blue )
635 labeltext,fonte,couleur = noeud.item.GetLabelText()
636 noeud.setText(0, labeltext)
637 self.appliEficas.listeNoeudsColores.append(noeud)
639 def update_node_texte_in_black(self):
640 """ Met a jour les noms des SD et valeurs des mots-cles """
641 self.setTextColor( 1,Qt.black )
642 value = self.item.GetText()
643 self.setText(1, value)
645 def update_node_texte(self):
646 """ Met a jour les noms des SD et valeurs des mots-cles """
647 value = self.item.GetText()
648 self.setText(1, value)
651 def update_node_texte_in_blue(self):
652 self.setTextColor( 1,Qt.blue )
653 value = self.item.GetText()
654 self.setText(1, value)
656 def update_nodes(self):
657 #print 'NODE update_nodes', self.item.GetLabelText()
658 self.build_children()
660 def update_valid(self) :
661 """Cette methode a pour but de mettre a jour la validite du noeud
662 et de propager la demande de mise a jour a son parent
664 #print "NODE update_valid", self.item.GetLabelText()
665 self.update_node_valid()
667 self.treeParent.update_valid()
671 def update_texte(self):
672 """ Met a jour les noms des SD et valeurs des mots-cles """
673 #print "NODE update_texte", self.item.GetLabelText()
674 self.update_node_texte()
675 if self.isExpanded() :
676 for child in self.children:
677 if child.isHidden() == false : child.update_texte()
680 def forceRecalculChildren(self,niveau):
681 if self.state=='recalcule' :
684 self.state='recalcule'
685 if hasattr(self.item,'object'):
686 self.item.object.state="modified"
687 for child in self.children:
688 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
692 def doPaste(self,node_selected,pos='after'):
694 Déclenche la copie de l'objet item avec pour cible
695 l'objet passé en argument : node_selected
697 #print 'je passe dans doPaste'
698 objet_a_copier = self.item.get_copie_objet()
699 child=node_selected.doPasteCommande(objet_a_copier,pos)
702 def doPasteCommande(self,objet_a_copier,pos='after'):
704 Réalise la copie de l'objet passé en argument qui est nécessairement
709 child = self.append_brother(objet_a_copier,pos)
714 def doPastePremier(self,objet_a_copier):
716 Réalise la copie de l'objet passé en argument (objet_a_copier)
718 objet = objet_a_copier.item.get_copie_objet()
719 child = self.append_child(objet,pos='first')
722 def plieToutEtReafficheSaufItem(self, itemADeplier):
723 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
724 self.editor.deplier = False
725 for item in self.children :
726 # il ne faut pas plier les blocs
727 from InterfaceQT4 import compobloc
728 if (isinstance(item,compobloc.Node)) : continue
730 if item==itemADeplier :
731 print itemADeplier.item.nom
732 itemADeplier.setDeplie()
734 self.affichePanneau()
736 def plieToutEtReaffiche(self):
737 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
738 self.editor.deplier = False
739 for item in self.children :
740 # il ne faut pas plier les blocs
741 from InterfaceQT4 import compobloc
742 if (isinstance(item,compobloc.Node)) : continue
744 self.affichePanneau()
746 def deplieToutEtReaffiche(self):
747 self.editor.deplier = True
748 for item in self.children :
750 self.affichePanneau()
753 #print "je mets inhibeExpand a true dans setPlie"
754 #print "je suis dans plieTout", self.item.get_nom()
756 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
758 self.tree.inhibeExpand=True
759 self.tree.collapseItem(self)
760 self.setPlieChildren()
761 self.tree.inhibeExpand=False
762 #print "je mets inhibeExpand a false dans setPlie"
765 # on ne plie pas au niveau 1
767 # for item in self.children :
768 # item.appartientAUnNoeudPlie=False
770 def setPlieChildren(self):
771 #print "dans setPlieChildren pour", self.item.nom
773 for c in self.children :
775 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
776 c.appartientAUnNoeudPlie=True
778 #print "dans setPlieChildren plie", c.item.nom
781 # Pour les blocs et les motcles list
782 # on affiche un niveau de plus
783 from InterfaceQT4 import compobloc
784 from InterfaceQT4 import compomclist
785 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
786 niveauPere=self.treeParent
787 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
788 niveauPere=niveauPere.treeParent
789 for c in self.children :
790 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
793 # on affiche un niveau de plus
794 #if isinstance(self,compomclist.Node) :
795 #if isinstance(self,compobloc.Node) :
796 # niveauPere=self.treeParent
797 # while (isinstance(niveauPere,compobloc.Node)):
798 # niveauPere=niveauPere.treeParent
799 # for c in self.children :
800 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
803 #print "dans setPlieChildren pour", self.item.nom
804 #print "je mets inhibeExpand a true dans setDeplie"
805 self.tree.inhibeExpand=True
807 self.tree.expandItem(self)
808 self.setDeplieChildren()
809 self.tree.inhibeExpand=False
810 #print "je mets inhibeExpand a false dans setDePlie"
812 def setDeplieChildren(self):
813 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
814 for c in self.children :
815 c.setDeplieChildren()
816 #print "dans setDeplieChildren ", c.item.nom
817 c.appartientAUnNoeudPlie=False
821 def selectAvant(self):
822 i=self.item.jdc.etapes.index(self.item.object)
824 cherche=self.item.jdc.etapes[i-1]
826 cherche=self.item.jdc.etapes[-1]
828 for i in self.tree.racine.children :
829 if i.item.object== cherche :
832 if node : node.affichePanneau()
834 def selectApres(self):
835 i=self.item.jdc.etapes.index(self.item.object)
837 cherche=self.item.jdc.etapes[i+1]
839 cherche=self.item.jdc.etapes[0]
841 for i in self.tree.racine.children :
842 if i.item.object== cherche :
845 if node : node.affichePanneau()