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
32 from PyQt4.QtGui import *
33 from PyQt4.QtCore import *
34 from Extensions.i18n import tr
35 from gereRegles import GereRegles
36 from monChoixCommande import MonChoixCommande
38 class JDCTree( QTreeWidget,GereRegles ):
39 def __init__( self, jdc_item, QWParent):
40 #if hasattr(QWParent,'widgetTree') :
41 self.editor = QWParent
43 if self.editor.widgetTree !=None :
44 QTreeWidget.__init__(self, self.editor.widgetTree )
45 self.editor.verticalLayout_2.addWidget(self)
46 if self.editor.enteteQTree=='complet':
47 self.headerItem().setText(0, "Commande ")
48 self.headerItem().setText(1, "Concept/Valeur")
50 self.headerItem().setText(0, "Commande ")
51 self.setColumnWidth(0,200)
52 self.setExpandsOnDoubleClick(False)
53 self.setSelectionMode(3)
55 QTreeWidget.__init__(self, None )
58 self.appliEficas = self.editor.appliEficas
59 self.childrenComplete=[]
60 self.racine=self.item.itemNode(self,self.item)
62 self.itemCourrant=None
65 self.itemClicked.connect(self.handleOnItem)
66 self.itemCollapsed.connect(self.handleCollapsedItem)
67 self.itemExpanded.connect(self.handleExpandedItem)
69 self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
70 self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
71 self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
73 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
74 self.node_selected=self.racine
75 self.inhibeExpand=True
76 self.expandItem(self.racine)
77 self.inhibeExpand=False
78 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
79 if self.racine.children !=[] :
82 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
83 else : self.racine.children[0].deplieToutEtReaffiche()
86 self.racine.children[0].fenetre.donnePremier()
87 else : self.racine.affichePanneau()
91 def contextMenuEvent(self,event) :
92 #print "contextMenuEvent"
93 coord=event.globalPos()
94 item= self.currentItem()
95 self.handleContextMenu(item,coord)
97 def handleContextMenu(self,item,coord):
99 Private slot to show the context menu of the listview.
101 @param itm the selected listview item (QListWidgetItem)
102 @param coord the position of the mouse pointer (QPoint)
103 Attention : existeMenu permet de savoir si un menu est associe a cet item
105 #print "handleContextMenu"
106 if item == None : return
107 if item.existeMenu == 0 : return
108 if item.menu == None:
109 item.createPopUpMenu()
110 if item.menu != None:
111 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
112 item.Graphe.setEnabled(1)
113 item.menu.exec_(coord)
116 def handleCollapsedItem(self,item):
117 #print "dans CollapsedItem", self.inhibeExpand
118 if self.inhibeExpand == True : return
119 # On traite le cas de l item non selectionne
121 while not (hasattr (itemParent,'getPanel')) :
122 itemParent=itemParent.treeParent
123 if self.tree.node_selected != itemParent :
124 item.setExpanded(False)
129 item.plieToutEtReaffiche()
132 def handleExpandedItem(self,item):
133 #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
134 if self.inhibeExpand == True : return
136 while not (hasattr (itemParent,'getPanel')) :
137 if itemParent.plie==True : itemParent.setDeplie()
138 itemParent=itemParent.treeParent
139 if self.tree.node_selected != itemParent :
140 item.setExpanded(True)
142 item.deplieToutEtReaffiche()
143 self.inhibeExpand == False
146 def handleOnItem(self,item,int):
147 print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
149 from InterfaceQT4 import composimp
150 self.inhibeExpand == True
151 self.itemCourrant=item
154 while not (hasattr (itemParent,'getPanel')) :
155 if itemParent.plie==True : itemParent.setDeplie()
156 itemParent=itemParent.treeParent
158 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
160 estUneFeuille=(isinstance(item,composimp.Node))
161 # il faut afficher le parent
162 print "estUneFeuille", estUneFeuille
163 print "afficheCommandesPliees", self.editor.afficheCommandesPliees
164 if estUneFeuille : itemParent.affichePanneau()
165 elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
166 else : itemParent.affichePanneau()
169 if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
170 elif itemParent!=item:
171 #self.tree.handleExpandedItem(item)
172 #item.fenetre.donnePremier()
173 #item.fenetre.rendActif()
174 print 'il faut afficher le 1er'
176 fr = item.item.get_fr()
177 if self.editor: self.editor.affiche_commentaire(unicode(fr))
181 self.inhibeExpand == False
182 #print "je mets inhibeExpand a false handleOnItem"
185 def choisitPremier(self,name):
186 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
187 self.racine.fenetre.close()
188 new_node=self.racine.append_brother(name,'after')
191 COMMENT = "COMMENTAIRE"
192 PARAMETERS = "PARAMETRE"
194 class JDCNode(QTreeWidgetItem,GereRegles):
195 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
196 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
199 self.vraiParent = treeParent
200 self.treeParent = treeParent
201 self.tree = self.treeParent.tree
202 self.editor = self.treeParent.editor
203 self.appliEficas = treeParent.appliEficas
205 self.childrenComplete=[]
208 from InterfaceQT4 import compocomm
209 from InterfaceQT4 import compoparam
210 from InterfaceQT4 import composimp
211 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
212 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.GetLabelText()[0]))
213 else: name = tr(str(tr( item.nom))+" :")
214 value = tr(str( item.GetText() ) )
218 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
219 else : mesColonnes=(name,)
221 mesColonnes=QStringList()
222 if self.editor.enteteQTree=='complet': mesColonnes << name << value
223 else : mesColonnes << name
225 if self.treeParent.plie==True :
227 self.appartientAUnNoeudPlie=True
230 self.appartientAUnNoeudPlie = False
232 if ancien and itemExpand : self.plie = False
233 if ancien and not itemExpand : self.plie = True
234 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
236 from InterfaceQT4 import compobloc
237 from InterfaceQT4 import compomclist
239 ajoutAuParentduNoeud=0
240 self.treeParent=treeParent
241 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
242 self.treeParent.childrenComplete.append(self)
243 self.treeParent=self.treeParent.vraiParent
244 self.treeParent.childrenComplete.append(self)
245 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
246 QTreeWidgetItem.__init__(self,None,mesColonnes)
248 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
251 self.setToolTip(0,self.item.get_fr())
252 self.setToolTip(1,self.item.get_fr())
253 repIcon=self.appliEficas.repIcon
255 self.setToolTip(0,QString(self.item.get_fr()))
256 self.setToolTip(1,QString(self.item.get_fr()))
257 repIcon=QString(self.appliEficas.repIcon)
259 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
260 self.setIcon(0,monIcone)
263 self.build_children()
267 self.item.connect("valid",self.onValid,())
268 self.item.connect("supp" ,self.onSupp,())
269 self.item.connect("add" ,self.onAdd,())
274 if self.item.getObject().isBLOC() :
275 self.setExpanded(True)
281 def build_children(self,posInsertion=10000):
282 """ Construit la liste des enfants de self """
283 """ Se charge de remettre les noeuds Expanded dans le meme etat """
284 #print "*********** build_children ",self,self.item, self.item.nom
286 self.listeItemExpanded=[]
287 self.listeItemPlie=[]
289 for enfant in self.childrenComplete :
290 if enfant.plie : self.listeItemPlie.append(enfant.item)
291 else : self.listeItemExpanded.append(enfant.item)
293 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
325 #if self.item.isactif():
326 #if self.editor.code == 'ASTER' and not(self.item.isactif()) :
327 # posera des pb si un code decide d appeler FIN un mot clef
328 # on resoudera a ce moment la
329 # pour l instant pas de poussiere sous le tapis
330 if not(self.item.isactif()) :
331 from monWidgetInactif import MonWidgetInactif
332 self.fenetre = MonWidgetInactif(self,self.editor)
335 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
336 if itemParent!=self :
337 itemParent.affichePanneau()
339 self.fenetre=self.getPanel()
341 #print "hhhhhhhhhh", self.editor.splitter.sizes()
342 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
343 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
344 self.editor.widgetCentraleLayout.removeItem(widget)
345 # ceinture et bretelle
346 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
347 #print "iiiiiiiiiiiiiii", self.editor.splitter.sizes()
348 if self.editor.fenetreCentraleAffichee != None :
349 #print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
350 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
351 self.editor.fenetreCentraleAffichee.setParent(None)
352 self.editor.fenetreCentraleAffichee.close()
353 self.editor.fenetreCentraleAffichee.deleteLater()
355 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
356 #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
357 self.editor.fenetreCentraleAffichee=self.fenetre
358 self.tree.node_selected= self
360 if self.editor.first :
361 #self.editor.splitter.setSizes((400,1400,400))
362 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
363 self.tree.inhibeExpand=True
364 self.tree.expandItem(self)
366 self.tree.inhibeExpand=False
367 #print "fin de affichePanneau", self.item.nom
368 #print "______________________________"
371 def createPopUpMenu(self):
372 #implemente dans les noeuds derives si necessaire
377 Cette methode a pour but de commentariser la commande pointee par self
379 # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
380 # (commentariser) un commentaire.
382 pos=self.treeParent.children.index(self)
383 commande_comment = self.item.get_objet_commentarise()
384 # On signale a l editeur du panel (le JDCDisplay) une modification
385 self.editor.init_modif()
386 self.treeParent.build_children()
387 self.treeParent.children[pos].select()
388 self.treeParent.children[pos].affichePanneau()
390 traceback.print_exc()
391 QMessageBox.critical( self.editor, "TOO BAD",str(e))
393 def unCommentIt(self):
395 Realise la decommentarisation de self
398 pos=self.treeParent.children.index(self)
399 commande,nom = self.item.uncomment()
400 self.editor.init_modif()
401 self.treeParent.build_children()
402 self.treeParent.children[pos].select()
403 self.treeParent.children[pos].affichePanneau()
405 QMessageBox.critical( self.editor, "Erreur !",str(e))
407 def addComment( self, after=True ):
409 Ajoute un commentaire a l'interieur du JDC :
411 self.editor.init_modif()
416 return self.append_brother( COMMENT, pos )
418 def addParameters( self, after=True ):
420 Ajoute un parametre a l'interieur du JDC :
422 self.editor.init_modif()
423 if after: pos = 'after'
425 child=self.append_brother( PARAMETERS, pos )
431 Rend le noeud courant (self) selectionne et deselectionne
434 #print "select pour", self.item.nom
435 for item in self.tree.selectedItems() :
437 self.tree.setCurrentItem( self )
439 #------------------------------------------------------------------
440 # Methodes de creation et destruction de noeuds
441 # Certaines de ces methodes peuvent etre appelees depuis l'externe
442 #------------------------------------------------------------------
443 def append_brother(self,name,pos='after',plier=False):
445 Permet d'ajouter un objet frere a l'objet associe au noeud self
446 par defaut on l'ajoute immediatement apres
449 self.editor.init_modif()
451 from InterfaceQT4 import compojdc
452 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
454 index = self.treeParent.children.index(self)
455 if pos == 'before': index = index
456 elif pos == 'after': index = index +1
458 print unicode(pos), tr(" n'est pas un index valide pour append_brother")
460 return self.treeParent.append_child(name,pos=index,plier=plier)
462 def verifiePosition(self,name,pos,aLaRacine=False):
463 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
464 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
466 etapes=self.item.get_jdc().etapes
467 if etapes == [] : return True
469 if aLaRacine == False :indexOu=etapes.index(self.item.object)
472 if pos=="after" : indexOu = indexOu+1
473 for e in etapes[:indexOu] :
475 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
476 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
477 if indexEtape > indexName :
478 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
479 QMessageBox.information( None,tr('insertion impossible'),comment, )
481 for e in etapes[indexOu:] :
483 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
484 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
485 if indexEtape < indexName :
486 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
487 QMessageBox.information( None,tr('insertion impossible'),comment, )
491 def append_child(self,name,pos=None,plier=False):
493 Methode pour ajouter un objet fils a l'objet associe au noeud self.
494 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
495 ou en position intermediaire.
496 Si pos vaut None, on le place a la position du catalogue.
498 #print "************** append_child ",self.item.GetLabelText(), plier
501 self.editor.init_modif()
505 index = len(self.children)
506 elif type(pos) == types.IntType :
509 elif type(pos) == types.InstanceType:
510 # pos est un item. Il faut inserer name apres pos
511 index = self.item.get_index(pos) +1
512 elif type(name) == types.InstanceType:
513 index = self.item.get_index_child(name.nom)
515 index = self.item.get_index_child(name)
517 # si on essaye d inserer a la racine
518 if (isinstance(self.treeParent,JDCTree) and index==0) :
519 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
520 if not verifiePosition : return 0
522 self.tree.inhibeExpand=True
523 obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
527 child=self.children[index]
528 if plier == True : child.setPlie()
529 else : child.setDeplie()
531 child=self.children[index]
532 self.tree.inhibeExpand=False
533 #print " fin append child"
537 self.editor.init_modif()
538 index = self.treeParent.children.index(self) - 1
539 if index < 0 : index =0
540 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
544 Methode externe pour la destruction de l'objet associe au noeud
546 self.editor.init_modif()
547 index = self.vraiParent.children.index(self) - 1
548 if index < 0 : index =0
550 if self.item.nom == "VARIABLE" :
553 ret,commentaire=self.vraiParent.item.suppitem(self.item)
555 self.editor.affiche_infos(commentaire,Qt.red)
557 self.editor.affiche_infos(commentaire)
558 self.treeParent.build_children()
559 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
560 else: toselect=self.treeParent
561 if recalcule : jdc.recalcule_etat_correlation()
563 if self.treeParent.childrenComplete :
564 notdeleted=self.treeParent.childrenComplete[index+1]
568 from InterfaceQT4 import compojdc
569 # cas ou on detruit dans l arbre sans affichage
570 if isinstance(self.treeParent,compojdc.Node) :
571 toselect.affichePanneau()
573 if self.treeParent.fenetre== None : return
574 #print "J appelle reaffiche de browser apres delete"
575 self.treeParent.fenetre.reaffiche(toselect)
577 def deleteMultiple(self,liste=()):
579 Methode externe pour la destruction d une liste de noeud
581 from InterfaceQT4 import compojdc
582 self.editor.init_modif()
587 while not(isinstance(jdc,compojdc.Node)):
590 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
591 if noeud.item.nom == "VARIABLE" : recalcule=1
592 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
593 if index < 0 : index =0
595 # Cas ou on détruit dans une ETape
597 parentPosition=self.treeParent
598 while not(isinstance(parentPosition, compojdc.Node)):
599 index=parentPosition.treeParent.children.index(parentPosition)
600 parentPosition=parentPosition.treeParent
603 noeud.treeParent.item.suppitem(noeud.item)
606 if recalcule : jdc.recalcule_etat_correlation()
607 try : toselect=parentPosition.children[index]
608 except : toselect=jdc
610 toselect.affichePanneau()
612 # #------------------------------------------------------------------
615 #print "onValid pour ", self.item.nom
616 if self.JESUISOFF==1 : return
618 if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
619 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
620 self.item.jdc.recalcule_etat_correlation()
621 if hasattr(self.item,'forceRecalcul'):
622 self.forceRecalculChildren(self.item.forceRecalcul)
623 self.editor.init_modif()
625 self.update_node_valid()
626 self.update_node_label()
627 self.update_node_texte()
629 def onAdd(self,object):
630 if self.JESUISOFF==1 : return
631 #print "onAdd pour ", self.item.nom, object.nom
632 self.editor.init_modif()
634 # PN -- non necessaire si item=jdc
635 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
637 def onSupp(self,object):
638 if self.JESUISOFF==1 : return
639 #print "onSup pour ", self.item.nom, object.nom
640 self.editor.init_modif()
642 # PN -- non necessaire si item=jdc
643 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
647 def update_node_valid(self):
648 """Cette methode remet a jour la validite du noeud (icone)
651 if monEnvQT5 : repIcon=self.appliEficas.repIcon
652 else : repIcon=QString(self.appliEficas.repIcon)
653 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
654 self.setIcon(0,monIcone)
657 def update_node_label(self):
658 """ Met a jour le label du noeud """
659 #print "NODE update_node_label", self.item.GetLabelText()
660 labeltext,fonte,couleur = self.item.GetLabelText()
662 #self.setText(0, labeltext)
665 def update_node_label_in_blue(self):
666 if hasattr(self.appliEficas,'noeudColore'):
667 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
668 self.appliEficas.noeudColore.update_node_label()
669 self.setTextColor( 0,Qt.blue )
670 labeltext,fonte,couleur = self.item.GetLabelText()
671 self.setText(0, labeltext)
672 self.appliEficas.noeudColore=self
674 def update_plusieurs_node_label_in_blue(self,liste):
675 if hasattr(self.appliEficas,'listeNoeudsColores'):
676 for noeud in self.appliEficas.listeNoeudsColores:
677 noeud.setTextColor( 0,Qt.black)
678 noeud.update_node_label()
679 self.appliEficas.listeNoeudsColores=[]
681 noeud.setTextColor( 0,Qt.blue )
682 labeltext,fonte,couleur = noeud.item.GetLabelText()
683 noeud.setText(0, labeltext)
684 self.appliEficas.listeNoeudsColores.append(noeud)
686 def update_node_texte_in_black(self):
687 """ Met a jour les noms des SD et valeurs des mots-cles """
688 self.setTextColor( 1,Qt.black )
689 value = self.item.GetText()
690 self.setText(1, value)
692 def update_node_texte(self):
693 """ Met a jour les noms des SD et valeurs des mots-cles """
694 value = self.item.GetText()
695 self.setText(1, value)
698 def update_node_texte_in_blue(self):
699 self.setTextColor( 1,Qt.blue )
700 value = self.item.GetText()
701 self.setText(1, value)
703 def update_nodes(self):
704 #print 'NODE update_nodes', self.item.GetLabelText()
705 self.build_children()
707 def update_valid(self) :
708 """Cette methode a pour but de mettre a jour la validite du noeud
709 et de propager la demande de mise a jour a son parent
711 #print "NODE update_valid", self.item.GetLabelText()
712 self.update_node_valid()
714 self.treeParent.update_valid()
718 def update_texte(self):
719 """ Met a jour les noms des SD et valeurs des mots-cles """
720 #print "NODE update_texte", self.item.GetLabelText()
721 self.update_node_texte()
722 if self.isExpanded() :
723 for child in self.children:
724 if child.isHidden() == false : child.update_texte()
727 def forceRecalculChildren(self,niveau):
728 if self.state=='recalcule' :
731 self.state='recalcule'
732 if hasattr(self.item,'object'):
733 self.item.object.state="modified"
734 for child in self.children:
735 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
739 def doPaste(self,node_selected,pos='after'):
741 Déclenche la copie de l'objet item avec pour cible
742 l'objet passé en argument : node_selected
744 #print 'je passe dans doPaste'
745 objet_a_copier = self.item.get_copie_objet()
746 child=node_selected.doPasteCommande(objet_a_copier,pos)
749 def doPasteCommande(self,objet_a_copier,pos='after'):
751 Réalise la copie de l'objet passé en argument qui est nécessairement
756 child = self.append_brother(objet_a_copier,pos)
761 def doPastePremier(self,objet_a_copier):
763 Réalise la copie de l'objet passé en argument (objet_a_copier)
765 objet = objet_a_copier.item.get_copie_objet()
766 child = self.append_child(objet,pos='first')
769 def plieToutEtReafficheSaufItem(self, itemADeplier):
770 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
771 from InterfaceQT4 import compojdc
772 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
773 self.editor.deplier = False
774 for item in self.children :
775 # il ne faut pas plier les blocs
776 from InterfaceQT4 import compobloc
777 if (isinstance(item,compobloc.Node)) : continue
779 if item==itemADeplier :
780 itemADeplier.setDeplie()
781 self.affichePanneau()
783 def plieToutEtReaffiche(self):
784 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
785 from InterfaceQT4 import compojdc
786 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
787 self.editor.deplier = False
788 for item in self.children :
789 # il ne faut pas plier les blocs
790 from InterfaceQT4 import compobloc
791 if (isinstance(item,compobloc.Node)) : continue
793 self.affichePanneau()
795 def deplieToutEtReaffiche(self):
796 self.editor.deplier = True
797 for item in self.children :
799 self.affichePanneau()
802 #print "je mets inhibeExpand a true dans setPlie"
803 #print "je suis dans plieTout", self.item.get_nom()
805 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
807 self.tree.inhibeExpand=True
808 self.tree.collapseItem(self)
809 self.setPlieChildren()
810 self.tree.inhibeExpand=False
811 #print "je mets inhibeExpand a false dans setPlie"
814 # on ne plie pas au niveau 1
816 # for item in self.children :
817 # item.appartientAUnNoeudPlie=False
819 def setPlieChildren(self):
820 #print "dans setPlieChildren pour", self.item.nom
822 for c in self.children :
824 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
825 c.appartientAUnNoeudPlie=True
827 #print "dans setPlieChildren plie", c.item.nom
830 # Pour les blocs et les motcles list
831 # on affiche un niveau de plus
832 from InterfaceQT4 import compobloc
833 from InterfaceQT4 import compomclist
834 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
835 niveauPere=self.treeParent
836 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
837 niveauPere=niveauPere.treeParent
838 for c in self.children :
839 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
842 # on affiche un niveau de plus
843 #if isinstance(self,compomclist.Node) :
844 #if isinstance(self,compobloc.Node) :
845 # niveauPere=self.treeParent
846 # while (isinstance(niveauPere,compobloc.Node)):
847 # niveauPere=niveauPere.treeParent
848 # for c in self.children :
849 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
852 #print "dans setPlieChildren pour", self.item.nom
853 #print "je mets inhibeExpand a true dans setDeplie"
854 self.tree.inhibeExpand=True
856 self.tree.expandItem(self)
857 self.setDeplieChildren()
858 self.tree.inhibeExpand=False
859 #print "je mets inhibeExpand a false dans setDePlie"
861 def setDeplieChildren(self):
862 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
863 for c in self.children :
864 c.setDeplieChildren()
865 #print "dans setDeplieChildren ", c.item.nom
866 c.appartientAUnNoeudPlie=False
870 def selectAvant(self):
871 i=self.item.jdc.etapes.index(self.item.object)
873 cherche=self.item.jdc.etapes[i-1]
875 cherche=self.item.jdc.etapes[-1]
877 for i in self.tree.racine.children :
878 if i.item.object== cherche :
882 node.affichePanneau()
885 def selectApres(self):
886 i=self.item.jdc.etapes.index(self.item.object)
888 cherche=self.item.jdc.etapes[i+1]
890 cherche=self.item.jdc.etapes[0]
892 for i in self.tree.racine.children :
893 if i.item.object== cherche :
897 node.affichePanneau()