]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/browser.py
Salome HOME
nettoyage des GetPanel et affichage pler deplier selon l ancien etat
[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 gereRegles import GereRegles
31 from monChoixCommande import MonChoixCommande
32
33 class JDCTree( QTreeWidget,GereRegles ):
34     def __init__( self, jdc_item, QWParent):        
35         #if hasattr(QWParent,'widgetTree') : 
36         self.editor        = QWParent
37         self.plie=False
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")
44            else :
45                  self.headerItem().setText(0,  "Commande   ")
46            self.setColumnWidth(0,200)
47            self.setExpandsOnDoubleClick(False)
48            self.setSelectionMode(3)
49         else :
50            QTreeWidget.__init__(self, None ) 
51         self.item          = jdc_item
52         self.tree          = self        
53         self.appliEficas   = self.editor.appliEficas
54         self.childrenComplete=[]
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,'getPanel')) : 
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,'getPanel')) : 
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
137     def handleOnItem(self,item,int):
138         #if (len(self.selectedIndexes())!=2): return
139         #print "je passe dans handleOnItem pour ", item.item.nom, item, item.item
140         self.inhibeExpand == True 
141         self.itemCourrant=item
142         itemParent=item
143         #print self.itemCourrant
144         while not (hasattr (itemParent,'getPanel')) : 
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()
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,GereRegles):
175     def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
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.JESUISOFF=0
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
195         mesColonnes=QStringList()
196         if self.editor.enteteQTree=='complet': mesColonnes <<  name << value
197         else : mesColonnes <<  name
198
199         if self.treeParent.plie==True :
200             self.plie        = True
201             self.appartientAUnNoeudPlie=True
202         else :
203             self.plie        = False
204             self.appartientAUnNoeudPlie = False
205         if ancien and itemExpand     : self.plie = False
206         if ancien and not itemExpand : self.plie = True 
207
208
209         from InterfaceQT4 import compobloc
210         from InterfaceQT4 import compomclist
211
212         ajoutAuParentduNoeud=0
213         self.treeParent=treeParent
214         while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) : 
215               self.treeParent.childrenComplete.append(self)
216               self.treeParent=self.treeParent.vraiParent
217         self.treeParent.childrenComplete.append(self)
218         if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) : 
219            QTreeWidgetItem.__init__(self,None,mesColonnes)
220         else :
221            QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
222
223         self.setToolTip(0,QString(self.item.get_fr()))
224         self.setToolTip(1,QString(self.item.get_fr()))
225
226         repIcon=QString(self.appliEficas.repIcon)
227         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
228         self.setIcon(0,monIcone)
229
230         self.children = []
231         self.build_children()
232         self.menu=None
233         self.existeMenu=1
234
235         self.item.connect("valid",self.onValid,())
236         self.item.connect("supp" ,self.onSupp,())
237         self.item.connect("add"  ,self.onAdd,())
238
239         self.state=""
240         self.fenetre=None
241         try :
242           if self.item.getObject().isBLOC() : 
243                 self.setExpanded(True) 
244                 self.plie=False
245         except :
246           pass
247
248
249     def build_children(self,posInsertion=10000):
250         """ Construit la liste des enfants de self """
251         """ Se charge de remettre les noeuds Expanded dans le meme etat """
252         #print "*********** build_children ",self,self.item, self.item.nom
253         
254         self.listeItemExpanded=[]
255         self.listeItemPlie=[]
256         for enfant in self.childrenComplete :
257             if enfant.isExpanded()      : self.listeItemExpanded.append(enfant.item)
258             if not(enfant.isExpanded()) : self.listeItemPlie.append(enfant.item)
259
260         for enfant in self.childrenComplete :
261             p=enfant.vraiParent
262             parent=enfant.treeParent
263             parent.removeChild(enfant)
264             enfant.JESUISOFF=1
265          
266         
267         self.children = []
268         self.childrenComplete = []
269         sublist = self.item._GetSubList()
270         ind=0
271         
272         for item in sublist :
273             itemExpand=False
274             ancien=False
275             if item in self.listeItemExpanded : itemExpand=True;  ancien=True
276             if item in self.listeItemPlie     : itemExpand=False; ancien=True
277             nouvelItem=item.itemNode(self,item,itemExpand,ancien)
278             self.children.append(nouvelItem)
279
280         #print "fin *********** build_children ",self,self.item, self.item.nom
281
282         
283     def chercheNoeudCorrespondant(self,objSimp):
284         sublist = self.item._GetSubList()
285         for node in self.childrenComplete:
286             if node.item.object==objSimp : return node
287         return None
288
289
290     def affichePanneau(self) :
291         #print " affichePanneau " , self.item.nom 
292         if self.item.isactif(): 
293            itemParent=self
294            while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent 
295            if itemParent!=self : 
296               itemParent.affichePanneau()
297               return
298            self.fenetre=self.getPanel()
299         else:
300             from monInactifPanel import PanelInactif
301             self.fenetre = PanelInactif(self,self.editor)
302          
303         self.editor.widgetCentraleLayout.addWidget(self.fenetre)
304
305         self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee
306         self.editor.fenetreCentraleAffichee=self.fenetre
307         self.tree.node_selected= self
308
309         if self.editor.anciennefenetre != None : 
310            a=self.editor.anciennefenetre.close()
311
312         if self.editor.widgetTree !=None  : index=1
313         else : index=0
314
315         if self.editor.first :
316            self.editor.splitter.setSizes((400,1400,400))
317            if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
318         self.tree.inhibeExpand=True
319         self.tree.expandItem(self)
320         self.select()
321         self.tree.inhibeExpand=False
322         #print "fin de affichePanneau"
323         #print "______________________________"
324           
325
326     def createPopUpMenu(self):
327         #implemente dans les noeuds derives si necessaire
328         self.existeMenu = 0
329
330     def commentIt(self):
331         """
332         Cette methode a pour but de commentariser la commande pointee par self
333         """
334         # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
335         # (commentariser) un commentaire.
336         try :
337             pos=self.treeParent.children.index(self)
338             commande_comment = self.item.get_objet_commentarise()
339             # On signale a l editeur du panel (le JDCDisplay) une modification
340             self.editor.init_modif()
341             self.treeParent.build_children()
342             self.treeParent.children[pos].select()
343             self.treeParent.children[pos].affichePanneau()
344         except Exception,e:
345             traceback.print_exc()
346             QMessageBox.critical( self.editor, "TOO BAD",str(e))
347         
348     def unCommentIt(self):
349         """
350         Realise la decommentarisation de self
351         """
352         try :
353             pos=self.treeParent.children.index(self)
354             commande,nom = self.item.uncomment()
355             self.editor.init_modif()
356             self.treeParent.build_children()
357             self.treeParent.children[pos].select()
358             self.treeParent.children[pos].affichePanneau()
359         except Exception,e:
360             QMessageBox.critical( self.editor, "Erreur !",str(e))
361         
362     def addComment( self, after=True ):
363         """
364         Ajoute un commentaire a l'interieur du JDC :
365         """
366         self.editor.init_modif()
367         if after:
368             pos = 'after'
369         else:
370             pos = 'before'
371         return self.append_brother( COMMENT, pos )
372                 
373     def addParameters( self, after=True ):
374         """
375         Ajoute un parametre a l'interieur du JDC :
376         """
377         self.editor.init_modif()
378         if after: pos = 'after'
379         else: pos = 'before'
380         child=self.append_brother( PARAMETERS, pos )
381         return  child
382     
383     
384     def select( self ):
385         """
386         Rend le noeud courant (self) selectionne et deselectionne
387         tous les autres
388         """        
389         for item in self.tree.selectedItems() :
390             item.setSelected(0)
391         self.setSelected( True )    
392         #self.setExpanded( True )    
393         self.tree.setCurrentItem( self )    
394         self.tree.node_selected= self
395                                
396     #------------------------------------------------------------------
397     # Methodes de creation et destruction de noeuds
398     # Certaines de ces methodes peuvent etre appelees depuis l'externe
399     #------------------------------------------------------------------
400     def append_brother(self,name,pos='after',plier=False):
401         """
402         Permet d'ajouter un objet frere a l'objet associe au noeud self
403         par defaut on l'ajoute immediatement apres 
404         Methode externe
405         """
406         self.editor.init_modif()
407
408         from InterfaceQT4 import compojdc
409         if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos)  : return 0
410         
411         index = self.treeParent.children.index(self)
412         if   pos == 'before': index = index
413         elif pos == 'after': index = index +1
414         else:
415             print unicode(pos), tr("  n'est pas un index valide pour append_brother")
416             return 0
417         return self.treeParent.append_child(name,pos=index,plier=plier)
418
419     def verifiePosition(self,name,pos,aLaRacine=False):
420         if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
421         indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
422
423         etapes=self.item.get_jdc().etapes
424         if etapes == [] : return True
425
426         if aLaRacine == False :indexOu=etapes.index(self.item.object)
427         else : indexOu=0
428
429         if pos=="after" : indexOu = indexOu+1
430         for e in etapes[:indexOu] :
431             nom=e.nom
432             if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
433             indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
434             if indexEtape > indexName :
435                comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
436                QMessageBox.information( None,tr('insertion impossible'),comment, )
437                return False
438         for e in etapes[indexOu:] :
439             nom=e.nom
440             if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
441             indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
442             if indexEtape < indexName :
443                comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
444                QMessageBox.information( None,tr('insertion impossible'),comment, )
445                return False
446         return True
447
448     def append_child(self,name,pos=None,plier=False):
449         """
450            Methode pour ajouter un objet fils a l'objet associe au noeud self.
451            On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
452            ou en position intermediaire.
453            Si pos vaut None, on le place a la position du catalogue.
454         """
455         #print "************** append_child ",self.item.GetLabelText(), plier
456
457          
458         self.editor.init_modif()
459         if pos == 'first':
460             index = 0
461         elif pos == 'last':
462             index = len(self.children)
463         elif type(pos) == types.IntType :
464             # position fixee
465             index = pos
466         elif type(pos) == types.InstanceType:
467             # pos est un item. Il faut inserer name apres pos
468             index = self.item.get_index(pos) +1
469         elif type(name) == types.InstanceType:
470             index = self.item.get_index_child(name.nom)
471         else:
472             index = self.item.get_index_child(name)
473
474         # si on essaye d inserer a la racine
475         if (isinstance(self.treeParent,JDCTree) and index==0) :
476            verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
477            if not verifiePosition : return 0
478
479         self.tree.inhibeExpand=True
480         obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
481         if obj is None:obj=0
482         if obj == 0:return 0
483         try :
484            child=self.children[index]
485            if plier == True : child.setPlie()
486            else             : child.setDeplie() 
487         except :
488            child=self.children[index]
489         self.tree.inhibeExpand=False
490         #print " fin append child"
491         return child
492
493     def deplace(self):
494         self.editor.init_modif()
495         index = self.treeParent.children.index(self) - 1 
496         if index < 0 : index =0
497         ret=self.treeParent.item.deplaceEntite(self.item.getObject())
498
499     def delete(self):
500         """ 
501             Methode externe pour la destruction de l'objet associe au noeud
502         """
503         self.editor.init_modif()
504         index = self.vraiParent.children.index(self) - 1 
505         if index < 0 : index =0
506         recalcule=0
507         if self.item.nom == "VARIABLE" :
508            recalcule=1
509            jdc=self.item.jdc
510         ret,commentaire=self.vraiParent.item.suppitem(self.item)
511         if ret==0 :
512           self.editor.affiche_infos(commentaire,Qt.red)
513         else :
514           self.editor.affiche_infos(commentaire)
515         self.treeParent.build_children()
516         if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
517         else: toselect=self.treeParent
518         if recalcule : jdc.recalcule_etat_correlation()
519         from InterfaceQT4 import compojdc
520         # cas ou on detruit dans l arbre sans affichage
521         if isinstance(self.treeParent,compojdc.Node) : 
522            toselect.affichePanneau()
523         else :
524            if self.treeParent.fenetre== None : return
525            #print "J appelle reaffiche de browser apres delete"
526            self.treeParent.fenetre.reaffiche(toselect)
527
528     def deleteMultiple(self,liste=()):
529         """ 
530             Methode externe pour la destruction d une liste de noeud
531         """
532         from InterfaceQT4 import compojdc 
533         self.editor.init_modif()
534         index=9999
535         recalcule=0
536         jdc=self.treeParent
537         parentPosition=jdc
538         while not(isinstance(jdc,compojdc.Node)):
539               jdc=jdc.treeParent
540         for noeud in liste :
541             if not( isinstance(noeud.treeParent, compojdc.Node)): continue
542             if noeud.item.nom == "VARIABLE" : recalcule=1
543             if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
544         if index < 0 : index =0
545
546         # Cas ou on détruit dans une ETape
547         if index == 9999 : 
548               parentPosition=self.treeParent
549               while not(isinstance(parentPosition, compojdc.Node)):
550                  index=parentPosition.treeParent.children.index(parentPosition)
551                  parentPosition=parentPosition.treeParent
552
553         for noeud in liste:
554             noeud.treeParent.item.suppitem(noeud.item)
555
556         jdc.build_children()
557         if recalcule : jdc.recalcule_etat_correlation()
558         try    : toselect=parentPosition.children[index]
559         except : toselect=jdc
560         toselect.select()
561         toselect.affichePanneau()
562 #        
563 #    #------------------------------------------------------------------
564     def onValid(self):        
565
566         #print "onValid pour ", self.item.nom
567         if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
568         if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
569            self.item.jdc.recalcule_etat_correlation()
570         if hasattr(self.item,'forceRecalcul'):
571            self.forceRecalculChildren(self.item.forceRecalcul)
572         self.editor.init_modif()
573         
574         self.update_node_valid()
575         self.update_node_label()
576         self.update_node_texte()
577
578     def onAdd(self,object):
579         if self.JESUISOFF==1 : return
580         self.editor.init_modif()
581         self.update_nodes()
582
583         # PN -- non necessaire si item=jdc
584         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
585  
586     def onSupp(self,object):
587         if self.JESUISOFF==1 : return
588         self.editor.init_modif()
589         self.update_nodes()
590         # PN -- non necessaire si item=jdc
591         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
592          
593
594
595
596     def update_node_valid(self):
597         """Cette methode remet a jour la validite du noeud (icone)
598            Elle appelle isvalid
599         """
600         repIcon=QString(self.appliEficas.repIcon)
601         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
602         self.setIcon(0,monIcone)
603
604
605     def update_node_label(self):
606         """ Met a jour le label du noeud """
607         #print "NODE update_node_label", self.item.GetLabelText()
608         labeltext,fonte,couleur = self.item.GetLabelText()
609         # PNPN a reflechir
610         #self.setText(0, labeltext)        
611     
612     
613     def update_node_label_in_blue(self):
614         if hasattr(self.appliEficas,'noeudColore'):
615            self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
616            self.appliEficas.noeudColore.update_node_label()
617         self.setTextColor( 0,Qt.blue )
618         labeltext,fonte,couleur = self.item.GetLabelText()
619         self.setText(0, labeltext)        
620         self.appliEficas.noeudColore=self
621
622     def update_plusieurs_node_label_in_blue(self,liste):
623         if hasattr(self.appliEficas,'listeNoeudsColores'):
624            for noeud in self.appliEficas.listeNoeudsColores:
625                noeud.setTextColor( 0,Qt.black)
626                noeud.update_node_label()
627         self.appliEficas.listeNoeudsColores=[]
628         for noeud in liste :
629             noeud.setTextColor( 0,Qt.blue )
630             labeltext,fonte,couleur = noeud.item.GetLabelText()
631             noeud.setText(0, labeltext)        
632             self.appliEficas.listeNoeudsColores.append(noeud)
633
634     def update_node_texte_in_black(self):
635         """ Met a jour les noms des SD et valeurs des mots-cles """
636         self.setTextColor( 1,Qt.black )
637         value = self.item.GetText()
638         self.setText(1, value)
639
640     def update_node_texte(self):
641         """ Met a jour les noms des SD et valeurs des mots-cles """
642         value = self.item.GetText()
643         self.setText(1, value)
644         
645
646     def update_node_texte_in_blue(self):
647         self.setTextColor( 1,Qt.blue )
648         value = self.item.GetText()
649         self.setText(1, value)
650
651     def update_nodes(self):
652         #print 'NODE update_nodes', self.item.GetLabelText()
653         self.build_children()
654
655     def update_valid(self) :
656         """Cette methode a pour but de mettre a jour la validite du noeud
657            et de propager la demande de mise a jour a son parent
658         """
659         #print "NODE update_valid", self.item.GetLabelText()
660         self.update_node_valid()
661         try :
662           self.treeParent.update_valid()
663         except:
664           pass
665             
666     def update_texte(self):
667         """ Met a jour les noms des SD et valeurs des mots-cles """
668         #print "NODE update_texte", self.item.GetLabelText()
669         self.update_node_texte()
670         if self.isExpanded() :
671             for child in self.children:
672                 if child.isHidden() == false : child.update_texte()
673
674
675     def forceRecalculChildren(self,niveau):
676         if self.state=='recalcule' : 
677            self.state=""
678            return
679         self.state='recalcule'
680         if hasattr(self.item,'object'):
681            self.item.object.state="modified"
682         for child in self.children:
683            if niveau > 0 : child.forceRecalculChildren(niveau - 1)
684               
685         
686
687     def doPaste(self,node_selected,pos='after'):
688         """
689             Déclenche la copie de l'objet item avec pour cible
690             l'objet passé en argument : node_selected
691         """
692         #print 'je passe dans doPaste'
693         objet_a_copier = self.item.get_copie_objet()
694         child=node_selected.doPasteCommande(objet_a_copier,pos)
695         return child
696
697     def doPasteCommande(self,objet_a_copier,pos='after'):
698         """
699           Réalise la copie de l'objet passé en argument qui est nécessairement
700           une commande
701         """
702         child=None
703         try :
704           child = self.append_brother(objet_a_copier,pos)
705         except :
706            pass
707         return child
708
709     def doPastePremier(self,objet_a_copier):
710         """
711            Réalise la copie de l'objet passé en argument (objet_a_copier)
712         """
713         objet = objet_a_copier.item.get_copie_objet()
714         child = self.append_child(objet,pos='first')
715         return child
716
717
718     def plieToutEtReaffiche(self):
719         #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
720         self.editor.deplier = False
721         for item in self.children :
722             # il ne faut pas plier les blocs 
723             from InterfaceQT4 import compobloc
724             if (isinstance(item,compobloc.Node)) : continue
725             item.setPlie()
726         self.affichePanneau()
727
728     def deplieToutEtReaffiche(self):
729         self.editor.deplier = True
730         for item in self.children :
731             item.setDeplie()
732         self.affichePanneau()
733
734     def setPlie(self):
735         #print "je mets inhibeExpand a true dans setPlie"
736         #print "je suis dans plieTout", self.item.get_nom()
737         import compojdc
738         if self.fenetre == self.editor.fenetreCentraleAffichee  and isinstance(self.treeParent,compojdc.Node): 
739            return
740         self.tree.inhibeExpand=True
741         self.tree.collapseItem(self)
742         self.setPlieChildren()
743         self.tree.inhibeExpand=False
744         #print "je mets inhibeExpand a false dans setPlie"
745
746
747         # on ne plie pas au niveau 1
748         #   self.plie=False
749         #   for item in self.children :
750         #       item.appartientAUnNoeudPlie=False
751
752     def setPlieChildren(self):
753         #print "dans setPlieChildren pour", self.item.nom
754         self.plie=True
755         for c in self.children :
756             c.setPlieChildren()
757             #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
758             c.appartientAUnNoeudPlie=True
759             c.plie=True
760             #print "dans setPlieChildren plie", c.item.nom
761             c.setExpanded(False)
762
763         # Pour les blocs et les motcles list
764         # on affiche un niveau de plus
765         from InterfaceQT4 import compobloc
766         from InterfaceQT4 import compomclist
767         if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) : 
768             niveauPere=self.treeParent
769             while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) : 
770                niveauPere=niveauPere.treeParent
771             for c in self.children :
772                 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
773                 c.setExpanded(False)
774
775         # on affiche un niveau de plus
776         #if isinstance(self,compomclist.Node)  : 
777         #if isinstance(self,compobloc.Node)  : 
778         #    niveauPere=self.treeParent
779         #    while (isinstance(niveauPere,compobloc.Node)):
780         #       niveauPere=niveauPere.treeParent
781         #    for c in self.children :
782         #        c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
783
784     def setDeplie(self):
785         #print "dans setPlieChildren pour", self.item.nom
786         #print "je mets inhibeExpand a true dans setDeplie"
787         self.tree.inhibeExpand=True
788         self.plie=False
789         self.tree.expandItem(self)
790         self.setDeplieChildren()
791         self.tree.inhibeExpand=False
792         #print "je mets inhibeExpand a false dans setDePlie"
793
794     def setDeplieChildren(self):
795         #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
796         for c in self.children :
797             c.setDeplieChildren()
798             #print "dans setDeplieChildren ", c.item.nom
799             c.appartientAUnNoeudPlie=False
800             c.setExpanded(True)
801             c.plie=False
802        
803     def selectAvant(self):
804         i=self.item.jdc.etapes.index(self.item.object)
805         try :
806            cherche=self.item.jdc.etapes[i-1]
807         except :
808            cherche=self.item.jdc.etapes[-1]
809         node=None
810         for i in self.tree.racine.children :
811             if i.item.object== cherche  : 
812                node=i
813                break
814         if node : node.affichePanneau()
815
816     def selectApres(self):
817         i=self.item.jdc.etapes.index(self.item.object)
818         try :
819            cherche=self.item.jdc.etapes[i+1]
820         except :
821            cherche=self.item.jdc.etapes[0]
822         node=None
823         for i in self.tree.racine.children :
824             if i.item.object== cherche  : 
825                node=i
826                break
827         if node : node.affichePanneau()