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)
352 self.editor.fenetreCentraleAffichee.setParent(None)
353 self.editor.fenetreCentraleAffichee.close()
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 hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
617 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
618 self.item.jdc.recalcule_etat_correlation()
619 if hasattr(self.item,'forceRecalcul'):
620 self.forceRecalculChildren(self.item.forceRecalcul)
621 self.editor.init_modif()
623 self.update_node_valid()
624 self.update_node_label()
625 self.update_node_texte()
627 def onAdd(self,object):
628 if self.JESUISOFF==1 : return
629 #print "onAdd pour ", self.item.nom, object.nom
630 self.editor.init_modif()
632 # PN -- non necessaire si item=jdc
633 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
635 def onSupp(self,object):
636 if self.JESUISOFF==1 : return
637 #print "onSup pour ", self.item.nom, object.nom
638 self.editor.init_modif()
640 # PN -- non necessaire si item=jdc
641 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
646 def update_node_valid(self):
647 """Cette methode remet a jour la validite du noeud (icone)
650 if monEnvQT5 : repIcon=self.appliEficas.repIcon
651 else : repIcon=QString(self.appliEficas.repIcon)
652 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
653 self.setIcon(0,monIcone)
656 def update_node_label(self):
657 """ Met a jour le label du noeud """
658 #print "NODE update_node_label", self.item.GetLabelText()
659 labeltext,fonte,couleur = self.item.GetLabelText()
661 #self.setText(0, labeltext)
664 def update_node_label_in_blue(self):
665 if hasattr(self.appliEficas,'noeudColore'):
666 self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
667 self.appliEficas.noeudColore.update_node_label()
668 self.setTextColor( 0,Qt.blue )
669 labeltext,fonte,couleur = self.item.GetLabelText()
670 self.setText(0, labeltext)
671 self.appliEficas.noeudColore=self
673 def update_plusieurs_node_label_in_blue(self,liste):
674 if hasattr(self.appliEficas,'listeNoeudsColores'):
675 for noeud in self.appliEficas.listeNoeudsColores:
676 noeud.setTextColor( 0,Qt.black)
677 noeud.update_node_label()
678 self.appliEficas.listeNoeudsColores=[]
680 noeud.setTextColor( 0,Qt.blue )
681 labeltext,fonte,couleur = noeud.item.GetLabelText()
682 noeud.setText(0, labeltext)
683 self.appliEficas.listeNoeudsColores.append(noeud)
685 def update_node_texte_in_black(self):
686 """ Met a jour les noms des SD et valeurs des mots-cles """
687 self.setTextColor( 1,Qt.black )
688 value = self.item.GetText()
689 self.setText(1, value)
691 def update_node_texte(self):
692 """ Met a jour les noms des SD et valeurs des mots-cles """
693 value = self.item.GetText()
694 self.setText(1, value)
697 def update_node_texte_in_blue(self):
698 self.setTextColor( 1,Qt.blue )
699 value = self.item.GetText()
700 self.setText(1, value)
702 def update_nodes(self):
703 #print 'NODE update_nodes', self.item.GetLabelText()
704 self.build_children()
706 def update_valid(self) :
707 """Cette methode a pour but de mettre a jour la validite du noeud
708 et de propager la demande de mise a jour a son parent
710 #print "NODE update_valid", self.item.GetLabelText()
711 self.update_node_valid()
713 self.treeParent.update_valid()
717 def update_texte(self):
718 """ Met a jour les noms des SD et valeurs des mots-cles """
719 #print "NODE update_texte", self.item.GetLabelText()
720 self.update_node_texte()
721 if self.isExpanded() :
722 for child in self.children:
723 if child.isHidden() == false : child.update_texte()
726 def forceRecalculChildren(self,niveau):
727 if self.state=='recalcule' :
730 self.state='recalcule'
731 if hasattr(self.item,'object'):
732 self.item.object.state="modified"
733 for child in self.children:
734 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
738 def doPaste(self,node_selected,pos='after'):
740 Déclenche la copie de l'objet item avec pour cible
741 l'objet passé en argument : node_selected
743 #print 'je passe dans doPaste'
744 objet_a_copier = self.item.get_copie_objet()
745 child=node_selected.doPasteCommande(objet_a_copier,pos)
748 def doPasteCommande(self,objet_a_copier,pos='after'):
750 Réalise la copie de l'objet passé en argument qui est nécessairement
755 child = self.append_brother(objet_a_copier,pos)
760 def doPastePremier(self,objet_a_copier):
762 Réalise la copie de l'objet passé en argument (objet_a_copier)
764 objet = objet_a_copier.item.get_copie_objet()
765 child = self.append_child(objet,pos='first')
768 def plieToutEtReafficheSaufItem(self, itemADeplier):
769 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
770 from InterfaceQT4 import compojdc
771 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
772 self.editor.deplier = False
773 for item in self.children :
774 # il ne faut pas plier les blocs
775 from InterfaceQT4 import compobloc
776 if (isinstance(item,compobloc.Node)) : continue
778 if item==itemADeplier :
779 itemADeplier.setDeplie()
780 self.affichePanneau()
782 def plieToutEtReaffiche(self):
783 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
784 from InterfaceQT4 import compojdc
785 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
786 self.editor.deplier = False
787 for item in self.children :
788 # il ne faut pas plier les blocs
789 from InterfaceQT4 import compobloc
790 if (isinstance(item,compobloc.Node)) : continue
792 self.affichePanneau()
794 def deplieToutEtReaffiche(self):
795 self.editor.deplier = True
796 for item in self.children :
798 self.affichePanneau()
801 #print "je mets inhibeExpand a true dans setPlie"
802 #print "je suis dans plieTout", self.item.get_nom()
804 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
806 self.tree.inhibeExpand=True
807 self.tree.collapseItem(self)
808 self.setPlieChildren()
809 self.tree.inhibeExpand=False
810 #print "je mets inhibeExpand a false dans setPlie"
813 # on ne plie pas au niveau 1
815 # for item in self.children :
816 # item.appartientAUnNoeudPlie=False
818 def setPlieChildren(self):
819 #print "dans setPlieChildren pour", self.item.nom
821 for c in self.children :
823 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
824 c.appartientAUnNoeudPlie=True
826 #print "dans setPlieChildren plie", c.item.nom
829 # Pour les blocs et les motcles list
830 # on affiche un niveau de plus
831 from InterfaceQT4 import compobloc
832 from InterfaceQT4 import compomclist
833 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
834 niveauPere=self.treeParent
835 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
836 niveauPere=niveauPere.treeParent
837 for c in self.children :
838 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
841 # on affiche un niveau de plus
842 #if isinstance(self,compomclist.Node) :
843 #if isinstance(self,compobloc.Node) :
844 # niveauPere=self.treeParent
845 # while (isinstance(niveauPere,compobloc.Node)):
846 # niveauPere=niveauPere.treeParent
847 # for c in self.children :
848 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
851 #print "dans setPlieChildren pour", self.item.nom
852 #print "je mets inhibeExpand a true dans setDeplie"
853 self.tree.inhibeExpand=True
855 self.tree.expandItem(self)
856 self.setDeplieChildren()
857 self.tree.inhibeExpand=False
858 #print "je mets inhibeExpand a false dans setDePlie"
860 def setDeplieChildren(self):
861 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
862 for c in self.children :
863 c.setDeplieChildren()
864 #print "dans setDeplieChildren ", c.item.nom
865 c.appartientAUnNoeudPlie=False
869 def selectAvant(self):
870 i=self.item.jdc.etapes.index(self.item.object)
872 cherche=self.item.jdc.etapes[i-1]
874 cherche=self.item.jdc.etapes[-1]
876 for i in self.tree.racine.children :
877 if i.item.object== cherche :
881 node.affichePanneau()
884 def selectApres(self):
885 i=self.item.jdc.etapes.index(self.item.object)
887 cherche=self.item.jdc.etapes[i+1]
889 cherche=self.item.jdc.etapes[0]
891 for i in self.tree.racine.children :
892 if i.item.object== cherche :
896 node.affichePanneau()