1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 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 PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem, QApplication, QMessageBox
35 from PyQt5.QtGui import QIcon
36 from PyQt5.QtCore import Qt
38 from Extensions.i18n import tr
39 from .gereRegles import GereRegles
40 from .monChoixCommande import MonChoixCommande
42 #------------------------------------------
43 class JDCTree( QTreeWidget,GereRegles ):
44 #------------------------------------------
46 def __init__( self, jdc_item, QWParent):
47 #----------------------------------------
48 self.editor = QWParent
50 if self.editor.widgetTree !=None :
51 QTreeWidget.__init__(self, self.editor.widgetTree )
52 self.editor.verticalLayout_2.addWidget(self)
53 if self.editor.enteteQTree=='complet':
54 self.headerItem().setText(0, "Commande ")
55 self.headerItem().setText(1, "Concept/Valeur")
57 self.headerItem().setText(0, "Commande ")
58 self.setColumnWidth(0,200)
59 self.setExpandsOnDoubleClick(False)
60 self.setSelectionMode(3)
62 QTreeWidget.__init__(self, None )
65 self.appliEficas = self.editor.appliEficas
66 self.childrenComplete=[]
67 self.racine=self.item.itemNode(self,self.item)
71 self.itemClicked.connect(self.handleOnItem)
72 self.itemCollapsed.connect(self.handleCollapsedItem)
73 self.itemExpanded.connect(self.handleExpandedItem)
75 self.node_selected = self.racine
76 self.inhibeExpand = True
77 self.expandItem(self.racine)
78 self.inhibeExpand = False
79 if self.racine.children !=[] :
80 if self.editor.maConfiguration.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
81 else : self.racine.children[0].deplieToutEtReaffiche()
82 self.racine.children[0].fenetre.donnePremier()
84 self.racine.affichePanneau()
86 def contextMenuEvent(self,event) :
87 #---------------------------------
88 coord = event.globalPos()
89 item = self.currentItem()
90 self.handleContextMenu(item,coord)
92 def handleContextMenu(self,item,coord):
93 #-------------------------------------
95 Private slot to show the context menu of the listview.
97 @param itm the selected listview item (QListWidgetItem)
98 @param coord the position of the mouse pointer (QPoint)
99 Attention : existeMenu permet de savoir si un menu est associe a cet item
101 #print ("handleContextMenu")
102 if item == None : return
103 self.itemCourant = item
104 if item.existeMenu == 0 : return
106 if item.menu == None:
107 item.createPopUpMenu()
108 # PNPN reflechir a qqchose de generique pour remplacer cette fonctionnalite
109 #if item.menu != None:
110 # if item.item.getNom() == "DISTRIBUTION" and item.item.isValid() :
111 # item.Graphe.setEnabled(1)
112 # item.menu.exec_(coord)
115 def handleCollapsedItem(self,item):
116 #----------------------------------
117 #print ("dans CollapsedItem", self.inhibeExpand )
118 if self.inhibeExpand == True : return
120 # On traite le cas de l item non selectionne
121 self.itemCourant = item
123 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
124 if self.tree.node_selected != itemParent :
125 item.setExpanded(False)
129 item.plieToutEtReaffiche()
132 def handleExpandedItem(self,item):
133 #----------------------------------
134 #print ("handleExpandedItem pour ", item.item.nom, self.inhibeExpand)
136 #traceback.print_stack()
137 if self.inhibeExpand == True : return
139 self.itemCourant = item
140 self.inhibeExpand = True
142 while not (hasattr (itemParent,'getPanel')) :
143 if itemParent.plie==True : itemParent.setDeplie()
144 itemParent=itemParent.treeParent
145 if self.tree.node_selected != itemParent :
146 item.setExpanded(True)
147 self.inhibeExpand = False
149 item.deplieToutEtReaffiche()
150 self.inhibeExpand = False
153 def handleOnItem(self,item,int):
154 #----------------------------------
155 #print ("je passe dans handleOnItem pour ",self, item.item.nom, item, item.item, item.item.getLabelText())
157 from InterfaceQT4 import composimp
158 self.inhibeExpand = True
159 self.itemCourant = item
162 # PN : 22 juil 2021 --> bizarre ce itemAvant Verifier le while
163 while not (hasattr (itemParent,'getPanel')) :
164 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 # Attention - Specification particuliere pour MT qui permet de nn afficher qu 1 niveau
172 # le catalogue contient cette indication dans fenetreIhm
173 if estUneFeuille and itemParent.fenetreIhm=='deplie1Niveau' :
174 itemAvant.afficheCeNiveau()
176 if estUneFeuille : itemParent.affichePanneau()
177 elif self.editor.maConfiguration.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
178 else : itemParent.affichePanneau()
181 elif (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
182 elif itemParent!=item: self.tree.handleExpandedItem(item)
186 fr = item.item.getFr()
187 chaineDecoupee= fr.split('\n')
188 if len(chaineDecoupee) > 3 :
189 txt='\n'.join(chaineDecoupee[0:2])+'...\nfull help : double clicked on validity chip of '+ str(item.item.nom)+ ' in central widget'
191 if self.editor: self.editor.afficheCommentaire(str(txt))
196 self.inhibeExpand = False
199 def choisitPremier(self,name):
200 #----------------------------
201 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
202 self.racine.fenetre.close()
203 new_node=self.racine.appendBrother(name,'after')
206 COMMENT = "COMMENTAIRE"
207 PARAMETERS = "PARAMETRE"
209 #------------------------------------------
210 class JDCNode(QTreeWidgetItem,GereRegles):
211 #------------------------------------------
212 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
213 #----------------------------------------------------------------------
214 #print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
219 self.vraiParent = treeParent
220 self.treeParent = treeParent
221 self.tree = self.treeParent.tree
222 self.editor = self.treeParent.editor
223 self.appliEficas = treeParent.appliEficas
225 self.firstAffiche = True
226 self.childrenComplete=[]
229 from InterfaceQT4 import compocomm
230 from InterfaceQT4 import compoparam
231 from InterfaceQT4 import composimp
232 if (isinstance(self.item,compocomm.COMMTreeItem)) : name = tr("Commentaire")
233 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name = tr(str(item.getLabelText()[0]))
234 else : name = tr(item.getLabelText()[0])
235 if item.nom != tr(item.nom) : name = str(tr(item.nom)+" :")
236 value = tr(str(item.getText() ) )
238 # si specialisation de la fenetre
239 if self.item.object.definition == None : self.fenetreIhm = None
240 # Cas des listes de mots_clefs
241 else : self.fenetreIhm = self.item.object.definition.fenetreIhm
243 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
244 else : mesColonnes=(name,)
246 if self.treeParent.plie==True :
248 self.appartientAUnNoeudPlie = True
249 if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
252 self.appartientAUnNoeudPlie = False
254 #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
256 if ancien and itemExpand : self.plie = False
257 if ancien and not itemExpand : self.plie = True
258 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
260 from InterfaceQT4 import compobloc
261 from InterfaceQT4 import compomclist
263 ajoutAuParentduNoeud=0
264 self.treeParent=treeParent
265 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
266 self.treeParent.childrenComplete.append(self)
267 self.treeParent=self.treeParent.vraiParent
268 self.treeParent.childrenComplete.append(self)
271 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)) :
272 # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
273 QTreeWidgetItem.__init__(self,None,mesColonnes)
275 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
277 self.setToolTip(0,self.item.getFr())
278 self.setToolTip(1,self.item.getFr())
279 repIcon=self.appliEficas.repIcon
281 couleur=self.item.getIconName()
282 monIcone = QIcon(repIcon+"/" + couleur + ".png")
284 self.setIcon(0,monIcone)
291 self.item.connect("valid",self.onValid,())
292 self.item.connect("supp" ,self.onSupp,())
293 self.item.connect("add" ,self.onAdd,())
294 self.item.connect("redessine" ,self.onRedessine,())
299 if self.item.getObject().isBLOC() :
300 self.setExpanded(True)
306 def buildChildren(self,posInsertion=10000):
307 #------------------------------------------
308 """ Construit la liste des enfants de self """
309 """ Se charge de remettre les noeuds Expanded dans le meme etat """
310 #print ("*********** buildChildren ",self,self.item, self.item.nom)
313 self.listeItemExpanded=[]
314 self.listeItemPlie=[]
316 for enfant in self.childrenComplete :
317 if enfant.plie : self.listeItemPlie.append(enfant.item)
318 else : self.listeItemExpanded.append(enfant.item)
320 for enfant in self.childrenComplete :
321 parent = enfant.treeParent
322 parent.removeChild(enfant)
327 self.childrenComplete = []
328 sublist = self.item._getSubList()
331 for item in sublist :
334 if item in self.listeItemExpanded : itemExpand=True; ancien=True
335 if item in self.listeItemPlie : itemExpand=False; ancien=True
336 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
337 self.children.append(nouvelItem)
339 #print ("fin *********** buildChildren ",self,self.item, self.item.nom, self.children)
342 def chercheNoeudCorrespondant(self,objSimp):
343 #-------------------------------------------
344 sublist = self.item._getSubList()
345 for node in self.childrenComplete:
346 if node.item.object==objSimp : return node
350 def afficheCeNiveau(self):
351 #-------------------------
352 #print ('afficheCeNiveau pour ', self.item.nom, self.item.getLabelText())
353 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
354 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
355 self.editor.widgetCentraleLayout.removeItem(widget)
356 if self.editor.fenetreCentraleAffichee != None :
357 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
358 self.editor.fenetreCentraleAffichee.setParent(None)
359 self.editor.fenetreCentraleAffichee.close()
360 self.editor.fenetreCentraleAffichee.deleteLater()
362 from monWidgetNiveauFact import MonWidgetNiveauFact, MonWidgetNiveauFactTableau
363 maDefinition = self.item.get_definition()
364 monObjet = self.item.object
365 if maDefinition.fenetreIhm=='Tableau' : self.maFenetreCadre=MonWidgetNiveauFactTableau(self,self.editor,maDefinition,monObjet)
366 else : self.maFenetreCadre=MonWidgetNiveauFact(self,self.editor,maDefinition,monObjet)
368 self.fenetre = self.maFenetreCadre
369 self.editor.widgetCentraleLayout.addWidget(self.maFenetreCadre)
370 self.editor.fenetreCentraleAffichee=self.maFenetreCadre
372 #print ('fin afficheCeNiveau pour ', self.item.nom)
375 def getPanelModifie(self):
376 #-------------------------
378 if self.fenetreIhm == None : return None
379 if self.fenetreIhm =='deplie1Niveau':
380 from InterfaceQT4.monWidgetCommandeDeplie1Niveau import MonWidgetCommandeDeplie1Niveau
381 return MonWidgetCommandeDeplie1Niveau (self,self.editor ,self.item.object)
385 def affichePanneau(self) :
386 #-------------------------
387 #print ('_________________ds affichePanneau pour', self.item.nom)
388 # pour l instant pas d inactif
389 if not(self.item.isActif()) :
390 from .monWidgetInactif import MonWidgetInactif
391 self.fenetre = MonWidgetInactif(self,self.editor)
394 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
395 if itemParent != self :
396 #print ('j appelle affichePanneau pour ', itemParent.item.nom , 'par', self.item.nom)
397 itemParent.affichePanneau()
398 #print ('fin _________________ds affichePanneau pour', self.item.nom)
401 self.fenetre = self.getPanelModifie()
402 if self.fenetre == None : self.fenetre=self.getPanel()
403 self.editor.restoreSplitterSizes()
405 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
406 widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
407 self.editor.widgetCentraleLayout.removeItem(widget)
409 # ceinture et bretelle
410 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
411 if self.editor.fenetreCentraleAffichee != None :
413 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
414 self.editor.fenetreCentraleAffichee.setParent(None)
415 self.editor.fenetreCentraleAffichee.close()
416 self.editor.fenetreCentraleAffichee.deleteLater()
420 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
421 #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
422 self.editor.fenetreCentraleAffichee=self.fenetre
423 self.tree.node_selected= self
425 if self.editor.first :
426 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
427 self.tree.inhibeExpand=True
428 self.tree.expandItem(self)
429 self.tree.inhibeExpand=False
430 #print( '_________________fin affichePanneau pour', self.item.nom)
433 def createPopUpMenu(self):
434 #-------------------------
435 #implemente dans les noeuds derives si necessaire
439 #-------------------------
441 Cette methode a pour but de commentariser la commande pointee par self
443 # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
444 # (commentariser) un commentaire.
446 pos=self.treeParent.children.index(self)
447 commande_comment = self.item.getObjetCommentarise()
448 # On signale a l editeur du panel (le JDCDisplay) une modification
449 self.editor.initModif()
450 self.treeParent.buildChildren()
451 self.treeParent.children[pos].select()
452 self.treeParent.children[pos].affichePanneau()
453 except Exception as e:
454 traceback.print_exc()
455 QMessageBox.critical( self.editor, "TOO BAD",str(e))
457 def unCommentIt(self):
458 #-------------------------
460 Realise la decommentarisation de self
463 pos=self.treeParent.children.index(self)
464 commande,nom = self.item.unComment()
465 self.editor.initModif()
466 self.treeParent.buildChildren()
467 self.treeParent.children[pos].select()
468 self.treeParent.children[pos].affichePanneau()
469 except Exception as e:
470 QMessageBox.critical( self.editor, "Erreur !",str(e))
472 def addComment( self, after=True ):
473 #-----------------------------------
475 Ajoute un commentaire a l'interieur du JDC :
477 self.editor.initModif()
482 return self.appendBrother( COMMENT, pos )
484 def addParameters( self, after=True ):
485 #-------------------------------------
487 Ajoute un parametre a l'interieur du JDC :
489 self.editor.initModif()
490 if after: pos = 'after'
492 child=self.appendBrother( PARAMETERS, pos )
499 Rend le noeud courant (self) selectionne et deselectionne
502 #print "select pour", self.item.nom
503 for item in self.tree.selectedItems() :
505 self.tree.setCurrentItem( self )
507 #------------------------------------------------------------------
508 # Methodes de creation et destruction de noeuds
509 #------------------------------------------------------------------
511 def appendBrother(self,name,pos='after',plier=False):
512 #----------------------------------------------------
514 Permet d'ajouter un objet frere a l'objet associe au noeud self
515 par defaut on l'ajoute immediatement apres
518 self.editor.initModif()
520 from InterfaceQT4 import compojdc
521 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
523 if self.treeParent != self.vraiParent :
524 index = self.vraiParent.children.index(self)
525 if pos == 'before' : index = index
526 elif pos == 'after' : index = index +1
527 return self.vraiParent.appendChild(name,pos=index,plier=plier)
529 index = self.treeParent.children.index(self)
530 if pos == 'before': index = index
531 elif pos == 'after' : index = index +1
533 print(pos, tr(" n'est pas un index valide pour appendBrother"))
535 return self.treeParent.appendChild(name,pos=index,plier=plier)
537 def verifiePosition(self,name,pos,aLaRacine=False):
538 #----------------------------------------------------
539 if name not in self.editor.readercata.Classement_Commandes_Ds_Arbre : return True
540 indexName=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(name)
542 etapes=self.item.getJdc().etapes
543 if etapes == [] : return True
545 if aLaRacine == False :indexOu=etapes.index(self.item.object)
548 if pos=="after" : indexOu = indexOu+1
549 for e in etapes[:indexOu] :
551 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
552 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
553 if indexEtape > indexName :
554 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
555 QMessageBox.information( None,tr('insertion impossible'),comment, )
557 for e in etapes[indexOu:] :
559 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
560 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
561 if indexEtape < indexName :
562 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
563 QMessageBox.information( None,tr('insertion impossible'),comment, )
567 def appendChild(self,name,pos=None,plier=False):
568 #------------------------------------------------
570 Methode pour ajouter un objet fils a l'objet associe au noeud self.
571 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
572 ou en position intermediaire.
573 Si pos vaut None, on le place a la position du catalogue.
575 #print ("************** appendChild ",self.item.getLabelText(), pos, plier)
577 #traceback.print_stack()
580 self.editor.initModif()
581 if pos == 'first' : index = 0
582 elif pos == 'last' : index = len(self.children)
583 elif type(pos) == int : index = pos # position fixee
584 elif type(pos) == object : index = self.item.getIndex(pos) +1 # pos est un item. Il faut inserer name apres pos
585 elif type(name) == object : index = self.item.getIndexChild(name.nom)
586 else : index = self.item.getIndexChild(name)
588 # si on essaye d inserer a la racine
589 if (isinstance(self.treeParent,JDCTree) and index==0) :
590 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
591 if not verifiePosition : return 0
593 self.tree.inhibeExpand = True
594 obj = self.item.addItem(name,index) # emet le signal 'add'
595 if obj is None : obj=0
596 if obj == 0 :return 0
600 child = self.children[index]
601 if plier == True : child.setPlie()
602 else : child.setDeplie()
604 child=self.children[index]
607 if len(obj) > 1 : self.buildChildren()
610 self.tree.inhibeExpand=False
611 #print (" fin append child")
616 self.editor.initModif()
617 index = self.treeParent.children.index(self) - 1
618 if index < 0 : index =0
619 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
624 Methode externe pour la destruction de l'objet associe au noeud
626 self.editor.initModif()
627 index = self.vraiParent.children.index(self) - 1
628 if index < 0 : index =0
631 if self.item.nom == "VARIABLE" :
635 ret,commentaire=self.vraiParent.item.suppItem(self.item)
636 if ret==0 : self.editor.afficheInfos(commentaire,Qt.red)
637 else : self.editor.afficheInfos(commentaire)
638 self.treeParent.buildChildren()
639 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
640 else : toselect=self.treeParent
642 if recalcule : jdc.recalculeEtatCorrelation()
644 if self.treeParent.childrenComplete :
645 notdeleted=self.treeParent.childrenComplete[index+1]
650 from InterfaceQT4 import compojdc
651 # cas ou on detruit dans l arbre sans affichage
652 if isinstance(self.treeParent,compojdc.Node) :
653 toselect.affichePanneau()
655 if self.treeParent.fenetre== None : return
656 #print "J appelle reaffiche de browser apres delete"
657 self.treeParent.fenetre.reaffiche(toselect)
659 def deleteMultiple(self,liste=()):
660 #--------------------------------
662 Methode externe pour la destruction d une liste de noeud
664 from InterfaceQT4 import compojdc
665 self.editor.initModif()
670 while not(isinstance(jdc,compojdc.Node)):
673 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
674 if noeud.item.nom == "VARIABLE" : recalcule=1
675 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
676 if index < 0 : index =0
678 # Cas ou on detruit dans une ETape
680 parentPosition=self.treeParent
681 while not(isinstance(parentPosition, compojdc.Node)):
682 index=parentPosition.treeParent.children.index(parentPosition)
683 parentPosition=parentPosition.treeParent
686 noeud.treeParent.item.suppItem(noeud.item)
689 if recalcule : jdc.recalculeEtatCorrelation()
690 try : toselect=parentPosition.children[index]
691 except : toselect=jdc
693 toselect.affichePanneau()
695 # ------------------------------------------------------------------
699 #print ("onValid pour ", self.item.nom)
700 if self.JESUISOFF==1 : return
702 if hasattr(self,'fenetre') and self.fenetre:
703 try : self.fenetre.setValide()
706 # PNPN lignes suivantes a repenser
707 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isValid():
708 self.item.jdc.recalculeEtatCorrelation()
709 if hasattr(self.item,'forceRecalcul') : self.forceRecalculChildren(self.item.forceRecalcul)
710 self.editor.initModif()
712 self.updateNodeValid()
713 self.updateNodeLabel()
714 self.updateNodeTexte()
717 def onAdd(self,object):
718 #----------------------
719 #print ("onAdd pour ", self.item.nom, object)
720 if self.JESUISOFF == 1 : return
721 self.editor.initModif()
723 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
725 def onSupp(self,object):
726 #-----------------------
727 #print ("onSup pour ", self.item.nom, object)
729 #traceback.print_stack()
730 if self.JESUISOFF==1 : return
731 self.editor.initModif()
733 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
735 def onRedessine(self):
736 #---------------------
737 #print ('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!je passe dans onRedessine pour', self.item.nom)
738 self.affichePanneau()
740 def updateNodeValid(self):
741 #-----------------------
742 """Cette methode remet a jour la validite du noeud (icone)
745 repIcon = self.appliEficas.repIcon
746 couleur = self.item.getIconName()
747 monIcone = QIcon(repIcon+"/" + couleur + ".png")
748 self.setIcon(0,monIcone)
752 def updateNodeLabel(self):
753 #-------------------------
754 """ Met a jour le label du noeud """
755 #print ("NODE updateNodeLabel", self.item.getLabelText())
756 labeltext,fonte,couleur = self.item.getLabelText()
758 if self.item.nom != tr(self.item.nom) : labeltext = str(tr(self.item.nom)+" :")
759 self.setText(0, tr(labeltext))
761 def updateNodeLabelInBlack(self):
762 #-------------------------------
763 if hasattr(self.appliEficas,'noeudColore'):
764 self.appliEficas.noeudColore.setForeground(0,Qt.black)
765 self.appliEficas.noeudColore.updateNodeLabel
767 def updateNodeLabelInBlue(self):
768 #-------------------------------
769 if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
770 self.setForeground(0,Qt.blue)
771 labeltext,fonte,couleur = self.item.getLabelText()
772 if self.item.nom != tr(self.item.nom) : labeltext = str(tr(self.item.nom)+" :")
773 self.setText(0, labeltext)
774 self.appliEficas.noeudColore=self
776 def updatePlusieursNodeLabelInBlue(self,liste):
777 #----------------------------------------------
778 if hasattr(self.appliEficas,'listeNoeudsColores'):
779 for noeud in self.appliEficas.listeNoeudsColores:
780 noeud.setTextColor( 0,Qt.black)
781 noeud.updateNodeLabel()
782 self.appliEficas.listeNoeudsColores=[]
784 noeud.setTextColor( 0,Qt.blue )
785 if item.nom != tr(item.nom) : labeltext = str(tr(item.nom)+" :")
786 labeltext,fonte,couleur = noeud.item.getLabelText()
787 noeud.setText(0, labeltext)
788 self.appliEficas.listeNoeudsColores.append(noeud)
790 def updateNodeTexteInBlack(self):
791 #--------------------------------
792 """ Met a jour les noms des SD et valeurs des mots-cles """
793 self.setTextColor( 1,Qt.black )
794 value = self.item.getText()
795 self.setText(1, value)
797 def updateNodeTexte(self):
798 #----------------------------
799 """ Met a jour les noms des SD et valeurs des mots-cles """
800 value = self.item.getText()
801 self.setText(1, value)
804 def updateNodeTexteInBlue(self):
805 #--------------------------------
806 self.setTextColor( 1,Qt.blue )
807 value = self.item.getText()
808 self.setText(1, value)
810 def updateNodes(self):
811 #--------------------------------
812 #print 'NODE updateNodes', self.item.getLabelText()
815 def updateValid(self) :
816 #----------------------
817 """Cette methode a pour but de mettre a jour la validite du noeud
818 et de propager la demande de mise a jour a son parent
820 #print "NODE updateValid", self.item.getLabelText()
821 self.updateNodeValid()
822 try : self.treeParent.updateValid()
825 def updateTexte(self):
826 #----------------------
827 """ Met a jour les noms des SD et valeurs des mots-cles """
828 #print "NODE updateTexte", self.item.getLabelText()
829 self.updateNodeTexte()
830 if self.isExpanded() :
831 for child in self.children:
832 if child.isHidden() == false : child.updateTexte()
835 def forceRecalculChildren(self,niveau):
836 #--------------------------------------
837 if self.state == 'recalcule' :
840 self.state='recalcule'
841 if hasattr(self.item,'object'):
842 self.item.object.state="modified"
843 for child in self.children:
844 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
848 def doPaste(self,node_selected,pos='after'):
849 #--------------------------------------------
851 Declenche la copie de l'objet item avec pour cible
852 l'objet passe en argument : node_selected
854 objet_a_copier = self.item.getCopieObjet()
855 child=node_selected.doPasteCommande(objet_a_copier,pos)
856 if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau()
857 self.updateNodeLabelInBlack()
860 def doPasteCommande(self,objet_a_copier,pos='after'):
861 #-----------------------------------------------------
863 Realise la copie de l'objet passe en argument qui est necessairement
869 child = self.appendBrother(objet_a_copier,pos)
874 def doPastePremier(self,objet_a_copier):
875 #---------------------------------------
877 Realise la copie de l'objet passe en argument (objet_a_copier)
879 objet = objet_a_copier.item.getCopieObjet()
880 child = self.appendChild(objet,pos='first')
883 def plieToutEtReafficheSaufItem(self, itemADeplier):
884 #---------------------------------------------------
885 self.inhibeExpand=True
886 from InterfaceQT4 import compojdc
887 if (isinstance(self, compojdc.Node)) :
888 self.affichePanneau()
889 self.inhibeExpand=False
891 self.editor.deplier = False
892 for item in self.children :
893 # il ne faut pas plier les blocs
894 from InterfaceQT4 import compobloc
895 if (isinstance(item,compobloc.Node)) : continue
897 if item==itemADeplier :
898 itemADeplier.setDeplie()
899 self.affichePanneau()
900 self.inhibeExpand=False
902 def plieToutEtReaffiche(self):
903 #-----------------------------
904 #print ('plieToutEtReaffiche', self.item.getNom())
905 from InterfaceQT4 import compojdc
906 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
907 self.inhibeExpand=True
908 self.editor.deplier = False
909 for item in self.children :
910 # il ne faut pas plier les blocs
911 from InterfaceQT4 import compobloc
912 if (isinstance(item,compobloc.Node)) : continue
914 self.affichePanneau()
915 #print ("fin plieToutEtReaffiche", self.item.getNom())
917 def deplieToutEtReaffiche(self):
918 #-----------------------------
919 self.editor.deplier = True
920 for item in self.children :
922 self.affichePanneau()
926 #print "je mets inhibeExpand a true dans setPlie"
927 #print ("je suis dans plieTout", self.item.getNom())
928 from . import compojdc
929 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
931 self.tree.inhibeExpand=True
932 self.tree.collapseItem(self)
933 self.setPlieChildren()
934 self.tree.inhibeExpand=False
935 #print "je mets inhibeExpand a false dans setPlie"
938 # on ne plie pas au niveau 1
940 # for item in self.children :
941 # item.appartientAUnNoeudPlie=False
943 def setPlieChildren(self):
944 #-----------------------------
946 from InterfaceQT4 import composimp
947 if isinstance(self,composimp.Node) : return
948 for c in self.children :
950 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0]
951 c.appartientAUnNoeudPlie=True
953 #print "dans setPlieChildren plie", c.item.nom
954 # 01/2018 PNPN : boucle sur MT __ La ligne suivante ne me semble pas necessaire
955 #if not (isinstance(c,composimp.Node)) :c.setExpanded(False)
957 # Pour les blocs et les motcles list
958 # on affiche un niveau de plus
959 from InterfaceQT4 import compobloc
960 from InterfaceQT4 import compomclist
961 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
962 niveauPere=self.treeParent
963 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
964 niveauPere=niveauPere.treeParent
965 for c in self.children :
966 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
967 #print ("dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie)
972 #-----------------------------
973 #print "dans setPlieChildren pour", self.item.nom
974 #print "je mets inhibeExpand a true dans setDeplie"
975 self.tree.inhibeExpand=True
977 self.tree.expandItem(self)
978 self.setDeplieChildren()
979 self.tree.inhibeExpand=False
980 #print "je mets inhibeExpand a false dans setDePlie"
982 def setDeplieChildren(self):
983 #-----------------------------
984 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.getLabelText()
985 for c in self.children :
986 c.setDeplieChildren()
987 #print "dans setDeplieChildren ", c.item.nom
988 c.appartientAUnNoeudPlie=False
992 def selectAvant(self):
993 #-----------------------------
994 i=self.item.jdc.etapes.index(self.item.object)
995 try : cherche=self.item.jdc.etapes[i-1]
996 except : cherche=self.item.jdc.etapes[-1]
998 for i in self.tree.racine.children :
999 if i.item.object== cherche :
1003 node.affichePanneau()
1006 def selectApres(self):
1007 #---------------------
1008 i=self.item.jdc.etapes.index(self.item.object)
1009 try : cherche=self.item.jdc.etapes[i+1]
1010 except : cherche=self.item.jdc.etapes[0]
1012 for i in self.tree.racine.children :
1013 if i.item.object== cherche :
1017 node.affichePanneau()