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 """
662 #print "NODE update_node_label", self.item.GetLabelText()
663 labeltext,fonte,couleur = self.item.GetLabelText()
665 #self.setText(0, labeltext)
668 def update_node_label_in_blue(self):
669 if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
670 self.setForeground(0,Qt.blue)
671 labeltext,fonte,couleur = self.item.GetLabelText()
672 self.setText(0, labeltext)
673 self.appliEficas.noeudColore=self
675 def update_plusieurs_node_label_in_blue(self,liste):
676 if hasattr(self.appliEficas,'listeNoeudsColores'):
677 for noeud in self.appliEficas.listeNoeudsColores:
678 noeud.setTextColor( 0,Qt.black)
679 noeud.update_node_label()
680 self.appliEficas.listeNoeudsColores=[]
682 noeud.setTextColor( 0,Qt.blue )
683 labeltext,fonte,couleur = noeud.item.GetLabelText()
684 noeud.setText(0, labeltext)
685 self.appliEficas.listeNoeudsColores.append(noeud)
687 def update_node_texte_in_black(self):
688 """ Met a jour les noms des SD et valeurs des mots-cles """
689 self.setTextColor( 1,Qt.black )
690 value = self.item.GetText()
691 self.setText(1, value)
693 def update_node_texte(self):
694 """ Met a jour les noms des SD et valeurs des mots-cles """
695 value = self.item.GetText()
696 self.setText(1, value)
699 def update_node_texte_in_blue(self):
700 self.setTextColor( 1,Qt.blue )
701 value = self.item.GetText()
702 self.setText(1, value)
704 def update_nodes(self):
705 #print 'NODE update_nodes', self.item.GetLabelText()
706 self.build_children()
708 def update_valid(self) :
709 """Cette methode a pour but de mettre a jour la validite du noeud
710 et de propager la demande de mise a jour a son parent
712 #print "NODE update_valid", self.item.GetLabelText()
713 self.update_node_valid()
715 self.treeParent.update_valid()
719 def update_texte(self):
720 """ Met a jour les noms des SD et valeurs des mots-cles """
721 #print "NODE update_texte", self.item.GetLabelText()
722 self.update_node_texte()
723 if self.isExpanded() :
724 for child in self.children:
725 if child.isHidden() == false : child.update_texte()
728 def forceRecalculChildren(self,niveau):
729 if self.state=='recalcule' :
732 self.state='recalcule'
733 if hasattr(self.item,'object'):
734 self.item.object.state="modified"
735 for child in self.children:
736 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
740 def doPaste(self,node_selected,pos='after'):
742 Declenche la copie de l'objet item avec pour cible
743 l'objet passe en argument : node_selected
745 #print 'je passe dans doPaste'
746 objet_a_copier = self.item.get_copie_objet()
747 child=node_selected.doPasteCommande(objet_a_copier,pos)
750 def doPasteCommande(self,objet_a_copier,pos='after'):
752 Realise la copie de l'objet passe en argument qui est necessairement
758 child = self.append_brother(objet_a_copier,pos)
763 def doPastePremier(self,objet_a_copier):
765 Realise la copie de l'objet passe en argument (objet_a_copier)
767 objet = objet_a_copier.item.get_copie_objet()
768 child = self.append_child(objet,pos='first')
771 def plieToutEtReafficheSaufItem(self, itemADeplier):
772 #print "je suis dans plieToutEtReaffiche", self.item.get_nom()
773 self.inhibeExpand=True
774 from InterfaceQT4 import compojdc
775 if (isinstance(self, compojdc.Node)) :
776 self.affichePanneau()
777 self.inhibeExpand=False
779 self.editor.deplier = False
780 for item in self.children :
781 # il ne faut pas plier les blocs
782 from InterfaceQT4 import compobloc
783 if (isinstance(item,compobloc.Node)) : continue
785 if item==itemADeplier :
786 itemADeplier.setDeplie()
787 self.affichePanneau()
788 self.inhibeExpand=False
790 def plieToutEtReaffiche(self):
791 from InterfaceQT4 import compojdc
792 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
793 self.inhibeExpand=True
794 self.editor.deplier = False
795 for item in self.children :
796 # il ne faut pas plier les blocs
797 from InterfaceQT4 import compobloc
798 if (isinstance(item,compobloc.Node)) : continue
800 self.affichePanneau()
802 def deplieToutEtReaffiche(self):
803 self.editor.deplier = True
804 for item in self.children :
806 self.affichePanneau()
809 #print "je mets inhibeExpand a true dans setPlie"
810 #print "je suis dans plieTout", self.item.get_nom()
811 from . import compojdc
812 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
814 self.tree.inhibeExpand=True
815 self.tree.collapseItem(self)
816 self.setPlieChildren()
817 self.tree.inhibeExpand=False
818 #print "je mets inhibeExpand a false dans setPlie"
821 # on ne plie pas au niveau 1
823 # for item in self.children :
824 # item.appartientAUnNoeudPlie=False
826 def setPlieChildren(self):
827 #print "dans setPlieChildren pour", self.item.nom
829 for c in self.children :
831 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0]
832 c.appartientAUnNoeudPlie=True
834 #print "dans setPlieChildren plie", c.item.nom
837 # Pour les blocs et les motcles list
838 # on affiche un niveau de plus
839 from InterfaceQT4 import compobloc
840 from InterfaceQT4 import compomclist
841 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
842 niveauPere=self.treeParent
843 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
844 niveauPere=niveauPere.treeParent
845 for c in self.children :
846 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
847 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie
850 # on affiche un niveau de plus
851 #if isinstance(self,compomclist.Node) :
852 #if isinstance(self,compobloc.Node) :
853 # niveauPere=self.treeParent
854 # while (isinstance(niveauPere,compobloc.Node)):
855 # niveauPere=niveauPere.treeParent
856 # for c in self.children :
857 # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
860 #print "dans setPlieChildren pour", self.item.nom
861 #print "je mets inhibeExpand a true dans setDeplie"
862 self.tree.inhibeExpand=True
864 self.tree.expandItem(self)
865 self.setDeplieChildren()
866 self.tree.inhibeExpand=False
867 #print "je mets inhibeExpand a false dans setDePlie"
869 def setDeplieChildren(self):
870 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText()
871 for c in self.children :
872 c.setDeplieChildren()
873 #print "dans setDeplieChildren ", c.item.nom
874 c.appartientAUnNoeudPlie=False
878 def selectAvant(self):
879 i=self.item.jdc.etapes.index(self.item.object)
881 cherche=self.item.jdc.etapes[i-1]
883 cherche=self.item.jdc.etapes[-1]
885 for i in self.tree.racine.children :
886 if i.item.object== cherche :
890 node.affichePanneau()
893 def selectApres(self):
894 i=self.item.jdc.etapes.index(self.item.object)
896 cherche=self.item.jdc.etapes[i+1]
898 cherche=self.item.jdc.etapes[0]
900 for i in self.tree.racine.children :
901 if i.item.object== cherche :
905 node.affichePanneau()
908 def ouvreLesNoeudsDsLArbre(self):
910 self.inhibeExpand = True
911 for i in range(self.childCount()):
912 self.child(i).inhibeExpand=True
913 self.child(i).setExpanded(True)
914 self.child(i).ouvreLesNoeudsDsLArbre()
915 self.child(i).inhibeExpand=False
916 self.inhibeExpand = False