-# Copyright (C) 2007-2013 EDF R&D
+# Copyright (C) 2007-2017 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# Modules Python
# Modules Eficas
-from PyQt4 import *
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+from __future__ import absolute_import
+from __future__ import print_function
+from PyQt5.QtWidgets import QWidget
+from PyQt5.QtCore import Qt
+
from Extensions.i18n import tr
-from gereIcones import FacultatifOuOptionnel
+
+from .gereIcones import FacultatifOuOptionnel
import Accas
+import traceback
# Import des panels
-class Groupe(QtGui.QWidget,FacultatifOuOptionnel):
+class Groupe(QWidget,FacultatifOuOptionnel):
"""
"""
def __init__(self,node,editor,parentQt,definition,obj,niveau,commande=None):
- QtGui.QWidget.__init__(self,None)
+ QWidget.__init__(self,None)
self.node=node
self.node.fenetre=self
#print "groupe : ",self.node.item.nom," ",self.node.fenetre
- #self.setFocusPolicy(Qt.StrongFocus)
self.setupUi(self)
self.editor=editor
self.obj=obj
self.appliEficas=self.editor.appliEficas
self.repIcon=self.appliEficas.repIcon
self.jdc=self.node.item.get_jdc()
- self.setPoubelle()
+ self.setIconePoubelle()
+ self.setIconesGenerales()
self.setRun()
self.setValide()
self.setReglesEtAide()
self.afficheMots()
self.listeMCAAjouter=[]
self.dictMCVenantDesBlocs={}
- if hasattr(self,'RBDeplie') : self.connect(self.RBDeplie,SIGNAL("clicked()"), self.Deplie)
- if hasattr(self,'RBPlie') : self.connect(self.RBPlie,SIGNAL("clicked()"), self.Plie)
+ if hasattr(self,'RBDeplie') : self.RBDeplie.clicked.connect(self.Deplie)
+ if hasattr(self,'RBPlie') : self.RBPlie.clicked.connect( self.Plie)
self.setAcceptDrops(True)
- #self.donneFocus()
def donneFocus(self):
for fenetre in self.listeFocus:
fenetre.prendLeFocus=1
fenetre.hide()
fenetre.show()
- break
def afficheMots(self):
+ #print "ds afficheMots ",self.node.item.nom
for node in self.node.children:
- #if node in self.node.listeMCVenantDesBlocs : continue
- # print "pas ", node.item.nom
- # continue
- if hasattr(self.node,'appartientAUnNoeudPlie') and self.node.appartientAUnNoeudPlie==True : return
+ #if node.item.nom == "Background" :print "afficheMots ",node," " ,node.item.nom, " ",node.plie ," ", node.appartientAUnNoeudPlie,node.getPanelGroupe
+ #if node.item.nom == "BackgroundError" :print "afficheMots ",node," " ,node.item.nom, " ",node.plie ," ", node.appartientAUnNoeudPlie,node.getPanelGroupe
+ # non return mais continue car il faut tenir compte des blocs
+ if node.appartientAUnNoeudPlie==True : continue
+ #print "je suis apres le if pour ",node.item.nom
widget=node.getPanelGroupe(self,self.maCommande)
- #print node
- #print node.item.nom
+ #print "widget pour ", node.item.nom, widget
self.listeFocus.append(node.fenetre)
- #print "fin afficheMots pou " ,self.node.item.nom
+ #print "fin pour " , self.node.item.nom
def calculOptionnel(self):
def afficheOptionnel(self):
liste=self.ajouteMCOptionnelDesBlocs()
- #chercheOptionnel=self.parentQt
- # Boucle necessaire pour les regroupements Adao
- #while not( hasattr(chercheOptionnel,'monOptionnel')):
- # chercheOptionnel=chercheOptionnel.parentQt
- #self.monOptionnel=chercheOptionnel.monOptionnel
self.monOptionnel=self.editor.widgetOptionnel
- self.monOptionnel.parentMC=self
- self.monOptionnel.affiche(liste)
+ self.monOptionnel.afficheOptionnel(liste,self)
+ #self.monOptionnel.affiche(liste)
def ajouteMCOptionnelDesBlocs(self):
- #print "Je passe dans ajouteMCOptionnelDesBlocs pour", self.node.item.nom
self.dictMCVenantDesBlocs={}
i=0
self.calculOptionnel()
liste=self.liste_mc
for MC in self.liste_mc : self.dictMCVenantDesBlocs[MC]=self
- while i < self.commandesLayout.count():
- from monWidgetBloc import MonWidgetBloc
+ # ce cas est le cas machine tournant sr le plie
+ try :
+ while i < self.commandesLayout.count():
+ from .monWidgetBloc import MonWidgetBloc
widget=self.commandesLayout.itemAt(i).widget()
i=i+1
if not(isinstance(widget,MonWidgetBloc)) : continue
widget.calculOptionnel()
listeW=widget.ajouteMCOptionnelDesBlocs()
- for MC in widget.dictMCVenantDesBlocs.keys():
- if MC in self.dictMCVenantDesBlocs.keys(): print "Pb Sur les MC"
+ for MC in widget.dictMCVenantDesBlocs:
+ if MC in self.dictMCVenantDesBlocs: print ("Pb Sur les MC" )
else : self.dictMCVenantDesBlocs[MC]=widget.dictMCVenantDesBlocs[MC]
liste=liste+listeW
+ except :
+ pass
return liste
def reaffiche(self,nodeAVoir=None):
- #print "dans reaffiche ________________________", nodeAVoir
+ #print "dans reaffiche de groupe.py", nodeAVoir
self.parentQt.reaffiche(nodeAVoir)
def recalculeListeMC(self,listeMC):
listeNom=texteListeNom.split("+")[1:]
firstNode=None
for nom in listeNom:
- if nom not in self.dictMCVenantDesBlocs.keys():
- print "bizarre, bizarre"
+ if nom not in self.dictMCVenantDesBlocs:
+ #print "bizarre, bizarre"
self.editor.init_modif()
nouveau=self.node.append_child(nom)
else :
nouveau=widget.node.append_child(nom)
if firstNode==None : firstNode=nouveau
if nouveau == None or nouveau == 0 :
- self.editor.affiche_infos(str('insertion impossible a cet endroit pour '+nom),Qt.red)
+ self.editor.affiche_infos(tr('insertion impossible a cet endroit pour '+nom),Qt.red)
self.reaffiche(firstNode)
-
+ if firstNode!=None and firstNode !=0 and firstNode.item!=None :
+ firstNode.select()
def Plie(self):
self.node.setPlie()
- self.reaffiche()
+ if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+ #if (len(self.node.item.get_genealogie())==2):
+ index=self.maCommande.commandesLayout.indexOf(self)
+ self.maCommande.reafficheSeulement(self,index)
+ return
+ #else :
+ # self.reaffiche(self.node)
+ #return
+ #print ('je reaffiche dans Plie')
+ self.reaffiche(self.node)
def Deplie(self):
self.node.setDeplie()
- self.reaffiche()
+ if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+ #if (len(self.node.item.get_genealogie())==2):
+ index=self.parentQt.commandesLayout.indexOf(self)
+ self.maCommande.reafficheSeulement(self,index)
+ return
+ #else :
+ # self.reaffiche(self.node)
+ #return
+ #print ('je reaffiche dans Plie')
+ self.reaffiche(self.node)
+
+
+ #def Plie(self):
+ #print ('Deplie', self)
+ #print (self.obj.nom)
+ #print (self.node.setPlie)
+ #print (self.parentQt)
+ #print (self)
+ # self.node.setPlie()
+ #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+ # itemAtraiter = self.node.item
+ # nodeAtraiter=self.node
+ #while (len(itemAtraiter.get_genealogie()) > 2 ):
+ # itemAtraiter=itemAtraiter.parent
+ # nodeAtraiter=nodeAtraiter.vraiParent
+ #ancien=nodeAtraiter.fenetre
+ #panneau = nodeAtraiter.getPanelGroupe(self,self.maCommande,insertIn=False)
+ #print (itemAtraiter,nodeAtraiter)
+ #self.parentQt.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly)
+ #nodeAtraiter.vraiParent.fenetre.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly)
+ #return
+ # if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+ # if (len(self.node.item.get_genealogie())==2):
+ #print (self)
+ #print (self.obj.nom)
+ #print (self.node.item.getlabeltext())
+ #print (self.parentQt)
+ #print (self.editor.fenetreCentraleAffichee)
+ #print (self.maCommande)
+ # index=self.parentQt.commandesLayout.indexOf(self)
+ #print (index)
+ # self.maCommande.reafficheSeulement(self,index)
+ #self.disconnect()
+ #for c in self.children():
+ # print (c)
+ # try :
+ # c.setParent(None)
+ # c.deleteLater()
+ # c.close()
+ # c.disconnect()
+ # except :
+ # print('poum')
+ #panneau = self.node.getPanelGroupe(self.parentQt,self.maCommande,insertIn=False)
+ # print (self.parentQt)
+ # print (self)
+ #self.parentQt.commandesLayout.replaceWidget(self,panneau,Qt.FindDirectChildrenOnly)
+ # self.parentQt.setUpdatesEnabled(True)
+ # print (dir(self.parentQt.commandesLayout))
+ #self.parentQt.commandesLayout.updateGeometry()
+ # else :
+ # self.reaffiche(self.node)
+ # return
+ #print ('je reaffiche dans Plie')
+ # self.reaffiche(self.node)
+#
+# def Deplie(self):
+# print ('Deplie', self)
+# print (self.obj.nom)
+# print (self.node.item.GetLabelText())
+# self.node.setDeplie()
+# #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") and (len(self.node.item.get_genealogie())==2):
+# #print (self.node.vraiParent.children)
+# #if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+# # itemAtraiter = self.node.item
+# # nodeAtraiter=self.node
+# # while (len(itemAtraiter.get_genealogie()) > 2 ):
+# # itemAtraiter=itemAtraiter.parent
+# # nodeAtraiter=nodeAtraiter.vraiParent
+# # ancien=nodeAtraiter.fenetre
+# # panneau = nodeAtraiter.getPanelGroupe(self,self.maCommande,insertIn=False)
+# #print (itemAtraiter,nodeAtraiter)
+# #self.parentQt.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly)
+# # nodeAtraiter.vraiParent.fenetre.commandesLayout.replaceWidget(ancien,panneau,Qt.FindDirectChildrenOnly)
+# # return
+# if self.editor.code== 'MT' and (self.maCommande.obj.nom == "ZONE") :
+# if (len(self.node.item.get_genealogie())==2):
+# #panneau = self.node.getPanelGroupe(self.parentQt,self.maCommande,insertIn=False)
+# #self.parentQt.commandesLayout.replaceWidget(self,panneau,Qt.FindDirectChildrenOnly)
+# #index=self.parentQt.commandesLayout.indexOf(self)
+# #index=self.maCommande.commandesLayout.indexOf(self)
+# #print ('index = ', index)
+# index=0
+# self.maCommande.reafficheSeulement(self,index)
+# else :
+# self.reaffiche(self.node)
+# return
+#
+# #print ('je reaffiche')
+# self.reaffiche(self.node)
+
+ def traiteClicSurLabel(self,texte):
+ if self.editor.code != "CARMELCND" : self.afficheOptionnel()