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
+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
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
itemParent=item
item.setPlie()
item.plieToutEtReaffiche()
+ item.select()
def handleExpandedItem(self,item):
- #print "dans ExpandItem", self.inhibeExpand
+ #print "handleExpandedItem pour ", item.item.nom, self.inhibeExpand
if self.inhibeExpand == True : return
- #print "apres if"
itemParent=item
while not (hasattr (itemParent,'getPanel')) :
if itemParent.plie==True : itemParent.setDeplie()
itemParent=itemParent.treeParent
- #print "apres if"
if self.tree.node_selected != itemParent :
item.setExpanded(True)
- #print "je suis la"
return
item.deplieToutEtReaffiche()
+ self.inhibeExpand == False
def handleOnItem(self,item,int):
- if (len(self.selectedIndexes())!=2): return
- #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.itemCourrant=item
itemParent=item
+
while not (hasattr (itemParent,'getPanel')) :
if itemParent.plie==True : itemParent.setDeplie()
itemParent=itemParent.treeParent
+
if itemParent.fenetre != self.editor.fenetreCentraleAffichee :
- if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche()
- else : itemParent.affichePanneau()
- if itemParent!=item and item.fenetre != None: item.fenetre.rendVisible()
+
+ estUneFeuille=(isinstance(item,composimp.Node))
+ # il faut afficher le parent
+ 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 itemParent!=item:
+ #self.tree.handleExpandedItem(item)
+ #item.fenetre.donnePremier()
+ #item.fenetre.rendActif()
+ 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.inhibeExpand == False
#print "je mets inhibeExpand a false handleOnItem"
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
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)
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)
- self.editor.widgetCentraleLayout.addWidget(self.fenetre)
+ #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.anciennefenetre=self.editor.fenetreCentraleAffichee
+ self.editor.widgetCentraleLayout.addWidget(self.fenetre)
+ #print "j ajoute ", self.fenetre, self.fenetre.node.item.nom
self.editor.fenetreCentraleAffichee=self.fenetre
self.tree.node_selected= self
- if self.editor.anciennefenetre != None :
- a=self.editor.anciennefenetre.close()
-
- if self.editor.widgetTree !=None : index=1
- else : index=0
-
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"
+ #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.setExpanded( True )
self.tree.setCurrentItem( self )
- self.tree.node_selected= self
#------------------------------------------------------------------
# Methodes de creation et destruction de noeuds
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 onAdd(self,object):
if self.JESUISOFF==1 : return
- print "onAdd pour ", self.item.nom, object.nom
+ #print "onAdd pour ", self.item.nom, object.nom
self.editor.init_modif()
self.update_nodes()
# PN -- non necessaire si item=jdc
def onSupp(self,object):
if self.JESUISOFF==1 : return
- print "onSup pour ", self.item.nom, object.nom
+ #print "onSup pour ", self.item.nom, object.nom
self.editor.init_modif()
self.update_nodes()
# PN -- non necessaire si item=jdc
"""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)
child = self.append_child(objet,pos='first')
return child
+ 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
+ from InterfaceQT4 import compobloc
+ if (isinstance(item,compobloc.Node)) : continue
+ item.setPlie()
+ if item==itemADeplier :
+ 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
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()