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