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.childrenIssusDesBlocs=[]
56 self.racine=self.item.itemNode(self,self.item)
58 self.itemCourrant=None
60 self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
61 self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
62 self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
64 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
65 self.node_selected=self.racine
66 self.inhibeExpand=True
67 self.expandItem(self.racine)
68 self.inhibeExpand=False
69 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
70 if self.racine.children !=[] :
73 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
74 else : self.racine.children[0].deplieToutEtReaffiche()
77 self.racine.children[0].fenetre.donnePremier()
78 else : self.racine.affichePanneau()
82 def contextMenuEvent(self,event) :
83 #print "contextMenuEvent"
84 coord=event.globalPos()
85 item= self.currentItem()
86 self.handleContextMenu(item,coord)
88 def handleContextMenu(self,item,coord):
90 Private slot to show the context menu of the listview.
92 @param itm the selected listview item (QListWidgetItem)
93 @param coord the position of the mouse pointer (QPoint)
94 Attention : existeMenu permet de savoir si un menu est associe a cet item
96 #print "handleContextMenu"
97 if item == None : return
98 if item.existeMenu == 0 : return
100 item.createPopUpMenu()
101 if item.menu != None:
102 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
103 item.Graphe.setEnabled(1)
104 item.menu.exec_(coord)
107 def handleCollapsedItem(self,item):
108 #print "dans CollapsedItem", self.inhibeExpand
109 if self.inhibeExpand == True : return
110 # On traite le cas de l item non selectionne
112 while not (hasattr (itemParent,'getPanel2')) :
113 itemParent=itemParent.treeParent
114 if self.tree.node_selected != itemParent :
115 item.setExpanded(False)
120 item.plieToutEtReaffiche()
122 def handleExpandedItem(self,item):
123 #print "dans ExpandItem", self.inhibeExpand
124 if self.inhibeExpand == True : return
127 while not (hasattr (itemParent,'getPanel2')) :
128 if itemParent.plie==True : itemParent.setDeplie()
129 itemParent=itemParent.treeParent
131 if self.tree.node_selected != itemParent :
132 item.setExpanded(True)
135 item.deplieToutEtReaffiche()
137 def handleOnItem(self,item,int):
138 #if (len(self.selectedIndexes())!=2): return
139 #print "je passe dans handleOnItem pour ", self.item.nom
140 self.inhibeExpand == True
141 self.itemCourrant=item
143 #print self.itemCourrant
144 while not (hasattr (itemParent,'getPanel2')) :
145 if itemParent.plie==True : itemParent.setDeplie()
146 itemParent=itemParent.treeParent
147 #print itemParent.item.nom
148 #print itemParent.fenetre
149 #print self.editor.afficheCommandesPliees
150 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
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,GereRegles):
175 def __init__( self, treeParent, item):
176 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
177 #print "creation d'un noeud : ", item.nom
180 self.vraiParent = treeParent
181 self.treeParent = treeParent
182 self.tree = self.treeParent.tree
183 self.editor = self.treeParent.editor
184 self.appliEficas = treeParent.appliEficas
185 self.treeParent.childrenIssusDesBlocs=[]
186 self.childrenComplete=[]
188 from InterfaceQT4 import compocomm
189 from InterfaceQT4 import compoparam
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
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():
301 #print self.getPanel2
302 while not (hasattr (itemParent,'getPanel2')) :
303 itemParent=itemParent.treeParent
304 if itemParent!=self :
305 itemParent.affichePanneau()
307 #print self.getPanel2
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 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 # old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
501 # if plier : child.plieToutEtReaffiche()
502 # else : child.affichePanneau()
503 # print "dans le 1er Try"
506 # Souci pour gerer les copies des AFFE d'une commande à l autre
508 # child=self.children[index]
509 # if plier == True : child.setPlie()
510 # else : child.setDeplie()
511 # print "dans le 2nd Try"
513 # child=self.children[index]
514 # print "dans le except"
517 child=self.children[index]
518 if plier == True : child.setPlie()
519 else : child.setDeplie()
521 child=self.children[index]
522 #print "dans le except"
523 self.tree.inhibeExpand=False
527 self.editor.init_modif()
528 index = self.treeParent.children.index(self) - 1
529 if index < 0 : index =0
530 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
534 Methode externe pour la destruction de l'objet associe au noeud
536 self.editor.init_modif()
537 index = self.vraiParent.children.index(self) - 1
538 if index < 0 : index =0
540 if self.item.nom == "VARIABLE" :
543 ret=self.vraiParent.item.suppitem(self.item)
544 self.treeParent.build_children()
545 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
546 else: toselect=self.treeParent
547 if recalcule : jdc.recalcule_etat_correlation()
548 from InterfaceQT4 import compojdc
549 # cas ou on detruit dans l arbre sans affichage
550 if isinstance(self.treeParent,compojdc.Node) :
551 toselect.affichePanneau()
553 if self.treeParent.fenetre== None : return
554 #print "J appelle reaffiche de browser apres delete"
555 self.treeParent.fenetre.reaffiche(toselect)
557 def deleteMultiple(self,liste=()):
559 Methode externe pour la destruction d une liste de noeud
561 from InterfaceQT4 import compojdc
562 self.editor.init_modif()
567 while not(isinstance(jdc,compojdc.Node)):
570 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
571 if noeud.item.nom == "VARIABLE" : recalcule=1
572 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
573 if index < 0 : index =0
575 # Cas ou on détruit dans une ETape
577 parentPosition=self.treeParent
578 while not(isinstance(parentPosition, compojdc.Node)):
579 index=parentPosition.treeParent.children.index(parentPosition)
580 parentPosition=parentPosition.treeParent
583 noeud.treeParent.item.suppitem(noeud.item)
586 if recalcule : jdc.recalcule_etat_correlation()
587 try : toselect=parentPosition.children[index]
588 except : toselect=jdc
590 toselect.affichePanneau()
592 # #------------------------------------------------------------------
595 #print "onValid pour ", self.item.nom
596 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
597 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
598 self.item.jdc.recalcule_etat_correlation()
599 if hasattr(self.item,'forceRecalcul'):
600 self.forceRecalculChildren(self.item.forceRecalcul)
601 self.editor.init_modif()
603 self.update_node_valid()
604 self.update_node_label()
605 self.update_node_texte()
607 def onAdd(self,object):
608 #print "onAdd pour ", self.item.nom
609 self.editor.init_modif()
611 #print "dans onAdd" ,self.item
612 # PN -- non necessaire si item=jdc
613 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
615 def onSupp(self,object):
616 #print "onSupp pour ", self.item.nom
617 self.editor.init_modif()
619 # PN -- non necessaire si item=jdc
620 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
622 def detruit_les_noeuds_issus_de_blocs(self,bloc):
623 from InterfaceQT4 import compobloc
624 if (isinstance(bloc,compobloc.Node)) :
625 for node in bloc.childrenComplete :
626 self.detruit_les_noeuds_issus_de_blocs(node)
627 parent=node.treeParent
628 #print "je detruit " , node.item.GetLabelText()
629 parent.removeChild(node)
631 def update_node_valid(self):
632 """Cette methode remet a jour la validite du noeud (icone)
635 repIcon=QString(self.appliEficas.repIcon)
636 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
637 self.setIcon(0,monIcone)
640 def update_node_label(self):
641 """ Met a jour le label du noeud """
642 #print "NODE update_node_label", self.item.GetLabelText()
643 labeltext,fonte,couleur = self.item.GetLabelText()
645 #self.setText(0, labeltext)
648 def update_node_label_in_blue(self):
649 if hasattr(self.appliEficas,'noeudColore'):
650 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
651 self.appliEficas.noeudColore.update_node_label()
652 self.setTextColor( 0,Qt.blue )
653 labeltext,fonte,couleur = self.item.GetLabelText()
654 self.setText(0, labeltext)
655 self.appliEficas.noeudColore=self
657 def update_plusieurs_node_label_in_blue(self,liste):
658 if hasattr(self.appliEficas,'listeNoeudsColores'):
659 for noeud in self.appliEficas.listeNoeudsColores:
660 noeud.setTextColor( 0,Qt.black)
661 noeud.update_node_label()
662 self.appliEficas.listeNoeudsColores=[]
664 noeud.setTextColor( 0,Qt.blue )
665 labeltext,fonte,couleur = noeud.item.GetLabelText()
666 noeud.setText(0, labeltext)
667 self.appliEficas.listeNoeudsColores.append(noeud)
669 def update_node_texte_in_black(self):
670 """ Met a jour les noms des SD et valeurs des mots-cles """
671 self.setTextColor( 1,Qt.black )
672 value = self.item.GetText()
673 self.setText(1, value)
675 def update_node_texte(self):
676 """ Met a jour les noms des SD et valeurs des mots-cles """
677 value = self.item.GetText()
678 self.setText(1, value)
680 def update_node_texte_in_blue(self):
681 self.setTextColor( 1,Qt.blue )
682 value = self.item.GetText()
683 self.setText(1, value)
685 def update_nodes(self):
686 #print 'NODE update_nodes', self.item.GetLabelText()
687 self.build_children()
689 def update_valid(self) :
690 """Cette methode a pour but de mettre a jour la validite du noeud
691 et de propager la demande de mise a jour a son parent
693 #print "NODE update_valid", self.item.GetLabelText()
694 self.update_node_valid()
696 self.treeParent.update_valid()
700 def update_texte(self):
701 """ Met a jour les noms des SD et valeurs des mots-cles """
702 #print "NODE update_texte", self.item.GetLabelText()
703 self.update_node_texte()
704 if self.isExpanded() :
705 for child in self.children:
706 if child.isHidden() == false : child.update_texte()
709 def forceRecalculChildren(self,niveau):
710 if self.state=='recalcule' :
713 self.state='recalcule'
714 if hasattr(self.item,'object'):
715 self.item.object.state="modified"
716 for child in self.children:
717 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
721 def doPaste(self,node_selected,pos='after'):
723 Déclenche la copie de l'objet item avec pour cible
724 l'objet passé en argument : node_selected
726 #print 'je passe dans doPaste'
727 objet_a_copier = self.item.get_copie_objet()
728 child=node_selected.doPasteCommande(objet_a_copier,pos)
731 def doPasteCommande(self,objet_a_copier,pos='after'):
733 Réalise la copie de l'objet passé en argument qui est nécessairement
738 child = self.append_brother(objet_a_copier,pos)
743 def doPastePremier(self,objet_a_copier):
745 Réalise la copie de l'objet passé en argument (objet_a_copier)
747 objet = objet_a_copier.item.get_copie_objet()
748 child = self.append_child(objet,pos='first')
752 def plieToutEtReaffiche(self):
753 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
754 self.editor.deplier = False
755 for item in self.children :
756 # il ne faut pas plier les blocs
757 from InterfaceQT4 import compobloc
758 if (isinstance(item,compobloc.Node)) : continue
760 self.affichePanneau()
762 def deplieToutEtReaffiche(self):
763 self.editor.deplier = True
764 for item in self.children :
766 self.affichePanneau()
769 #print "je mets inhibeExpand a true dans setPlie"
770 #print "je suis dans plieTout", self.item.get_nom()
772 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
774 self.tree.inhibeExpand=True
775 self.tree.collapseItem(self)
776 self.setPlieChildren()
777 self.tree.inhibeExpand=False
778 #print "je mets inhibeExpand a false dans setPlie"
781 # on ne plie pas au niveau 1
783 # for item in self.children :
784 # item.appartientAUnNoeudPlie=False
786 def setPlieChildren(self):
788 for c in self.children :
790 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
791 c.appartientAUnNoeudPlie=True
795 # Pour les blocs et les motcles list
796 # on affiche un niveau de plus
797 from InterfaceQT4 import compobloc
798 from InterfaceQT4 import compomclist
799 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
800 niveauPere=self.treeParent
801 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
802 niveauPere=niveauPere.treeParent
803 for c in self.children :
804 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
807 # on affiche un niveau de plus
808 #if isinstance(self,compomclist.Node) :
809 #if isinstance(self,compobloc.Node) :
810 # niveauPere=self.treeParent
811 # while (isinstance(niveauPere,compobloc.Node)):
812 # niveauPere=niveauPere.treeParent
813 # for c in self.children :
814 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
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 appartientAUnNoeudPlie=False ", c.item.GetLabelText()
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()