1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
27 from determine import monEnvQT5
29 from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem
30 from PyQt5.QtGui import QIcon
31 from PyQt5.QtCore import Qt
33 from PyQt4.QtGui import *
34 from PyQt4.QtCore import *
35 from Extensions.i18n import tr
36 from gereRegles import GereRegles
37 from monChoixCommande import MonChoixCommande
39 class JDCTree( QTreeWidget,GereRegles ):
40 def __init__( self, jdc_item, QWParent):
41 #if hasattr(QWParent,'widgetTree') :
42 self.editor = QWParent
44 if self.editor.widgetTree !=None :
45 QTreeWidget.__init__(self, self.editor.widgetTree )
46 self.editor.verticalLayout_2.addWidget(self)
47 if self.editor.enteteQTree=='complet':
48 self.headerItem().setText(0, "Commande ")
49 self.headerItem().setText(1, "Concept/Valeur")
51 self.headerItem().setText(0, "Commande ")
52 self.setColumnWidth(0,200)
53 self.setExpandsOnDoubleClick(False)
54 self.setSelectionMode(3)
56 QTreeWidget.__init__(self, None )
59 self.appliEficas = self.editor.appliEficas
60 self.childrenComplete=[]
61 self.racine=self.item.itemNode(self,self.item)
63 self.itemCourrant=None
66 self.itemClicked.connect(self.handleOnItem)
67 self.itemCollapsed.connect(self.handleCollapsedItem)
68 self.itemExpanded.connect(self.handleExpandedItem)
70 self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
71 self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
72 self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
74 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
75 self.node_selected=self.racine
76 self.inhibeExpand=True
77 self.expandItem(self.racine)
78 self.inhibeExpand=False
79 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
80 if self.racine.children !=[] :
83 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
84 else : self.racine.children[0].deplieToutEtReaffiche()
87 self.racine.children[0].fenetre.donnePremier()
88 else : self.racine.affichePanneau()
92 def contextMenuEvent(self,event) :
93 #print "contextMenuEvent"
94 coord=event.globalPos()
95 item= self.currentItem()
96 self.handleContextMenu(item,coord)
98 def handleContextMenu(self,item,coord):
100 Private slot to show the context menu of the listview.
102 @param itm the selected listview item (QListWidgetItem)
103 @param coord the position of the mouse pointer (QPoint)
104 Attention : existeMenu permet de savoir si un menu est associe a cet item
106 #print "handleContextMenu"
107 if item == None : return
108 if item.existeMenu == 0 : return
109 if item.menu == None:
110 item.createPopUpMenu()
111 if item.menu != None:
112 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
113 item.Graphe.setEnabled(1)
114 item.menu.exec_(coord)
117 def handleCollapsedItem(self,item):
118 #print "dans CollapsedItem", self.inhibeExpand
119 if self.inhibeExpand == True : return
120 # On traite le cas de l item non selectionne
122 while not (hasattr (itemParent,'getPanel')) :
123 itemParent=itemParent.treeParent
124 if self.tree.node_selected != itemParent :
125 item.setExpanded(False)
130 item.plieToutEtReaffiche()
133 def handleExpandedItem(self,item):
134 #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
135 if self.inhibeExpand == True : return
137 while not (hasattr (itemParent,'getPanel')) :
138 if itemParent.plie==True : itemParent.setDeplie()
139 itemParent=itemParent.treeParent
140 if self.tree.node_selected != itemParent :
141 item.setExpanded(True)
143 item.deplieToutEtReaffiche()
144 self.inhibeExpand == False
147 def handleOnItem(self,item,int):
148 print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
150 from InterfaceQT4 import composimp
151 self.inhibeExpand == True
152 self.itemCourrant=item
155 while not (hasattr (itemParent,'getPanel')) :
156 if itemParent.plie==True : itemParent.setDeplie()
157 itemParent=itemParent.treeParent
159 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
161 estUneFeuille=(isinstance(item,composimp.Node))
162 # il faut afficher le parent
163 print "estUneFeuille", estUneFeuille
164 print "afficheCommandesPliees", self.editor.afficheCommandesPliees
165 if estUneFeuille : itemParent.affichePanneau()
166 elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
167 else : itemParent.affichePanneau()
170 if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
171 elif itemParent!=item:
172 #self.tree.handleExpandedItem(item)
173 #item.fenetre.donnePremier()
174 #item.fenetre.rendActif()
175 print 'il faut afficher le 1er'
177 fr = item.item.get_fr()
178 if self.editor: self.editor.affiche_commentaire(unicode(fr))
182 self.inhibeExpand == False
183 #print "je mets inhibeExpand a false handleOnItem"
186 def choisitPremier(self,name):
187 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
188 self.racine.fenetre.close()
189 new_node=self.racine.append_brother(name,'after')
192 COMMENT = "COMMENTAIRE"
193 PARAMETERS = "PARAMETRE"
195 class JDCNode(QTreeWidgetItem,GereRegles):
196 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
197 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
200 self.vraiParent = treeParent
201 self.treeParent = treeParent
202 self.tree = self.treeParent.tree
203 self.editor = self.treeParent.editor
204 self.appliEficas = treeParent.appliEficas
206 self.childrenComplete=[]
209 from InterfaceQT4 import compocomm
210 from InterfaceQT4 import compoparam
211 from InterfaceQT4 import composimp
212 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
213 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.GetLabelText()[0]))
214 else: name = tr(str(tr( item.nom))+" :")
215 value = tr(str( item.GetText() ) )
219 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
220 else : mesColonnes=(name,)
222 mesColonnes=QStringList()
223 if self.editor.enteteQTree=='complet': mesColonnes << name << value
224 else : mesColonnes << name
226 if self.treeParent.plie==True :
228 self.appartientAUnNoeudPlie=True
231 self.appartientAUnNoeudPlie = False
233 if ancien and itemExpand : self.plie = False
234 if ancien and not itemExpand : self.plie = True
235 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
237 from InterfaceQT4 import compobloc
238 from InterfaceQT4 import compomclist
240 ajoutAuParentduNoeud=0
241 self.treeParent=treeParent
242 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
243 self.treeParent.childrenComplete.append(self)
244 self.treeParent=self.treeParent.vraiParent
245 self.treeParent.childrenComplete.append(self)
246 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
247 QTreeWidgetItem.__init__(self,None,mesColonnes)
249 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
252 self.setToolTip(0,self.item.get_fr())
253 self.setToolTip(1,self.item.get_fr())
254 repIcon=self.appliEficas.repIcon
256 self.setToolTip(0,QString(self.item.get_fr()))
257 self.setToolTip(1,QString(self.item.get_fr()))
258 repIcon=QString(self.appliEficas.repIcon)
260 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
261 self.setIcon(0,monIcone)
264 self.build_children()
268 self.item.connect("valid",self.onValid,())
269 self.item.connect("supp" ,self.onSupp,())
270 self.item.connect("add" ,self.onAdd,())
275 if self.item.getObject().isBLOC() :
276 self.setExpanded(True)
282 def build_children(self,posInsertion=10000):
283 """ Construit la liste des enfants de self """
284 """ Se charge de remettre les noeuds Expanded dans le meme etat """
285 #print "*********** build_children ",self,self.item, self.item.nom
287 self.listeItemExpanded=[]
288 self.listeItemPlie=[]
290 for enfant in self.childrenComplete :
291 if enfant.plie : self.listeItemPlie.append(enfant.item)
292 else : self.listeItemExpanded.append(enfant.item)
294 for enfant in self.childrenComplete :
295 parent=enfant.treeParent
296 parent.removeChild(enfant)
301 self.childrenComplete = []
302 sublist = self.item._GetSubList()
305 for item in sublist :
308 if item in self.listeItemExpanded : itemExpand=True; ancien=True
309 if item in self.listeItemPlie : itemExpand=False; ancien=True
310 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
311 self.children.append(nouvelItem)
313 #print "fin *********** build_children ",self,self.item, self.item.nom
316 def chercheNoeudCorrespondant(self,objSimp):
317 sublist = self.item._GetSubList()
318 for node in self.childrenComplete:
319 if node.item.object==objSimp : return node
323 def affichePanneau(self) :
324 #print " affichePanneau " , self.item.nom
326 #if self.item.isactif():
327 #if self.editor.code == 'ASTER' and not(self.item.isactif()) :
328 # posera des pb si un code decide d appeler FIN un mot clef
329 # on resoudera a ce moment la
330 # pour l instant pas de poussiere sous le tapis
331 if not(self.item.isactif()) :
332 from monWidgetInactif import MonWidgetInactif
333 self.fenetre = MonWidgetInactif(self,self.editor)
336 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
337 if itemParent!=self :
338 itemParent.affichePanneau()
340 self.fenetre=self.getPanel()
342 #print "hhhhhhhhhh", self.editor.splitter.sizes()
343 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
344 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
345 self.editor.widgetCentraleLayout.removeItem(widget)
346 # ceinture et bretelle
347 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
348 #print "iiiiiiiiiiiiiii", self.editor.splitter.sizes()
349 if self.editor.fenetreCentraleAffichee != None :
350 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
351 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
352 self.editor.fenetreCentraleAffichee.setParent(None)
353 self.editor.fenetreCentraleAffichee.close()
354 self.editor.fenetreCentraleAffichee.deleteLater()
356 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
357 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
358 self.editor.fenetreCentraleAffichee=self.fenetre
359 self.tree.node_selected= self
361 if self.editor.first :
362 #self.editor.splitter.setSizes((400,1400,400))
363 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
364 self.tree.inhibeExpand=True
365 self.tree.expandItem(self)
367 self.tree.inhibeExpand=False
368 #print "fin de affichePanneau", self.item.nom
369 #print "______________________________"
372 def createPopUpMenu(self):
373 #implemente dans les noeuds derives si necessaire
378 Cette methode a pour but de commentariser la commande pointee par self
380 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
381 # (commentariser) un commentaire.
383 pos=self.treeParent.children.index(self)
384 commande_comment = self.item.get_objet_commentarise()
385 # On signale a l editeur du panel (le JDCDisplay) une modification
386 self.editor.init_modif()
387 self.treeParent.build_children()
388 self.treeParent.children[pos].select()
389 self.treeParent.children[pos].affichePanneau()
391 traceback.print_exc()
392 QMessageBox.critical( self.editor, "TOO BAD",str(e))
394 def unCommentIt(self):
396 Realise la decommentarisation de self
399 pos=self.treeParent.children.index(self)
400 commande,nom = self.item.uncomment()
401 self.editor.init_modif()
402 self.treeParent.build_children()
403 self.treeParent.children[pos].select()
404 self.treeParent.children[pos].affichePanneau()
406 QMessageBox.critical( self.editor, "Erreur !",str(e))
408 def addComment( self, after=True ):
410 Ajoute un commentaire a l'interieur du JDC :
412 self.editor.init_modif()
417 return self.append_brother( COMMENT, pos )
419 def addParameters( self, after=True ):
421 Ajoute un parametre a l'interieur du JDC :
423 self.editor.init_modif()
424 if after: pos = 'after'
426 child=self.append_brother( PARAMETERS, pos )
432 Rend le noeud courant (self) selectionne et deselectionne
435 #print "select pour", self.item.nom
436 for item in self.tree.selectedItems() :
438 self.tree.setCurrentItem( self )
440 #------------------------------------------------------------------
441 # Methodes de creation et destruction de noeuds
442 # Certaines de ces methodes peuvent etre appelees depuis l'externe
443 #------------------------------------------------------------------
444 def append_brother(self,name,pos='after',plier=False):
446 Permet d'ajouter un objet frere a l'objet associe au noeud self
447 par defaut on l'ajoute immediatement apres
450 self.editor.init_modif()
452 from InterfaceQT4 import compojdc
453 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
455 index = self.treeParent.children.index(self)
456 if pos == 'before': index = index
457 elif pos == 'after': index = index +1
459 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
461 return self.treeParent.append_child(name,pos=index,plier=plier)
463 def verifiePosition(self,name,pos,aLaRacine=False):
464 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
465 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
467 etapes=self.item.get_jdc().etapes
468 if etapes == [] : return True
470 if aLaRacine == False :indexOu=etapes.index(self.item.object)
473 if pos=="after" : indexOu = indexOu+1
474 for e in etapes[:indexOu] :
476 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
477 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
478 if indexEtape > indexName :
479 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
480 QMessageBox.information( None,tr('insertion impossible'),comment, )
482 for e in etapes[indexOu:] :
484 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
485 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
486 if indexEtape < indexName :
487 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
488 QMessageBox.information( None,tr('insertion impossible'),comment, )
492 def append_child(self,name,pos=None,plier=False):
494 Methode pour ajouter un objet fils a l'objet associe au noeud self.
495 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
496 ou en position intermediaire.
497 Si pos vaut None, on le place a la position du catalogue.
499 #print "************** append_child ",self.item.GetLabelText(), plier
502 self.editor.init_modif()
506 index = len(self.children)
507 elif type(pos) == types.IntType :
510 elif type(pos) == types.InstanceType:
511 # pos est un item. Il faut inserer name apres pos
512 index = self.item.get_index(pos) +1
513 elif type(name) == types.InstanceType:
514 index = self.item.get_index_child(name.nom)
516 index = self.item.get_index_child(name)
518 # si on essaye d inserer a la racine
519 if (isinstance(self.treeParent,JDCTree) and index==0) :
520 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
521 if not verifiePosition : return 0
523 self.tree.inhibeExpand=True
524 obj=self.item.additem(name,index) # emet le signal 'add'
528 child=self.children[index]
529 if plier == True : child.setPlie()
530 else : child.setDeplie()
532 child=self.children[index]
533 self.tree.inhibeExpand=False
534 #print " fin append child"
538 self.editor.init_modif()
539 index = self.treeParent.children.index(self) - 1
540 if index < 0 : index =0
541 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
545 Methode externe pour la destruction de l'objet associe au noeud
547 self.editor.init_modif()
548 index = self.vraiParent.children.index(self) - 1
549 if index < 0 : index =0
551 if self.item.nom == "VARIABLE" :
554 ret,commentaire=self.vraiParent.item.suppitem(self.item)
556 self.editor.affiche_infos(commentaire,Qt.red)
558 self.editor.affiche_infos(commentaire)
559 self.treeParent.build_children()
560 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
561 else: toselect=self.treeParent
562 if recalcule : jdc.recalcule_etat_correlation()
564 if self.treeParent.childrenComplete :
565 notdeleted=self.treeParent.childrenComplete[index+1]
569 from InterfaceQT4 import compojdc
570 # cas ou on detruit dans l arbre sans affichage
571 if isinstance(self.treeParent,compojdc.Node) :
572 toselect.affichePanneau()
574 if self.treeParent.fenetre== None : return
575 #print "J appelle reaffiche de browser apres delete"
576 self.treeParent.fenetre.reaffiche(toselect)
578 def deleteMultiple(self,liste=()):
580 Methode externe pour la destruction d une liste de noeud
582 from InterfaceQT4 import compojdc
583 self.editor.init_modif()
588 while not(isinstance(jdc,compojdc.Node)):
591 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
592 if noeud.item.nom == "VARIABLE" : recalcule=1
593 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
594 if index < 0 : index =0
596 # Cas ou on détruit dans une ETape
598 parentPosition=self.treeParent
599 while not(isinstance(parentPosition, compojdc.Node)):
600 index=parentPosition.treeParent.children.index(parentPosition)
601 parentPosition=parentPosition.treeParent
604 noeud.treeParent.item.suppitem(noeud.item)
607 if recalcule : jdc.recalcule_etat_correlation()
608 try : toselect=parentPosition.children[index]
609 except : toselect=jdc
611 toselect.affichePanneau()
613 # #------------------------------------------------------------------
616 #print "onValid pour ", self.item.nom
617 if self.JESUISOFF==1 : return
618 if hasattr(self,'fenetre') and self.fenetre:
620 self.fenetre.setValide()
622 print "onValid pour ", self.item.nom, self,'pb'
624 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
625 self.item.jdc.recalcule_etat_correlation()
626 if hasattr(self.item,'forceRecalcul'):
627 self.forceRecalculChildren(self.item.forceRecalcul)
628 self.editor.init_modif()
630 self.update_node_valid()
631 self.update_node_label()
632 self.update_node_texte()
634 def onAdd(self,object):
635 if self.JESUISOFF==1 : return
636 #print "onAdd pour ", self.item.nom, object.nom
637 self.editor.init_modif()
639 # PN -- non necessaire si item=jdc
640 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
642 def onSupp(self,object):
643 if self.JESUISOFF==1 : return
644 #print "onSup pour ", self.item.nom, object.nom
645 self.editor.init_modif()
647 # PN -- non necessaire si item=jdc
648 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
652 def update_node_valid(self):
653 """Cette methode remet a jour la validite du noeud (icone)
656 if monEnvQT5 : repIcon=self.appliEficas.repIcon
657 else : repIcon=QString(self.appliEficas.repIcon)
658 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
659 self.setIcon(0,monIcone)
662 def update_node_label(self):
663 """ Met a jour le label du noeud """
664 #print "NODE update_node_label", self.item.GetLabelText()
665 labeltext,fonte,couleur = self.item.GetLabelText()
667 #self.setText(0, labeltext)
670 def update_node_label_in_blue(self):
671 if hasattr(self.appliEficas,'noeudColore'):
672 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
673 self.appliEficas.noeudColore.update_node_label()
674 self.setTextColor( 0,Qt.blue )
675 labeltext,fonte,couleur = self.item.GetLabelText()
676 self.setText(0, labeltext)
677 self.appliEficas.noeudColore=self
679 def update_plusieurs_node_label_in_blue(self,liste):
680 if hasattr(self.appliEficas,'listeNoeudsColores'):
681 for noeud in self.appliEficas.listeNoeudsColores:
682 noeud.setTextColor( 0,Qt.black)
683 noeud.update_node_label()
684 self.appliEficas.listeNoeudsColores=[]
686 noeud.setTextColor( 0,Qt.blue )
687 labeltext,fonte,couleur = noeud.item.GetLabelText()
688 noeud.setText(0, labeltext)
689 self.appliEficas.listeNoeudsColores.append(noeud)
691 def update_node_texte_in_black(self):
692 """ Met a jour les noms des SD et valeurs des mots-cles """
693 self.setTextColor( 1,Qt.black )
694 value = self.item.GetText()
695 self.setText(1, value)
697 def update_node_texte(self):
698 """ Met a jour les noms des SD et valeurs des mots-cles """
699 value = self.item.GetText()
700 self.setText(1, value)
703 def update_node_texte_in_blue(self):
704 self.setTextColor( 1,Qt.blue )
705 value = self.item.GetText()
706 self.setText(1, value)
708 def update_nodes(self):
709 #print 'NODE update_nodes', self.item.GetLabelText()
710 self.build_children()
712 def update_valid(self) :
713 """Cette methode a pour but de mettre a jour la validite du noeud
714 et de propager la demande de mise a jour a son parent
716 #print "NODE update_valid", self.item.GetLabelText()
717 self.update_node_valid()
719 self.treeParent.update_valid()
723 def update_texte(self):
724 """ Met a jour les noms des SD et valeurs des mots-cles """
725 #print "NODE update_texte", self.item.GetLabelText()
726 self.update_node_texte()
727 if self.isExpanded() :
728 for child in self.children:
729 if child.isHidden() == false : child.update_texte()
732 def forceRecalculChildren(self,niveau):
733 if self.state=='recalcule' :
736 self.state='recalcule'
737 if hasattr(self.item,'object'):
738 self.item.object.state="modified"
739 for child in self.children:
740 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
744 def doPaste(self,node_selected,pos='after'):
746 Déclenche la copie de l'objet item avec pour cible
747 l'objet passé en argument : node_selected
749 #print 'je passe dans doPaste'
750 objet_a_copier = self.item.get_copie_objet()
751 child=node_selected.doPasteCommande(objet_a_copier,pos)
754 def doPasteCommande(self,objet_a_copier,pos='after'):
756 Réalise la copie de l'objet passé en argument qui est nécessairement
761 child = self.append_brother(objet_a_copier,pos)
766 def doPastePremier(self,objet_a_copier):
768 Réalise la copie de l'objet passé en argument (objet_a_copier)
770 objet = objet_a_copier.item.get_copie_objet()
771 child = self.append_child(objet,pos='first')
774 def plieToutEtReafficheSaufItem(self, itemADeplier):
775 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
776 from InterfaceQT4 import compojdc
777 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
778 self.editor.deplier = False
779 for item in self.children :
780 # il ne faut pas plier les blocs
781 from InterfaceQT4 import compobloc
782 if (isinstance(item,compobloc.Node)) : continue
784 if item==itemADeplier :
785 itemADeplier.setDeplie()
786 self.affichePanneau()
788 def plieToutEtReaffiche(self):
789 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
790 from InterfaceQT4 import compojdc
791 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
792 self.editor.deplier = False
793 for item in self.children :
794 # il ne faut pas plier les blocs
795 from InterfaceQT4 import compobloc
796 if (isinstance(item,compobloc.Node)) : continue
798 self.affichePanneau()
800 def deplieToutEtReaffiche(self):
801 self.editor.deplier = True
802 for item in self.children :
804 self.affichePanneau()
807 #print "je mets inhibeExpand a true dans setPlie"
808 #print "je suis dans plieTout", self.item.get_nom()
810 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
812 self.tree.inhibeExpand=True
813 self.tree.collapseItem(self)
814 self.setPlieChildren()
815 self.tree.inhibeExpand=False
816 #print "je mets inhibeExpand a false dans setPlie"
819 # on ne plie pas au niveau 1
821 # for item in self.children :
822 # item.appartientAUnNoeudPlie=False
824 def setPlieChildren(self):
825 #print "dans setPlieChildren pour", self.item.nom
827 for c in self.children :
829 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
830 c.appartientAUnNoeudPlie=True
832 #print "dans setPlieChildren plie", c.item.nom
835 # Pour les blocs et les motcles list
836 # on affiche un niveau de plus
837 from InterfaceQT4 import compobloc
838 from InterfaceQT4 import compomclist
839 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
840 niveauPere=self.treeParent
841 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
842 niveauPere=niveauPere.treeParent
843 for c in self.children :
844 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
847 # on affiche un niveau de plus
848 #if isinstance(self,compomclist.Node) :
849 #if isinstance(self,compobloc.Node) :
850 # niveauPere=self.treeParent
851 # while (isinstance(niveauPere,compobloc.Node)):
852 # niveauPere=niveauPere.treeParent
853 # for c in self.children :
854 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
857 #print "dans setPlieChildren pour", self.item.nom
858 #print "je mets inhibeExpand a true dans setDeplie"
859 self.tree.inhibeExpand=True
861 self.tree.expandItem(self)
862 self.setDeplieChildren()
863 self.tree.inhibeExpand=False
864 #print "je mets inhibeExpand a false dans setDePlie"
866 def setDeplieChildren(self):
867 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
868 for c in self.children :
869 c.setDeplieChildren()
870 #print "dans setDeplieChildren ", c.item.nom
871 c.appartientAUnNoeudPlie=False
875 def selectAvant(self):
876 i=self.item.jdc.etapes.index(self.item.object)
878 cherche=self.item.jdc.etapes[i-1]
880 cherche=self.item.jdc.etapes[-1]
882 for i in self.tree.racine.children :
883 if i.item.object== cherche :
887 node.affichePanneau()
890 def selectApres(self):
891 i=self.item.jdc.etapes.index(self.item.object)
893 cherche=self.item.jdc.etapes[i+1]
895 cherche=self.item.jdc.etapes[0]
897 for i in self.tree.racine.children :
898 if i.item.object== cherche :
902 node.affichePanneau()