Salome HOME
e983a591746e5f4ec279aeb2cbb2cf4ec7bd5230
[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 from PyQt4 import *
26 from PyQt4.QtGui  import *
27 from PyQt4.QtCore import *
28 from Extensions.i18n import tr
29 from monChoixCommande import MonChoixCommande
30
31 class JDCTree( QTreeWidget ):
32     def __init__( self, jdc_item, QWParent):        
33         #if hasattr(QWParent,'widgetTree') : 
34         self.editor        = QWParent
35         self.plie=False
36         if self.editor.widgetTree !=None  :
37            QTreeWidget.__init__(self, self.editor.widgetTree ) 
38            self.editor.verticalLayout_2.addWidget(self)
39            if self.editor.enteteQTree=='complet':
40                  self.headerItem().setText(0,  "Commande   ")
41                  self.headerItem().setText(1, "Concept/Valeur")
42            else :
43                  self.headerItem().setText(0,  "Commande   ")
44            self.setColumnWidth(0,200)
45            self.setExpandsOnDoubleClick(False)
46            self.setSelectionMode(3)
47         else :
48            QTreeWidget.__init__(self, None ) 
49         self.item          = jdc_item
50         self.tree          = self        
51         self.appliEficas   = self.editor.appliEficas
52         self.childrenComplete=[]
53         self.childrenIssusDesBlocs=[]
54         self.racine=self.item.itemNode(self,self.item)
55  
56         self.itemCourrant=None
57
58         self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
59         self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
60         self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
61
62         #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
63         self.node_selected=self.racine
64         self.inhibeExpand=True
65         self.expandItem(self.racine)
66         self.inhibeExpand=False
67         #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
68         if self.racine.children !=[] :  
69            if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
70            else : self.racine.children[0].deplieToutEtReaffiche()
71         else : self.racine.affichePanneau()
72
73
74     def contextMenuEvent(self,event) :
75         print "contextMenuEvent"
76         coord=event.globalPos()
77         item= self.currentItem()
78         self.handleContextMenu(item,coord)
79
80     def handleContextMenu(self,item,coord):
81         """
82         Private slot to show the context menu of the listview.
83         
84         @param itm the selected listview item (QListWidgetItem)
85         @param coord the position of the mouse pointer (QPoint)
86         Attention : existeMenu permet de savoir si un menu est associe a cet item
87         """
88         print "handleContextMenu"
89         if item == None : return
90         if item.existeMenu == 0 : return
91         if item.menu == None:
92            item.createPopUpMenu()
93         if item.menu != None:
94            if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
95               item.Graphe.setEnabled(1)
96            item.menu.exec_(coord)            
97             
98
99     def handleCollapsedItem(self,item):
100         print "dans CollapsedItem", self.inhibeExpand  
101         if self.inhibeExpand == True : return
102         #print "apres if"
103         #print "item = ", item, item.item.get_nom()
104         #itemParent=item
105         #while not (hasattr (itemParent,'getPanel2')) : 
106         #   print "While itemParent = ", itemParent, itemParent.item.get_nom()
107         #   print itemParent.plie
108         #   if itemParent.plie==True : itemParent.setPlie()
109         #   itemParent=itemParent.treeParent 
110         #if self.tree.node_selected != self : 
111         #     item.setExpanded(False)
112         #     return
113         item.setPlie()
114         #print "apres 2ndif"
115         item.plieToutEtReaffiche()
116
117     def handleExpandedItem(self,item):
118         #print "dans ExpandItem", self.inhibeExpand  
119         if self.inhibeExpand == True : return
120         #print "apres if"
121         itemParent=item
122         while not (hasattr (itemParent,'getPanel2')) : 
123            if itemParent.plie==True : itemParent.setDeplie()
124            itemParent=itemParent.treeParent 
125         #print "apres if"
126         if self.tree.node_selected != itemParent : 
127              item.setExpanded(True)
128              #print "je suis la"
129              return
130         item.deplieToutEtReaffiche()
131
132     def handleOnItem(self,item,int):
133         #if (len(self.selectedIndexes())!=2): return
134         print "je passe dans handleOnItem"
135         self.inhibeExpand == True 
136         self.itemCourrant=item
137         itemParent=item
138         #print self.itemCourrant
139         while not (hasattr (itemParent,'getPanel2')) : 
140            if itemParent.plie==True : itemParent.setDeplie()
141            itemParent=itemParent.treeParent 
142         #print itemParent
143         #print itemParent.fenetre
144         #print self.editor.afficheCommandesPliees
145         if itemParent.fenetre != self.editor.fenetreCentraleAffichee : 
146             #print self.editor.afficheCommandesPliees
147             if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche()
148             else :                                  itemParent.affichePanneau()
149         if itemParent!=item : item.fenetre.rendVisible()
150         #try :
151         if 1:
152            fr = item.item.get_fr()
153            if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
154         #except:
155         else :
156             pass
157         self.inhibeExpand == False 
158         #print "je mets inhibeExpand a false handleOnItem"
159
160
161     def choisitPremier(self,name):
162         self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
163         self.racine.fenetre.close()
164         new_node=self.racine.append_brother(name,'after')
165  
166 # type de noeud
167 COMMENT     = "COMMENTAIRE"
168 PARAMETERS  = "PARAMETRE"
169  
170 class JDCNode(QTreeWidgetItem):
171     def __init__( self, treeParent, item):
172         #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
173         self.a=0
174         self.item        = item
175         self.vraiParent  = treeParent
176         self.treeParent  = treeParent
177         self.tree        = self.treeParent.tree
178         self.editor      = self.treeParent.editor
179         self.appliEficas = treeParent.appliEficas
180         self.treeParent.childrenIssusDesBlocs=[]
181         self.childrenComplete=[]
182                         
183         from InterfaceQT4 import compocomm
184         from InterfaceQT4 import compoparam
185         if   (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
186         elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
187         else:   name  = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
188         value = self.appliEficas.trUtf8(str( item.GetText() ) )
189
190         mesColonnes=QStringList()
191         if self.editor.enteteQTree=='complet': mesColonnes <<  name << value
192         else : mesColonnes <<  name
193
194         if self.treeParent.plie==True :
195             self.plie        = True
196             self.appartientAUnNoeudPlie=True
197         else :
198             self.plie        = False
199             self.appartientAUnNoeudPlie = False
200         #print "self.plie", self.plie
201         #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie
202         #print self.treeParent
203
204         ajoutAuParentduNoeud=0
205         from InterfaceQT4 import compobloc
206         while (isinstance(self.treeParent,compobloc.Node)) :
207               self.treeParent=self.treeParent.treeParent
208               ajoutAuParentduNoeud=1
209         if ajoutAuParentduNoeud :
210            treeParent.childrenComplete.append(self)
211            self.treeParent.childrenIssusDesBlocs.append(self)
212         while (isinstance(self.treeParent,compobloc.Node)) : self.treeParent=self.treeParent.treeParent
213
214         if isinstance(self,compobloc.Node) : 
215            QTreeWidgetItem.__init__(self,None,mesColonnes)
216         else :
217            QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
218            self.treeParent.childrenComplete.append(self)
219
220         self.setToolTip(0,QString(self.item.get_fr()))
221         self.setToolTip(1,QString(self.item.get_fr()))
222
223         repIcon=QString(self.appliEficas.repIcon)
224         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
225         self.setIcon(0,monIcone)
226
227         self.children = []
228         self.build_children()
229         self.menu=None
230         self.existeMenu=1
231
232         self.item.connect("valid",self.onValid,())
233         self.item.connect("supp" ,self.onSupp,())
234         self.item.connect("add"  ,self.onAdd,())
235         self.state=""
236         self.fenetre=None
237         try :
238           if self.item.getObject().isBLOC() : self.setExpanded(True) 
239         except :
240           pass
241
242
243     def build_children(self,posInsertion=10000):
244         """ Construit la liste des enfants de self """
245         """ Se charge de remettre les noeuds Expanded dans le meme etat """
246         #print "*********** build_children ",self.item, self.item.GetLabelText()
247         
248         listeExpanded=[]
249         for item in self.childrenComplete :
250             #try :
251             #  print "              je detruis ",  item.item.GetLabelText() ," parent : ", item.treeParent.item.GetLabelText()
252             #except :
253             #  print "mot clef fact"
254             if item.isExpanded():
255                if self.childrenComplete.index(item) < posInsertion :
256                   listeExpanded.append(self.childrenComplete.index(item))
257                else :
258                   listeExpanded.append( self.childrenComplete.index(item) +1)
259             self.detruit_les_noeuds_issus_de_blocs(item)
260             parent=item.treeParent
261             parent.removeChild(item)
262
263         self.children = []
264         self.childrenComplete = []
265         sublist = self.item._GetSubList()
266         ind=0
267         for item in sublist :
268             nouvelItem=item.itemNode(self,item)
269             self.children.append(nouvelItem)
270             #print "         J ajoute ", nouvelItem ,nouvelItem.item.GetLabelText(),"dans" ,self.item.GetLabelText()
271             #if ind in listeExpanded : nouvelItem.setExpanded(1)
272  
273             #if ind in listeExpanded : print "plie=0"
274             #else                   : print "plie=1"
275             #if ind in listeExpanded : nouvelItem.plie=0
276             #else                   : nouvelItem.plie=1
277             ind=ind+1
278         #print "*********** fin build_children ",self.item, self.item.GetLabelText()
279         
280     def chercheNoeudCorrespondant(self,objSimp):
281         sublist = self.item._GetSubList()
282         for node in self.childrenComplete:
283             if node.item.object==objSimp : return node
284         return None
285
286     def affichePanneau(self) :
287         print "dans affichePanneau appel getPanel2", self.item.GetLabelText()
288         if self.item.isactif(): 
289            itemParent=self
290            while not (hasattr (itemParent,'getPanel2')) : 
291                 itemParent=itemParent.treeParent 
292            if itemParent!=self : 
293               itemParent.affichePanneau()
294               return
295            self.fenetre=self.getPanel2()
296         else:
297             from monInactifPanel import PanelInactif
298             self.fenetre = PanelInactif(self,self.editor)
299          
300         self.editor.widgetCentraleLayout.addWidget(self.fenetre)
301         print "widgetCentraleLayout = ", self.editor.widgetCentraleLayout
302         print "nouvelle fenetre ", self.fenetre, " associee a ", self
303
304         self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee
305         #print "ancienne fenetre ", self.editor.anciennefenetre
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            #print "je ferme ", self.editor.anciennefenetre
312
313         if self.editor.widgetTree !=None  : index=1
314         else : index=0
315
316         if self.editor.first :
317            self.editor.splitter.setSizes((400,1400,400))
318            if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
319         self.tree.inhibeExpand=True
320         self.tree.expandItem(self)
321         self.select()
322         self.tree.inhibeExpand=False
323         #print "fin de affichePanneau"
324         #print "______________________________"
325           
326
327     def createPopUpMenu(self):
328         #implemente dans les noeuds derives si necessaire
329         self.existeMenu = 0
330
331     def commentIt(self):
332         """
333         Cette methode a pour but de commentariser la commande pointee par self
334         """
335         # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
336         # (commentariser) un commentaire.
337         try :
338             pos=self.treeParent.children.index(self)
339             commande_comment = self.item.get_objet_commentarise()
340             # On signale a l editeur du panel (le JDCDisplay) une modification
341             self.editor.init_modif()
342             self.treeParent.build_children()
343             self.treeParent.children[pos].select()
344             self.treeParent.children[pos].affichePanneau()
345         except Exception,e:
346             traceback.print_exc()
347             QMessageBox.critical( self.editor, "TOO BAD",str(e))
348         
349     def unCommentIt(self):
350         """
351         Realise la decommentarisation de self
352         """
353         try :
354             pos=self.treeParent.children.index(self)
355             commande,nom = self.item.uncomment()
356             self.editor.init_modif()
357             self.treeParent.build_children()
358             self.treeParent.children[pos].select()
359             self.treeParent.children[pos].affichePanneau()
360         except Exception,e:
361             QMessageBox.critical( self.editor, "Erreur !",str(e))
362         
363     def addComment( self, after=True ):
364         """
365         Ajoute un commentaire a l'interieur du JDC :
366         """
367         self.editor.init_modif()
368         if after:
369             pos = 'after'
370         else:
371             pos = 'before'
372         return self.append_brother( COMMENT, pos )
373                 
374     def addParameters( self, after=True ):
375         """
376         Ajoute un parametre a l'interieur du JDC :
377         """
378         self.editor.init_modif()
379         if after:
380             pos = 'after'
381         else:
382             pos = 'before'
383         return self.append_brother( PARAMETERS, pos )
384     
385     
386     def select( self ):
387         """
388         Rend le noeud courant (self) selectionne et deselectionne
389         tous les autres
390         """        
391         for item in self.tree.selectedItems() :
392             item.setSelected(0)
393         self.setSelected( True )    
394         #self.setExpanded( True )    
395         self.tree.setCurrentItem( self )    
396         self.tree.node_selected= self
397                                
398     #------------------------------------------------------------------
399     # Methodes de creation et destruction de noeuds
400     # Certaines de ces methodes peuvent etre appelees depuis l'externe
401     #------------------------------------------------------------------
402     def append_brother(self,name,pos='after',plier=False):
403         """
404         Permet d'ajouter un objet frere a l'objet associe au noeud self
405         par defaut on l'ajoute immediatement apres 
406         Methode externe
407         """
408         self.editor.init_modif()
409         index = self.treeParent.children.index(self)
410         if   pos == 'before': index = index
411         elif pos == 'after': index = index +1
412         else:
413             print unicode(pos), tr("  n'est pas un index valide pour append_brother")
414             return 0
415         return self.treeParent.append_child(name,pos=index,plier=plier)
416
417     def append_child(self,name,pos=None,plier=False):
418         """
419            Methode pour ajouter un objet fils a l'objet associe au noeud self.
420            On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
421            ou en position intermediaire.
422            Si pos vaut None, on le place a la position du catalogue.
423         """
424         print "************** append_child ",self.item.GetLabelText(), plier
425         self.editor.init_modif()
426         if pos == 'first':
427             index = 0
428         elif pos == 'last':
429             index = len(self.children)
430         elif type(pos) == types.IntType :
431             # position fixee
432             index = pos
433         elif type(pos) == types.InstanceType:
434             # pos est un item. Il faut inserer name apres pos
435             index = self.item.get_index(pos) +1
436         elif type(name) == types.InstanceType:
437             index = self.item.get_index_child(name.nom)
438         else:
439             index = self.item.get_index_child(name)
440         self.tree.inhibeExpand=True
441         obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
442         if obj is None:obj=0
443         if obj == 0:return 0
444         #try :
445         #  old_obj = self.item.object.get_child(name.nom,restreint = 'oui')
446         #  child=old_obj[-1]
447         #  if plier : child.plieToutEtReaffiche()
448         #  else     : child.affichePanneau() 
449         #  print "dans le 1er Try"
450         #else :
451         #except:
452           # Souci pour gerer les copies des AFFE d'une commande à l autre
453         #  try :
454         #     child=self.children[index]
455         #     if plier == True : child.setPlie()
456         #     else             : child.setDeplie() 
457         #     print "dans le 2nd Try"
458         #  except :
459         #     child=self.children[index]
460         #     print "dans le except"
461         try :
462         #if 1:
463            child=self.children[index]
464            if plier == True : child.setPlie()
465            else             : child.setDeplie() 
466         except :
467            child=self.children[index]
468            print "dans le except"
469         self.tree.inhibeExpand=False
470         return child
471
472     def deplace(self):
473         self.editor.init_modif()
474         index = self.treeParent.children.index(self) - 1 
475         if index < 0 : index =0
476         ret=self.treeParent.item.deplaceEntite(self.item.getObject())
477
478     def delete(self):
479         """ 
480             Methode externe pour la destruction de l'objet associe au noeud
481         """
482         self.editor.init_modif()
483         index = self.vraiParent.children.index(self) - 1 
484         if index < 0 : index =0
485         recalcule=0
486         if self.item.nom == "VARIABLE" :
487            recalcule=1
488            jdc=self.item.jdc
489         ret=self.vraiParent.item.suppitem(self.item)
490         self.treeParent.build_children()
491         if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
492         else: toselect=self.treeParent
493         if recalcule : jdc.recalcule_etat_correlation()
494         from InterfaceQT4 import compojdc
495         # cas ou on detruit dans l arbre sans affichage
496         if isinstance(self.treeParent,compojdc.Node) : 
497            toselect.affichePanneau()
498         else :
499            if self.treeParent.fenetre== None : return
500            print "J appelle reaffiche de browser apres delete"
501            self.treeParent.fenetre.reaffiche(toselect)
502
503     def deleteMultiple(self,liste=()):
504         """ 
505             Methode externe pour la destruction d une liste de noeud
506         """
507         from InterfaceQT4 import compojdc 
508         self.editor.init_modif()
509         index=9999
510         recalcule=0
511         jdc=self.treeParent
512         parentPosition=jdc
513         while not(isinstance(jdc,compojdc.Node)):
514               jdc=jdc.treeParent
515         for noeud in liste :
516             if not( isinstance(noeud.treeParent, compojdc.Node)): continue
517             if noeud.item.nom == "VARIABLE" : recalcule=1
518             if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
519         if index < 0 : index =0
520
521         # Cas ou on détruit dans une ETape
522         if index == 9999 : 
523               parentPosition=self.treeParent
524               while not(isinstance(parentPosition, compojdc.Node)):
525                  index=parentPosition.treeParent.children.index(parentPosition)
526                  parentPosition=parentPosition.treeParent
527
528         for noeud in liste:
529             noeud.treeParent.item.suppitem(noeud.item)
530
531         jdc.build_children()
532         if recalcule : jdc.recalcule_etat_correlation()
533         try    : toselect=parentPosition.children[index]
534         except : toselect=jdc
535         toselect.select()
536         toselect.affichePanneau()
537 #        
538 #    #------------------------------------------------------------------
539     def onValid(self):        
540
541         #print "onValid pour ", self.item.nom
542         if hasattr(self,'fenetre') and self.fenetre: 
543            self.fenetre.setValide()
544         if self.item.nom == "VARIABLE" and self.item.isvalid():
545            self.item.jdc.recalcule_etat_correlation()
546         if hasattr(self.item,'forceRecalcul'):
547            self.forceRecalculChildren(self.item.forceRecalcul)
548         self.editor.init_modif()
549         
550         self.update_node_valid()
551         self.update_node_label()
552         self.update_node_texte()
553
554     def onAdd(self,object):
555         #print "onAdd pour ", self.item.nom
556         self.editor.init_modif()
557         self.update_nodes()
558         print "dans onAdd" ,self.item 
559         # PN -- non necessaire si item=jdc
560         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
561  
562     def onSupp(self,object):
563         #print "onSupp pour ", self.item.nom
564         self.editor.init_modif()
565         self.update_nodes()
566         # PN -- non necessaire si item=jdc
567         if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
568          
569     def detruit_les_noeuds_issus_de_blocs(self,bloc):
570         from InterfaceQT4 import compobloc
571         if (isinstance(bloc,compobloc.Node)) :
572            for node in bloc.childrenComplete :
573                self.detruit_les_noeuds_issus_de_blocs(node)
574                parent=node.treeParent
575                #print "je detruit " , node.item.GetLabelText()
576                parent.removeChild(node)
577
578     def update_node_valid(self):
579         """Cette methode remet a jour la validite du noeud (icone)
580            Elle appelle isvalid
581         """
582         repIcon=QString(self.appliEficas.repIcon)
583         monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
584         self.setIcon(0,monIcone)
585
586
587     def update_node_label(self):
588         """ Met a jour le label du noeud """
589         #print "NODE update_node_label", self.item.GetLabelText()
590         labeltext,fonte,couleur = self.item.GetLabelText()
591         # PNPN a reflechir
592         #self.setText(0, labeltext)        
593     
594     
595     def update_node_label_in_blue(self):
596         if hasattr(self.appliEficas,'noeudColore'):
597            self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
598            self.appliEficas.noeudColore.update_node_label()
599         self.setTextColor( 0,Qt.blue )
600         labeltext,fonte,couleur = self.item.GetLabelText()
601         self.setText(0, labeltext)        
602         self.appliEficas.noeudColore=self
603
604     def update_plusieurs_node_label_in_blue(self,liste):
605         if hasattr(self.appliEficas,'listeNoeudsColores'):
606            for noeud in self.appliEficas.listeNoeudsColores:
607                noeud.setTextColor( 0,Qt.black)
608                noeud.update_node_label()
609         self.appliEficas.listeNoeudsColores=[]
610         for noeud in liste :
611             noeud.setTextColor( 0,Qt.blue )
612             labeltext,fonte,couleur = noeud.item.GetLabelText()
613             noeud.setText(0, labeltext)        
614             self.appliEficas.listeNoeudsColores.append(noeud)
615
616     def update_node_texte_in_black(self):
617         """ Met a jour les noms des SD et valeurs des mots-cles """
618         self.setTextColor( 1,Qt.black )
619         value = self.item.GetText()
620         self.setText(1, value)
621
622     def update_node_texte(self):
623         """ Met a jour les noms des SD et valeurs des mots-cles """
624         value = self.item.GetText()
625         self.setText(1, value)
626
627     def update_node_texte_in_blue(self):
628         self.setTextColor( 1,Qt.blue )
629         value = self.item.GetText()
630         self.setText(1, value)
631
632     def update_nodes(self):
633         #print 'NODE update_nodes', self.item.GetLabelText()
634         self.build_children()
635
636     def update_valid(self) :
637         """Cette methode a pour but de mettre a jour la validite du noeud
638            et de propager la demande de mise a jour a son parent
639         """
640         #print "NODE update_valid", self.item.GetLabelText()
641         self.update_node_valid()
642         try :
643           self.treeParent.update_valid()
644         except:
645           pass
646             
647     def update_texte(self):
648         """ Met a jour les noms des SD et valeurs des mots-cles """
649         #print "NODE update_texte", self.item.GetLabelText()
650         self.update_node_texte()
651         if self.isExpanded() :
652             for child in self.children:
653                 if child.isHidden() == false : child.update_texte()
654
655
656     def forceRecalculChildren(self,niveau):
657         if self.state=='recalcule' : 
658            self.state=""
659            return
660         self.state='recalcule'
661         if hasattr(self.item,'object'):
662            self.item.object.state="modified"
663         for child in self.children:
664            if niveau > 0 : child.forceRecalculChildren(niveau - 1)
665               
666         
667
668     def doPaste(self,node_selected,pos='after'):
669         """
670             Déclenche la copie de l'objet item avec pour cible
671             l'objet passé en argument : node_selected
672         """
673         #print 'je passe dans doPaste'
674         objet_a_copier = self.item.get_copie_objet()
675         child=node_selected.doPasteCommande(objet_a_copier,pos)
676         return child
677
678     def doPasteCommande(self,objet_a_copier,pos='after'):
679         """
680           Réalise la copie de l'objet passé en argument qui est nécessairement
681           une commande
682         """
683         child=None
684         try :
685           child = self.append_brother(objet_a_copier,pos)
686         except :
687            pass
688         return child
689
690     def doPastePremier(self,objet_a_copier):
691         """
692            Réalise la copie de l'objet passé en argument (objet_a_copier)
693         """
694         objet = objet_a_copier.item.get_copie_objet()
695         child = self.append_child(objet,pos='first')
696         return child
697
698
699     def plieToutEtReaffiche(self):
700         print "je suis dans plieToutEtReaffiche", self.item.get_nom()
701         self.editor.deplier = False
702         for item in self.children :
703             item.setPlie()
704         self.affichePanneau()
705
706     def deplieToutEtReaffiche(self):
707         self.editor.deplier = True
708         for item in self.children :
709             item.setDeplie()
710         self.affichePanneau()
711
712     def setPlie(self):
713         #print "je mets inhibeExpand a true dans setPlie"
714         print "je suis dans plieTout", self.item.get_nom()
715         self.tree.inhibeExpand=True
716         self.tree.collapseItem(self)
717         self.setPlieChildren()
718
719         # on ne plie pas au niveau 1
720         #from InterfaceQT4 import compojdc
721         #if not(isinstance(self.treeParent,compojdc.Node)) : 
722         #   self.plie=True
723         #else :
724         #   self.plie=False
725         #   for item in self.children :
726         #       item.appartientAUnNoeudPlie=False
727         #self.tree.inhibeExpand=False
728         #print "je mets inhibeExpand a false dans setPlie"
729
730     def setPlieChildren(self):
731         self.plie=True
732         for c in self.children :
733             c.setPlieChildren()
734             print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
735             c.appartientAUnNoeudPlie=True
736             c.plie=True
737             c.setExpanded(True)
738             
739
740     def setDeplie(self):
741         #print "je mets inhibeExpand a true dans setDeplie"
742         self.tree.inhibeExpand=True
743         self.plie=False
744         self.tree.expandItem(self)
745         self.setDeplieChildren()
746         self.tree.inhibeExpand=False
747         print "je mets inhibeExpand a false dans setDePlie"
748
749     def setDeplieChildren(self):
750         print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
751         for c in self.children :
752             c.setDeplieChildren()
753             print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText()
754             c.appartientAUnNoeudPlie=False
755             c.setExpanded(True)
756             c.plie=False
757        
758     def selectAvant(self):
759         i=self.item.jdc.etapes.index(self.item.object)
760         try :
761            cherche=self.item.jdc.etapes[i-1]
762         except :
763            cherche=self.item.jdc.etapes[-1]
764         node=None
765         for i in self.tree.racine.children :
766             if i.item.object== cherche  : 
767                node=i
768                break
769         if node : node.affichePanneau()
770
771     def selectApres(self):
772         i=self.item.jdc.etapes.index(self.item.object)
773         try :
774            cherche=self.item.jdc.etapes[i+1]
775         except :
776            cherche=self.item.jdc.etapes[0]
777         node=None
778         for i in self.tree.racine.children :
779             if i.item.object== cherche  : 
780                node=i
781                break
782         if node : node.affichePanneau()