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 determine import monEnvQT5
29 from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem
30 from PyQt5.QtGui import QIcon
31 from PyQt5.QtCore import Qt
33 from PyQt4.QtGui import *
34 from PyQt4.QtCore import *
35 from Extensions.i18n import tr
36 from gereRegles import GereRegles
37 from monChoixCommande import MonChoixCommande
39 class JDCTree( QTreeWidget,GereRegles ):
40 def __init__( self, jdc_item, QWParent):
41 #if hasattr(QWParent,'widgetTree') :
42 self.editor = QWParent
44 if self.editor.widgetTree !=None :
45 QTreeWidget.__init__(self, self.editor.widgetTree )
46 self.editor.verticalLayout_2.addWidget(self)
47 if self.editor.enteteQTree=='complet':
48 self.headerItem().setText(0, "Commande ")
49 self.headerItem().setText(1, "Concept/Valeur")
51 self.headerItem().setText(0, "Commande ")
52 self.setColumnWidth(0,200)
53 self.setExpandsOnDoubleClick(False)
54 self.setSelectionMode(3)
56 QTreeWidget.__init__(self, None )
59 self.appliEficas = self.editor.appliEficas
60 self.childrenComplete=[]
61 self.racine=self.item.itemNode(self,self.item)
63 self.itemCourrant=None
66 self.itemClicked.connect(self.handleOnItem)
67 self.itemCollapsed.connect(self.handleCollapsedItem)
68 self.itemExpanded.connect(self.handleExpandedItem)
70 self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
71 self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
72 self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
74 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
75 self.node_selected=self.racine
76 self.inhibeExpand=True
77 self.expandItem(self.racine)
78 self.inhibeExpand=False
79 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
80 if self.racine.children !=[] :
83 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
84 else : self.racine.children[0].deplieToutEtReaffiche()
87 self.racine.children[0].fenetre.donnePremier()
88 else : self.racine.affichePanneau()
92 def contextMenuEvent(self,event) :
93 #print "contextMenuEvent"
94 coord=event.globalPos()
95 item= self.currentItem()
96 self.handleContextMenu(item,coord)
98 def handleContextMenu(self,item,coord):
100 Private slot to show the context menu of the listview.
102 @param itm the selected listview item (QListWidgetItem)
103 @param coord the position of the mouse pointer (QPoint)
104 Attention : existeMenu permet de savoir si un menu est associe a cet item
106 #print "handleContextMenu"
107 if item == None : return
108 if item.existeMenu == 0 : return
109 if item.menu == None:
110 item.createPopUpMenu()
111 if item.menu != None:
112 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
113 item.Graphe.setEnabled(1)
114 item.menu.exec_(coord)
117 def handleCollapsedItem(self,item):
118 #print "dans CollapsedItem", self.inhibeExpand
119 if self.inhibeExpand == True : return
120 # On traite le cas de l item non selectionne
122 while not (hasattr (itemParent,'getPanel')) :
123 itemParent=itemParent.treeParent
124 if self.tree.node_selected != itemParent :
125 item.setExpanded(False)
130 item.plieToutEtReaffiche()
133 def handleExpandedItem(self,item):
134 #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
135 if self.inhibeExpand == True : return
137 while not (hasattr (itemParent,'getPanel')) :
138 if itemParent.plie==True : itemParent.setDeplie()
139 itemParent=itemParent.treeParent
140 if self.tree.node_selected != itemParent :
141 item.setExpanded(True)
143 item.deplieToutEtReaffiche()
144 self.inhibeExpand == False
147 def handleOnItem(self,item,int):
148 #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
150 from InterfaceQT4 import composimp
151 self.inhibeExpand == True
152 self.itemCourrant=item
155 while not (hasattr (itemParent,'getPanel')) :
156 if itemParent.plie==True : itemParent.setDeplie()
157 itemParent=itemParent.treeParent
159 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
161 estUneFeuille=(isinstance(item,composimp.Node))
162 # il faut afficher le parent
163 #print "estUneFeuille", estUneFeuille
164 #print "afficheCommandesPliees", self.editor.afficheCommandesPliees
165 if estUneFeuille : itemParent.affichePanneau()
166 elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
167 else : itemParent.affichePanneau()
170 if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
171 elif itemParent!=item:
172 self.tree.handleExpandedItem(item)
173 #item.fenetre.donnePremier()
174 #item.fenetre.rendActif()
175 #print 'il faut afficher le 1er'
178 fr = item.item.get_fr()
179 if self.editor: self.editor.affiche_commentaire(unicode(fr))
183 self.inhibeExpand == False
184 #print "je mets inhibeExpand a false handleOnItem"
187 def choisitPremier(self,name):
188 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
189 self.racine.fenetre.close()
190 new_node=self.racine.append_brother(name,'after')
193 COMMENT = "COMMENTAIRE"
194 PARAMETERS = "PARAMETRE"
196 class JDCNode(QTreeWidgetItem,GereRegles):
197 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
198 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
201 self.vraiParent = treeParent
202 self.treeParent = treeParent
203 self.tree = self.treeParent.tree
204 self.editor = self.treeParent.editor
205 self.appliEficas = treeParent.appliEficas
207 self.childrenComplete=[]
210 from InterfaceQT4 import compocomm
211 from InterfaceQT4 import compoparam
212 from InterfaceQT4 import composimp
213 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
214 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.GetLabelText()[0]))
215 else: name = tr(str(tr( item.nom))+" :")
216 value = tr(str( item.GetText() ) )
220 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
221 else : mesColonnes=(name,)
223 mesColonnes=QStringList()
224 if self.editor.enteteQTree=='complet': mesColonnes << name << value
225 else : mesColonnes << name
227 if self.treeParent.plie==True :
229 self.appartientAUnNoeudPlie=True
230 if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
233 self.appartientAUnNoeudPlie = False
235 #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
237 if ancien and itemExpand : self.plie = False
238 if ancien and not itemExpand : self.plie = True
239 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
241 from InterfaceQT4 import compobloc
242 from InterfaceQT4 import compomclist
244 ajoutAuParentduNoeud=0
245 self.treeParent=treeParent
246 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
247 self.treeParent.childrenComplete.append(self)
248 self.treeParent=self.treeParent.vraiParent
249 self.treeParent.childrenComplete.append(self)
252 if (isinstance(self,compobloc.Node) or (isinstance(self,compomclist.Node) and self.item.isMCList()) or ( hasattr(self.item.parent,'inhibeValidator') and isinstance(self,compomclist.Node) and self.item.parent.inhibeValidator)) :
253 # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
254 QTreeWidgetItem.__init__(self,None,mesColonnes)
256 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
259 self.setToolTip(0,self.item.get_fr())
260 self.setToolTip(1,self.item.get_fr())
261 repIcon=self.appliEficas.repIcon
263 self.setToolTip(0,QString(self.item.get_fr()))
264 self.setToolTip(1,QString(self.item.get_fr()))
265 repIcon=QString(self.appliEficas.repIcon)
267 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
268 self.setIcon(0,monIcone)
271 self.build_children()
275 self.item.connect("valid",self.onValid,())
276 self.item.connect("supp" ,self.onSupp,())
277 self.item.connect("add" ,self.onAdd,())
282 if self.item.getObject().isBLOC() :
283 self.setExpanded(True)
289 def build_children(self,posInsertion=10000):
290 """ Construit la liste des enfants de self """
291 """ Se charge de remettre les noeuds Expanded dans le meme etat """
292 #print "*********** build_children ",self,self.item, self.item.nom
294 self.listeItemExpanded=[]
295 self.listeItemPlie=[]
297 for enfant in self.childrenComplete :
298 if enfant.plie : self.listeItemPlie.append(enfant.item)
299 else : self.listeItemExpanded.append(enfant.item)
301 for enfant in self.childrenComplete :
302 parent=enfant.treeParent
303 parent.removeChild(enfant)
308 self.childrenComplete = []
309 sublist = self.item._GetSubList()
312 for item in sublist :
315 if item in self.listeItemExpanded : itemExpand=True; ancien=True
316 if item in self.listeItemPlie : itemExpand=False; ancien=True
317 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
318 self.children.append(nouvelItem)
320 #print "fin *********** build_children ",self,self.item, self.item.nom, self.children
323 def chercheNoeudCorrespondant(self,objSimp):
324 sublist = self.item._GetSubList()
325 for node in self.childrenComplete:
326 if node.item.object==objSimp : return node
330 def affichePanneau(self) :
331 #if self.item.isactif():
332 #if self.editor.code == 'ASTER' and not(self.item.isactif()) :
333 # posera des pb si un code decide d appeler FIN un mot clef
334 # on resoudera a ce moment la
335 # pour l instant pas de poussiere sous le tapis
336 if not(self.item.isactif()) :
337 from monWidgetInactif import MonWidgetInactif
338 self.fenetre = MonWidgetInactif(self,self.editor)
341 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
342 if itemParent!=self :
343 itemParent.affichePanneau()
345 self.fenetre=self.getPanel()
347 #print "hhhhhhhhhh", self.editor.splitter.sizes()
348 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
349 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
350 self.editor.widgetCentraleLayout.removeItem(widget)
351 # ceinture et bretelle
352 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
353 #print "iiiiiiiiiiiiiii", self.editor.splitter.sizes()
354 if self.editor.fenetreCentraleAffichee != None :
355 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
356 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
357 self.editor.fenetreCentraleAffichee.setParent(None)
358 self.editor.fenetreCentraleAffichee.close()
359 self.editor.fenetreCentraleAffichee.deleteLater()
361 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
362 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
363 self.editor.fenetreCentraleAffichee=self.fenetre
364 self.tree.node_selected= self
366 if self.editor.first :
367 #self.editor.splitter.setSizes((400,1400,400))
368 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
369 self.tree.inhibeExpand=True
370 self.tree.expandItem(self)
372 self.tree.inhibeExpand=False
373 #print "fin de affichePanneau", self.item.nom
374 #print "______________________________"
377 def createPopUpMenu(self):
378 #implemente dans les noeuds derives si necessaire
383 Cette methode a pour but de commentariser la commande pointee par self
385 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
386 # (commentariser) un commentaire.
388 pos=self.treeParent.children.index(self)
389 commande_comment = self.item.get_objet_commentarise()
390 # On signale a l editeur du panel (le JDCDisplay) une modification
391 self.editor.init_modif()
392 self.treeParent.build_children()
393 self.treeParent.children[pos].select()
394 self.treeParent.children[pos].affichePanneau()
396 traceback.print_exc()
397 QMessageBox.critical( self.editor, "TOO BAD",str(e))
399 def unCommentIt(self):
401 Realise la decommentarisation de self
404 pos=self.treeParent.children.index(self)
405 commande,nom = self.item.uncomment()
406 self.editor.init_modif()
407 self.treeParent.build_children()
408 self.treeParent.children[pos].select()
409 self.treeParent.children[pos].affichePanneau()
411 QMessageBox.critical( self.editor, "Erreur !",str(e))
413 def addComment( self, after=True ):
415 Ajoute un commentaire a l'interieur du JDC :
417 self.editor.init_modif()
422 return self.append_brother( COMMENT, pos )
424 def addParameters( self, after=True ):
426 Ajoute un parametre a l'interieur du JDC :
428 self.editor.init_modif()
429 if after: pos = 'after'
431 child=self.append_brother( PARAMETERS, pos )
437 Rend le noeud courant (self) selectionne et deselectionne
440 #print "select pour", self.item.nom
441 for item in self.tree.selectedItems() :
443 self.tree.setCurrentItem( self )
445 #------------------------------------------------------------------
446 # Methodes de creation et destruction de noeuds
447 # Certaines de ces methodes peuvent etre appelees depuis l'externe
448 #------------------------------------------------------------------
449 def append_brother(self,name,pos='after',plier=False):
451 Permet d'ajouter un objet frere a l'objet associe au noeud self
452 par defaut on l'ajoute immediatement apres
455 self.editor.init_modif()
457 from InterfaceQT4 import compojdc
458 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
460 index = self.treeParent.children.index(self)
461 if pos == 'before': index = index
462 elif pos == 'after': index = index +1
464 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
466 return self.treeParent.append_child(name,pos=index,plier=plier)
468 def verifiePosition(self,name,pos,aLaRacine=False):
469 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
470 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
472 etapes=self.item.get_jdc().etapes
473 if etapes == [] : return True
475 if aLaRacine == False :indexOu=etapes.index(self.item.object)
478 if pos=="after" : indexOu = indexOu+1
479 for e in etapes[:indexOu] :
481 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
482 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
483 if indexEtape > indexName :
484 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
485 QMessageBox.information( None,tr('insertion impossible'),comment, )
487 for e in etapes[indexOu:] :
489 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
490 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
491 if indexEtape < indexName :
492 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
493 QMessageBox.information( None,tr('insertion impossible'),comment, )
497 def append_child(self,name,pos=None,plier=False):
499 Methode pour ajouter un objet fils a l'objet associe au noeud self.
500 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
501 ou en position intermediaire.
502 Si pos vaut None, on le place a la position du catalogue.
504 #print "************** append_child ",self.item.GetLabelText(), plier
507 self.editor.init_modif()
511 index = len(self.children)
512 elif type(pos) == types.IntType :
515 elif type(pos) == types.InstanceType:
516 # pos est un item. Il faut inserer name apres pos
517 index = self.item.get_index(pos) +1
518 elif type(name) == types.InstanceType:
519 index = self.item.get_index_child(name.nom)
521 index = self.item.get_index_child(name)
523 # si on essaye d inserer a la racine
524 if (isinstance(self.treeParent,JDCTree) and index==0) :
525 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
526 if not verifiePosition : return 0
528 self.tree.inhibeExpand=True
529 obj=self.item.additem(name,index) # emet le signal 'add'
533 child=self.children[index]
534 if plier == True : child.setPlie()
535 else : child.setDeplie()
537 child=self.children[index]
538 self.tree.inhibeExpand=False
539 #print " fin append child"
543 self.editor.init_modif()
544 index = self.treeParent.children.index(self) - 1
545 if index < 0 : index =0
546 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
550 Methode externe pour la destruction de l'objet associe au noeud
552 self.editor.init_modif()
553 index = self.vraiParent.children.index(self) - 1
554 if index < 0 : index =0
556 if self.item.nom == "VARIABLE" :
559 ret,commentaire=self.vraiParent.item.suppitem(self.item)
561 self.editor.affiche_infos(commentaire,Qt.red)
563 self.editor.affiche_infos(commentaire)
564 self.treeParent.build_children()
565 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
566 else: toselect=self.treeParent
567 if recalcule : jdc.recalcule_etat_correlation()
569 if self.treeParent.childrenComplete :
570 notdeleted=self.treeParent.childrenComplete[index+1]
574 from InterfaceQT4 import compojdc
575 # cas ou on detruit dans l arbre sans affichage
576 if isinstance(self.treeParent,compojdc.Node) :
577 toselect.affichePanneau()
579 if self.treeParent.fenetre== None : return
580 #print "J appelle reaffiche de browser apres delete"
581 self.treeParent.fenetre.reaffiche(toselect)
583 def deleteMultiple(self,liste=()):
585 Methode externe pour la destruction d une liste de noeud
587 from InterfaceQT4 import compojdc
588 self.editor.init_modif()
593 while not(isinstance(jdc,compojdc.Node)):
596 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
597 if noeud.item.nom == "VARIABLE" : recalcule=1
598 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
599 if index < 0 : index =0
601 # Cas ou on détruit dans une ETape
603 parentPosition=self.treeParent
604 while not(isinstance(parentPosition, compojdc.Node)):
605 index=parentPosition.treeParent.children.index(parentPosition)
606 parentPosition=parentPosition.treeParent
609 noeud.treeParent.item.suppitem(noeud.item)
612 if recalcule : jdc.recalcule_etat_correlation()
613 try : toselect=parentPosition.children[index]
614 except : toselect=jdc
616 toselect.affichePanneau()
618 # #------------------------------------------------------------------
621 #print "onValid pour ", self.item.nom
622 if self.JESUISOFF==1 : return
623 if hasattr(self,'fenetre') and self.fenetre:
625 self.fenetre.setValide()
627 # print "onValid pour ", self.item.nom, self,'pb'
630 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
631 self.item.jdc.recalcule_etat_correlation()
632 if hasattr(self.item,'forceRecalcul'):
633 self.forceRecalculChildren(self.item.forceRecalcul)
634 self.editor.init_modif()
636 self.update_node_valid()
637 self.update_node_label()
638 self.update_node_texte()
640 def onAdd(self,object):
641 if self.JESUISOFF==1 : return
642 #print "onAdd pour ", self.item.nom, object.nom
643 self.editor.init_modif()
645 # PN -- non necessaire si item=jdc
646 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
648 def onSupp(self,object):
649 if self.JESUISOFF==1 : return
650 #print "onSup pour ", self.item.nom, object.nom
651 self.editor.init_modif()
653 # PN -- non necessaire si item=jdc
654 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
658 def update_node_valid(self):
659 """Cette methode remet a jour la validite du noeud (icone)
662 if monEnvQT5 : repIcon=self.appliEficas.repIcon
663 else : repIcon=QString(self.appliEficas.repIcon)
664 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
665 self.setIcon(0,monIcone)
668 def update_node_label(self):
669 """ Met a jour le label du noeud """
670 #print "NODE update_node_label", self.item.GetLabelText()
671 labeltext,fonte,couleur = self.item.GetLabelText()
673 #self.setText(0, labeltext)
676 def update_node_label_in_blue(self):
677 if hasattr(self.appliEficas,'noeudColore'):
678 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
679 self.appliEficas.noeudColore.update_node_label()
680 self.setTextColor( 0,Qt.blue )
681 labeltext,fonte,couleur = self.item.GetLabelText()
682 self.setText(0, labeltext)
683 self.appliEficas.noeudColore=self
685 def update_plusieurs_node_label_in_blue(self,liste):
686 if hasattr(self.appliEficas,'listeNoeudsColores'):
687 for noeud in self.appliEficas.listeNoeudsColores:
688 noeud.setTextColor( 0,Qt.black)
689 noeud.update_node_label()
690 self.appliEficas.listeNoeudsColores=[]
692 noeud.setTextColor( 0,Qt.blue )
693 labeltext,fonte,couleur = noeud.item.GetLabelText()
694 noeud.setText(0, labeltext)
695 self.appliEficas.listeNoeudsColores.append(noeud)
697 def update_node_texte_in_black(self):
698 """ Met a jour les noms des SD et valeurs des mots-cles """
699 self.setTextColor( 1,Qt.black )
700 value = self.item.GetText()
701 self.setText(1, value)
703 def update_node_texte(self):
704 """ Met a jour les noms des SD et valeurs des mots-cles """
705 value = self.item.GetText()
706 self.setText(1, value)
709 def update_node_texte_in_blue(self):
710 self.setTextColor( 1,Qt.blue )
711 value = self.item.GetText()
712 self.setText(1, value)
714 def update_nodes(self):
715 #print 'NODE update_nodes', self.item.GetLabelText()
716 self.build_children()
718 def update_valid(self) :
719 """Cette methode a pour but de mettre a jour la validite du noeud
720 et de propager la demande de mise a jour a son parent
722 #print "NODE update_valid", self.item.GetLabelText()
723 self.update_node_valid()
725 self.treeParent.update_valid()
729 def update_texte(self):
730 """ Met a jour les noms des SD et valeurs des mots-cles """
731 #print "NODE update_texte", self.item.GetLabelText()
732 self.update_node_texte()
733 if self.isExpanded() :
734 for child in self.children:
735 if child.isHidden() == false : child.update_texte()
738 def forceRecalculChildren(self,niveau):
739 if self.state=='recalcule' :
742 self.state='recalcule'
743 if hasattr(self.item,'object'):
744 self.item.object.state="modified"
745 for child in self.children:
746 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
750 def doPaste(self,node_selected,pos='after'):
752 Déclenche la copie de l'objet item avec pour cible
753 l'objet passé en argument : node_selected
755 #print 'je passe dans doPaste'
756 objet_a_copier = self.item.get_copie_objet()
757 child=node_selected.doPasteCommande(objet_a_copier,pos)
760 def doPasteCommande(self,objet_a_copier,pos='after'):
762 Réalise la copie de l'objet passé en argument qui est nécessairement
767 child = self.append_brother(objet_a_copier,pos)
772 def doPastePremier(self,objet_a_copier):
774 Réalise la copie de l'objet passé en argument (objet_a_copier)
776 objet = objet_a_copier.item.get_copie_objet()
777 child = self.append_child(objet,pos='first')
780 def plieToutEtReafficheSaufItem(self, itemADeplier):
781 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
782 from InterfaceQT4 import compojdc
783 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
784 self.editor.deplier = False
785 for item in self.children :
786 # il ne faut pas plier les blocs
787 from InterfaceQT4 import compobloc
788 if (isinstance(item,compobloc.Node)) : continue
790 if item==itemADeplier :
791 itemADeplier.setDeplie()
792 self.affichePanneau()
794 def plieToutEtReaffiche(self):
795 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
796 from InterfaceQT4 import compojdc
797 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
798 self.editor.deplier = False
799 for item in self.children :
800 # il ne faut pas plier les blocs
801 from InterfaceQT4 import compobloc
802 if (isinstance(item,compobloc.Node)) : continue
804 self.affichePanneau()
806 def deplieToutEtReaffiche(self):
807 self.editor.deplier = True
808 for item in self.children :
810 self.affichePanneau()
813 #print "je mets inhibeExpand a true dans setPlie"
814 #print "je suis dans plieTout", self.item.get_nom()
816 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
818 self.tree.inhibeExpand=True
819 self.tree.collapseItem(self)
820 self.setPlieChildren()
821 self.tree.inhibeExpand=False
822 #print "je mets inhibeExpand a false dans setPlie"
825 # on ne plie pas au niveau 1
827 # for item in self.children :
828 # item.appartientAUnNoeudPlie=False
830 def setPlieChildren(self):
831 #print "dans setPlieChildren pour", self.item.nom
833 for c in self.children :
835 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
836 c.appartientAUnNoeudPlie=True
838 #print "dans setPlieChildren plie", c.item.nom
841 # Pour les blocs et les motcles list
842 # on affiche un niveau de plus
843 from InterfaceQT4 import compobloc
844 from InterfaceQT4 import compomclist
845 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
846 niveauPere=self.treeParent
847 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
848 niveauPere=niveauPere.treeParent
849 for c in self.children :
850 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
851 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie
854 # on affiche un niveau de plus
855 #if isinstance(self,compomclist.Node) :
856 #if isinstance(self,compobloc.Node) :
857 # niveauPere=self.treeParent
858 # while (isinstance(niveauPere,compobloc.Node)):
859 # niveauPere=niveauPere.treeParent
860 # for c in self.children :
861 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
864 #print "dans setPlieChildren pour", self.item.nom
865 #print "je mets inhibeExpand a true dans setDeplie"
866 self.tree.inhibeExpand=True
868 self.tree.expandItem(self)
869 self.setDeplieChildren()
870 self.tree.inhibeExpand=False
871 #print "je mets inhibeExpand a false dans setDePlie"
873 def setDeplieChildren(self):
874 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
875 for c in self.children :
876 c.setDeplieChildren()
877 #print "dans setDeplieChildren ", c.item.nom
878 c.appartientAUnNoeudPlie=False
882 def selectAvant(self):
883 i=self.item.jdc.etapes.index(self.item.object)
885 cherche=self.item.jdc.etapes[i-1]
887 cherche=self.item.jdc.etapes[-1]
889 for i in self.tree.racine.children :
890 if i.item.object== cherche :
894 node.affichePanneau()
897 def selectApres(self):
898 i=self.item.jdc.etapes.index(self.item.object)
900 cherche=self.item.jdc.etapes[i+1]
902 cherche=self.item.jdc.etapes[0]
904 for i in self.tree.racine.children :
905 if i.item.object== cherche :
909 node.affichePanneau()