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() ) )
195 mesColonnes=QStringList()
196 if self.editor.enteteQTree=='complet': mesColonnes << name << value
197 else : mesColonnes << name
199 if self.treeParent.plie==True :
201 self.appartientAUnNoeudPlie=True
204 self.appartientAUnNoeudPlie = False
205 #print "self.plie", self.plie
206 #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie
207 #print self.treeParent
209 ajoutAuParentduNoeud=0
210 from InterfaceQT4 import compobloc
211 from InterfaceQT4 import compomclist
212 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
213 #while (isinstance(self.treeParent,compobloc.Node)) :
214 self.treeParent=self.treeParent.treeParent
215 ajoutAuParentduNoeud=1
216 if ajoutAuParentduNoeud :
217 treeParent.childrenComplete.append(self)
218 self.treeParent.childrenIssusDesBlocs.append(self)
219 while (isinstance(self.treeParent,compobloc.Node)) : self.treeParent=self.treeParent.treeParent
221 #if isinstance(self,compobloc.Node) :
222 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
223 QTreeWidgetItem.__init__(self,None,mesColonnes)
225 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
226 self.treeParent.childrenComplete.append(self)
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,())
246 if self.item.getObject().isBLOC() :
247 self.setExpanded(True)
253 def build_children(self,posInsertion=10000):
254 """ Construit la liste des enfants de self """
255 """ Se charge de remettre les noeuds Expanded dans le meme etat """
256 #print "*********** build_children ",self.item, self.item.GetLabelText()
259 for item in self.childrenComplete :
261 #if item.isExpanded():
262 # if self.childrenComplete.index(item) < posInsertion :
263 # listeExpanded.append(self.childrenComplete.index(item))
264 # print dir(item.item )
266 # listeExpanded.append( self.childrenComplete.index(item) +1)
267 self.detruit_les_noeuds_issus_de_blocs(item)
268 parent=item.treeParent
269 parent.removeChild(item)
273 self.childrenComplete = []
274 sublist = self.item._GetSubList()
276 for item in sublist :
277 nouvelItem=item.itemNode(self,item)
278 self.children.append(nouvelItem)
279 #print " J ajoute ", nouvelItem ,nouvelItem.item.GetLabelText(),"dans" ,self.item.GetLabelText()
281 #if ind in listeExpanded : nouvelItem.setExpanded(1)
283 #if ind in listeExpanded : print "plie=0"
284 #else : print "plie=1"
285 #if ind in listeExpanded : nouvelItem.plie=0
286 #else : nouvelItem.plie=1
289 #print "*********** fin build_children ",self.item, self.item.GetLabelText()
291 def chercheNoeudCorrespondant(self,objSimp):
292 sublist = self.item._GetSubList()
293 for node in self.childrenComplete:
294 if node.item.object==objSimp : return node
297 def affichePanneau(self) :
298 #print "dans affichePanneau appel getPanel2", self.item.GetLabelText()
299 if self.item.isactif():
302 #print self.getPanel2
303 while not (hasattr (itemParent,'getPanel2')) :
304 itemParent=itemParent.treeParent
305 if itemParent!=self :
306 itemParent.affichePanneau()
308 #print self.getPanel2
309 self.fenetre=self.getPanel2()
311 from monInactifPanel import PanelInactif
312 self.fenetre = PanelInactif(self,self.editor)
314 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
315 #print "widgetCentraleLayout = ", self.editor.widgetCentraleLayout
316 #print "nouvelle fenetre ", self.fenetre, " associee a ", self
318 self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee
319 #print "ancienne fenetre ", self.editor.anciennefenetre
320 self.editor.fenetreCentraleAffichee=self.fenetre
321 self.tree.node_selected= self
323 if self.editor.anciennefenetre != None :
324 a=self.editor.anciennefenetre.close()
325 #print "je ferme ", self.editor.anciennefenetre
327 if self.editor.widgetTree !=None : index=1
330 if self.editor.first :
331 self.editor.splitter.setSizes((400,1400,400))
332 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
333 self.tree.inhibeExpand=True
334 self.tree.expandItem(self)
336 self.tree.inhibeExpand=False
337 #print "fin de affichePanneau"
338 #print "______________________________"
341 def createPopUpMenu(self):
342 #implemente dans les noeuds derives si necessaire
347 Cette methode a pour but de commentariser la commande pointee par self
349 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
350 # (commentariser) un commentaire.
352 pos=self.treeParent.children.index(self)
353 commande_comment = self.item.get_objet_commentarise()
354 # On signale a l editeur du panel (le JDCDisplay) une modification
355 self.editor.init_modif()
356 self.treeParent.build_children()
357 self.treeParent.children[pos].select()
358 self.treeParent.children[pos].affichePanneau()
360 traceback.print_exc()
361 QMessageBox.critical( self.editor, "TOO BAD",str(e))
363 def unCommentIt(self):
365 Realise la decommentarisation de self
368 pos=self.treeParent.children.index(self)
369 commande,nom = self.item.uncomment()
370 self.editor.init_modif()
371 self.treeParent.build_children()
372 self.treeParent.children[pos].select()
373 self.treeParent.children[pos].affichePanneau()
375 QMessageBox.critical( self.editor, "Erreur !",str(e))
377 def addComment( self, after=True ):
379 Ajoute un commentaire a l'interieur du JDC :
381 self.editor.init_modif()
386 return self.append_brother( COMMENT, pos )
388 def addParameters( self, after=True ):
390 Ajoute un parametre a l'interieur du JDC :
392 self.editor.init_modif()
393 if after: pos = 'after'
395 child=self.append_brother( PARAMETERS, pos )
401 Rend le noeud courant (self) selectionne et deselectionne
404 #print "je suis sur select"
405 for item in self.tree.selectedItems() :
407 self.setSelected( True )
408 #self.setExpanded( True )
409 self.tree.setCurrentItem( self )
410 self.tree.node_selected= self
412 #------------------------------------------------------------------
413 # Methodes de creation et destruction de noeuds
414 # Certaines de ces methodes peuvent etre appelees depuis l'externe
415 #------------------------------------------------------------------
416 def append_brother(self,name,pos='after',plier=False):
418 Permet d'ajouter un objet frere a l'objet associe au noeud self
419 par defaut on l'ajoute immediatement apres
422 self.editor.init_modif()
424 verifiePosition=self.verifiePosition(name,pos)
425 if not verifiePosition : return 0
427 index = self.treeParent.children.index(self)
428 if pos == 'before': index = index
429 elif pos == 'after': index = index +1
431 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
433 return self.treeParent.append_child(name,pos=index,plier=plier)
435 def verifiePosition(self,name,pos):
436 from InterfaceQT4 import compojdc
437 if not (isinstance(self.treeParent, compojdc.Node)) : return True
438 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
439 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
441 etapes=self.item.jdc.etapes
442 if etapes == [] : return True
444 indexOu=etapes.index(self.item.object)
445 if pos=="after" : indexOu = indexOu+1
446 #print self.editor.Classement_Commandes_Ds_Arbre
451 for e in etapes[:indexOu] :
453 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
454 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
455 if indexEtape > indexName :
456 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
457 QMessageBox.information( None,tr('insertion impossible'),comment, )
459 for e in etapes[indexOu:] :
461 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
462 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
463 if indexEtape < indexName :
464 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
465 QMessageBox.information( None,tr('insertion impossible'),comment, )
469 def append_child(self,name,pos=None,plier=False):
471 Methode pour ajouter un objet fils a l'objet associe au noeud self.
472 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
473 ou en position intermediaire.
474 Si pos vaut None, on le place a la position du catalogue.
476 #print "************** append_child ",self.item.GetLabelText(), plier
477 self.editor.init_modif()
481 index = len(self.children)
482 elif type(pos) == types.IntType :
485 elif type(pos) == types.InstanceType:
486 # pos est un item. Il faut inserer name apres pos
487 index = self.item.get_index(pos) +1
488 elif type(name) == types.InstanceType:
489 index = self.item.get_index_child(name.nom)
491 index = self.item.get_index_child(name)
492 self.tree.inhibeExpand=True
493 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
497 # old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
499 # if plier : child.plieToutEtReaffiche()
500 # else : child.affichePanneau()
501 # print "dans le 1er Try"
504 # Souci pour gerer les copies des AFFE d'une commande à l autre
506 # child=self.children[index]
507 # if plier == True : child.setPlie()
508 # else : child.setDeplie()
509 # print "dans le 2nd Try"
511 # child=self.children[index]
512 # print "dans le except"
515 child=self.children[index]
516 if plier == True : child.setPlie()
517 else : child.setDeplie()
519 child=self.children[index]
520 #print "dans le except"
521 self.tree.inhibeExpand=False
525 self.editor.init_modif()
526 index = self.treeParent.children.index(self) - 1
527 if index < 0 : index =0
528 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
532 Methode externe pour la destruction de l'objet associe au noeud
534 self.editor.init_modif()
535 index = self.vraiParent.children.index(self) - 1
536 if index < 0 : index =0
538 if self.item.nom == "VARIABLE" :
541 ret=self.vraiParent.item.suppitem(self.item)
542 self.treeParent.build_children()
543 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
544 else: toselect=self.treeParent
545 if recalcule : jdc.recalcule_etat_correlation()
546 from InterfaceQT4 import compojdc
547 # cas ou on detruit dans l arbre sans affichage
548 if isinstance(self.treeParent,compojdc.Node) :
549 toselect.affichePanneau()
551 if self.treeParent.fenetre== None : return
552 #print "J appelle reaffiche de browser apres delete"
553 self.treeParent.fenetre.reaffiche(toselect)
555 def deleteMultiple(self,liste=()):
557 Methode externe pour la destruction d une liste de noeud
559 from InterfaceQT4 import compojdc
560 self.editor.init_modif()
565 while not(isinstance(jdc,compojdc.Node)):
568 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
569 if noeud.item.nom == "VARIABLE" : recalcule=1
570 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
571 if index < 0 : index =0
573 # Cas ou on détruit dans une ETape
575 parentPosition=self.treeParent
576 while not(isinstance(parentPosition, compojdc.Node)):
577 index=parentPosition.treeParent.children.index(parentPosition)
578 parentPosition=parentPosition.treeParent
581 noeud.treeParent.item.suppitem(noeud.item)
584 if recalcule : jdc.recalcule_etat_correlation()
585 try : toselect=parentPosition.children[index]
586 except : toselect=jdc
588 toselect.affichePanneau()
590 # #------------------------------------------------------------------
593 #print "onValid pour ", self.item.nom
594 if hasattr(self,'fenetre') and self.fenetre:
595 self.fenetre.setValide()
596 if self.item.nom == "VARIABLE" and self.item.isvalid():
597 self.item.jdc.recalcule_etat_correlation()
598 if hasattr(self.item,'forceRecalcul'):
599 self.forceRecalculChildren(self.item.forceRecalcul)
600 self.editor.init_modif()
602 self.update_node_valid()
603 self.update_node_label()
604 self.update_node_texte()
606 def onAdd(self,object):
607 #print "onAdd pour ", self.item.nom
608 self.editor.init_modif()
610 #print "dans onAdd" ,self.item
611 # PN -- non necessaire si item=jdc
612 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
614 def onSupp(self,object):
615 #print "onSupp pour ", self.item.nom
616 self.editor.init_modif()
618 # PN -- non necessaire si item=jdc
619 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
621 def detruit_les_noeuds_issus_de_blocs(self,bloc):
622 from InterfaceQT4 import compobloc
623 if (isinstance(bloc,compobloc.Node)) :
624 for node in bloc.childrenComplete :
625 self.detruit_les_noeuds_issus_de_blocs(node)
626 parent=node.treeParent
627 #print "je detruit " , node.item.GetLabelText()
628 parent.removeChild(node)
630 def update_node_valid(self):
631 """Cette methode remet a jour la validite du noeud (icone)
634 repIcon=QString(self.appliEficas.repIcon)
635 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
636 self.setIcon(0,monIcone)
639 def update_node_label(self):
640 """ Met a jour le label du noeud """
641 #print "NODE update_node_label", self.item.GetLabelText()
642 labeltext,fonte,couleur = self.item.GetLabelText()
644 #self.setText(0, labeltext)
647 def update_node_label_in_blue(self):
648 if hasattr(self.appliEficas,'noeudColore'):
649 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
650 self.appliEficas.noeudColore.update_node_label()
651 self.setTextColor( 0,Qt.blue )
652 labeltext,fonte,couleur = self.item.GetLabelText()
653 self.setText(0, labeltext)
654 self.appliEficas.noeudColore=self
656 def update_plusieurs_node_label_in_blue(self,liste):
657 if hasattr(self.appliEficas,'listeNoeudsColores'):
658 for noeud in self.appliEficas.listeNoeudsColores:
659 noeud.setTextColor( 0,Qt.black)
660 noeud.update_node_label()
661 self.appliEficas.listeNoeudsColores=[]
663 noeud.setTextColor( 0,Qt.blue )
664 labeltext,fonte,couleur = noeud.item.GetLabelText()
665 noeud.setText(0, labeltext)
666 self.appliEficas.listeNoeudsColores.append(noeud)
668 def update_node_texte_in_black(self):
669 """ Met a jour les noms des SD et valeurs des mots-cles """
670 self.setTextColor( 1,Qt.black )
671 value = self.item.GetText()
672 self.setText(1, value)
674 def update_node_texte(self):
675 """ Met a jour les noms des SD et valeurs des mots-cles """
676 value = self.item.GetText()
677 self.setText(1, value)
679 def update_node_texte_in_blue(self):
680 self.setTextColor( 1,Qt.blue )
681 value = self.item.GetText()
682 self.setText(1, value)
684 def update_nodes(self):
685 #print 'NODE update_nodes', self.item.GetLabelText()
686 self.build_children()
688 def update_valid(self) :
689 """Cette methode a pour but de mettre a jour la validite du noeud
690 et de propager la demande de mise a jour a son parent
692 #print "NODE update_valid", self.item.GetLabelText()
693 self.update_node_valid()
695 self.treeParent.update_valid()
699 def update_texte(self):
700 """ Met a jour les noms des SD et valeurs des mots-cles """
701 #print "NODE update_texte", self.item.GetLabelText()
702 self.update_node_texte()
703 if self.isExpanded() :
704 for child in self.children:
705 if child.isHidden() == false : child.update_texte()
708 def forceRecalculChildren(self,niveau):
709 if self.state=='recalcule' :
712 self.state='recalcule'
713 if hasattr(self.item,'object'):
714 self.item.object.state="modified"
715 for child in self.children:
716 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
720 def doPaste(self,node_selected,pos='after'):
722 Déclenche la copie de l'objet item avec pour cible
723 l'objet passé en argument : node_selected
725 #print 'je passe dans doPaste'
726 objet_a_copier = self.item.get_copie_objet()
727 child=node_selected.doPasteCommande(objet_a_copier,pos)
730 def doPasteCommande(self,objet_a_copier,pos='after'):
732 Réalise la copie de l'objet passé en argument qui est nécessairement
737 child = self.append_brother(objet_a_copier,pos)
742 def doPastePremier(self,objet_a_copier):
744 Réalise la copie de l'objet passé en argument (objet_a_copier)
746 objet = objet_a_copier.item.get_copie_objet()
747 child = self.append_child(objet,pos='first')
751 def plieToutEtReaffiche(self):
752 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
753 self.editor.deplier = False
754 for item in self.children :
756 self.affichePanneau()
758 def deplieToutEtReaffiche(self):
759 self.editor.deplier = True
760 for item in self.children :
762 self.affichePanneau()
765 #print "je mets inhibeExpand a true dans setPlie"
766 #print "je suis dans plieTout", self.item.get_nom()
768 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
770 self.tree.inhibeExpand=True
771 self.tree.collapseItem(self)
772 self.setPlieChildren()
773 self.tree.inhibeExpand=False
774 #print "je mets inhibeExpand a false dans setPlie"
777 # on ne plie pas au niveau 1
779 # for item in self.children :
780 # item.appartientAUnNoeudPlie=False
782 def setPlieChildren(self):
784 for c in self.children :
786 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
787 c.appartientAUnNoeudPlie=True
791 # Pour les blocs et les motcles list
792 # on affiche un niveau de plus
793 from InterfaceQT4 import compobloc
794 from InterfaceQT4 import compomclist
795 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
796 niveauPere=self.treeParent
797 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
798 niveauPere=niveauPere.treeParent
799 for c in self.children :
800 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
803 # on affiche un niveau de plus
804 #if isinstance(self,compomclist.Node) :
805 #if isinstance(self,compobloc.Node) :
806 # niveauPere=self.treeParent
807 # while (isinstance(niveauPere,compobloc.Node)):
808 # niveauPere=niveauPere.treeParent
809 # for c in self.children :
810 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
813 #print "je mets inhibeExpand a true dans setDeplie"
814 self.tree.inhibeExpand=True
816 self.tree.expandItem(self)
817 self.setDeplieChildren()
818 self.tree.inhibeExpand=False
819 #print "je mets inhibeExpand a false dans setDePlie"
821 def setDeplieChildren(self):
822 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
823 for c in self.children :
824 c.setDeplieChildren()
825 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText()
826 c.appartientAUnNoeudPlie=False
830 def selectAvant(self):
831 i=self.item.jdc.etapes.index(self.item.object)
833 cherche=self.item.jdc.etapes[i-1]
835 cherche=self.item.jdc.etapes[-1]
837 for i in self.tree.racine.children :
838 if i.item.object== cherche :
841 if node : node.affichePanneau()
843 def selectApres(self):
844 i=self.item.jdc.etapes.index(self.item.object)
846 cherche=self.item.jdc.etapes[i+1]
848 cherche=self.item.jdc.etapes[0]
850 for i in self.tree.racine.children :
851 if i.item.object== cherche :
854 if node : node.affichePanneau()