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
21 from __future__ import absolute_import
22 from __future__ import print_function
24 from builtins import str
25 from builtins import range
30 from . import typeNode
34 from six.moves import range
35 from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem, QApplication, QMessageBox
36 from PyQt5.QtGui import QIcon
37 from PyQt5.QtCore import Qt
38 from Extensions.i18n import tr
39 from .gereRegles import GereRegles
40 from .monChoixCommande import MonChoixCommande
42 class JDCTree( QTreeWidget,GereRegles ):
43 def __init__( self, jdc_item, QWParent):
44 #if hasattr(QWParent,'widgetTree') :
45 self.editor = QWParent
47 if self.editor.widgetTree !=None :
48 QTreeWidget.__init__(self, self.editor.widgetTree )
49 self.editor.verticalLayout_2.addWidget(self)
50 if self.editor.enteteQTree=='complet':
51 self.headerItem().setText(0, "Commande ")
52 self.headerItem().setText(1, "Concept/Valeur")
54 self.headerItem().setText(0, "Commande ")
55 self.setColumnWidth(0,200)
56 self.setExpandsOnDoubleClick(False)
57 self.setSelectionMode(3)
59 QTreeWidget.__init__(self, None )
62 self.appliEficas = self.editor.appliEficas
63 self.childrenComplete=[]
64 self.racine=self.item.itemNode(self,self.item)
66 self.itemCourrant=None
68 self.itemClicked.connect(self.handleOnItem)
69 self.itemCollapsed.connect(self.handleCollapsedItem)
70 self.itemExpanded.connect(self.handleExpandedItem)
72 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
73 self.node_selected=self.racine
74 self.inhibeExpand=True
75 self.expandItem(self.racine)
76 self.inhibeExpand=False
77 #print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
78 if self.racine.children !=[] :
79 #self.editor.initSplitterSizes(3)
80 if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
81 else : self.racine.children[0].deplieToutEtReaffiche()
82 self.racine.children[0].fenetre.donnePremier()
84 #self.editor.initSplitterSizes(2)
85 self.racine.affichePanneau()
86 #print self.editor.splitter.sizes()
90 def contextMenuEvent(self,event) :
91 #print "contextMenuEvent"
92 coord=event.globalPos()
93 item= self.currentItem()
94 self.handleContextMenu(item,coord)
96 def handleContextMenu(self,item,coord):
98 Private slot to show the context menu of the listview.
100 @param itm the selected listview item (QListWidgetItem)
101 @param coord the position of the mouse pointer (QPoint)
102 Attention : existeMenu permet de savoir si un menu est associe a cet item
104 #print "handleContextMenu"
105 if item == None : return
106 if item.existeMenu == 0 : return
107 if item.menu == None:
108 item.createPopUpMenu()
109 if item.menu != None:
110 if item.item.get_nom() == "DISTRIBUTION" and item.item.isvalid() :
111 item.Graphe.setEnabled(1)
112 item.menu.exec_(coord)
115 def handleCollapsedItem(self,item):
116 #print "dans CollapsedItem", self.inhibeExpand
117 if self.inhibeExpand == True : return
118 # On traite le cas de l item non selectionne
120 while not (hasattr (itemParent,'getPanel')) :
121 itemParent=itemParent.treeParent
122 if self.tree.node_selected != itemParent :
123 item.setExpanded(False)
128 item.plieToutEtReaffiche()
131 def handleExpandedItem(self,item):
132 #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
134 #traceback.print_stack()
135 if self.inhibeExpand == True : return
136 self.inhibeExpand = True
138 while not (hasattr (itemParent,'getPanel')) :
139 if itemParent.plie==True : itemParent.setDeplie()
140 itemParent=itemParent.treeParent
141 if self.tree.node_selected != itemParent :
142 item.setExpanded(True)
143 self.inhibeExpand = False
145 item.deplieToutEtReaffiche()
146 self.inhibeExpand = False
149 def handleOnItem(self,item,int):
150 #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
152 from InterfaceQT4 import composimp
153 self.inhibeExpand = True
154 self.itemCourrant=item
157 while not (hasattr (itemParent,'getPanel')) :
158 if itemParent.plie==True : itemParent.setDeplie()
159 itemParent=itemParent.treeParent
161 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
163 estUneFeuille=(isinstance(item,composimp.Node))
164 # il faut afficher le parent
165 #print "estUneFeuille", estUneFeuille
166 #print "afficheCommandesPliees", self.editor.afficheCommandesPliees
167 if estUneFeuille : itemParent.affichePanneau()
168 elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
169 else : itemParent.affichePanneau()
172 elif (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
173 elif itemParent!=item:
174 self.tree.handleExpandedItem(item)
175 #item.fenetre.donnePremier()
176 #item.fenetre.rendActif()
177 #print 'il faut afficher le 1er'
180 fr = item.item.get_fr()
181 if self.editor: self.editor.affiche_commentaire(six.text_type(fr))
185 self.inhibeExpand = False
186 #print "je mets inhibeExpand a false handleOnItem"
189 def choisitPremier(self,name):
190 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
191 self.racine.fenetre.close()
192 new_node=self.racine.append_brother(name,'after')
195 COMMENT = "COMMENTAIRE"
196 PARAMETERS = "PARAMETRE"
198 class JDCNode(QTreeWidgetItem,GereRegles):
199 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
200 #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self
203 self.vraiParent = treeParent
204 self.treeParent = treeParent
205 self.tree = self.treeParent.tree
206 self.editor = self.treeParent.editor
207 self.appliEficas = treeParent.appliEficas
209 self.childrenComplete=[]
212 from InterfaceQT4 import compocomm
213 from InterfaceQT4 import compoparam
214 from InterfaceQT4 import composimp
215 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
216 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.GetLabelText()[0]))
217 else: name = tr(str(tr( item.nom))+" :")
218 value = tr(str( item.GetText() ) )
221 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
222 else : mesColonnes=(name,)
224 if self.treeParent.plie==True :
226 self.appartientAUnNoeudPlie=True
227 if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
230 self.appartientAUnNoeudPlie = False
232 #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
234 if ancien and itemExpand : self.plie = False
235 if ancien and not itemExpand : self.plie = True
236 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
238 from InterfaceQT4 import compobloc
239 from InterfaceQT4 import compomclist
241 ajoutAuParentduNoeud=0
242 self.treeParent=treeParent
243 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
244 self.treeParent.childrenComplete.append(self)
245 self.treeParent=self.treeParent.vraiParent
246 self.treeParent.childrenComplete.append(self)
249 if (isinstance(self,compobloc.Node) or (isinstance(self,compomclist.Node) and self.item.isMCList()) or ( hasattr(self.item.parent,'inhibeValidator') and isinstance(self,compomclist.Node) and self.item.parent.inhibeValidator)) :
250 # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
251 QTreeWidgetItem.__init__(self,None,mesColonnes)
253 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
255 self.setToolTip(0,self.item.get_fr())
256 self.setToolTip(1,self.item.get_fr())
257 repIcon=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 :
294 parent=enfant.treeParent
295 parent.removeChild(enfant)
300 self.childrenComplete = []
301 sublist = self.item._GetSubList()
304 for item in sublist :
307 if item in self.listeItemExpanded : itemExpand=True; ancien=True
308 if item in self.listeItemPlie : itemExpand=False; ancien=True
309 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
310 self.children.append(nouvelItem)
312 #print "fin *********** build_children ",self,self.item, self.item.nom, self.children
315 def chercheNoeudCorrespondant(self,objSimp):
316 sublist = self.item._GetSubList()
317 for node in self.childrenComplete:
318 if node.item.object==objSimp : return node
322 def affichePanneau(self) :
323 #if self.editor.code == 'ASTER' and not(self.item.isactif()) :
324 # posera des pb si un code decide d appeler FIN un mot clef
325 # on resoudera a ce moment la
326 # pour l instant pas de poussiere sous le tapis
327 if not(self.item.isactif()) :
328 from .monWidgetInactif import MonWidgetInactif
329 self.fenetre = MonWidgetInactif(self,self.editor)
332 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
333 if itemParent!=self :
334 itemParent.affichePanneau()
336 self.fenetre=self.getPanel()
337 #self.editor.restoreSplitterSizes()
339 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
340 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
341 self.editor.widgetCentraleLayout.removeItem(widget)
342 # ceinture et bretelle
343 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
344 if self.editor.fenetreCentraleAffichee != None :
345 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
346 self.editor.fenetreCentraleAffichee.setParent(None)
347 self.editor.fenetreCentraleAffichee.close()
348 self.editor.fenetreCentraleAffichee.deleteLater()
350 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
351 #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
352 self.editor.fenetreCentraleAffichee=self.fenetre
353 self.tree.node_selected= self
355 if self.editor.first :
356 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
357 self.tree.inhibeExpand=True
358 self.tree.expandItem(self)
359 self.tree.inhibeExpand=False
360 #print "fin de affichePanneau", self.item.nom
361 #print "______________________________"
364 def createPopUpMenu(self):
365 #implemente dans les noeuds derives si necessaire
370 Cette methode a pour but de commentariser la commande pointee par self
372 # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
373 # (commentariser) un commentaire.
375 pos=self.treeParent.children.index(self)
376 commande_comment = self.item.get_objet_commentarise()
377 # On signale a l editeur du panel (le JDCDisplay) une modification
378 self.editor.init_modif()
379 self.treeParent.build_children()
380 self.treeParent.children[pos].select()
381 self.treeParent.children[pos].affichePanneau()
382 except Exception as e:
383 traceback.print_exc()
384 QMessageBox.critical( self.editor, "TOO BAD",str(e))
386 def unCommentIt(self):
388 Realise la decommentarisation de self
391 pos=self.treeParent.children.index(self)
392 commande,nom = self.item.uncomment()
393 self.editor.init_modif()
394 self.treeParent.build_children()
395 self.treeParent.children[pos].select()
396 self.treeParent.children[pos].affichePanneau()
397 except Exception as e:
398 QMessageBox.critical( self.editor, "Erreur !",str(e))
400 def addComment( self, after=True ):
402 Ajoute un commentaire a l'interieur du JDC :
404 self.editor.init_modif()
409 return self.append_brother( COMMENT, pos )
411 def addParameters( self, after=True ):
413 Ajoute un parametre a l'interieur du JDC :
415 self.editor.init_modif()
416 if after: pos = 'after'
418 child=self.append_brother( PARAMETERS, pos )
424 Rend le noeud courant (self) selectionne et deselectionne
427 #print "select pour", self.item.nom
428 for item in self.tree.selectedItems() :
430 self.tree.setCurrentItem( self )
432 #------------------------------------------------------------------
433 # Methodes de creation et destruction de noeuds
434 # Certaines de ces methodes peuvent etre appelees depuis l'externe
435 #------------------------------------------------------------------
436 def append_brother(self,name,pos='after',plier=False):
438 Permet d'ajouter un objet frere a l'objet associe au noeud self
439 par defaut on l'ajoute immediatement apres
442 self.editor.init_modif()
444 from InterfaceQT4 import compojdc
445 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
447 if self.treeParent != self.vraiParent :
448 index = self.vraiParent.children.index(self)
449 if pos == 'before': index = index
450 elif pos == 'after': index = index +1
451 return self.vraiParent.append_child(name,pos=index,plier=plier)
453 index = self.treeParent.children.index(self)
454 if pos == 'before': index = index
455 elif pos == 'after': index = index +1
457 print(six.text_type(pos), tr(" n'est pas un index valide pour append_brother"))
459 return self.treeParent.append_child(name,pos=index,plier=plier)
461 def verifiePosition(self,name,pos,aLaRacine=False):
462 if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
463 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name)
465 etapes=self.item.get_jdc().etapes
466 if etapes == [] : return True
468 if aLaRacine == False :indexOu=etapes.index(self.item.object)
471 if pos=="after" : indexOu = indexOu+1
472 for e in etapes[:indexOu] :
474 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
475 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
476 if indexEtape > indexName :
477 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
478 QMessageBox.information( None,tr('insertion impossible'),comment, )
480 for e in etapes[indexOu:] :
482 if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue
483 indexEtape=self.editor.Classement_Commandes_Ds_Arbre.index(nom)
484 if indexEtape < indexName :
485 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
486 QMessageBox.information( None,tr('insertion impossible'),comment, )
490 def append_child(self,name,pos=None,plier=False):
492 Methode pour ajouter un objet fils a l'objet associe au noeud self.
493 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
494 ou en position intermediaire.
495 Si pos vaut None, on le place a la position du catalogue.
497 #print "************** append_child ",self.item.GetLabelText(), plier
500 self.editor.init_modif()
504 index = len(self.children)
505 elif type(pos) == int :
508 elif type(pos) == types.InstanceType:
509 # pos est un item. Il faut inserer name apres pos
510 index = self.item.get_index(pos) +1
511 elif type(name) == types.InstanceType:
512 index = self.item.get_index_child(name.nom)
514 index = self.item.get_index_child(name)
516 # si on essaye d inserer a la racine
517 if (isinstance(self.treeParent,JDCTree) and index==0) :
518 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
519 if not verifiePosition : return 0
521 self.tree.inhibeExpand=True
522 obj=self.item.additem(name,index) # emet le signal 'add'
526 child=self.children[index]
527 if plier == True : child.setPlie()
528 else : child.setDeplie()
530 child=self.children[index]
531 self.tree.inhibeExpand=False
532 #print (" fin append child")
536 self.editor.init_modif()
537 index = self.treeParent.children.index(self) - 1
538 if index < 0 : index =0
539 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
543 Methode externe pour la destruction de l'objet associe au noeud
545 self.editor.init_modif()
546 index = self.vraiParent.children.index(self) - 1
547 if index < 0 : index =0
549 if self.item.nom == "VARIABLE" :
552 ret,commentaire=self.vraiParent.item.suppitem(self.item)
554 self.editor.affiche_infos(commentaire,Qt.red)
556 self.editor.affiche_infos(commentaire)
557 self.treeParent.build_children()
558 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
559 else: toselect=self.treeParent
560 if recalcule : jdc.recalcule_etat_correlation()
562 if self.treeParent.childrenComplete :
563 notdeleted=self.treeParent.childrenComplete[index+1]
567 from InterfaceQT4 import compojdc
568 # cas ou on detruit dans l arbre sans affichage
569 if isinstance(self.treeParent,compojdc.Node) :
570 toselect.affichePanneau()
572 if self.treeParent.fenetre== None : return
573 #print "J appelle reaffiche de browser apres delete"
574 self.treeParent.fenetre.reaffiche(toselect)
576 def deleteMultiple(self,liste=()):
578 Methode externe pour la destruction d une liste de noeud
580 from InterfaceQT4 import compojdc
581 self.editor.init_modif()
586 while not(isinstance(jdc,compojdc.Node)):
589 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
590 if noeud.item.nom == "VARIABLE" : recalcule=1
591 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
592 if index < 0 : index =0
594 # Cas ou on detruit dans une ETape
596 parentPosition=self.treeParent
597 while not(isinstance(parentPosition, compojdc.Node)):
598 index=parentPosition.treeParent.children.index(parentPosition)
599 parentPosition=parentPosition.treeParent
602 noeud.treeParent.item.suppitem(noeud.item)
605 if recalcule : jdc.recalcule_etat_correlation()
606 try : toselect=parentPosition.children[index]
607 except : toselect=jdc
609 toselect.affichePanneau()
611 # #------------------------------------------------------------------
614 #print "onValid pour ", self.item.nom
615 if self.JESUISOFF==1 : return
616 if hasattr(self,'fenetre') and self.fenetre:
618 self.fenetre.setValide()
620 # print "onValid pour ", self.item.nom, self,'pb'
623 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
624 self.item.jdc.recalcule_etat_correlation()
625 if hasattr(self.item,'forceRecalcul'):
626 self.forceRecalculChildren(self.item.forceRecalcul)
627 self.editor.init_modif()
629 self.update_node_valid()
630 self.update_node_label()
631 self.update_node_texte()
633 def onAdd(self,object):
634 if self.JESUISOFF==1 : return
635 #print "onAdd pour ", self.item.nom, object.nom
636 self.editor.init_modif()
638 # PN -- non necessaire si item=jdc
639 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
641 def onSupp(self,object):
642 if self.JESUISOFF==1 : return
643 #print "onSup pour ", self.item.nom, object.nom
644 self.editor.init_modif()
646 # PN -- non necessaire si item=jdc
647 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
651 def update_node_valid(self):
652 """Cette methode remet a jour la validite du noeud (icone)
655 repIcon=self.appliEficas.repIcon
656 monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
657 self.setIcon(0,monIcone)
660 def update_node_label(self):
661 """ Met a jour le label du noeud """
663 #print "NODE update_node_label", self.item.GetLabelText()
664 #labeltext,fonte,couleur = self.item.GetLabelText()
666 #self.setText(0, labeltext)
669 def update_node_label_in_blue(self):
670 if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
671 self.setForeground(0,Qt.blue)
672 labeltext,fonte,couleur = self.item.GetLabelText()
673 self.setText(0, labeltext)
674 self.appliEficas.noeudColore=self
676 def update_plusieurs_node_label_in_blue(self,liste):
677 if hasattr(self.appliEficas,'listeNoeudsColores'):
678 for noeud in self.appliEficas.listeNoeudsColores:
679 noeud.setTextColor( 0,Qt.black)
680 noeud.update_node_label()
681 self.appliEficas.listeNoeudsColores=[]
683 noeud.setTextColor( 0,Qt.blue )
684 labeltext,fonte,couleur = noeud.item.GetLabelText()
685 noeud.setText(0, labeltext)
686 self.appliEficas.listeNoeudsColores.append(noeud)
688 def update_node_texte_in_black(self):
689 """ Met a jour les noms des SD et valeurs des mots-cles """
690 self.setTextColor( 1,Qt.black )
691 value = self.item.GetText()
692 self.setText(1, value)
694 def update_node_texte(self):
695 """ Met a jour les noms des SD et valeurs des mots-cles """
696 value = self.item.GetText()
697 self.setText(1, value)
700 def update_node_texte_in_blue(self):
701 self.setTextColor( 1,Qt.blue )
702 value = self.item.GetText()
703 self.setText(1, value)
705 def update_nodes(self):
706 #print 'NODE update_nodes', self.item.GetLabelText()
707 self.build_children()
709 def update_valid(self) :
710 """Cette methode a pour but de mettre a jour la validite du noeud
711 et de propager la demande de mise a jour a son parent
713 #print "NODE update_valid", self.item.GetLabelText()
714 self.update_node_valid()
716 self.treeParent.update_valid()
720 def update_texte(self):
721 """ Met a jour les noms des SD et valeurs des mots-cles """
722 #print "NODE update_texte", self.item.GetLabelText()
723 self.update_node_texte()
724 if self.isExpanded() :
725 for child in self.children:
726 if child.isHidden() == false : child.update_texte()
729 def forceRecalculChildren(self,niveau):
730 if self.state=='recalcule' :
733 self.state='recalcule'
734 if hasattr(self.item,'object'):
735 self.item.object.state="modified"
736 for child in self.children:
737 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
741 def doPaste(self,node_selected,pos='after'):
743 Declenche la copie de l'objet item avec pour cible
744 l'objet passe en argument : node_selected
746 #print 'je passe dans doPaste'
747 objet_a_copier = self.item.get_copie_objet()
748 child=node_selected.doPasteCommande(objet_a_copier,pos)
751 def doPasteCommande(self,objet_a_copier,pos='after'):
753 Realise la copie de l'objet passe en argument qui est necessairement
759 child = self.append_brother(objet_a_copier,pos)
764 def doPastePremier(self,objet_a_copier):
766 Realise la copie de l'objet passe en argument (objet_a_copier)
768 objet = objet_a_copier.item.get_copie_objet()
769 child = self.append_child(objet,pos='first')
772 def plieToutEtReafficheSaufItem(self, itemADeplier):
773 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
774 self.inhibeExpand=True
775 from InterfaceQT4 import compojdc
776 if (isinstance(self, compojdc.Node)) :
777 self.affichePanneau()
778 self.inhibeExpand=False
780 self.editor.deplier = False
781 for item in self.children :
782 # il ne faut pas plier les blocs
783 from InterfaceQT4 import compobloc
784 if (isinstance(item,compobloc.Node)) : continue
786 if item==itemADeplier :
787 itemADeplier.setDeplie()
788 self.affichePanneau()
789 self.inhibeExpand=False
791 def plieToutEtReaffiche(self):
792 from InterfaceQT4 import compojdc
793 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
794 self.inhibeExpand=True
795 self.editor.deplier = False
796 for item in self.children :
797 # il ne faut pas plier les blocs
798 from InterfaceQT4 import compobloc
799 if (isinstance(item,compobloc.Node)) : continue
801 self.affichePanneau()
803 def deplieToutEtReaffiche(self):
804 self.editor.deplier = True
805 for item in self.children :
807 self.affichePanneau()
810 #print "je mets inhibeExpand a true dans setPlie"
811 #print "je suis dans plieTout", self.item.get_nom()
812 from . import compojdc
813 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
815 self.tree.inhibeExpand=True
816 self.tree.collapseItem(self)
817 self.setPlieChildren()
818 self.tree.inhibeExpand=False
819 #print "je mets inhibeExpand a false dans setPlie"
822 # on ne plie pas au niveau 1
824 # for item in self.children :
825 # item.appartientAUnNoeudPlie=False
827 def setPlieChildren(self):
828 #print "dans setPlieChildren pour", self.item.nom
830 for c in self.children :
832 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
833 c.appartientAUnNoeudPlie=True
835 #print "dans setPlieChildren plie", c.item.nom
838 # Pour les blocs et les motcles list
839 # on affiche un niveau de plus
840 from InterfaceQT4 import compobloc
841 from InterfaceQT4 import compomclist
842 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
843 niveauPere=self.treeParent
844 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
845 niveauPere=niveauPere.treeParent
846 for c in self.children :
847 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
848 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie
851 # on affiche un niveau de plus
852 #if isinstance(self,compomclist.Node) :
853 #if isinstance(self,compobloc.Node) :
854 # niveauPere=self.treeParent
855 # while (isinstance(niveauPere,compobloc.Node)):
856 # niveauPere=niveauPere.treeParent
857 # for c in self.children :
858 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
861 #print "dans setPlieChildren pour", self.item.nom
862 #print "je mets inhibeExpand a true dans setDeplie"
863 self.tree.inhibeExpand=True
865 self.tree.expandItem(self)
866 self.setDeplieChildren()
867 self.tree.inhibeExpand=False
868 #print "je mets inhibeExpand a false dans setDePlie"
870 def setDeplieChildren(self):
871 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
872 for c in self.children :
873 c.setDeplieChildren()
874 #print "dans setDeplieChildren ", c.item.nom
875 c.appartientAUnNoeudPlie=False
879 def selectAvant(self):
880 i=self.item.jdc.etapes.index(self.item.object)
882 cherche=self.item.jdc.etapes[i-1]
884 cherche=self.item.jdc.etapes[-1]
886 for i in self.tree.racine.children :
887 if i.item.object== cherche :
891 node.affichePanneau()
894 def selectApres(self):
895 i=self.item.jdc.etapes.index(self.item.object)
897 cherche=self.item.jdc.etapes[i+1]
899 cherche=self.item.jdc.etapes[0]
901 for i in self.tree.racine.children :
902 if i.item.object== cherche :
906 node.affichePanneau()
909 def ouvreLesNoeudsDsLArbre(self):
911 self.inhibeExpand = True
912 for i in range(self.childCount()):
913 self.child(i).inhibeExpand=True
914 self.child(i).setExpanded(True)
915 self.child(i).ouvreLesNoeudsDsLArbre()
916 self.child(i).inhibeExpand=False
917 self.inhibeExpand = False