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
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 if itemParent.fenetreIhm == 'deplie1Niveau' :
178 if item == itemParent : itemParent.affichePanneau()
179 else : itemAvant.afficheCeNiveau()
180 elif estUneFeuille : itemParent.affichePanneau()
181 elif self.editor.maConfiguration.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
182 else : itemParent.affichePanneau()
185 elif (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
186 elif itemParent!=item: self.tree.handleExpandedItem(item)
190 fr = item.item.getFr()
191 chaineDecoupee= fr.split('\n')
192 if len(chaineDecoupee) > 3 :
193 txt='\n'.join(chaineDecoupee[0:2])+'...\nfull help : double clicked on validity chip of '+ str(item.item.nom)+ ' in central widget'
195 if self.editor: self.editor.afficheCommentaire(str(txt))
200 self.inhibeExpand = False
203 def choisitPremier(self,name):
204 #----------------------------
205 self.editor.layoutJDCCHOIX.removeWidget(self.racine.fenetre)
206 self.racine.fenetre.close()
207 new_node=self.racine.appendBrother(name,'after')
210 COMMENT = "COMMENTAIRE"
211 PARAMETERS = "PARAMETRE"
213 #------------------------------------------
214 class JDCNode(QTreeWidgetItem,GereRegles):
215 #------------------------------------------
216 def __init__( self, treeParent, item, itemExpand=False, ancien=False ):
217 #----------------------------------------------------------------------
218 #print ("creation d'un noeud : ", item, " ",item.nom,"", treeParent, self)
223 self.vraiParent = treeParent
224 self.treeParent = treeParent
225 self.tree = self.treeParent.tree
226 self.editor = self.treeParent.editor
227 self.appliEficas = treeParent.appliEficas
229 self.firstAffiche = True
230 self.childrenComplete=[]
233 from InterfaceQT4 import compocomm
234 from InterfaceQT4 import compoparam
235 from InterfaceQT4 import composimp
236 if (isinstance(self.item,compocomm.COMMTreeItem)) : name = tr("Commentaire")
237 elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name = tr(str(item.getLabelText()[0]))
238 else : name = tr(item.getLabelText()[0])
239 if item.nom != tr(item.nom) : name = str(tr(item.nom)+" :")
240 value = tr(str(item.getText() ) )
242 # si specialisation de la fenetre
243 if self.item.object.definition == None : self.fenetreIhm = None
244 # Cas des listes de mots_clefs
245 else : self.fenetreIhm = self.item.object.definition.fenetreIhm
247 if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
248 else : mesColonnes=(name,)
250 if self.treeParent.plie==True :
252 self.appartientAUnNoeudPlie = True
253 if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
256 self.appartientAUnNoeudPlie = False
258 #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
260 if ancien and itemExpand : self.plie = False
261 if ancien and not itemExpand : self.plie = True
262 if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
264 from InterfaceQT4 import compobloc
265 from InterfaceQT4 import compomclist
267 ajoutAuParentduNoeud=0
268 self.treeParent=treeParent
269 while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) :
270 self.treeParent.childrenComplete.append(self)
271 self.treeParent=self.treeParent.vraiParent
272 self.treeParent.childrenComplete.append(self)
275 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)) :
276 # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
277 QTreeWidgetItem.__init__(self,None,mesColonnes)
279 QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
281 self.setToolTip(0,self.item.getFr())
282 self.setToolTip(1,self.item.getFr())
283 repIcon=self.appliEficas.repIcon
285 couleur=self.item.getIconName()
286 monIcone = QIcon(repIcon+"/" + couleur + ".png")
288 self.setIcon(0,monIcone)
295 self.item.connect("valid",self.onValid,())
296 self.item.connect("supp" ,self.onSupp,())
297 self.item.connect("add" ,self.onAdd,())
298 self.item.connect("redessine" ,self.onRedessine,())
303 if self.item.getObject().isBLOC() :
304 self.setExpanded(True)
310 def buildChildren(self,posInsertion=10000):
311 #------------------------------------------
312 """ Construit la liste des enfants de self """
313 """ Se charge de remettre les noeuds Expanded dans le meme etat """
314 #print ("*********** buildChildren ",self,self.item, self.item.nom)
317 self.listeItemExpanded=[]
318 self.listeItemPlie=[]
320 for enfant in self.childrenComplete :
321 if enfant.plie : self.listeItemPlie.append(enfant.item)
322 else : self.listeItemExpanded.append(enfant.item)
324 for enfant in self.childrenComplete :
325 parent = enfant.treeParent
326 parent.removeChild(enfant)
331 self.childrenComplete = []
332 sublist = self.item._getSubList()
335 for item in sublist :
338 if item in self.listeItemExpanded : itemExpand=True; ancien=True
339 if item in self.listeItemPlie : itemExpand=False; ancien=True
340 nouvelItem=item.itemNode(self,item,itemExpand,ancien)
341 self.children.append(nouvelItem)
343 #print ("fin *********** buildChildren ",self,self.item, self.item.nom, self.children)
346 def chercheNoeudCorrespondant(self,objSimp):
347 #-------------------------------------------
348 sublist = self.item._getSubList()
349 for node in self.childrenComplete:
350 if node.item.object==objSimp : return node
354 def afficheCeNiveau(self):
355 #-------------------------
356 #print ('afficheCeNiveau pour ', self.item.nom, self.item.getLabelText())
357 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
358 widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
359 self.editor.widgetCentraleLayout.removeItem(widget)
360 if self.editor.fenetreCentraleAffichee != None :
361 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
362 self.editor.fenetreCentraleAffichee.setParent(None)
363 self.editor.fenetreCentraleAffichee.close()
364 self.editor.fenetreCentraleAffichee.deleteLater()
366 from monWidgetNiveauFact import MonWidgetNiveauFact, MonWidgetNiveauFactTableau
367 maDefinition = self.item.get_definition()
368 monObjet = self.item.object
369 if maDefinition.fenetreIhm=='Tableau' : self.maFenetreCadre=MonWidgetNiveauFactTableau(self,self.editor,maDefinition,monObjet)
370 else : self.maFenetreCadre=MonWidgetNiveauFact(self,self.editor,maDefinition,monObjet)
372 self.fenetre = self.maFenetreCadre
373 self.editor.widgetCentraleLayout.addWidget(self.maFenetreCadre)
374 self.editor.fenetreCentraleAffichee=self.maFenetreCadre
376 #print ('fin afficheCeNiveau pour ', self.item.nom)
379 def getPanelModifie(self):
380 #-------------------------
382 if self.fenetreIhm == None : return None
383 if self.fenetreIhm =='deplie1Niveau':
384 from InterfaceQT4.monWidgetCommandeDeplie1Niveau import MonWidgetCommandeDeplie1Niveau
385 return MonWidgetCommandeDeplie1Niveau (self,self.editor ,self.item.object)
389 def affichePanneau(self) :
390 #-------------------------
391 #print ('_________________ds affichePanneau pour', self.item.nom)
392 # pour l instant pas d inactif
393 if not(self.item.isActif()) :
394 from .monWidgetInactif import MonWidgetInactif
395 self.fenetre = MonWidgetInactif(self,self.editor)
398 while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
399 if itemParent != self :
400 #print ('j appelle affichePanneau pour ', itemParent.item.nom , 'par', self.item.nom)
401 itemParent.affichePanneau()
402 #print ('fin _________________ds affichePanneau pour', self.item.nom)
405 self.fenetre = self.getPanelModifie()
406 if self.fenetre == None : self.fenetre=self.getPanel()
407 self.editor.restoreSplitterSizes()
409 for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
410 widget = self.editor.widgetCentraleLayout.itemAt(indiceWidget)
411 self.editor.widgetCentraleLayout.removeItem(widget)
413 # ceinture et bretelle
414 #print 'old fenetre = ',self.editor.fenetreCentraleAffichee
415 if self.editor.fenetreCentraleAffichee != None :
417 self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
418 self.editor.fenetreCentraleAffichee.setParent(None)
419 self.editor.fenetreCentraleAffichee.close()
420 self.editor.fenetreCentraleAffichee.deleteLater()
424 self.editor.widgetCentraleLayout.addWidget(self.fenetre)
425 #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
426 self.editor.fenetreCentraleAffichee=self.fenetre
427 self.tree.node_selected= self
429 if self.editor.first :
430 if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
431 self.tree.inhibeExpand=True
432 self.tree.expandItem(self)
433 self.tree.inhibeExpand=False
434 #print( '_________________fin affichePanneau pour', self.item.nom)
437 def createPopUpMenu(self):
438 #-------------------------
439 #implemente dans les noeuds derives si necessaire
443 #-------------------------
445 Cette methode a pour but de commentariser la commande pointee par self
447 # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
448 # (commentariser) un commentaire.
450 pos=self.treeParent.children.index(self)
451 commande_comment = self.item.getObjetCommentarise()
452 # On signale a l editeur du panel (le JDCDisplay) une modification
453 self.editor.initModif()
454 self.treeParent.buildChildren()
455 self.treeParent.children[pos].select()
456 self.treeParent.children[pos].affichePanneau()
457 except Exception as e:
458 traceback.print_exc()
459 QMessageBox.critical( self.editor, "TOO BAD",str(e))
461 def unCommentIt(self):
462 #-------------------------
464 Realise la decommentarisation de self
467 pos=self.treeParent.children.index(self)
468 commande,nom = self.item.unComment()
469 self.editor.initModif()
470 self.treeParent.buildChildren()
471 self.treeParent.children[pos].select()
472 self.treeParent.children[pos].affichePanneau()
473 except Exception as e:
474 QMessageBox.critical( self.editor, "Erreur !",str(e))
476 def addComment( self, after=True ):
477 #-----------------------------------
479 Ajoute un commentaire a l'interieur du JDC :
481 self.editor.initModif()
486 return self.appendBrother( COMMENT, pos )
488 def addParameters( self, after=True ):
489 #-------------------------------------
491 Ajoute un parametre a l'interieur du JDC :
493 self.editor.initModif()
494 if after: pos = 'after'
496 child=self.appendBrother( PARAMETERS, pos )
503 Rend le noeud courant (self) selectionne et deselectionne
506 #print "select pour", self.item.nom
507 for item in self.tree.selectedItems() :
509 self.tree.setCurrentItem( self )
511 #------------------------------------------------------------------
512 # Methodes de creation et destruction de noeuds
513 #------------------------------------------------------------------
515 def appendBrother(self,name,pos='after',plier=False):
516 #----------------------------------------------------
518 Permet d'ajouter un objet frere a l'objet associe au noeud self
519 par defaut on l'ajoute immediatement apres
522 self.editor.initModif()
524 from InterfaceQT4 import compojdc
525 if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
527 if self.treeParent != self.vraiParent :
528 index = self.vraiParent.children.index(self)
529 if pos == 'before' : index = index
530 elif pos == 'after' : index = index +1
531 return self.vraiParent.appendChild(name,pos=index,plier=plier)
533 index = self.treeParent.children.index(self)
534 if pos == 'before': index = index
535 elif pos == 'after' : index = index +1
537 print(pos, tr(" n'est pas un index valide pour appendBrother"))
539 return self.treeParent.appendChild(name,pos=index,plier=plier)
541 def verifiePosition(self,name,pos,aLaRacine=False):
542 #----------------------------------------------------
543 if name not in self.editor.readercata.Classement_Commandes_Ds_Arbre : return True
544 indexName=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(name)
546 etapes=self.item.getJdc().etapes
547 if etapes == [] : return True
549 if aLaRacine == False :indexOu=etapes.index(self.item.object)
552 if pos=="after" : indexOu = indexOu+1
553 for e in etapes[:indexOu] :
555 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
556 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
557 if indexEtape > indexName :
558 comment=tr('le mot clef ')+name+tr(' doit etre insere avant ')+nom
559 QMessageBox.information( None,tr('insertion impossible'),comment, )
561 for e in etapes[indexOu:] :
563 if nom not in self.editor.readercata.Classement_Commandes_Ds_Arbre : continue
564 indexEtape=self.editor.readercata.Classement_Commandes_Ds_Arbre.index(nom)
565 if indexEtape < indexName :
566 comment=tr('le mot clef ')+name+tr(' doit etre insere apres ')+nom
567 QMessageBox.information( None,tr('insertion impossible'),comment, )
571 def appendChild(self,name,pos=None,plier=False):
572 #------------------------------------------------
574 Methode pour ajouter un objet fils a l'objet associe au noeud self.
575 On peut l'ajouter en debut de liste (pos='first'), en fin (pos='last')
576 ou en position intermediaire.
577 Si pos vaut None, on le place a la position du catalogue.
579 #print ("************** appendChild ",self.item.getLabelText(), pos, plier)
581 #traceback.print_stack()
584 self.editor.initModif()
585 if pos == 'first' : index = 0
586 elif pos == 'last' : index = len(self.children)
587 elif type(pos) == int : index = pos # position fixee
588 elif type(pos) == object : index = self.item.getIndex(pos) +1 # pos est un item. Il faut inserer name apres pos
589 elif type(name) == object : index = self.item.getIndexChild(name.nom)
590 else : index = self.item.getIndexChild(name)
592 # si on essaye d inserer a la racine
593 if (isinstance(self.treeParent,JDCTree) and index==0) :
594 verifiePosition=self.verifiePosition(name,'first',aLaRacine=True)
595 if not verifiePosition : return 0
597 self.tree.inhibeExpand = True
598 obj = self.item.addItem(name,index) # emet le signal 'add'
599 if obj is None : obj=0
600 if obj == 0 :return 0
604 child = self.children[index]
605 if plier == True : child.setPlie()
606 else : child.setDeplie()
608 child=self.children[index]
611 if len(obj) > 1 : self.buildChildren()
614 self.tree.inhibeExpand=False
615 #print (" fin append child")
620 self.editor.initModif()
621 index = self.treeParent.children.index(self) - 1
622 if index < 0 : index =0
623 ret=self.treeParent.item.deplaceEntite(self.item.getObject())
628 Methode externe pour la destruction de l'objet associe au noeud
630 self.editor.initModif()
631 index = self.vraiParent.children.index(self) - 1
632 if index < 0 : index =0
635 if self.item.nom == "VARIABLE" :
639 ret,commentaire=self.vraiParent.item.suppItem(self.item)
640 if ret==0 : self.editor.afficheInfos(commentaire,Qt.red)
641 else : self.editor.afficheInfos(commentaire)
642 self.treeParent.buildChildren()
643 if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
644 else : toselect=self.treeParent
646 if recalcule : jdc.recalculeEtatCorrelation()
648 if self.treeParent.childrenComplete :
649 notdeleted=self.treeParent.childrenComplete[index+1]
654 from InterfaceQT4 import compojdc
655 # cas ou on detruit dans l arbre sans affichage
656 if isinstance(self.treeParent,compojdc.Node) :
657 toselect.affichePanneau()
659 if self.treeParent.fenetre== None : return
660 #print "J appelle reaffiche de browser apres delete"
661 self.treeParent.fenetre.reaffiche(toselect)
663 def deleteMultiple(self,liste=()):
664 #--------------------------------
666 Methode externe pour la destruction d une liste de noeud
668 from InterfaceQT4 import compojdc
669 self.editor.initModif()
674 while not(isinstance(jdc,compojdc.Node)):
677 if not( isinstance(noeud.treeParent, compojdc.Node)): continue
678 if noeud.item.nom == "VARIABLE" : recalcule=1
679 if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
680 if index < 0 : index =0
682 # Cas ou on detruit dans une ETape
684 parentPosition=self.treeParent
685 while not(isinstance(parentPosition, compojdc.Node)):
686 index=parentPosition.treeParent.children.index(parentPosition)
687 parentPosition=parentPosition.treeParent
690 noeud.treeParent.item.suppItem(noeud.item)
693 if recalcule : jdc.recalculeEtatCorrelation()
694 try : toselect=parentPosition.children[index]
695 except : toselect=jdc
697 toselect.affichePanneau()
699 # ------------------------------------------------------------------
703 #print ("onValid pour ", self.item.nom)
704 if self.JESUISOFF==1 : return
706 if hasattr(self,'fenetre') and self.fenetre:
707 try : self.fenetre.setValide()
710 # PNPN lignes suivantes a repenser
711 if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isValid():
712 self.item.jdc.recalculeEtatCorrelation()
713 if hasattr(self.item,'forceRecalcul') : self.forceRecalculChildren(self.item.forceRecalcul)
714 self.editor.initModif()
716 self.updateNodeValid()
717 self.updateNodeLabel()
718 self.updateNodeTexte()
721 def onAdd(self,object):
722 #----------------------
723 #print ("onAdd pour ", self.item.nom, object)
724 if self.JESUISOFF == 1 : return
725 self.editor.initModif()
727 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
729 def onSupp(self,object):
730 #-----------------------
731 #print ("onSup pour ", self.item.nom, object)
733 #traceback.print_stack()
734 if self.JESUISOFF==1 : return
735 self.editor.initModif()
737 if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True
739 def onRedessine(self):
740 #---------------------
741 print ('dans redessine pour', self)
742 self.updateNodeTexte()
743 #if not(self.fenetre): return
744 # a priori l objet C++ n est plus la si la fenetre n est pas visible
746 def updateNodeValid(self):
747 #-----------------------
748 """Cette methode remet a jour la validite du noeud (icone)
751 repIcon = self.appliEficas.repIcon
752 couleur = self.item.getIconName()
753 monIcone = QIcon(repIcon+"/" + couleur + ".png")
754 self.setIcon(0,monIcone)
758 def updateNodeLabel(self):
759 #-------------------------
760 """ Met a jour le label du noeud """
761 #print ("NODE updateNodeLabel", self.item.getLabelText())
762 labeltext,fonte,couleur = self.item.getLabelText()
764 if self.item.nom != tr(self.item.nom) : labeltext = str(tr(self.item.nom)+" :")
765 self.setText(0, tr(labeltext))
767 def updateNodeLabelInBlack(self):
768 #-------------------------------
769 if hasattr(self.appliEficas,'noeudColore'):
770 self.appliEficas.noeudColore.setForeground(0,Qt.black)
771 self.appliEficas.noeudColore.updateNodeLabel
773 def updateNodeLabelInBlue(self):
774 #-------------------------------
775 if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
776 self.setForeground(0,Qt.blue)
777 labeltext,fonte,couleur = self.item.getLabelText()
778 if self.item.nom != tr(self.item.nom) : labeltext = str(tr(self.item.nom)+" :")
779 self.setText(0, labeltext)
780 self.appliEficas.noeudColore=self
782 def updatePlusieursNodeLabelInBlue(self,liste):
783 #----------------------------------------------
784 if hasattr(self.appliEficas,'listeNoeudsColores'):
785 for noeud in self.appliEficas.listeNoeudsColores:
786 noeud.setTextColor( 0,Qt.black)
787 noeud.updateNodeLabel()
788 self.appliEficas.listeNoeudsColores=[]
790 noeud.setTextColor( 0,Qt.blue )
791 if item.nom != tr(item.nom) : labeltext = str(tr(item.nom)+" :")
792 labeltext,fonte,couleur = noeud.item.getLabelText()
793 noeud.setText(0, labeltext)
794 self.appliEficas.listeNoeudsColores.append(noeud)
796 def updateNodeTexteInBlack(self):
797 #--------------------------------
798 """ Met a jour les noms des SD et valeurs des mots-cles """
799 self.setTextColor( 1,Qt.black )
800 value = self.item.getText()
801 self.setText(1, value)
803 def updateNodeTexte(self):
804 #----------------------------
805 """ Met a jour les noms des SD et valeurs des mots-cles """
806 value = self.item.getText()
807 self.setText(1, value)
810 def updateNodeTexteInBlue(self):
811 #--------------------------------
812 self.setTextColor( 1,Qt.blue )
813 value = self.item.getText()
814 self.setText(1, value)
816 def updateNodes(self):
817 #--------------------------------
818 #print 'NODE updateNodes', self.item.getLabelText()
821 def updateValid(self) :
822 #----------------------
823 """Cette methode a pour but de mettre a jour la validite du noeud
824 et de propager la demande de mise a jour a son parent
826 #print "NODE updateValid", self.item.getLabelText()
827 self.updateNodeValid()
828 try : self.treeParent.updateValid()
831 def updateTexte(self):
832 #----------------------
833 """ Met a jour les noms des SD et valeurs des mots-cles """
834 #print "NODE updateTexte", self.item.getLabelText()
835 self.updateNodeTexte()
836 if self.isExpanded() :
837 for child in self.children:
838 if child.isHidden() == false : child.updateTexte()
841 def forceRecalculChildren(self,niveau):
842 #--------------------------------------
843 if self.state == 'recalcule' :
846 self.state='recalcule'
847 if hasattr(self.item,'object'):
848 self.item.object.state="modified"
849 for child in self.children:
850 if niveau > 0 : child.forceRecalculChildren(niveau - 1)
854 def doPaste(self,node_selected,pos='after'):
855 #--------------------------------------------
857 Declenche la copie de l'objet item avec pour cible
858 l'objet passe en argument : node_selected
860 objet_a_copier = self.item.getCopieObjet()
861 child=node_selected.doPasteCommande(objet_a_copier,pos)
862 if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau()
863 self.updateNodeLabelInBlack()
866 def doPasteCommande(self,objet_a_copier,pos='after'):
867 #-----------------------------------------------------
869 Realise la copie de l'objet passe en argument qui est necessairement
875 child = self.appendBrother(objet_a_copier,pos)
880 def doPastePremier(self,objet_a_copier):
881 #---------------------------------------
883 Realise la copie de l'objet passe en argument (objet_a_copier)
885 objet = objet_a_copier.item.getCopieObjet()
886 child = self.appendChild(objet,pos='first')
889 def plieToutEtReafficheSaufItem(self, itemADeplier):
890 #---------------------------------------------------
891 self.inhibeExpand=True
892 from InterfaceQT4 import compojdc
893 if (isinstance(self, compojdc.Node)) :
894 self.affichePanneau()
895 self.inhibeExpand=False
897 self.editor.deplier = False
898 for item in self.children :
899 # il ne faut pas plier les blocs
900 from InterfaceQT4 import compobloc
901 if (isinstance(item,compobloc.Node)) : continue
903 if item==itemADeplier :
904 itemADeplier.setDeplie()
905 self.affichePanneau()
906 self.inhibeExpand=False
908 def plieToutEtReaffiche(self):
909 #-----------------------------
910 #print ('plieToutEtReaffiche', self.item.getNom())
911 from InterfaceQT4 import compojdc
912 if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
913 self.inhibeExpand=True
914 self.editor.deplier = False
915 for item in self.children :
916 # il ne faut pas plier les blocs
917 from InterfaceQT4 import compobloc
918 if (isinstance(item,compobloc.Node)) : continue
920 self.affichePanneau()
921 #print ("fin plieToutEtReaffiche", self.item.getNom())
923 def deplieToutEtReaffiche(self):
924 #-----------------------------
925 self.editor.deplier = True
926 for item in self.children :
928 self.affichePanneau()
932 #print "je mets inhibeExpand a true dans setPlie"
933 #print ("je suis dans plieTout", self.item.getNom())
934 from . import compojdc
935 if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
937 self.tree.inhibeExpand=True
938 self.tree.collapseItem(self)
939 self.setPlieChildren()
940 self.tree.inhibeExpand=False
941 #print "je mets inhibeExpand a false dans setPlie"
944 # on ne plie pas au niveau 1
946 # for item in self.children :
947 # item.appartientAUnNoeudPlie=False
949 def setPlieChildren(self):
950 #-----------------------------
952 from InterfaceQT4 import composimp
953 if isinstance(self,composimp.Node) : return
954 for c in self.children :
956 #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0]
957 c.appartientAUnNoeudPlie=True
959 #print "dans setPlieChildren plie", c.item.nom
960 # 01/2018 PNPN : boucle sur MT __ La ligne suivante ne me semble pas necessaire
961 #if not (isinstance(c,composimp.Node)) :c.setExpanded(False)
963 # Pour les blocs et les motcles list
964 # on affiche un niveau de plus
965 from InterfaceQT4 import compobloc
966 from InterfaceQT4 import compomclist
967 if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
968 niveauPere=self.treeParent
969 while (isinstance(niveauPere,compobloc.Node) or (isinstance(niveauPere,compomclist.Node) and niveauPere.item.isMCList())) :
970 niveauPere=niveauPere.treeParent
971 for c in self.children :
972 c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
973 #print ("dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.getLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie)
978 #-----------------------------
979 #print "dans setPlieChildren pour", self.item.nom
980 #print "je mets inhibeExpand a true dans setDeplie"
981 self.tree.inhibeExpand=True
983 self.tree.expandItem(self)
984 self.setDeplieChildren()
985 self.tree.inhibeExpand=False
986 #print "je mets inhibeExpand a false dans setDePlie"
988 def setDeplieChildren(self):
989 #-----------------------------
990 #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.getLabelText()
991 for c in self.children :
992 c.setDeplieChildren()
993 #print "dans setDeplieChildren ", c.item.nom
994 c.appartientAUnNoeudPlie=False
998 def selectAvant(self):
999 #-----------------------------
1000 i=self.item.jdc.etapes.index(self.item.object)
1001 try : cherche=self.item.jdc.etapes[i-1]
1002 except : cherche=self.item.jdc.etapes[-1]
1004 for i in self.tree.racine.children :
1005 if i.item.object== cherche :
1009 node.affichePanneau()
1012 def selectApres(self):
1013 #---------------------
1014 i=self.item.jdc.etapes.index(self.item.object)
1015 try : cherche=self.item.jdc.etapes[i+1]
1016 except : cherche=self.item.jdc.etapes[0]
1018 for i in self.tree.racine.children :
1019 if i.item.object== cherche :
1023 node.affichePanneau()