# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-import string,re
+from __future__ import absolute_import
+from __future__ import print_function
+try :
+ from builtins import str
+ from builtins import range
+except : pass
+import re
import types,sys,os
import traceback
-import typeNode
+from . import typeNode
#import pdb
-from determine import monEnvQT5
-if monEnvQT5 :
- from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem
- from PyQt5.QtGui import QIcon
-else :
- from PyQt4.QtGui import *
- from PyQt4.QtCore import *
+import six
+from six.moves import range
+from PyQt5.QtWidgets import QTreeWidget , QTreeWidgetItem, QApplication, QMessageBox
+from PyQt5.QtGui import QIcon
+from PyQt5.QtCore import Qt
from Extensions.i18n import tr
-from gereRegles import GereRegles
-from monChoixCommande import MonChoixCommande
+from .gereRegles import GereRegles
+from .monChoixCommande import MonChoixCommande
class JDCTree( QTreeWidget,GereRegles ):
def __init__( self, jdc_item, QWParent):
self.itemCourrant=None
- 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)
+ self.itemClicked.connect(self.handleOnItem)
+ self.itemCollapsed.connect(self.handleCollapsedItem)
+ self.itemExpanded.connect(self.handleExpandedItem)
#PNPNPN verifier dans quel cas on se trouve : affiche l arbre ou la commande
self.node_selected=self.racine
self.inhibeExpand=False
#print "self.editor.afficheCommandesPliees", self.editor.afficheCommandesPliees
if self.racine.children !=[] :
-
-
+ #self.editor.initSplitterSizes(3)
if self.editor.afficheCommandesPliees : self.racine.children[0].plieToutEtReaffiche()
else : self.racine.children[0].deplieToutEtReaffiche()
-
-
self.racine.children[0].fenetre.donnePremier()
- else : self.racine.affichePanneau()
+ else :
+ #self.editor.initSplitterSizes(2)
+ self.racine.affichePanneau()
+ #print self.editor.splitter.sizes()
#PNPNPN
#pdb.set_trace()
def handleCollapsedItem(self,item):
- print "dans CollapsedItem", self.inhibeExpand
+ #print "dans CollapsedItem", self.inhibeExpand
if self.inhibeExpand == True : return
# On traite le cas de l item non selectionne
itemParent=item
def handleExpandedItem(self,item):
#print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
+ #import traceback
+ #traceback.print_stack()
if self.inhibeExpand == True : return
+ self.inhibeExpand = True
itemParent=item
while not (hasattr (itemParent,'getPanel')) :
if itemParent.plie==True : itemParent.setDeplie()
itemParent=itemParent.treeParent
if self.tree.node_selected != itemParent :
item.setExpanded(True)
+ self.inhibeExpand = False
return
item.deplieToutEtReaffiche()
- self.inhibeExpand == False
+ self.inhibeExpand = False
def handleOnItem(self,item,int):
- print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
+ #print "je passe dans handleOnItem pour ",self, item.item.nom, item, item.item
from InterfaceQT4 import composimp
- self.inhibeExpand == True
+ self.inhibeExpand = True
self.itemCourrant=item
itemParent=item
estUneFeuille=(isinstance(item,composimp.Node))
# il faut afficher le parent
- print "estUneFeuille", estUneFeuille
- print "afficheCommandesPliees", self.editor.afficheCommandesPliees
+ #print "estUneFeuille", estUneFeuille
+ #print "afficheCommandesPliees", self.editor.afficheCommandesPliees
if estUneFeuille : itemParent.affichePanneau()
elif self.editor.afficheCommandesPliees : itemParent.plieToutEtReafficheSaufItem(item)
else : itemParent.affichePanneau()
- if (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
+ elif (isinstance(item,composimp.Node)) and item.fenetre : item.fenetre.rendVisible()
elif itemParent!=item:
- #self.tree.handleExpandedItem(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.affiche_commentaire(unicode(fr))
+ if self.editor: self.editor.affiche_commentaire(six.text_type(fr))
except:
pass
item.select()
- self.inhibeExpand == False
+ self.inhibeExpand = False
#print "je mets inhibeExpand a false handleOnItem"
value = tr(str( item.GetText() ) )
- 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.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)
- 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)
+ self.setToolTip(0,self.item.get_fr())
+ self.setToolTip(1,self.item.get_fr())
+ repIcon=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.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
+ from .monWidgetInactif import MonWidgetInactif
self.fenetre = MonWidgetInactif(self,self.editor)
else:
itemParent=self
itemParent.affichePanneau()
return
self.fenetre=self.getPanel()
+ #self.editor.restoreSplitterSizes()
for indiceWidget in range(self.editor.widgetCentraleLayout.count()):
widget=self.editor.widgetCentraleLayout.itemAt(indiceWidget)
# ceinture et bretelle
#print 'old fenetre = ',self.editor.fenetreCentraleAffichee
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
+ #print ("j ajoute ", self.fenetre, self.fenetre.node.item.nom)
self.editor.fenetreCentraleAffichee=self.fenetre
self.tree.node_selected= self
if self.editor.first :
- #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.tree.inhibeExpand=False
#print "fin de affichePanneau", self.item.nom
#print "______________________________"
"""
Cette methode a pour but de commentariser la commande pointee par self
"""
- # On traite par une exception le cas ou l'utilisateur final cherche a désactiver
+ # On traite par une exception le cas ou l'utilisateur final cherche a desactiver
# (commentariser) un commentaire.
try :
pos=self.treeParent.children.index(self)
self.treeParent.build_children()
self.treeParent.children[pos].select()
self.treeParent.children[pos].affichePanneau()
- except Exception,e:
+ except Exception as e:
traceback.print_exc()
QMessageBox.critical( self.editor, "TOO BAD",str(e))
self.treeParent.build_children()
self.treeParent.children[pos].select()
self.treeParent.children[pos].affichePanneau()
- except Exception,e:
+ except Exception as e:
QMessageBox.critical( self.editor, "Erreur !",str(e))
def addComment( self, after=True ):
Rend le noeud courant (self) selectionne et deselectionne
tous les autres
"""
- print "select pour", self.item.nom
+ #print "select pour", self.item.nom
for item in self.tree.selectedItems() :
item.setSelected(0)
self.tree.setCurrentItem( self )
from InterfaceQT4 import compojdc
if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0
- index = self.treeParent.children.index(self)
- if pos == 'before': index = index
- elif pos == 'after': index = index +1
- else:
- print unicode(pos), tr(" n'est pas un index valide pour append_brother")
- return 0
- return self.treeParent.append_child(name,pos=index,plier=plier)
+ if self.treeParent != self.vraiParent :
+ index = self.vraiParent.children.index(self)
+ if pos == 'before': index = index
+ elif pos == 'after': index = index +1
+ return self.vraiParent.append_child(name,pos=index,plier=plier)
+ else :
+ index = self.treeParent.children.index(self)
+ if pos == 'before': index = index
+ elif pos == 'after': index = index +1
+ else:
+ print(six.text_type(pos), tr(" n'est pas un index valide pour append_brother"))
+ return 0
+ return self.treeParent.append_child(name,pos=index,plier=plier)
def verifiePosition(self,name,pos,aLaRacine=False):
if name not in self.editor.Classement_Commandes_Ds_Arbre : return True
index = 0
elif pos == 'last':
index = len(self.children)
- elif type(pos) == types.IntType :
+ elif type(pos) == int :
# position fixee
index = pos
elif type(pos) == types.InstanceType:
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 :
except :
child=self.children[index]
self.tree.inhibeExpand=False
- #print " fin append child"
+ #print (" fin append child")
return child
def deplace(self):
if noeud.treeParent.children.index(noeud) < index : index=noeud.treeParent.children.index(noeud)
if index < 0 : index =0
- # Cas ou on détruit dans une ETape
+ # Cas ou on detruit dans une ETape
if index == 9999 :
parentPosition=self.treeParent
while not(isinstance(parentPosition, 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
"""
- if monEnvQT5 : repIcon=self.appliEficas.repIcon
- else : repIcon=QString(self.appliEficas.repIcon)
+ repIcon=self.appliEficas.repIcon
monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png")
self.setIcon(0,monIcone)
def update_node_label(self):
""" Met a jour le label du noeud """
+ pass
#print "NODE update_node_label", self.item.GetLabelText()
- labeltext,fonte,couleur = self.item.GetLabelText()
+ #labeltext,fonte,couleur = self.item.GetLabelText()
# PNPN a reflechir
#self.setText(0, labeltext)
def update_node_label_in_blue(self):
- if hasattr(self.appliEficas,'noeudColore'):
- self.appliEficas.noeudColore.setTextColor( 0,Qt.black)
- self.appliEficas.noeudColore.update_node_label()
- self.setTextColor( 0,Qt.blue )
+ if hasattr(self.appliEficas,'noeudColore'): self.appliEficas.noeudColore.setForeground(0,Qt.black)
+ self.setForeground(0,Qt.blue)
labeltext,fonte,couleur = self.item.GetLabelText()
self.setText(0, labeltext)
self.appliEficas.noeudColore=self
def doPaste(self,node_selected,pos='after'):
"""
- Déclenche la copie de l'objet item avec pour cible
- l'objet passé en argument : node_selected
+ Declenche la copie de l'objet item avec pour cible
+ l'objet passe en argument : node_selected
"""
#print 'je passe dans doPaste'
objet_a_copier = self.item.get_copie_objet()
def doPasteCommande(self,objet_a_copier,pos='after'):
"""
- Réalise la copie de l'objet passé en argument qui est nécessairement
+ Realise la copie de l'objet passe en argument qui est necessairement
une commande
"""
child=None
try :
+ #if 1 :
child = self.append_brother(objet_a_copier,pos)
except :
pass
def doPastePremier(self,objet_a_copier):
"""
- Réalise la copie de l'objet passé en argument (objet_a_copier)
+ Realise la copie de l'objet passe en argument (objet_a_copier)
"""
objet = objet_a_copier.item.get_copie_objet()
child = self.append_child(objet,pos='first')
def plieToutEtReafficheSaufItem(self, itemADeplier):
#print "je suis dans plieToutEtReaffiche", self.item.get_nom()
+ self.inhibeExpand=True
from InterfaceQT4 import compojdc
- if (isinstance(self, compojdc.Node)) : self.affichePanneau(); return
+ if (isinstance(self, compojdc.Node)) :
+ self.affichePanneau()
+ self.inhibeExpand=False
+ return
self.editor.deplier = False
for item in self.children :
# il ne faut pas plier les blocs
if item==itemADeplier :
itemADeplier.setDeplie()
self.affichePanneau()
+ self.inhibeExpand=False
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.inhibeExpand=True
self.editor.deplier = False
for item in self.children :
# il ne faut pas plier les blocs
def setPlie(self):
#print "je mets inhibeExpand a true dans setPlie"
#print "je suis dans plieTout", self.item.get_nom()
- import compojdc
+ from . import compojdc
if self.fenetre == self.editor.fenetreCentraleAffichee and isinstance(self.treeParent,compojdc.Node):
return
self.tree.inhibeExpand=True
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 node :
node.affichePanneau()
node.select()
+
+ def ouvreLesNoeudsDsLArbre(self):
+ return
+ self.inhibeExpand = True
+ for i in range(self.childCount()):
+ self.child(i).inhibeExpand=True
+ self.child(i).setExpanded(True)
+ self.child(i).ouvreLesNoeudsDsLArbre()
+ self.child(i).inhibeExpand=False
+ self.inhibeExpand = False