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 from InterfaceQT4 import composimp
140 self.inhibeExpand == True
141 self.itemCourrant=item
144 while not (hasattr (itemParent,'getPanel')) :
145 if itemParent.plie==True : itemParent.setDeplie()
146 itemParent=itemParent.treeParent
148 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
150 estUneFeuille=(isinstance(item,composimp.Node))
151 # il faut afficher le parent
152 print "estUneFeuille", estUneFeuille
153 print "afficheCommandesPliees", self.editor.afficheCommandesPliees
154 if estUneFeuille : itemParent.affichePanneau()
155 elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
156 else : itemParent.affichePanneau()
159 if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
160 elif itemParent!=item:
161 #self.tree.handleExpandedItem(item)
162 #item.fenetre.donnePremier()
163 #item.fenetre.rendActif()
164 print 'il faut afficher le 1er'
166 fr = item.item.get_fr()
167 if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
171 self.inhibeExpand == False
172 #print "je mets inhibeExpand a false handleOnItem"
175 def choisitPremier(self,name):
176 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
177 self.racine.fenetre.close()
178 new_node=self.racine.append_brother(name,'after')
181 COMMENT = "COMMENTAIRE"
182 PARAMETERS = "PARAMETRE"
184 class JDCNode(QTreeWidgetItem,GereRegles):
185 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
186 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
189 self.vraiParent = treeParent
190 self.treeParent = treeParent
191 self.tree = self.treeParent.tree
192 self.editor = self.treeParent.editor
193 self.appliEficas = treeParent.appliEficas
195 self.childrenComplete=[]
198 from InterfaceQT4 import compocomm
199 from InterfaceQT4 import compoparam
200 from InterfaceQT4 import composimp
201 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
202 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
203 else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
204 value = self.appliEficas.trUtf8(str( item.GetText() ) )
207 mesColonnes=QStringList()
208 if self.editor.enteteQTree=='complet': mesColonnes << name << value
209 else : mesColonnes << name
211 if self.treeParent.plie==True :
213 self.appartientAUnNoeudPlie=True
216 self.appartientAUnNoeudPlie = False
218 if ancien and itemExpand : self.plie = False
219 if ancien and not itemExpand : self.plie = True
220 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
222 from InterfaceQT4 import compobloc
223 from InterfaceQT4 import compomclist
225 ajoutAuParentduNoeud=0
226 self.treeParent=treeParent
227 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
228 self.treeParent.childrenComplete.append(self)
229 self.treeParent=self.treeParent.vraiParent
230 self.treeParent.childrenComplete.append(self)
231 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
232 QTreeWidgetItem.__init__(self,None,mesColonnes)
234 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
236 self.setToolTip(0,QString(self.item.get_fr()))
237 self.setToolTip(1,QString(self.item.get_fr()))
239 repIcon=QString(self.appliEficas.repIcon)
240 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
241 self.setIcon(0,monIcone)
244 self.build_children()
248 self.item.connect("valid",self.onValid,())
249 self.item.connect("supp" ,self.onSupp,())
250 self.item.connect("add" ,self.onAdd,())
255 if self.item.getObject().isBLOC() :
256 self.setExpanded(True)
262 def build_children(self,posInsertion=10000):
263 """ Construit la liste des enfants de self """
264 """ Se charge de remettre les noeuds Expanded dans le meme etat """
265 #print "*********** build_children ",self,self.item, self.item.nom
267 self.listeItemExpanded=[]
268 self.listeItemPlie=[]
270 for enfant in self.childrenComplete :
271 if enfant.plie : self.listeItemPlie.append(enfant.item)
272 else : self.listeItemExpanded.append(enfant.item)
274 for enfant in self.childrenComplete :
276 parent=enfant.treeParent
277 parent.removeChild(enfant)
282 self.childrenComplete = []
283 sublist = self.item._GetSubList()
286 for item in sublist :
289 if item in self.listeItemExpanded : itemExpand=True; ancien=True
290 if item in self.listeItemPlie : itemExpand=False; ancien=True
291 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
292 self.children.append(nouvelItem)
294 #print "fin *********** build_children ",self,self.item, self.item.nom
297 def chercheNoeudCorrespondant(self,objSimp):
298 sublist = self.item._GetSubList()
299 for node in self.childrenComplete:
300 if node.item.object==objSimp : return node
304 def affichePanneau(self) :
305 #print " affichePanneau " , self.item.nom
306 if self.item.isactif():
308 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
309 if itemParent!=self :
310 itemParent.affichePanneau()
312 self.fenetre=self.getPanel()
314 from monInactifPanel import PanelInactif
315 self.fenetre = PanelInactif(self,self.editor)
317 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
318 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
319 self.editor.widgetCentraleLayout.removeItem(widget)
320 # ceinture et bretelle
321 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
322 if self.editor.fenetreCentraleAffichee != None :
323 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
324 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
325 self.editor.fenetreCentraleAffichee.close()
327 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
328 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
329 self.editor.fenetreCentraleAffichee=self.fenetre
330 self.tree.node_selected= self
332 if self.editor.first :
333 self.editor.splitter.setSizes((400,1400,400))
334 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
335 self.tree.inhibeExpand=True
336 self.tree.expandItem(self)
338 self.tree.inhibeExpand=False
339 #print "fin de affichePanneau", self.item.nom
340 #print "______________________________"
343 def createPopUpMenu(self):
344 #implemente dans les noeuds derives si necessaire
349 Cette methode a pour but de commentariser la commande pointee par self
351 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
352 # (commentariser) un commentaire.
354 pos=self.treeParent.children.index(self)
355 commande_comment = self.item.get_objet_commentarise()
356 # On signale a l editeur du panel (le JDCDisplay) une modification
357 self.editor.init_modif()
358 self.treeParent.build_children()
359 self.treeParent.children[pos].select()
360 self.treeParent.children[pos].affichePanneau()
362 traceback.print_exc()
363 QMessageBox.critical( self.editor, "TOO BAD",str(e))
365 def unCommentIt(self):
367 Realise la decommentarisation de self
370 pos=self.treeParent.children.index(self)
371 commande,nom = self.item.uncomment()
372 self.editor.init_modif()
373 self.treeParent.build_children()
374 self.treeParent.children[pos].select()
375 self.treeParent.children[pos].affichePanneau()
377 QMessageBox.critical( self.editor, "Erreur !",str(e))
379 def addComment( self, after=True ):
381 Ajoute un commentaire a l'interieur du JDC :
383 self.editor.init_modif()
388 return self.append_brother( COMMENT, pos )
390 def addParameters( self, after=True ):
392 Ajoute un parametre a l'interieur du JDC :
394 self.editor.init_modif()
395 if after: pos = 'after'
397 child=self.append_brother( PARAMETERS, pos )
403 Rend le noeud courant (self) selectionne et deselectionne
406 print "select pour", self.item.nom
407 for item in self.tree.selectedItems() :
409 self.tree.setCurrentItem( 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 from InterfaceQT4 import compojdc
424 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : 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,aLaRacine=False):
435 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
436 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
438 etapes=self.item.get_jdc().etapes
439 if etapes == [] : return True
441 if aLaRacine == False :indexOu=etapes.index(self.item.object)
444 if pos=="after" : indexOu = indexOu+1
445 for e in etapes[:indexOu] :
447 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
448 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
449 if indexEtape > indexName :
450 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
451 QMessageBox.information( None,tr('insertion impossible'),comment, )
453 for e in etapes[indexOu:] :
455 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
456 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
457 if indexEtape < indexName :
458 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
459 QMessageBox.information( None,tr('insertion impossible'),comment, )
463 def append_child(self,name,pos=None,plier=False):
465 Methode pour ajouter un objet fils a l'objet associe au noeud self.
466 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
467 ou en position intermediaire.
468 Si pos vaut None, on le place a la position du catalogue.
470 #print "************** append_child ",self.item.GetLabelText(), plier
473 self.editor.init_modif()
477 index = len(self.children)
478 elif type(pos) == types.IntType :
481 elif type(pos) == types.InstanceType:
482 # pos est un item. Il faut inserer name apres pos
483 index = self.item.get_index(pos) +1
484 elif type(name) == types.InstanceType:
485 index = self.item.get_index_child(name.nom)
487 index = self.item.get_index_child(name)
489 # si on essaye d inserer a la racine
490 if (isinstance(self.treeParent,JDCTree) and index==0) :
491 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
492 if not verifiePosition : return 0
494 self.tree.inhibeExpand=True
495 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
499 child=self.children[index]
500 if plier == True : child.setPlie()
501 else : child.setDeplie()
503 child=self.children[index]
504 self.tree.inhibeExpand=False
505 #print " fin append child"
509 self.editor.init_modif()
510 index = self.treeParent.children.index(self) - 1
511 if index < 0 : index =0
512 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
516 Methode externe pour la destruction de l'objet associe au noeud
518 self.editor.init_modif()
519 index = self.vraiParent.children.index(self) - 1
520 if index < 0 : index =0
522 if self.item.nom == "VARIABLE" :
525 ret,commentaire=self.vraiParent.item.suppitem(self.item)
527 self.editor.affiche_infos(commentaire,Qt.red)
529 self.editor.affiche_infos(commentaire)
530 self.treeParent.build_children()
531 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
532 else: toselect=self.treeParent
533 if recalcule : jdc.recalcule_etat_correlation()
534 from InterfaceQT4 import compojdc
535 # cas ou on detruit dans l arbre sans affichage
536 if isinstance(self.treeParent,compojdc.Node) :
537 toselect.affichePanneau()
539 if self.treeParent.fenetre== None : return
540 #print "J appelle reaffiche de browser apres delete"
541 self.treeParent.fenetre.reaffiche(toselect)
543 def deleteMultiple(self,liste=()):
545 Methode externe pour la destruction d une liste de noeud
547 from InterfaceQT4 import compojdc
548 self.editor.init_modif()
553 while not(isinstance(jdc,compojdc.Node)):
556 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
557 if noeud.item.nom == "VARIABLE" : recalcule=1
558 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
559 if index < 0 : index =0
561 # Cas ou on détruit dans une ETape
563 parentPosition=self.treeParent
564 while not(isinstance(parentPosition, compojdc.Node)):
565 index=parentPosition.treeParent.children.index(parentPosition)
566 parentPosition=parentPosition.treeParent
569 noeud.treeParent.item.suppitem(noeud.item)
572 if recalcule : jdc.recalcule_etat_correlation()
573 try : toselect=parentPosition.children[index]
574 except : toselect=jdc
576 toselect.affichePanneau()
578 # #------------------------------------------------------------------
581 #print "onValid pour ", self.item.nom
582 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
583 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
584 self.item.jdc.recalcule_etat_correlation()
585 if hasattr(self.item,'forceRecalcul'):
586 self.forceRecalculChildren(self.item.forceRecalcul)
587 self.editor.init_modif()
589 self.update_node_valid()
590 self.update_node_label()
591 self.update_node_texte()
593 def onAdd(self,object):
594 if self.JESUISOFF==1 : return
595 #print "onAdd pour ", self.item.nom, object.nom
596 self.editor.init_modif()
598 # PN -- non necessaire si item=jdc
599 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
601 def onSupp(self,object):
602 if self.JESUISOFF==1 : return
603 #print "onSup pour ", self.item.nom, object.nom
604 self.editor.init_modif()
606 # PN -- non necessaire si item=jdc
607 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
612 def update_node_valid(self):
613 """Cette methode remet a jour la validite du noeud (icone)
616 repIcon=QString(self.appliEficas.repIcon)
617 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
618 self.setIcon(0,monIcone)
621 def update_node_label(self):
622 """ Met a jour le label du noeud """
623 #print "NODE update_node_label", self.item.GetLabelText()
624 labeltext,fonte,couleur = self.item.GetLabelText()
626 #self.setText(0, labeltext)
629 def update_node_label_in_blue(self):
630 if hasattr(self.appliEficas,'noeudColore'):
631 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
632 self.appliEficas.noeudColore.update_node_label()
633 self.setTextColor( 0,Qt.blue )
634 labeltext,fonte,couleur = self.item.GetLabelText()
635 self.setText(0, labeltext)
636 self.appliEficas.noeudColore=self
638 def update_plusieurs_node_label_in_blue(self,liste):
639 if hasattr(self.appliEficas,'listeNoeudsColores'):
640 for noeud in self.appliEficas.listeNoeudsColores:
641 noeud.setTextColor( 0,Qt.black)
642 noeud.update_node_label()
643 self.appliEficas.listeNoeudsColores=[]
645 noeud.setTextColor( 0,Qt.blue )
646 labeltext,fonte,couleur = noeud.item.GetLabelText()
647 noeud.setText(0, labeltext)
648 self.appliEficas.listeNoeudsColores.append(noeud)
650 def update_node_texte_in_black(self):
651 """ Met a jour les noms des SD et valeurs des mots-cles """
652 self.setTextColor( 1,Qt.black )
653 value = self.item.GetText()
654 self.setText(1, value)
656 def update_node_texte(self):
657 """ Met a jour les noms des SD et valeurs des mots-cles """
658 value = self.item.GetText()
659 self.setText(1, value)
662 def update_node_texte_in_blue(self):
663 self.setTextColor( 1,Qt.blue )
664 value = self.item.GetText()
665 self.setText(1, value)
667 def update_nodes(self):
668 #print 'NODE update_nodes', self.item.GetLabelText()
669 self.build_children()
671 def update_valid(self) :
672 """Cette methode a pour but de mettre a jour la validite du noeud
673 et de propager la demande de mise a jour a son parent
675 #print "NODE update_valid", self.item.GetLabelText()
676 self.update_node_valid()
678 self.treeParent.update_valid()
682 def update_texte(self):
683 """ Met a jour les noms des SD et valeurs des mots-cles """
684 #print "NODE update_texte", self.item.GetLabelText()
685 self.update_node_texte()
686 if self.isExpanded() :
687 for child in self.children:
688 if child.isHidden() == false : child.update_texte()
691 def forceRecalculChildren(self,niveau):
692 if self.state=='recalcule' :
695 self.state='recalcule'
696 if hasattr(self.item,'object'):
697 self.item.object.state="modified"
698 for child in self.children:
699 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
703 def doPaste(self,node_selected,pos='after'):
705 Déclenche la copie de l'objet item avec pour cible
706 l'objet passé en argument : node_selected
708 #print 'je passe dans doPaste'
709 objet_a_copier = self.item.get_copie_objet()
710 child=node_selected.doPasteCommande(objet_a_copier,pos)
713 def doPasteCommande(self,objet_a_copier,pos='after'):
715 Réalise la copie de l'objet passé en argument qui est nécessairement
720 child = self.append_brother(objet_a_copier,pos)
725 def doPastePremier(self,objet_a_copier):
727 Réalise la copie de l'objet passé en argument (objet_a_copier)
729 objet = objet_a_copier.item.get_copie_objet()
730 child = self.append_child(objet,pos='first')
733 def plieToutEtReafficheSaufItem(self, itemADeplier):
734 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
735 from InterfaceQT4 import compojdc
736 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
737 self.editor.deplier = False
738 for item in self.children :
739 # il ne faut pas plier les blocs
740 from InterfaceQT4 import compobloc
741 if (isinstance(item,compobloc.Node)) : continue
743 if item==itemADeplier :
744 itemADeplier.setDeplie()
745 self.affichePanneau()
747 def plieToutEtReaffiche(self):
748 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
749 from InterfaceQT4 import compojdc
750 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
751 self.editor.deplier = False
752 for item in self.children :
753 # il ne faut pas plier les blocs
754 from InterfaceQT4 import compobloc
755 if (isinstance(item,compobloc.Node)) : continue
757 self.affichePanneau()
759 def deplieToutEtReaffiche(self):
760 self.editor.deplier = True
761 for item in self.children :
763 self.affichePanneau()
766 #print "je mets inhibeExpand a true dans setPlie"
767 #print "je suis dans plieTout", self.item.get_nom()
769 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
771 self.tree.inhibeExpand=True
772 self.tree.collapseItem(self)
773 self.setPlieChildren()
774 self.tree.inhibeExpand=False
775 #print "je mets inhibeExpand a false dans setPlie"
778 # on ne plie pas au niveau 1
780 # for item in self.children :
781 # item.appartientAUnNoeudPlie=False
783 def setPlieChildren(self):
784 #print "dans setPlieChildren pour", self.item.nom
786 for c in self.children :
788 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
789 c.appartientAUnNoeudPlie=True
791 #print "dans setPlieChildren plie", c.item.nom
794 # Pour les blocs et les motcles list
795 # on affiche un niveau de plus
796 from InterfaceQT4 import compobloc
797 from InterfaceQT4 import compomclist
798 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
799 niveauPere=self.treeParent
800 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
801 niveauPere=niveauPere.treeParent
802 for c in self.children :
803 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
806 # on affiche un niveau de plus
807 #if isinstance(self,compomclist.Node) :
808 #if isinstance(self,compobloc.Node) :
809 # niveauPere=self.treeParent
810 # while (isinstance(niveauPere,compobloc.Node)):
811 # niveauPere=niveauPere.treeParent
812 # for c in self.children :
813 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
816 #print "dans setPlieChildren pour", self.item.nom
817 #print "je mets inhibeExpand a true dans setDeplie"
818 self.tree.inhibeExpand=True
820 self.tree.expandItem(self)
821 self.setDeplieChildren()
822 self.tree.inhibeExpand=False
823 #print "je mets inhibeExpand a false dans setDePlie"
825 def setDeplieChildren(self):
826 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
827 for c in self.children :
828 c.setDeplieChildren()
829 #print "dans setDeplieChildren ", c.item.nom
830 c.appartientAUnNoeudPlie=False
834 def selectAvant(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[-1]
841 for i in self.tree.racine.children :
842 if i.item.object== cherche :
845 if node : node.affichePanneau()
847 def selectApres(self):
848 i=self.item.jdc.etapes.index(self.item.object)
850 cherche=self.item.jdc.etapes[i+1]
852 cherche=self.item.jdc.etapes[0]
854 for i in self.tree.racine.children :
855 if i.item.object== cherche :
858 if node : node.affichePanneau()