1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 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
31 from . import typeNode
34 from six.moves import range
36 from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem, QApplication, QMessageBox
37 from PyQt5.QtGui import QIcon
38 from PyQt5.QtCore import Qt
39 from Extensions.i18n import tr
40 from .gereRegles import GereRegles
41 from .monChoixCommande import MonChoixCommande
43 #------------------------------------------
44 class JDCTree( QTreeWidget,GereRegles ):
45 #------------------------------------------
47 def __init__( self, jdc_item, QWParent):
48 #if hasattr(QWParent,'widgetTree') :
49 self.editor = QWParent
51 if self.editor.widgetTree !=None :
52 QTreeWidget.__init__(self, self.editor.widgetTree )
53 self.editor.verticalLayout_2.addWidget(self)
54 if self.editor.enteteQTree=='complet':
55 self.headerItem().setText(0, "Commande ")
56 self.headerItem().setText(1, "Concept/Valeur")
58 self.headerItem().setText(0, "Commande ")
59 self.setColumnWidth(0,200)
60 self.setExpandsOnDoubleClick(False)
61 self.setSelectionMode(3)
63 QTreeWidget.__init__(self, None )
66 self.appliEficas = self.editor.appliEficas
67 self.childrenComplete=[]
68 self.racine=self.item.itemNode(self,self.item)
72 self.itemClicked.connect(self.handleOnItem)
73 self.itemCollapsed.connect(self.handleCollapsedItem)
74 self.itemExpanded.connect(self.handleExpandedItem)
76 #PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
77 self.node_selected=self.racine
78 self.inhibeExpand=True
79 self.expandItem(self.racine)
80 self.inhibeExpand=False
81 #print ("self.editor.maConfiguration.afficheCommandesPliees", self.editor.maConfiguration.afficheCommandesPliees)
82 if self.racine.children !=[] :
83 #self.editor.initSplitterSizes(3)
84 if self.editor.maConfiguration.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
85 else : self.racine.children[0].deplieToutEtReaffiche()
86 self.racine.children[0].fenetre.donnePremier()
88 #self.editor.initSplitterSizes(2)
89 self.racine.affichePanneau()
90 #print self.editor.splitter.sizes()
94 def contextMenuEvent(self,event) :
95 #print "contextMenuEvent"
96 coord=event.globalPos()
97 item= self.currentItem()
98 self.handleContextMenu(item,coord)
100 def handleContextMenu(self,item,coord):
102 Private slot to show the context menu of the listview.
104 @param itm the selected listview item (QListWidgetItem)
105 @param coord the position of the mouse pointer (QPoint)
106 Attention : existeMenu permet de savoir si un menu est associe a cet item
108 #print "handleContextMenu"
109 if item == None : return
110 self.itemCourant=item
111 if item.existeMenu == 0 : return
112 if item.menu == None:
113 item.createPopUpMenu()
114 if item.menu != None:
115 if item.item.getNom() == "DISTRIBUTION" and item.item.isValid() :
116 item.Graphe.setEnabled(1)
117 item.menu.exec_(coord)
120 def handleCollapsedItem(self,item):
121 #print "dans CollapsedItem", self.inhibeExpand
122 if self.inhibeExpand == True : return
123 self.itemCourant=item
124 # On traite le cas de l item non selectionne
126 while not (hasattr (itemParent,'getPanel')) :
127 itemParent=itemParent.treeParent
128 if self.tree.node_selected != itemParent :
129 item.setExpanded(False)
134 item.plieToutEtReaffiche()
137 def handleExpandedItem(self,item):
138 #print ("handleExpandedItem pour ", item.item.nom, self.inhibeExpand)
140 #traceback.print_stack()
141 if self.inhibeExpand == True : return
142 self.itemCourant=item
143 self.inhibeExpand = True
145 while not (hasattr (itemParent,'getPanel')) :
146 if itemParent.plie==True : itemParent.setDeplie()
147 itemParent=itemParent.treeParent
148 if self.tree.node_selected != itemParent :
149 item.setExpanded(True)
150 self.inhibeExpand = False
152 item.deplieToutEtReaffiche()
153 self.inhibeExpand = False
156 def handleOnItem(self,item,int):
157 #print ("je passe dans handleOnItem pour ",self, item.item.nom, item, item.item, item.item.getLabelText())
159 from InterfaceQT4 import composimp
160 self.inhibeExpand = True
161 self.itemCourant=item
164 while not (hasattr (itemParent,'getPanel')) :
165 if itemParent.plie==True : itemParent.setDeplie()
166 itemParent=itemParent.treeParent
168 if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
169 estUneFeuille=(isinstance(item,composimp.Node))
170 # il faut afficher le parent
171 if estUneFeuille : itemParent.affichePanneau()
172 elif self.editor.maConfiguration.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
173 else : itemParent.affichePanneau()
176 elif (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
177 elif itemParent!=item:
178 self.tree.handleExpandedItem(item)
179 #item.fenetre.donnePremier()
180 #item.fenetre.rendActif()
181 #print 'il faut afficher le 1er'
184 fr = item.item.getFr()
185 chaineDecoupee= fr.split('\n')
186 if len(chaineDecoupee) > 3 :
187 txt='\n'.join(chaineDecoupee[0:2])+'...\nfull help : double clicked on validity chip of '+ str(item.item.nom)+ ' in central widget'
191 self.editor.afficheCommentaire(six.text_type(txt))
195 self.inhibeExpand = False
196 #print "je mets inhibeExpand a false handleOnItem"
199 def choisitPremier(self,name):
200 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
201 self.racine.fenetre.close()
202 new_node=self.racine.appendBrother(name,'after')
205 COMMENT = "COMMENTAIRE"
206 PARAMETERS = "PARAMETRE"
208 #------------------------------------------
209 class JDCNode(QTreeWidgetItem,GereRegles):
210 #------------------------------------------
211 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
212 #print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
217 self.vraiParent = treeParent
218 self.treeParent = treeParent
219 self.tree = self.treeParent.tree
220 self.editor = self.treeParent.editor
221 self.appliEficas = treeParent.appliEficas
223 self.childrenComplete=[]
226 from InterfaceQT4 import compocomm
227 from InterfaceQT4 import compoparam
228 from InterfaceQT4 import composimp
229 if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
230 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.getLabelText()[0]))
231 #else: name = tr(str(tr(item.getLabelText()[0]))+" :")
232 else: name = tr(item.getLabelText()[0])
233 if item.nom != tr(item.nom) : name = str(tr(item.nom)+" :")
234 value = tr(str( item.getText() ) )
236 # si specialisation de la fenetre
237 if self.item.object.definition == None : self.fenetreIhm = None
238 # Cas des listes de mots_clefs
239 else : self.fenetreIhm = self.item.object.definition.fenetreIhm
241 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
242 else : mesColonnes=(name,)
244 if self.treeParent.plie==True :
246 self.appartientAUnNoeudPlie=True
247 if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
250 self.appartientAUnNoeudPlie = False
252 #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
254 if ancien and itemExpand : self.plie = False
255 if ancien and not itemExpand : self.plie = True
256 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
258 from InterfaceQT4 import compobloc
259 from InterfaceQT4 import compomclist
261 ajoutAuParentduNoeud=0
262 self.treeParent=treeParent
263 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
264 self.treeParent.childrenComplete.append(self)
265 self.treeParent=self.treeParent.vraiParent
266 self.treeParent.childrenComplete.append(self)
269 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)) :
270 # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
271 QTreeWidgetItem.__init__(self,None,mesColonnes)
273 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
275 self.setToolTip(0,self.item.getFr())
276 self.setToolTip(1,self.item.getFr())
277 repIcon=self.appliEficas.repIcon
279 couleur=self.item.getIconName()
280 monIcone = QIcon(repIcon+"/" + couleur + ".png")
282 self.setIcon(0,monIcone)
289 self.item.connect("valid",self.onValid,())
290 self.item.connect("supp" ,self.onSupp,())
291 self.item.connect("add" ,self.onAdd,())
296 if self.item.getObject().isBLOC() :
297 self.setExpanded(True)
303 def buildChildren(self,posInsertion=10000):
304 """ Construit la liste des enfants de self """
305 """ Se charge de remettre les noeuds Expanded dans le meme etat """
306 #print ("*********** buildChildren ",self,self.item, self.item.nom)
309 self.listeItemExpanded=[]
310 self.listeItemPlie=[]
312 for enfant in self.childrenComplete :
313 if enfant.plie : self.listeItemPlie.append(enfant.item)
314 else : self.listeItemExpanded.append(enfant.item)
316 for enfant in self.childrenComplete :
317 parent=enfant.treeParent
318 parent.removeChild(enfant)
323 self.childrenComplete = []
324 sublist = self.item._getSubList()
327 for item in sublist :
330 if item in self.listeItemExpanded : itemExpand=True; ancien=True
331 if item in self.listeItemPlie : itemExpand=False; ancien=True
332 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
333 self.children.append(nouvelItem)
335 #print ("fin *********** buildChildren ",self,self.item, self.item.nom, self.children)
338 def chercheNoeudCorrespondant(self,objSimp):
339 sublist = self.item._getSubList()
340 for node in self.childrenComplete:
341 if node.item.object==objSimp : return node
345 def afficheCeNiveau(self):
346 #print ('afficheCeNiveau pour ', self.item.nom, self.item.getLabelText())
347 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
348 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
349 self.editor.widgetCentraleLayout.removeItem(widget)
350 if self.editor.fenetreCentraleAffichee != None :
351 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
352 self.editor.fenetreCentraleAffichee.setParent(None)
353 self.editor.fenetreCentraleAffichee.close()
354 self.editor.fenetreCentraleAffichee.deleteLater()
356 from monWidgetNiveauFact import MonWidgetNiveauFact, MonWidgetNiveauFactTableau
357 maDefinition=self.item.get_definition()
358 monObjet=self.item.object
359 if maDefinition.fenetreIhm=='Tableau' : self.maFenetreCadre=MonWidgetNiveauFactTableau(self,self.editor,maDefinition,monObjet)
360 else : self.maFenetreCadre=MonWidgetNiveauFact(self,self.editor,maDefinition,monObjet)
361 self.fenetre=self.maFenetreCadre
362 self.editor.widgetCentraleLayout.addWidget(self.maFenetreCadre)
363 self.editor.fenetreCentraleAffichee=self.maFenetreCadre
365 #print ('fin afficheCeNiveau pour ', self.item.nom)
368 def getPanelModifie(self):
370 if self.fenetreIhm == None : return None
371 if self.fenetreIhm=='deplie1Niveau':
372 from InterfaceQT4.monWidgetCommandeDeplie1Niveau import MonWidgetCommandeDeplie1Niveau
373 return MonWidgetCommandeDeplie1Niveau (self,self.editor ,self.item.object)
377 def affichePanneau(self) :
378 #if self.editor.code == 'ASTER' and not(self.item.isActif()) :
379 # posera des pb si un code decide d appeler FIN un mot clef
380 # on resoudera a ce moment la
381 # pour l pas de poussiere sous le tapis
382 #print ('_________________ds affichePanneau pour', self.item.nom)
383 if not(self.item.isActif()) :
384 from .monWidgetInactif import MonWidgetInactif
385 self.fenetre = MonWidgetInactif(self,self.editor)
388 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
389 if itemParent!=self :
390 #print ('j appelle affichePanneau pour ', itemParent.item.nom , 'par', self.item.nom)
391 itemParent.affichePanneau()
392 #print ('fin _________________ds affichePanneau pour', self.item.nom)
394 self.fenetre=self.getPanelModifie()
395 if self.fenetre == None : self.fenetre=self.getPanel()
396 self.editor.restoreSplitterSizes()
398 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
399 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
400 self.editor.widgetCentraleLayout.removeItem(widget)
401 # ceinture et bretelle
402 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
403 if self.editor.fenetreCentraleAffichee != None :
404 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
405 self.editor.fenetreCentraleAffichee.setParent(None)
406 self.editor.fenetreCentraleAffichee.close()
407 self.editor.fenetreCentraleAffichee.deleteLater()
409 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
410 #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
411 self.editor.fenetreCentraleAffichee=self.fenetre
412 self.tree.node_selected= self
414 if self.editor.first :
415 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
416 self.tree.inhibeExpand=True
417 self.tree.expandItem(self)
418 self.tree.inhibeExpand=False
419 #print( '_________________fin affichePanneau pour', self.item.nom)
422 def createPopUpMenu(self):
423 #implemente dans les noeuds derives si necessaire
428 Cette methode a pour but de commentariser la commande pointee par self
430 # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
431 # (commentariser) un commentaire.
433 pos=self.treeParent.children.index(self)
434 commande_comment = self.item.getObjetCommentarise()
435 # On signale a l editeur du panel (le JDCDisplay) une modification
436 self.editor.initModif()
437 self.treeParent.buildChildren()
438 self.treeParent.children[pos].select()
439 self.treeParent.children[pos].affichePanneau()
440 except Exception as e:
441 traceback.print_exc()
442 QMessageBox.critical( self.editor, "TOO BAD",str(e))
444 def unCommentIt(self):
446 Realise la decommentarisation de self
449 pos=self.treeParent.children.index(self)
450 commande,nom = self.item.unComment()
451 self.editor.initModif()
452 self.treeParent.buildChildren()
453 self.treeParent.children[pos].select()
454 self.treeParent.children[pos].affichePanneau()
455 except Exception as e:
456 QMessageBox.critical( self.editor, "Erreur !",str(e))
458 def addComment( self, after=True ):
460 Ajoute un commentaire a l'interieur du JDC :
462 self.editor.initModif()
467 return self.appendBrother( COMMENT, pos )
469 def addParameters( self, after=True ):
471 Ajoute un parametre a l'interieur du JDC :
473 self.editor.initModif()
474 if after: pos = 'after'
476 child=self.appendBrother( PARAMETERS, pos )
482 Rend le noeud courant (self) selectionne et deselectionne
485 #print "select pour", self.item.nom
486 for item in self.tree.selectedItems() :
488 self.tree.setCurrentItem( self )
490 #------------------------------------------------------------------
491 # Methodes de creation et destruction de noeuds
492 # Certaines de ces methodes peuvent etre appelees depuis l'externe
493 #------------------------------------------------------------------
494 def appendBrother(self,name,pos='after',plier=False):
496 Permet d'ajouter un objet frere a l'objet associe au noeud self
497 par defaut on l'ajoute immediatement apres
500 self.editor.initModif()
502 from InterfaceQT4 import compojdc
503 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
505 if self.treeParent != self.vraiParent :
506 index = self.vraiParent.children.index(self)
507 if pos == 'before': index = index
508 elif pos == 'after': index = index +1
509 return self.vraiParent.appendChild(name,pos=index,plier=plier)
511 index = self.treeParent.children.index(self)
512 if pos == 'before': index = index
513 elif pos == 'after': index = index +1
515 print(six.text_type(pos), tr(" n'est pas un index valide pour appendBrother"))
517 return self.treeParent.appendChild(name,pos=index,plier=plier)
519 def verifiePosition(self,name,pos,aLaRacine=False):
520 if name not in self.editor.readercata.Classement_Commandes_Ds_Arbre : return True
521 indexName=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(name)
523 etapes=self.item.getJdc().etapes
524 if etapes == [] : return True
526 if aLaRacine == False :indexOu=etapes.index(self.item.object)
529 if pos=="after" : indexOu = indexOu+1
530 for e in etapes[:indexOu] :
532 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
533 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
534 if indexEtape > indexName :
535 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
536 QMessageBox.information( None,tr('insertion impossible'),comment, )
538 for e in etapes[indexOu:] :
540 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
541 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
542 if indexEtape < indexName :
543 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
544 QMessageBox.information( None,tr('insertion impossible'),comment, )
548 def appendChild(self,name,pos=None,plier=False):
550 Methode pour ajouter un objet fils a l'objet associe au noeud self.
551 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
552 ou en position intermediaire.
553 Si pos vaut None, on le place a la position du catalogue.
555 #print ("************** appendChild ",self.item.getLabelText(), pos, plier)
557 #traceback.print_stack()
560 self.editor.initModif()
564 index = len(self.children)
565 elif type(pos) == int :
568 elif type(pos) == types.InstanceType:
569 # pos est un item. Il faut inserer name apres pos
570 index = self.item.getIndex(pos) +1
571 elif type(name) == types.InstanceType:
572 index = self.item.getIndexChild(name.nom)
574 index = self.item.getIndexChild(name)
576 # si on essaye d inserer a la racine
577 if (isinstance(self.treeParent,JDCTree) and index==0) :
578 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
579 if not verifiePosition : return 0
581 self.tree.inhibeExpand=True
582 obj=self.item.addItem(name,index) # emet le signal 'add'
587 child=self.children[index]
588 if plier == True : child.setPlie()
589 else : child.setDeplie()
591 child=self.children[index]
593 if len(obj) > 1 : self.buildChildren()
595 self.tree.inhibeExpand=False
596 #print (" fin append child")
600 self.editor.initModif()
601 index = self.treeParent.children.index(self) - 1
602 if index < 0 : index =0
603 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
607 Methode externe pour la destruction de l'objet associe au noeud
609 self.editor.initModif()
610 index = self.vraiParent.children.index(self) - 1
611 if index < 0 : index =0
613 if self.item.nom == "VARIABLE" :
616 ret,commentaire=self.vraiParent.item.suppItem(self.item)
618 self.editor.afficheInfos(commentaire,Qt.red)
620 self.editor.afficheInfos(commentaire)
621 self.treeParent.buildChildren()
622 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
623 else: toselect=self.treeParent
624 if recalcule : jdc.recalculeEtatCorrelation()
626 if self.treeParent.childrenComplete :
627 notdeleted=self.treeParent.childrenComplete[index+1]
631 from InterfaceQT4 import compojdc
632 # cas ou on detruit dans l arbre sans affichage
633 if isinstance(self.treeParent,compojdc.Node) :
634 toselect.affichePanneau()
636 if self.treeParent.fenetre== None : return
637 #print "J appelle reaffiche de browser apres delete"
638 self.treeParent.fenetre.reaffiche(toselect)
640 def deleteMultiple(self,liste=()):
642 Methode externe pour la destruction d une liste de noeud
644 from InterfaceQT4 import compojdc
645 self.editor.initModif()
650 while not(isinstance(jdc,compojdc.Node)):
653 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
654 if noeud.item.nom == "VARIABLE" : recalcule=1
655 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
656 if index < 0 : index =0
658 # Cas ou on detruit dans une ETape
660 parentPosition=self.treeParent
661 while not(isinstance(parentPosition, compojdc.Node)):
662 index=parentPosition.treeParent.children.index(parentPosition)
663 parentPosition=parentPosition.treeParent
666 noeud.treeParent.item.suppItem(noeud.item)
669 if recalcule : jdc.recalculeEtatCorrelation()
670 try : toselect=parentPosition.children[index]
671 except : toselect=jdc
673 toselect.affichePanneau()
675 # #------------------------------------------------------------------
678 #print ("onValid pour ", self.item.nom)
679 if self.JESUISOFF==1 : return
680 if hasattr(self,'fenetre') and self.fenetre:
682 self.fenetre.setValide()
684 # print "onValid pour ", self.item.nom, self,'pb'
687 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isValid():
688 self.item.jdc.recalculeEtatCorrelation()
689 if hasattr(self.item,'forceRecalcul'):
690 self.forceRecalculChildren(self.item.forceRecalcul)
691 self.editor.initModif()
693 self.updateNodeValid()
694 self.updateNodeLabel()
695 self.updateNodeTexte()
697 def onAdd(self,object):
698 if self.JESUISOFF==1 : return
699 #print "onAdd pour ", self.item.nom, object.nom
700 self.editor.initModif()
702 # PN -- non necessaire si item=jdc
703 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
705 def onSupp(self,object):
706 if self.JESUISOFF==1 : return
707 #print "onSup pour ", self.item.nom, object.nom
708 self.editor.initModif()
710 # PN -- non necessaire si item=jdc
711 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
715 def updateNodeValid(self):
716 """Cette methode remet a jour la validite du noeud (icone)
719 repIcon=self.appliEficas.repIcon
720 couleur=self.item.getIconName()
721 monIcone = QIcon(repIcon+"/" + couleur + ".png")
722 self.setIcon(0,monIcone)
726 def updateNodeLabel(self):
727 """ Met a jour le label du noeud """
728 #print "NODE updateNodeLabel", self.item.getLabelText()
729 labeltext,fonte,couleur = self.item.getLabelText()
731 self.setText(0, labeltext)
733 def updateNodeLabelInBlack(self):
734 if hasattr(self.appliEficas,'noeudColore'):
735 self.appliEficas.noeudColore.setForeground(0,Qt.black)
736 self.appliEficas.noeudColore.updateNodeLabel
738 def updateNodeLabelInBlue(self):
739 if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
740 self.setForeground(0,Qt.blue)
741 labeltext,fonte,couleur = self.item.getLabelText()
742 self.setText(0, labeltext)
743 self.appliEficas.noeudColore=self
745 def updatePlusieursNodeLabelInBlue(self,liste):
746 if hasattr(self.appliEficas,'listeNoeudsColores'):
747 for noeud in self.appliEficas.listeNoeudsColores:
748 noeud.setTextColor( 0,Qt.black)
749 noeud.updateNodeLabel()
750 self.appliEficas.listeNoeudsColores=[]
752 noeud.setTextColor( 0,Qt.blue )
753 labeltext,fonte,couleur = noeud.item.getLabelText()
754 noeud.setText(0, labeltext)
755 self.appliEficas.listeNoeudsColores.append(noeud)
757 def updateNodeTexteInBlack(self):
758 """ Met a jour les noms des SD et valeurs des mots-cles """
759 self.setTextColor( 1,Qt.black )
760 value = self.item.getText()
761 self.setText(1, value)
763 def updateNodeTexte(self):
764 """ Met a jour les noms des SD et valeurs des mots-cles """
765 value = self.item.getText()
766 self.setText(1, value)
769 def updateNodeTexteInBlue(self):
770 self.setTextColor( 1,Qt.blue )
771 value = self.item.getText()
772 self.setText(1, value)
774 def updateNodes(self):
775 #print 'NODE updateNodes', self.item.getLabelText()
778 def updateValid(self) :
779 """Cette methode a pour but de mettre a jour la validite du noeud
780 et de propager la demande de mise a jour a son parent
782 #print "NODE updateValid", self.item.getLabelText()
783 self.updateNodeValid()
785 self.treeParent.updateValid()
789 def updateTexte(self):
790 """ Met a jour les noms des SD et valeurs des mots-cles """
791 #print "NODE updateTexte", self.item.getLabelText()
792 self.updateNodeVexte()
793 if self.isExpanded() :
794 for child in self.children:
795 if child.isHidden() == false : child.updateTexte()
798 def forceRecalculChildren(self,niveau):
799 if self.state=='recalcule' :
802 self.state='recalcule'
803 if hasattr(self.item,'object'):
804 self.item.object.state="modified"
805 for child in self.children:
806 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
810 def doPaste(self,node_selected,pos='after'):
812 Declenche la copie de l'objet item avec pour cible
813 l'objet passe en argument : node_selected
815 objet_a_copier = self.item.getCopieObjet()
816 child=node_selected.doPasteCommande(objet_a_copier,pos)
817 if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau()
818 self.updateNodeLabelInBlack()
821 def doPasteCommande(self,objet_a_copier,pos='after'):
823 Realise la copie de l'objet passe en argument qui est necessairement
829 child = self.appendBrother(objet_a_copier,pos)
834 def doPastePremier(self,objet_a_copier):
836 Realise la copie de l'objet passe en argument (objet_a_copier)
838 objet = objet_a_copier.item.getCopieObjet()
839 child = self.appendChild(objet,pos='first')
842 def plieToutEtReafficheSaufItem(self, itemADeplier):
843 self.inhibeExpand=True
844 from InterfaceQT4 import compojdc
845 if (isinstance(self, compojdc.Node)) :
846 self.affichePanneau()
847 self.inhibeExpand=False
849 self.editor.deplier = False
850 for item in self.children :
851 # il ne faut pas plier les blocs
852 from InterfaceQT4 import compobloc
853 if (isinstance(item,compobloc.Node)) : continue
855 if item==itemADeplier :
856 itemADeplier.setDeplie()
857 self.affichePanneau()
858 self.inhibeExpand=False
860 def plieToutEtReaffiche(self):
861 #print ('plieToutEtReaffiche', self.item.getNom())
862 from InterfaceQT4 import compojdc
863 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
864 self.inhibeExpand=True
865 self.editor.deplier = False
866 for item in self.children :
867 # il ne faut pas plier les blocs
868 from InterfaceQT4 import compobloc
869 if (isinstance(item,compobloc.Node)) : continue
871 self.affichePanneau()
872 #print ("fin plieToutEtReaffiche", self.item.getNom())
874 def deplieToutEtReaffiche(self):
875 self.editor.deplier = True
876 for item in self.children :
878 self.affichePanneau()
881 #print "je mets inhibeExpand a true dans setPlie"
882 #print ("je suis dans plieTout", self.item.getNom())
883 from . import compojdc
884 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
886 self.tree.inhibeExpand=True
887 self.tree.collapseItem(self)
888 self.setPlieChildren()
889 self.tree.inhibeExpand=False
890 #print "je mets inhibeExpand a false dans setPlie"
893 # on ne plie pas au niveau 1
895 # for item in self.children :
896 # item.appartientAUnNoeudPlie=False
898 def setPlieChildren(self):
900 from InterfaceQT4 import composimp
901 if isinstance(self,composimp.Node) : return
902 for c in self.children :
904 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0]
905 c.appartientAUnNoeudPlie=True
907 #print "dans setPlieChildren plie", c.item.nom
908 # 01/2018 PNPN : boucle sur MT __ La ligne suivante ne me semble pas necessaire
909 #if not (isinstance(c,composimp.Node)) :c.setExpanded(False)
911 # Pour les blocs et les motcles list
912 # on affiche un niveau de plus
913 from InterfaceQT4 import compobloc
914 from InterfaceQT4 import compomclist
915 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
916 niveauPere=self.treeParent
917 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
918 niveauPere=niveauPere.treeParent
919 for c in self.children :
920 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
921 #print ("dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie)
926 #print "dans setPlieChildren pour", self.item.nom
927 #print "je mets inhibeExpand a true dans setDeplie"
928 self.tree.inhibeExpand=True
930 self.tree.expandItem(self)
931 self.setDeplieChildren()
932 self.tree.inhibeExpand=False
933 #print "je mets inhibeExpand a false dans setDePlie"
935 def setDeplieChildren(self):
936 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.getLabelText()
937 for c in self.children :
938 c.setDeplieChildren()
939 #print "dans setDeplieChildren ", c.item.nom
940 c.appartientAUnNoeudPlie=False
944 def selectAvant(self):
945 i=self.item.jdc.etapes.index(self.item.object)
947 cherche=self.item.jdc.etapes[i-1]
949 cherche=self.item.jdc.etapes[-1]
951 for i in self.tree.racine.children :
952 if i.item.object== cherche :
956 node.affichePanneau()
959 def selectApres(self):
960 i=self.item.jdc.etapes.index(self.item.object)
962 cherche=self.item.jdc.etapes[i+1]
964 cherche=self.item.jdc.etapes[0]
966 for i in self.tree.racine.children :
967 if i.item.object== cherche :
971 node.affichePanneau()
974 def ouvreLesNoeudsDsLArbre(self):
976 self.inhibeExpand = True
977 for i in range(self.childCount()):
978 self.child(i).inhibeExpand=True
979 self.child(i).setExpanded(True)
980 self.child(i).ouvreLesNoeudsDsLArbre()
981 self.child(i).inhibeExpand=False
982 self.inhibeExpand = False