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 monChoixCommande import MonChoixCommande
32 class JDCTree( QTreeWidget ):
33 def __init__( self, jdc_item, QWParent):
34 #if hasattr(QWParent,'widgetTree') :
35 self.editor = QWParent
37 if self.editor.widgetTree !=None :
38 QTreeWidget.__init__(self, self.editor.widgetTree )
39 self.editor.verticalLayout_2.addWidget(self)
40 if self.editor.enteteQTree=='complet':
41 self.headerItem().setText(0, "Commande ")
42 self.headerItem().setText(1, "Concept/Valeur")
44 self.headerItem().setText(0, "Commande ")
45 self.setColumnWidth(0,200)
46 self.setExpandsOnDoubleClick(False)
47 self.setSelectionMode(3)
49 QTreeWidget.__init__(self, None )
52 self.appliEficas = self.editor.appliEficas
53 self.childrenComplete=[]
54 self.childrenIssusDesBlocs=[]
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,'getPanel2')) :
112 itemParent=itemParent.treeParent
113 if self.tree.node_selected != itemParent :
114 item.setExpanded(False)
119 item.plieToutEtReaffiche()
121 def handleExpandedItem(self,item):
122 #print "dans ExpandItem", self.inhibeExpand
123 if self.inhibeExpand == True : return
126 while not (hasattr (itemParent,'getPanel2')) :
127 if itemParent.plie==True : itemParent.setDeplie()
128 itemParent=itemParent.treeParent
130 if self.tree.node_selected != itemParent :
131 item.setExpanded(True)
134 item.deplieToutEtReaffiche()
136 def handleOnItem(self,item,int):
137 #if (len(self.selectedIndexes())!=2): return
138 #print "je passe dans handleOnItem"
139 self.inhibeExpand == True
140 self.itemCourrant=item
142 #print self.itemCourrant
143 while not (hasattr (itemParent,'getPanel2')) :
144 if itemParent.plie==True : itemParent.setDeplie()
145 itemParent=itemParent.treeParent
147 #print itemParent.fenetre
148 #print self.editor.afficheCommandesPliees
149 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
150 #print self.editor.afficheCommandesPliees
151 if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche()
152 else : itemParent.affichePanneau()
153 if itemParent!=item and item.fenetre != None: item.fenetre.rendVisible()
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):
175 def __init__( self, treeParent, item):
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
184 self.treeParent.childrenIssusDesBlocs=[]
185 self.childrenComplete=[]
187 from InterfaceQT4 import compocomm
188 from InterfaceQT4 import compoparam
189 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
190 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
191 else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
192 value = self.appliEficas.trUtf8(str( item.GetText() ) )
194 mesColonnes=QStringList()
195 if self.editor.enteteQTree=='complet': mesColonnes << name << value
196 else : mesColonnes << name
198 if self.treeParent.plie==True :
200 self.appartientAUnNoeudPlie=True
203 self.appartientAUnNoeudPlie = False
204 #print "self.plie", self.plie
205 #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie
206 #print self.treeParent
208 ajoutAuParentduNoeud=0
209 from InterfaceQT4 import compobloc
210 from InterfaceQT4 import compomclist
211 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
212 #while (isinstance(self.treeParent,compobloc.Node)) :
213 self.treeParent=self.treeParent.treeParent
214 ajoutAuParentduNoeud=1
215 if ajoutAuParentduNoeud :
216 treeParent.childrenComplete.append(self)
217 self.treeParent.childrenIssusDesBlocs.append(self)
218 while (isinstance(self.treeParent,compobloc.Node)) : self.treeParent=self.treeParent.treeParent
220 #if isinstance(self,compobloc.Node) :
221 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
222 QTreeWidgetItem.__init__(self,None,mesColonnes)
224 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
225 self.treeParent.childrenComplete.append(self)
227 self.setToolTip(0,QString(self.item.get_fr()))
228 self.setToolTip(1,QString(self.item.get_fr()))
230 repIcon=QString(self.appliEficas.repIcon)
231 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
232 self.setIcon(0,monIcone)
235 self.build_children()
239 self.item.connect("valid",self.onValid,())
240 self.item.connect("supp" ,self.onSupp,())
241 self.item.connect("add" ,self.onAdd,())
245 if self.item.getObject().isBLOC() :
246 self.setExpanded(True)
252 def build_children(self,posInsertion=10000):
253 """ Construit la liste des enfants de self """
254 """ Se charge de remettre les noeuds Expanded dans le meme etat """
255 #print "*********** build_children ",self.item, self.item.GetLabelText()
258 for item in self.childrenComplete :
260 #if item.isExpanded():
261 # if self.childrenComplete.index(item) < posInsertion :
262 # listeExpanded.append(self.childrenComplete.index(item))
263 # print dir(item.item )
265 # listeExpanded.append( self.childrenComplete.index(item) +1)
266 self.detruit_les_noeuds_issus_de_blocs(item)
267 parent=item.treeParent
268 parent.removeChild(item)
272 self.childrenComplete = []
273 sublist = self.item._GetSubList()
275 for item in sublist :
276 nouvelItem=item.itemNode(self,item)
277 self.children.append(nouvelItem)
278 #print " J ajoute ", nouvelItem ,nouvelItem.item.GetLabelText(),"dans" ,self.item.GetLabelText()
280 #if ind in listeExpanded : nouvelItem.setExpanded(1)
282 #if ind in listeExpanded : print "plie=0"
283 #else : print "plie=1"
284 #if ind in listeExpanded : nouvelItem.plie=0
285 #else : nouvelItem.plie=1
288 #print "*********** fin build_children ",self.item, self.item.GetLabelText()
290 def chercheNoeudCorrespondant(self,objSimp):
291 sublist = self.item._GetSubList()
292 for node in self.childrenComplete:
293 if node.item.object==objSimp : return node
296 def affichePanneau(self) :
297 print "dans affichePanneau appel getPanel2", self.item.GetLabelText()
298 if self.item.isactif():
302 while not (hasattr (itemParent,'getPanel2')) :
303 itemParent=itemParent.treeParent
304 if itemParent!=self :
305 itemParent.affichePanneau()
308 self.fenetre=self.getPanel2()
310 from monInactifPanel import PanelInactif
311 self.fenetre = PanelInactif(self,self.editor)
313 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
314 #print "widgetCentraleLayout = ", self.editor.widgetCentraleLayout
315 #print "nouvelle fenetre ", self.fenetre, " associee a ", self
317 self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee
318 #print "ancienne fenetre ", self.editor.anciennefenetre
319 self.editor.fenetreCentraleAffichee=self.fenetre
320 self.tree.node_selected= self
322 if self.editor.anciennefenetre != None :
323 a=self.editor.anciennefenetre.close()
324 #print "je ferme ", self.editor.anciennefenetre
326 if self.editor.widgetTree !=None : index=1
329 if self.editor.first :
330 self.editor.splitter.setSizes((400,1400,400))
331 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
332 self.tree.inhibeExpand=True
333 self.tree.expandItem(self)
335 self.tree.inhibeExpand=False
336 #print "fin de affichePanneau"
337 #print "______________________________"
340 def createPopUpMenu(self):
341 #implemente dans les noeuds derives si necessaire
346 Cette methode a pour but de commentariser la commande pointee par self
348 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
349 # (commentariser) un commentaire.
351 pos=self.treeParent.children.index(self)
352 commande_comment = self.item.get_objet_commentarise()
353 # On signale a l editeur du panel (le JDCDisplay) une modification
354 self.editor.init_modif()
355 self.treeParent.build_children()
356 self.treeParent.children[pos].select()
357 self.treeParent.children[pos].affichePanneau()
359 traceback.print_exc()
360 QMessageBox.critical( self.editor, "TOO BAD",str(e))
362 def unCommentIt(self):
364 Realise la decommentarisation de self
367 pos=self.treeParent.children.index(self)
368 commande,nom = self.item.uncomment()
369 self.editor.init_modif()
370 self.treeParent.build_children()
371 self.treeParent.children[pos].select()
372 self.treeParent.children[pos].affichePanneau()
374 QMessageBox.critical( self.editor, "Erreur !",str(e))
376 def addComment( self, after=True ):
378 Ajoute un commentaire a l'interieur du JDC :
380 self.editor.init_modif()
385 return self.append_brother( COMMENT, pos )
387 def addParameters( self, after=True ):
389 Ajoute un parametre a l'interieur du JDC :
391 self.editor.init_modif()
392 if after: pos = 'after'
394 child=self.append_brother( PARAMETERS, pos )
400 Rend le noeud courant (self) selectionne et deselectionne
403 #print "je suis sur select"
404 for item in self.tree.selectedItems() :
406 self.setSelected( True )
407 #self.setExpanded( True )
408 self.tree.setCurrentItem( self )
409 self.tree.node_selected= self
411 #------------------------------------------------------------------
412 # Methodes de creation et destruction de noeuds
413 # Certaines de ces methodes peuvent etre appelees depuis l'externe
414 #------------------------------------------------------------------
415 def append_brother(self,name,pos='after',plier=False):
417 Permet d'ajouter un objet frere a l'objet associe au noeud self
418 par defaut on l'ajoute immediatement apres
421 self.editor.init_modif()
423 verifiePosition=self.verifiePosition(name,pos)
424 if not verifiePosition : return 0
426 index = self.treeParent.children.index(self)
427 if pos == 'before': index = index
428 elif pos == 'after': index = index +1
430 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
432 return self.treeParent.append_child(name,pos=index,plier=plier)
434 def verifiePosition(self,name,pos):
435 from InterfaceQT4 import compojdc
436 if not (isinstance(self.treeParent, compojdc.Node)) : return True
437 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
438 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
440 etapes=self.item.jdc.etapes
441 if etapes == [] : return True
443 indexOu=etapes.index(self.item.object)
444 if pos=="after" : indexOu = indexOu+1
445 print self.editor.Classement_Commandes_Ds_Arbre
450 for e in etapes[:indexOu] :
452 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
453 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
454 if indexEtape > indexName :
455 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
456 QMessageBox.information( None,tr('insertion impossible'),comment, )
458 for e in etapes[indexOu:] :
460 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
461 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
462 if indexEtape < indexName :
463 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
464 QMessageBox.information( None,tr('insertion impossible'),comment, )
468 def append_child(self,name,pos=None,plier=False):
470 Methode pour ajouter un objet fils a l'objet associe au noeud self.
471 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
472 ou en position intermediaire.
473 Si pos vaut None, on le place a la position du catalogue.
475 #print "************** append_child ",self.item.GetLabelText(), plier
476 self.editor.init_modif()
480 index = len(self.children)
481 elif type(pos) == types.IntType :
484 elif type(pos) == types.InstanceType:
485 # pos est un item. Il faut inserer name apres pos
486 index = self.item.get_index(pos) +1
487 elif type(name) == types.InstanceType:
488 index = self.item.get_index_child(name.nom)
490 index = self.item.get_index_child(name)
491 self.tree.inhibeExpand=True
492 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
496 # old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
498 # if plier : child.plieToutEtReaffiche()
499 # else : child.affichePanneau()
500 # print "dans le 1er Try"
503 # Souci pour gerer les copies des AFFE d'une commande à l autre
505 # child=self.children[index]
506 # if plier == True : child.setPlie()
507 # else : child.setDeplie()
508 # print "dans le 2nd Try"
510 # child=self.children[index]
511 # print "dans le except"
514 child=self.children[index]
515 if plier == True : child.setPlie()
516 else : child.setDeplie()
518 child=self.children[index]
519 #print "dans le except"
520 self.tree.inhibeExpand=False
524 self.editor.init_modif()
525 index = self.treeParent.children.index(self) - 1
526 if index < 0 : index =0
527 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
531 Methode externe pour la destruction de l'objet associe au noeud
533 self.editor.init_modif()
534 index = self.vraiParent.children.index(self) - 1
535 if index < 0 : index =0
537 if self.item.nom == "VARIABLE" :
540 ret=self.vraiParent.item.suppitem(self.item)
541 self.treeParent.build_children()
542 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
543 else: toselect=self.treeParent
544 if recalcule : jdc.recalcule_etat_correlation()
545 from InterfaceQT4 import compojdc
546 # cas ou on detruit dans l arbre sans affichage
547 if isinstance(self.treeParent,compojdc.Node) :
548 toselect.affichePanneau()
550 if self.treeParent.fenetre== None : return
551 #print "J appelle reaffiche de browser apres delete"
552 self.treeParent.fenetre.reaffiche(toselect)
554 def deleteMultiple(self,liste=()):
556 Methode externe pour la destruction d une liste de noeud
558 from InterfaceQT4 import compojdc
559 self.editor.init_modif()
564 while not(isinstance(jdc,compojdc.Node)):
567 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
568 if noeud.item.nom == "VARIABLE" : recalcule=1
569 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
570 if index < 0 : index =0
572 # Cas ou on détruit dans une ETape
574 parentPosition=self.treeParent
575 while not(isinstance(parentPosition, compojdc.Node)):
576 index=parentPosition.treeParent.children.index(parentPosition)
577 parentPosition=parentPosition.treeParent
580 noeud.treeParent.item.suppitem(noeud.item)
583 if recalcule : jdc.recalcule_etat_correlation()
584 try : toselect=parentPosition.children[index]
585 except : toselect=jdc
587 toselect.affichePanneau()
589 # #------------------------------------------------------------------
592 #print "onValid pour ", self.item.nom
593 if hasattr(self,'fenetre') and self.fenetre:
594 self.fenetre.setValide()
595 if self.item.nom == "VARIABLE" and self.item.isvalid():
596 self.item.jdc.recalcule_etat_correlation()
597 if hasattr(self.item,'forceRecalcul'):
598 self.forceRecalculChildren(self.item.forceRecalcul)
599 self.editor.init_modif()
601 self.update_node_valid()
602 self.update_node_label()
603 self.update_node_texte()
605 def onAdd(self,object):
606 #print "onAdd pour ", self.item.nom
607 self.editor.init_modif()
609 #print "dans onAdd" ,self.item
610 # PN -- non necessaire si item=jdc
611 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
613 def onSupp(self,object):
614 #print "onSupp pour ", self.item.nom
615 self.editor.init_modif()
617 # PN -- non necessaire si item=jdc
618 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
620 def detruit_les_noeuds_issus_de_blocs(self,bloc):
621 from InterfaceQT4 import compobloc
622 if (isinstance(bloc,compobloc.Node)) :
623 for node in bloc.childrenComplete :
624 self.detruit_les_noeuds_issus_de_blocs(node)
625 parent=node.treeParent
626 #print "je detruit " , node.item.GetLabelText()
627 parent.removeChild(node)
629 def update_node_valid(self):
630 """Cette methode remet a jour la validite du noeud (icone)
633 repIcon=QString(self.appliEficas.repIcon)
634 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
635 self.setIcon(0,monIcone)
638 def update_node_label(self):
639 """ Met a jour le label du noeud """
640 #print "NODE update_node_label", self.item.GetLabelText()
641 labeltext,fonte,couleur = self.item.GetLabelText()
643 #self.setText(0, labeltext)
646 def update_node_label_in_blue(self):
647 if hasattr(self.appliEficas,'noeudColore'):
648 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
649 self.appliEficas.noeudColore.update_node_label()
650 self.setTextColor( 0,Qt.blue )
651 labeltext,fonte,couleur = self.item.GetLabelText()
652 self.setText(0, labeltext)
653 self.appliEficas.noeudColore=self
655 def update_plusieurs_node_label_in_blue(self,liste):
656 if hasattr(self.appliEficas,'listeNoeudsColores'):
657 for noeud in self.appliEficas.listeNoeudsColores:
658 noeud.setTextColor( 0,Qt.black)
659 noeud.update_node_label()
660 self.appliEficas.listeNoeudsColores=[]
662 noeud.setTextColor( 0,Qt.blue )
663 labeltext,fonte,couleur = noeud.item.GetLabelText()
664 noeud.setText(0, labeltext)
665 self.appliEficas.listeNoeudsColores.append(noeud)
667 def update_node_texte_in_black(self):
668 """ Met a jour les noms des SD et valeurs des mots-cles """
669 self.setTextColor( 1,Qt.black )
670 value = self.item.GetText()
671 self.setText(1, value)
673 def update_node_texte(self):
674 """ Met a jour les noms des SD et valeurs des mots-cles """
675 value = self.item.GetText()
676 self.setText(1, value)
678 def update_node_texte_in_blue(self):
679 self.setTextColor( 1,Qt.blue )
680 value = self.item.GetText()
681 self.setText(1, value)
683 def update_nodes(self):
684 #print 'NODE update_nodes', self.item.GetLabelText()
685 self.build_children()
687 def update_valid(self) :
688 """Cette methode a pour but de mettre a jour la validite du noeud
689 et de propager la demande de mise a jour a son parent
691 #print "NODE update_valid", self.item.GetLabelText()
692 self.update_node_valid()
694 self.treeParent.update_valid()
698 def update_texte(self):
699 """ Met a jour les noms des SD et valeurs des mots-cles """
700 #print "NODE update_texte", self.item.GetLabelText()
701 self.update_node_texte()
702 if self.isExpanded() :
703 for child in self.children:
704 if child.isHidden() == false : child.update_texte()
707 def forceRecalculChildren(self,niveau):
708 if self.state=='recalcule' :
711 self.state='recalcule'
712 if hasattr(self.item,'object'):
713 self.item.object.state="modified"
714 for child in self.children:
715 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
719 def doPaste(self,node_selected,pos='after'):
721 Déclenche la copie de l'objet item avec pour cible
722 l'objet passé en argument : node_selected
724 #print 'je passe dans doPaste'
725 objet_a_copier = self.item.get_copie_objet()
726 child=node_selected.doPasteCommande(objet_a_copier,pos)
729 def doPasteCommande(self,objet_a_copier,pos='after'):
731 Réalise la copie de l'objet passé en argument qui est nécessairement
736 child = self.append_brother(objet_a_copier,pos)
741 def doPastePremier(self,objet_a_copier):
743 Réalise la copie de l'objet passé en argument (objet_a_copier)
745 objet = objet_a_copier.item.get_copie_objet()
746 child = self.append_child(objet,pos='first')
750 def plieToutEtReaffiche(self):
751 print "je suis dans plieToutEtReaffiche", self.item.get_nom()
752 self.editor.deplier = False
753 for item in self.children :
755 self.affichePanneau()
757 def deplieToutEtReaffiche(self):
758 self.editor.deplier = True
759 for item in self.children :
761 self.affichePanneau()
764 #print "je mets inhibeExpand a true dans setPlie"
765 #print "je suis dans plieTout", self.item.get_nom()
767 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
769 self.tree.inhibeExpand=True
770 self.tree.collapseItem(self)
771 self.setPlieChildren()
772 self.tree.inhibeExpand=False
773 #print "je mets inhibeExpand a false dans setPlie"
776 # on ne plie pas au niveau 1
778 # for item in self.children :
779 # item.appartientAUnNoeudPlie=False
781 def setPlieChildren(self):
783 for c in self.children :
785 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
786 c.appartientAUnNoeudPlie=True
790 # Pour les blocs et les motcles list
791 # on affiche un niveau de plus
792 from InterfaceQT4 import compobloc
793 from InterfaceQT4 import compomclist
794 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
795 niveauPere=self.treeParent
796 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
797 niveauPere=niveauPere.treeParent
798 for c in self.children :
799 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
802 # on affiche un niveau de plus
803 #if isinstance(self,compomclist.Node) :
804 #if isinstance(self,compobloc.Node) :
805 # niveauPere=self.treeParent
806 # while (isinstance(niveauPere,compobloc.Node)):
807 # niveauPere=niveauPere.treeParent
808 # for c in self.children :
809 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
812 #print "je mets inhibeExpand a true dans setDeplie"
813 self.tree.inhibeExpand=True
815 self.tree.expandItem(self)
816 self.setDeplieChildren()
817 self.tree.inhibeExpand=False
818 #print "je mets inhibeExpand a false dans setDePlie"
820 def setDeplieChildren(self):
821 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
822 for c in self.children :
823 c.setDeplieChildren()
824 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText()
825 c.appartientAUnNoeudPlie=False
829 def selectAvant(self):
830 i=self.item.jdc.etapes.index(self.item.object)
832 cherche=self.item.jdc.etapes[i-1]
834 cherche=self.item.jdc.etapes[-1]
836 for i in self.tree.racine.children :
837 if i.item.object== cherche :
840 if node : node.affichePanneau()
842 def selectApres(self):
843 i=self.item.jdc.etapes.index(self.item.object)
845 cherche=self.item.jdc.etapes[i+1]
847 cherche=self.item.jdc.etapes[0]
849 for i in self.tree.racine.children :
850 if i.item.object== cherche :
853 if node : node.affichePanneau()