Salome HOME
pb d accent. on les enleve en français
[tools/eficas.git] / InterfaceQT4 / browser.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import string,re
22 import types,sys,os
23 import traceback
24 import typeNode
25 import pdb
26 from PyQt4 import *
27 from PyQt4.QtGui  import *
28 from PyQt4.QtCore import *
29 from Extensions.i18n import tr
30 from monChoixCommande import MonChoixCommande
31
32 class JDCTree( QTreeWidget ):
33     def __init__( self, jdc_item, QWParent):        
34         #if hasattr(QWParent,'widgetTree') : 
35         self.editor        = QWParent
36         self.plie=False
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")
43            else :
44                  self.headerItem().setText(0,  "Commande   ")
45            self.setColumnWidth(0,200)
46            self.setExpandsOnDoubleClick(False)
47            self.setSelectionMode(3)
48         else :
49            QTreeWidget.__init__(self, None ) 
50         self.item          = jdc_item
51         self.tree          = self        
52         self.appliEficas   = self.editor.appliEficas
53         self.childrenComplete=[]
54         self.childrenIssusDesBlocs=[]
55         self.racine=self.item.itemNode(self,self.item)
56  
57         self.itemCourrant=None
58
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)
62
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 !=[] :  
70
71             
72            if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
73            else : self.racine.children[0].deplieToutEtReaffiche()
74         
75
76            self.racine.children[0].fenetre.donnePremier()
77         else : self.racine.affichePanneau()
78         #PNPNPN
79         #pdb.set_trace()
80
81     def contextMenuEvent(self,event) :
82         #print "contextMenuEvent"
83         coord=event.globalPos()
84         item= self.currentItem()
85         self.handleContextMenu(item,coord)
86
87     def handleContextMenu(self,item,coord):
88         """
89         Private slot to show the context menu of the listview.
90         
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
94         """
95         #print "handleContextMenu"
96         if item == None : return
97         if item.existeMenu == 0 : return
98         if item.menu == None:
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)            
104             
105
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
110         itemParent=item
111         while not (hasattr (itemParent,'getPanel2')) : 
112            itemParent=itemParent.treeParent 
113         if self.tree.node_selected != itemParent : 
114              item.setExpanded(False)
115              return
116
117         itemParent=item
118         item.setPlie()
119         item.plieToutEtReaffiche()
120
121     def handleExpandedItem(self,item):
122         #print "dans ExpandItem", self.inhibeExpand  
123         if self.inhibeExpand == True : return
124         #print "apres if"
125         itemParent=item
126         while not (hasattr (itemParent,'getPanel2')) : 
127            if itemParent.plie==True : itemParent.setDeplie()
128            itemParent=itemParent.treeParent 
129         #print "apres if"
130         if self.tree.node_selected != itemParent : 
131              item.setExpanded(True)
132              #print "je suis la"
133              return
134         item.deplieToutEtReaffiche()
135
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
141         itemParent=item
142         #print self.itemCourrant
143         while not (hasattr (itemParent,'getPanel2')) : 
144            if itemParent.plie==True : itemParent.setDeplie()
145            itemParent=itemParent.treeParent 
146         #print itemParent
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()
154         #try :
155         if 1:
156            fr = item.item.get_fr()
157            if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
158         #except:
159         else :
160             pass
161         self.inhibeExpand == False 
162         #print "je mets inhibeExpand a false handleOnItem"
163
164
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')
169  
170 # type de noeud
171 COMMENT     = "COMMENTAIRE"
172 PARAMETERS  = "PARAMETRE"
173  
174 class JDCNode(QTreeWidgetItem):
175     def __init__( self, treeParent, item):
176         #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
177         self.a=0
178         self.item        = item
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=[]
186                         
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() ) )
193
194         mesColonnes=QStringList()
195         if self.editor.enteteQTree=='complet': mesColonnes <<  name << value
196         else : mesColonnes <<  name
197
198         if self.treeParent.plie==True :
199             self.plie        = True
200             self.appartientAUnNoeudPlie=True
201         else :
202             self.plie        = False
203             self.appartientAUnNoeudPlie = False
204         #print "self.plie", self.plie
205         #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie
206         #print self.treeParent
207
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
219
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)
223         else :
224            QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
225            self.treeParent.childrenComplete.append(self)
226
227         self.setToolTip(0,QString(self.item.get_fr()))
228         self.setToolTip(1,QString(self.item.get_fr()))
229
230         repIcon=QString(self.appliEficas.repIcon)
231         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
232         self.setIcon(0,monIcone)
233
234         self.children = []
235         self.build_children()
236         self.menu=None
237         self.existeMenu=1
238
239         self.item.connect("valid",self.onValid,())
240         self.item.connect("supp" ,self.onSupp,())
241         self.item.connect("add"  ,self.onAdd,())
242         self.state=""
243         self.fenetre=None
244         try :
245           if self.item.getObject().isBLOC() : 
246                 self.setExpanded(True) 
247                 self.plie=False
248         except :
249           pass
250
251
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()
256         
257         listeExpanded=[]
258         for item in self.childrenComplete :
259             #print dir(item)
260             #if item.isExpanded():
261             #   if self.childrenComplete.index(item) < posInsertion :
262             #      listeExpanded.append(self.childrenComplete.index(item))
263             #      print dir(item.item )
264             #   else :
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)
269
270         #print listeExpanded
271         self.children = []
272         self.childrenComplete = []
273         sublist = self.item._GetSubList()
274         ind=0
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()
279             #print item
280             #if ind in listeExpanded : nouvelItem.setExpanded(1)
281  
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
286             #ind=ind+1
287
288         #print "*********** fin build_children ",self.item, self.item.GetLabelText()
289         
290     def chercheNoeudCorrespondant(self,objSimp):
291         sublist = self.item._GetSubList()
292         for node in self.childrenComplete:
293             if node.item.object==objSimp : return node
294         return None
295
296     def affichePanneau(self) :
297         print "dans affichePanneau appel getPanel2", self.item.GetLabelText()
298         if self.item.isactif(): 
299            itemParent=self
300            print self
301            print self.getPanel2
302            while not (hasattr (itemParent,'getPanel2')) : 
303                 itemParent=itemParent.treeParent 
304            if itemParent!=self : 
305               itemParent.affichePanneau()
306               return
307            print self.getPanel2
308            self.fenetre=self.getPanel2()
309         else:
310             from monInactifPanel import PanelInactif
311             self.fenetre = PanelInactif(self,self.editor)
312          
313         self.editor.widgetCentraleLayout.addWidget(self.fenetre)
314         #print "widgetCentraleLayout = ", self.editor.widgetCentraleLayout
315         #print "nouvelle fenetre ", self.fenetre, " associee a ", self
316
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
321
322         if self.editor.anciennefenetre != None : 
323            a=self.editor.anciennefenetre.close()
324            #print "je ferme ", self.editor.anciennefenetre
325
326         if self.editor.widgetTree !=None  : index=1
327         else : index=0
328
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)
334         self.select()
335         self.tree.inhibeExpand=False
336         #print "fin de affichePanneau"
337         #print "______________________________"
338           
339
340     def createPopUpMenu(self):
341         #implemente dans les noeuds derives si necessaire
342         self.existeMenu = 0
343
344     def commentIt(self):
345         """
346         Cette methode a pour but de commentariser la commande pointee par self
347         """
348         # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
349         # (commentariser) un commentaire.
350         try :
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()
358         except Exception,e:
359             traceback.print_exc()
360             QMessageBox.critical( self.editor, "TOO BAD",str(e))
361         
362     def unCommentIt(self):
363         """
364         Realise la decommentarisation de self
365         """
366         try :
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()
373         except Exception,e:
374             QMessageBox.critical( self.editor, "Erreur !",str(e))
375         
376     def addComment( self, after=True ):
377         """
378         Ajoute un commentaire a l'interieur du JDC :
379         """
380         self.editor.init_modif()
381         if after:
382             pos = 'after'
383         else:
384             pos = 'before'
385         return self.append_brother( COMMENT, pos )
386                 
387     def addParameters( self, after=True ):
388         """
389         Ajoute un parametre a l'interieur du JDC :
390         """
391         self.editor.init_modif()
392         if after: pos = 'after'
393         else: pos = 'before'
394         child=self.append_brother( PARAMETERS, pos )
395         return  child
396     
397     
398     def select( self ):
399         """
400         Rend le noeud courant (self) selectionne et deselectionne
401         tous les autres
402         """        
403         #print "je suis sur select"
404         for item in self.tree.selectedItems() :
405             item.setSelected(0)
406         self.setSelected( True )    
407         #self.setExpanded( True )    
408         self.tree.setCurrentItem( self )    
409         self.tree.node_selected= self
410                                
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):
416         """
417         Permet d'ajouter un objet frere a l'objet associe au noeud self
418         par defaut on l'ajoute immediatement apres 
419         Methode externe
420         """
421         self.editor.init_modif()
422         index = self.treeParent.children.index(self)
423         if   pos == 'before': index = index
424         elif pos == 'after': index = index +1
425         else:
426             print unicode(pos), tr("  n'est pas un index valide pour append_brother")
427             return 0
428         return self.treeParent.append_child(name,pos=index,plier=plier)
429
430     def append_child(self,name,pos=None,plier=False):
431         """
432            Methode pour ajouter un objet fils a l'objet associe au noeud self.
433            On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
434            ou en position intermediaire.
435            Si pos vaut None, on le place a la position du catalogue.
436         """
437         #print "************** append_child ",self.item.GetLabelText(), plier
438         self.editor.init_modif()
439         if pos == 'first':
440             index = 0
441         elif pos == 'last':
442             index = len(self.children)
443         elif type(pos) == types.IntType :
444             # position fixee
445             index = pos
446         elif type(pos) == types.InstanceType:
447             # pos est un item. Il faut inserer name apres pos
448             index = self.item.get_index(pos) +1
449         elif type(name) == types.InstanceType:
450             index = self.item.get_index_child(name.nom)
451         else:
452             index = self.item.get_index_child(name)
453         self.tree.inhibeExpand=True
454         obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
455         if obj is None:obj=0
456         if obj == 0:return 0
457         #try :
458         #  old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
459         #  child=old_obj[-1]
460         #  if plier : child.plieToutEtReaffiche()
461         #  else     : child.affichePanneau() 
462         #  print "dans le 1er Try"
463         #else :
464         #except:
465           # Souci pour gerer les copies des AFFE d'une commande à l autre
466         #  try :
467         #     child=self.children[index]
468         #     if plier == True : child.setPlie()
469         #     else             : child.setDeplie() 
470         #     print "dans le 2nd Try"
471         #  except :
472         #     child=self.children[index]
473         #     print "dans le except"
474         try :
475         #if 1:
476            child=self.children[index]
477            if plier == True : child.setPlie()
478            else             : child.setDeplie() 
479         except :
480            child=self.children[index]
481            #print "dans le except"
482         self.tree.inhibeExpand=False
483         return child
484
485     def deplace(self):
486         self.editor.init_modif()
487         index = self.treeParent.children.index(self) - 1 
488         if index < 0 : index =0
489         ret=self.treeParent.item.deplaceEntite(self.item.getObject())
490
491     def delete(self):
492         """ 
493             Methode externe pour la destruction de l'objet associe au noeud
494         """
495         self.editor.init_modif()
496         index = self.vraiParent.children.index(self) - 1 
497         if index < 0 : index =0
498         recalcule=0
499         if self.item.nom == "VARIABLE" :
500            recalcule=1
501            jdc=self.item.jdc
502         ret=self.vraiParent.item.suppitem(self.item)
503         self.treeParent.build_children()
504         if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
505         else: toselect=self.treeParent
506         if recalcule : jdc.recalcule_etat_correlation()
507         from InterfaceQT4 import compojdc
508         # cas ou on detruit dans l arbre sans affichage
509         if isinstance(self.treeParent,compojdc.Node) : 
510            toselect.affichePanneau()
511         else :
512            if self.treeParent.fenetre== None : return
513            #print "J appelle reaffiche de browser apres delete"
514            self.treeParent.fenetre.reaffiche(toselect)
515
516     def deleteMultiple(self,liste=()):
517         """ 
518             Methode externe pour la destruction d une liste de noeud
519         """
520         from InterfaceQT4 import compojdc 
521         self.editor.init_modif()
522         index=9999
523         recalcule=0
524         jdc=self.treeParent
525         parentPosition=jdc
526         while not(isinstance(jdc,compojdc.Node)):
527               jdc=jdc.treeParent
528         for noeud in liste :
529             if not( isinstance(noeud.treeParent, compojdc.Node)): continue
530             if noeud.item.nom == "VARIABLE" : recalcule=1
531             if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
532         if index < 0 : index =0
533
534         # Cas ou on détruit dans une ETape
535         if index == 9999 : 
536               parentPosition=self.treeParent
537               while not(isinstance(parentPosition, compojdc.Node)):
538                  index=parentPosition.treeParent.children.index(parentPosition)
539                  parentPosition=parentPosition.treeParent
540
541         for noeud in liste:
542             noeud.treeParent.item.suppitem(noeud.item)
543
544         jdc.build_children()
545         if recalcule : jdc.recalcule_etat_correlation()
546         try    : toselect=parentPosition.children[index]
547         except : toselect=jdc
548         toselect.select()
549         toselect.affichePanneau()
550 #        
551 #    #------------------------------------------------------------------
552     def onValid(self):        
553
554         #print "onValid pour ", self.item.nom
555         if hasattr(self,'fenetre') and self.fenetre: 
556            self.fenetre.setValide()
557         if self.item.nom == "VARIABLE" and self.item.isvalid():
558            self.item.jdc.recalcule_etat_correlation()
559         if hasattr(self.item,'forceRecalcul'):
560            self.forceRecalculChildren(self.item.forceRecalcul)
561         self.editor.init_modif()
562         
563         self.update_node_valid()
564         self.update_node_label()
565         self.update_node_texte()
566
567     def onAdd(self,object):
568         #print "onAdd pour ", self.item.nom
569         self.editor.init_modif()
570         self.update_nodes()
571         #print "dans onAdd" ,self.item 
572         # PN -- non necessaire si item=jdc
573         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
574  
575     def onSupp(self,object):
576         #print "onSupp pour ", self.item.nom
577         self.editor.init_modif()
578         self.update_nodes()
579         # PN -- non necessaire si item=jdc
580         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
581          
582     def detruit_les_noeuds_issus_de_blocs(self,bloc):
583         from InterfaceQT4 import compobloc
584         if (isinstance(bloc,compobloc.Node)) :
585            for node in bloc.childrenComplete :
586                self.detruit_les_noeuds_issus_de_blocs(node)
587                parent=node.treeParent
588                #print "je detruit " , node.item.GetLabelText()
589                parent.removeChild(node)
590
591     def update_node_valid(self):
592         """Cette methode remet a jour la validite du noeud (icone)
593            Elle appelle isvalid
594         """
595         repIcon=QString(self.appliEficas.repIcon)
596         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
597         self.setIcon(0,monIcone)
598
599
600     def update_node_label(self):
601         """ Met a jour le label du noeud """
602         #print "NODE update_node_label", self.item.GetLabelText()
603         labeltext,fonte,couleur = self.item.GetLabelText()
604         # PNPN a reflechir
605         #self.setText(0, labeltext)        
606     
607     
608     def update_node_label_in_blue(self):
609         if hasattr(self.appliEficas,'noeudColore'):
610            self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
611            self.appliEficas.noeudColore.update_node_label()
612         self.setTextColor( 0,Qt.blue )
613         labeltext,fonte,couleur = self.item.GetLabelText()
614         self.setText(0, labeltext)        
615         self.appliEficas.noeudColore=self
616
617     def update_plusieurs_node_label_in_blue(self,liste):
618         if hasattr(self.appliEficas,'listeNoeudsColores'):
619            for noeud in self.appliEficas.listeNoeudsColores:
620                noeud.setTextColor( 0,Qt.black)
621                noeud.update_node_label()
622         self.appliEficas.listeNoeudsColores=[]
623         for noeud in liste :
624             noeud.setTextColor( 0,Qt.blue )
625             labeltext,fonte,couleur = noeud.item.GetLabelText()
626             noeud.setText(0, labeltext)        
627             self.appliEficas.listeNoeudsColores.append(noeud)
628
629     def update_node_texte_in_black(self):
630         """ Met a jour les noms des SD et valeurs des mots-cles """
631         self.setTextColor( 1,Qt.black )
632         value = self.item.GetText()
633         self.setText(1, value)
634
635     def update_node_texte(self):
636         """ Met a jour les noms des SD et valeurs des mots-cles """
637         value = self.item.GetText()
638         self.setText(1, value)
639
640     def update_node_texte_in_blue(self):
641         self.setTextColor( 1,Qt.blue )
642         value = self.item.GetText()
643         self.setText(1, value)
644
645     def update_nodes(self):
646         #print 'NODE update_nodes', self.item.GetLabelText()
647         self.build_children()
648
649     def update_valid(self) :
650         """Cette methode a pour but de mettre a jour la validite du noeud
651            et de propager la demande de mise a jour a son parent
652         """
653         #print "NODE update_valid", self.item.GetLabelText()
654         self.update_node_valid()
655         try :
656           self.treeParent.update_valid()
657         except:
658           pass
659             
660     def update_texte(self):
661         """ Met a jour les noms des SD et valeurs des mots-cles """
662         #print "NODE update_texte", self.item.GetLabelText()
663         self.update_node_texte()
664         if self.isExpanded() :
665             for child in self.children:
666                 if child.isHidden() == false : child.update_texte()
667
668
669     def forceRecalculChildren(self,niveau):
670         if self.state=='recalcule' : 
671            self.state=""
672            return
673         self.state='recalcule'
674         if hasattr(self.item,'object'):
675            self.item.object.state="modified"
676         for child in self.children:
677            if niveau > 0 : child.forceRecalculChildren(niveau - 1)
678               
679         
680
681     def doPaste(self,node_selected,pos='after'):
682         """
683             Déclenche la copie de l'objet item avec pour cible
684             l'objet passé en argument : node_selected
685         """
686         #print 'je passe dans doPaste'
687         objet_a_copier = self.item.get_copie_objet()
688         child=node_selected.doPasteCommande(objet_a_copier,pos)
689         return child
690
691     def doPasteCommande(self,objet_a_copier,pos='after'):
692         """
693           Réalise la copie de l'objet passé en argument qui est nécessairement
694           une commande
695         """
696         child=None
697         try :
698           child = self.append_brother(objet_a_copier,pos)
699         except :
700            pass
701         return child
702
703     def doPastePremier(self,objet_a_copier):
704         """
705            Réalise la copie de l'objet passé en argument (objet_a_copier)
706         """
707         objet = objet_a_copier.item.get_copie_objet()
708         child = self.append_child(objet,pos='first')
709         return child
710
711
712     def plieToutEtReaffiche(self):
713         print "je suis dans plieToutEtReaffiche", self.item.get_nom()
714         self.editor.deplier = False
715         for item in self.children :
716             item.setPlie()
717         self.affichePanneau()
718
719     def deplieToutEtReaffiche(self):
720         self.editor.deplier = True
721         for item in self.children :
722             item.setDeplie()
723         self.affichePanneau()
724
725     def setPlie(self):
726         #print "je mets inhibeExpand a true dans setPlie"
727         #print "je suis dans plieTout", self.item.get_nom()
728         import compojdc
729         if self.fenetre == self.editor.fenetreCentraleAffichee  and isinstance(self.treeParent,compojdc.Node): 
730            return
731         self.tree.inhibeExpand=True
732         self.tree.collapseItem(self)
733         self.setPlieChildren()
734         self.tree.inhibeExpand=False
735         #print "je mets inhibeExpand a false dans setPlie"
736
737
738         # on ne plie pas au niveau 1
739         #   self.plie=False
740         #   for item in self.children :
741         #       item.appartientAUnNoeudPlie=False
742
743     def setPlieChildren(self):
744         self.plie=True
745         for c in self.children :
746             c.setPlieChildren()
747             #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
748             c.appartientAUnNoeudPlie=True
749             c.plie=True
750             c.setExpanded(False)
751
752         # Pour les blocs et les motcles list
753         # on affiche un niveau de plus
754         from InterfaceQT4 import compobloc
755         from InterfaceQT4 import compomclist
756         if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) : 
757             niveauPere=self.treeParent
758             while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) : 
759                niveauPere=niveauPere.treeParent
760             for c in self.children :
761                 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
762                 c.setExpanded(False)
763
764         # on affiche un niveau de plus
765         #if isinstance(self,compomclist.Node)  : 
766         #if isinstance(self,compobloc.Node)  : 
767         #    niveauPere=self.treeParent
768         #    while (isinstance(niveauPere,compobloc.Node)):
769         #       niveauPere=niveauPere.treeParent
770         #    for c in self.children :
771         #        c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
772
773     def setDeplie(self):
774         #print "je mets inhibeExpand a true dans setDeplie"
775         self.tree.inhibeExpand=True
776         self.plie=False
777         self.tree.expandItem(self)
778         self.setDeplieChildren()
779         self.tree.inhibeExpand=False
780         #print "je mets inhibeExpand a false dans setDePlie"
781
782     def setDeplieChildren(self):
783         #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
784         for c in self.children :
785             c.setDeplieChildren()
786             #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText()
787             c.appartientAUnNoeudPlie=False
788             c.setExpanded(True)
789             c.plie=False
790        
791     def selectAvant(self):
792         i=self.item.jdc.etapes.index(self.item.object)
793         try :
794            cherche=self.item.jdc.etapes[i-1]
795         except :
796            cherche=self.item.jdc.etapes[-1]
797         node=None
798         for i in self.tree.racine.children :
799             if i.item.object== cherche  : 
800                node=i
801                break
802         if node : node.affichePanneau()
803
804     def selectApres(self):
805         i=self.item.jdc.etapes.index(self.item.object)
806         try :
807            cherche=self.item.jdc.etapes[i+1]
808         except :
809            cherche=self.item.jdc.etapes[0]
810         node=None
811         for i in self.tree.racine.children :
812             if i.item.object== cherche  : 
813                node=i
814                break
815         if node : node.affichePanneau()