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