import types,sys,os
import traceback
import typeNode
-import pdb
-from PyQt4 import *
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+#import pdb
+
+from determine import monEnvQT5
+if monEnvQT5 :
+ from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem
+ from PyQt5.QtGui import QIcon
+ from PyQt5.QtCore import Qt
+else :
+ from PyQt4.QtGui import *
+ from PyQt4.QtCore import *
from Extensions.i18n import tr
from gereRegles import GereRegles
from monChoixCommande import MonChoixCommande
self.itemCourrant=None
- self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
- self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
- self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
+ if monEnvQT5 :
+ self.itemClicked.connect(self.handleOnItem)
+ self.itemCollapsed.connect(self.handleCollapsedItem)
+ self.itemExpanded.connect(self.handleExpandedItem)
+ else :
+ self.connect(self, SIGNAL("itemClicked ( QTreeWidgetItem * ,int) "), self.handleOnItem)
+ self.connect(self, SIGNAL("itemCollapsed ( QTreeWidgetItem *) "), self.handleCollapsedItem)
+ self.connect(self, SIGNAL("itemExpanded ( QTreeWidgetItem *) "), self.handleExpandedItem)
#PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
self.node_selected=self.racine
item.setExpanded(True)
return
item.deplieToutEtReaffiche()
+ self.inhibeExpand == False
def handleOnItem(self,item,int):
#print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
+
+ from InterfaceQT4 import composimp
self.inhibeExpand == True
self.itemCourrant=item
itemParent=item
+
while not (hasattr (itemParent,'getPanel')) :
if itemParent.plie==True : itemParent.setDeplie()
itemParent=itemParent.treeParent
+
if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
+
+ estUneFeuille=(isinstance(item,composimp.Node))
# il faut afficher le parent
- if self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
- else : itemParent.affichePanneau()
+ #print "estUneFeuille", estUneFeuille
+ #print "afficheCommandesPliees", self.editor.afficheCommandesPliees
+ if estUneFeuille : itemParent.affichePanneau()
+ elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
+ else : itemParent.affichePanneau()
- from InterfaceQT4 import composimp
if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
elif itemParent!=item:
#self.tree.handleExpandedItem(item)
#item.fenetre.donnePremier()
#item.fenetre.rendActif()
- print 'il faut afficher le 1er'
+ #print 'il faut afficher le 1er'
try :
fr = item.item.get_fr()
- if self.editor: self.editor.labelCommentaire.setText(unicode(fr))
+ if self.editor: self.editor.affiche_commentaire(unicode(fr))
except:
pass
item.select()
self.appliEficas = treeParent.appliEficas
self.JESUISOFF=0
self.childrenComplete=[]
+
from InterfaceQT4 import compocomm
from InterfaceQT4 import compoparam
from InterfaceQT4 import composimp
if (isinstance(self.item,compocomm.COMMTreeItem)) : name=tr("Commentaire")
- elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0]))
- else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :")
- value = self.appliEficas.trUtf8(str( item.GetText() ) )
+ elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=tr(str(item.GetLabelText()[0]))
+ else: name = tr(str(tr( item.nom))+" :")
+ value = tr(str( item.GetText() ) )
- mesColonnes=QStringList()
- if self.editor.enteteQTree=='complet': mesColonnes << name << value
- else : mesColonnes << name
+ if monEnvQT5:
+ if self.editor.enteteQTree=='complet':mesColonnes=(name,value)
+ else : mesColonnes=(name,)
+ else :
+ mesColonnes=QStringList()
+ if self.editor.enteteQTree=='complet': mesColonnes << name << value
+ else : mesColonnes << name
if self.treeParent.plie==True :
self.plie = True
self.appartientAUnNoeudPlie=True
+ if self.treeParent.item.isMCList() : self.appartientAUnNoeudPlie = self.treeParent.appartientAUnNoeudPlie
else :
self.plie = False
self.appartientAUnNoeudPlie = False
+ #if item.nom == "POUTRE" :print "creation d'un noeud : ", item, " ",item.nom,"", self.treeParent, self.appartientAUnNoeudPlie , self.plie
+
if ancien and itemExpand : self.plie = False
if ancien and not itemExpand : self.plie = True
if (isinstance(self.item,composimp.SIMPTreeItem)) : self.plie=False
self.treeParent.childrenComplete.append(self)
self.treeParent=self.treeParent.vraiParent
self.treeParent.childrenComplete.append(self)
- if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) :
+
+
+ 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)) :
+ # Le dernier or ne sert que lorsqu'on est en train de creer une liste par les validator
QTreeWidgetItem.__init__(self,None,mesColonnes)
else :
QTreeWidgetItem.__init__(self,self.treeParent,mesColonnes)
- self.setToolTip(0,QString(self.item.get_fr()))
- self.setToolTip(1,QString(self.item.get_fr()))
+ if monEnvQT5 :
+ self.setToolTip(0,self.item.get_fr())
+ self.setToolTip(1,self.item.get_fr())
+ repIcon=self.appliEficas.repIcon
+ else :
+ self.setToolTip(0,QString(self.item.get_fr()))
+ self.setToolTip(1,QString(self.item.get_fr()))
+ repIcon=QString(self.appliEficas.repIcon)
- repIcon=QString(self.appliEficas.repIcon)
monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
self.setIcon(0,monIcone)
else : self.listeItemExpanded.append(enfant.item)
for enfant in self.childrenComplete :
- p=enfant.vraiParent
parent=enfant.treeParent
parent.removeChild(enfant)
enfant.JESUISOFF=1
nouvelItem=item.itemNode(self,item,itemExpand,ancien)
self.children.append(nouvelItem)
- #print "fin *********** build_children ",self,self.item, self.item.nom
+ #print "fin *********** build_children ",self,self.item, self.item.nom, self.children
def chercheNoeudCorrespondant(self,objSimp):
def affichePanneau(self) :
- #print " affichePanneau " , self.item.nom
- if self.item.isactif():
+ #if self.item.isactif():
+ #if self.editor.code == 'ASTER' and not(self.item.isactif()) :
+ # posera des pb si un code decide d appeler FIN un mot clef
+ # on resoudera a ce moment la
+ # pour l instant pas de poussiere sous le tapis
+ if not(self.item.isactif()) :
+ from monWidgetInactif import MonWidgetInactif
+ self.fenetre = MonWidgetInactif(self,self.editor)
+ else:
itemParent=self
while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent
if itemParent!=self :
itemParent.affichePanneau()
return
self.fenetre=self.getPanel()
- else:
- from monInactifPanel import PanelInactif
- self.fenetre = PanelInactif(self,self.editor)
+ #print "hhhhhhhhhh", self.editor.splitter.sizes()
for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
self.editor.widgetCentraleLayout.removeItem(widget)
# ceinture et bretelle
#print 'old fenetre = ',self.editor.fenetreCentraleAffichee
+ #print "iiiiiiiiiiiiiii", self.editor.splitter.sizes()
if self.editor.fenetreCentraleAffichee != None :
#print "j enleve ", self.editor.fenetreCentraleAffichee, self.editor.fenetreCentraleAffichee.node.item.nom
self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee)
+ self.editor.fenetreCentraleAffichee.setParent(None)
self.editor.fenetreCentraleAffichee.close()
+ self.editor.fenetreCentraleAffichee.deleteLater()
self.editor.widgetCentraleLayout.addWidget(self.fenetre)
#print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
self.tree.node_selected= self
if self.editor.first :
- self.editor.splitter.setSizes((400,1400,400))
+ #self.editor.splitter.setSizes((400,1400,400))
if not(isinstance(self.fenetre,MonChoixCommande)): self.editor.first=False
self.tree.inhibeExpand=True
self.tree.expandItem(self)
- self.select()
+ #self.select()
self.tree.inhibeExpand=False
#print "fin de affichePanneau", self.item.nom
#print "______________________________"
Rend le noeud courant (self) selectionne et deselectionne
tous les autres
"""
+ #print "select pour", self.item.nom
for item in self.tree.selectedItems() :
item.setSelected(0)
- self.setSelected( True )
self.tree.setCurrentItem( self )
#------------------------------------------------------------------
if not verifiePosition : return 0
self.tree.inhibeExpand=True
- obj=self.item.additem(name,index) #CS_pbruno emet le signal 'add'
+ obj=self.item.additem(name,index) # emet le signal 'add'
if obj is None:obj=0
if obj == 0:return 0
try :
if self.treeParent.childrenComplete : toselect=self.treeParent.childrenComplete[index]
else: toselect=self.treeParent
if recalcule : jdc.recalcule_etat_correlation()
+ if ret==0 :
+ if self.treeParent.childrenComplete :
+ notdeleted=self.treeParent.childrenComplete[index+1]
+ notdeleted.select()
+ else :
+ toselect.select()
from InterfaceQT4 import compojdc
# cas ou on detruit dans l arbre sans affichage
if isinstance(self.treeParent,compojdc.Node) :
def onValid(self):
#print "onValid pour ", self.item.nom
- if hasattr(self,'fenetre') and self.fenetre: self.fenetre.setValide()
+ if self.JESUISOFF==1 : return
+ if hasattr(self,'fenetre') and self.fenetre:
+ try :
+ self.fenetre.setValide()
+ except :
+ # print "onValid pour ", self.item.nom, self,'pb'
+ pass
+
if (self.item.nom == "VARIABLE" or self.item.nom == "DISTRIBUTION") and self.item.isvalid():
self.item.jdc.recalcule_etat_correlation()
if hasattr(self.item,'forceRecalcul'):
-
def update_node_valid(self):
"""Cette methode remet a jour la validite du noeud (icone)
Elle appelle isvalid
"""
- repIcon=QString(self.appliEficas.repIcon)
+ if monEnvQT5 : repIcon=self.appliEficas.repIcon
+ else : repIcon=QString(self.appliEficas.repIcon)
monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
self.setIcon(0,monIcone)
def plieToutEtReafficheSaufItem(self, itemADeplier):
#print "je suis dans plieToutEtReaffiche", self.item.get_nom()
+ from InterfaceQT4 import compojdc
+ if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
self.editor.deplier = False
for item in self.children :
# il ne faut pas plier les blocs
if (isinstance(item,compobloc.Node)) : continue
item.setPlie()
if item==itemADeplier :
- print itemADeplier.item.nom
itemADeplier.setDeplie()
-
self.affichePanneau()
def plieToutEtReaffiche(self):
#print "je suis dans plieToutEtReaffiche", self.item.get_nom()
+ from InterfaceQT4 import compojdc
+ if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
self.editor.deplier = False
for item in self.children :
# il ne faut pas plier les blocs
niveauPere=niveauPere.treeParent
for c in self.children :
c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie
+ #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0], "mis a la valeur ", niveauPere.appartientAUnNoeudPlie
c.setExpanded(False)
# on affiche un niveau de plus
if i.item.object== cherche :
node=i
break
- if node : node.affichePanneau()
+ if node :
+ node.affichePanneau()
+ node.select()
def selectApres(self):
i=self.item.jdc.etapes.index(self.item.object)
if i.item.object== cherche :
node=i
break
- if node : node.affichePanneau()
+ if node :
+ node.affichePanneau()
+ node.select()