X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2Fbrowser.py;h=0db619cb2d1642a17ba7ec672b189ad72928f11b;hb=4bd8d1e0738d27448fc887a4d99ef85eb469da33;hp=65a7e67120263383b7f4756bc9bf2e581d987ce9;hpb=e61aff6d6540bbc57004cc8276163587a4efb51b;p=tools%2Feficas.git diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 65a7e671..0db619cb 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -18,18 +18,28 @@ # 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 -import pdb -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from . import typeNode +#import pdb + +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 monChoixCommande import MonChoixCommande +from .gereRegles import GereRegles +from .monChoixCommande import MonChoixCommande -class JDCTree( QTreeWidget ): +class JDCTree( QTreeWidget,GereRegles ): def __init__( self, jdc_item, QWParent): #if hasattr(QWParent,'widgetTree') : self.editor = QWParent @@ -51,14 +61,13 @@ class JDCTree( QTreeWidget ): self.tree = self self.appliEficas = self.editor.appliEficas self.childrenComplete=[] - self.childrenIssusDesBlocs=[] self.racine=self.item.itemNode(self,self.item) 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) + 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 @@ -67,14 +76,14 @@ class JDCTree( QTreeWidget ): 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() @@ -108,7 +117,7 @@ class JDCTree( QTreeWidget ): if self.inhibeExpand == True : return # On traite le cas de l item non selectionne itemParent=item - while not (hasattr (itemParent,'getPanel2')) : + while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent if self.tree.node_selected != itemParent : item.setExpanded(False) @@ -117,48 +126,63 @@ class JDCTree( QTreeWidget ): 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 + #import traceback + #traceback.print_stack() if self.inhibeExpand == True : return - #print "apres if" + self.inhibeExpand = True itemParent=item - while not (hasattr (itemParent,'getPanel2')) : + 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" + self.inhibeExpand = False return item.deplieToutEtReaffiche() + self.inhibeExpand = False + def handleOnItem(self,item,int): - #if (len(self.selectedIndexes())!=2): return - #print "je passe dans handleOnItem" - self.inhibeExpand == True + #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 - #print self.itemCourrant - while not (hasattr (itemParent,'getPanel2')) : + + while not (hasattr (itemParent,'getPanel')) : if itemParent.plie==True : itemParent.setDeplie() itemParent=itemParent.treeParent - #print itemParent - #print itemParent.fenetre - #print self.editor.afficheCommandesPliees + if itemParent.fenetre != self.editor.fenetreCentraleAffichee : - #print self.editor.afficheCommandesPliees - if self.editor.afficheCommandesPliees : itemParent.plieToutEtReaffiche() - else : itemParent.affichePanneau() - if itemParent!=item and item.fenetre != None: item.fenetre.rendVisible() - #try : - if 1: + + 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() + + + elif (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)) - #except: - else : + if self.editor: self.editor.affiche_commentaire(six.text_type(fr)) + except: pass - self.inhibeExpand == False + item.select() + self.inhibeExpand = False #print "je mets inhibeExpand a false handleOnItem" @@ -171,64 +195,69 @@ class JDCTree( QTreeWidget ): COMMENT = "COMMENTAIRE" PARAMETERS = "PARAMETRE" -class JDCNode(QTreeWidgetItem): - def __init__( self, treeParent, item): +class JDCNode(QTreeWidgetItem,GereRegles): + def __init__( self, treeParent, item, itemExpand=False, ancien=False ): #print "creation d'un noeud : ", item, " ",item.nom,"", treeParent, self - self.a=0 + #self.a=0 self.item = item self.vraiParent = treeParent self.treeParent = treeParent self.tree = self.treeParent.tree self.editor = self.treeParent.editor self.appliEficas = treeParent.appliEficas - self.treeParent.childrenIssusDesBlocs=[] + 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.GetLabelText()[0]))+" :") + else: name = tr(str(tr(item.GetLabelText()[0]))) + if item.nom != tr(item.nom) : name = str(tr(item.nom)+" :") + value = tr(str( item.GetText() ) ) - 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 - #print "self.plie", self.plie - #print "self.appartientAUnNoeudPlie", self.appartientAUnNoeudPlie - #print self.treeParent - ajoutAuParentduNoeud=0 + #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 + from InterfaceQT4 import compobloc from InterfaceQT4 import compomclist + + ajoutAuParentduNoeud=0 + self.treeParent=treeParent while (isinstance(self.treeParent,compobloc.Node) or ( isinstance(self.treeParent,compomclist.Node) and self.treeParent.item.isMCList())) : - #while (isinstance(self.treeParent,compobloc.Node)) : - self.treeParent=self.treeParent.treeParent - ajoutAuParentduNoeud=1 - if ajoutAuParentduNoeud : - treeParent.childrenComplete.append(self) - self.treeParent.childrenIssusDesBlocs.append(self) - while (isinstance(self.treeParent,compobloc.Node)) : self.treeParent=self.treeParent.treeParent - - #if isinstance(self,compobloc.Node) : - if (isinstance(self,compobloc.Node) or ( isinstance(self,compomclist.Node) and self.item.isMCList())) : + 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()) 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.treeParent.childrenComplete.append(self) - self.setToolTip(0,QString(self.item.get_fr())) - self.setToolTip(1,QString(self.item.get_fr())) + self.setToolTip(0,self.item.get_fr()) + self.setToolTip(1,self.item.get_fr()) + repIcon=self.appliEficas.repIcon - repIcon=QString(self.appliEficas.repIcon) monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png") self.setIcon(0,monIcone) @@ -240,6 +269,7 @@ class JDCNode(QTreeWidgetItem): self.item.connect("valid",self.onValid,()) self.item.connect("supp" ,self.onSupp,()) self.item.connect("add" ,self.onAdd,()) + self.state="" self.fenetre=None try : @@ -253,40 +283,36 @@ class JDCNode(QTreeWidgetItem): def build_children(self,posInsertion=10000): """ Construit la liste des enfants de self """ """ Se charge de remettre les noeuds Expanded dans le meme etat """ - #print "*********** build_children ",self.item, self.item.GetLabelText() + #print "*********** build_children ",self,self.item, self.item.nom + + self.listeItemExpanded=[] + self.listeItemPlie=[] + + for enfant in self.childrenComplete : + if enfant.plie : self.listeItemPlie.append(enfant.item) + else : self.listeItemExpanded.append(enfant.item) + + for enfant in self.childrenComplete : + parent=enfant.treeParent + parent.removeChild(enfant) + enfant.JESUISOFF=1 + - listeExpanded=[] - for item in self.childrenComplete : - #print dir(item) - #if item.isExpanded(): - # if self.childrenComplete.index(item) < posInsertion : - # listeExpanded.append(self.childrenComplete.index(item)) - # print dir(item.item ) - # else : - # listeExpanded.append( self.childrenComplete.index(item) +1) - self.detruit_les_noeuds_issus_de_blocs(item) - parent=item.treeParent - parent.removeChild(item) - - #print listeExpanded self.children = [] self.childrenComplete = [] sublist = self.item._GetSubList() ind=0 + for item in sublist : - nouvelItem=item.itemNode(self,item) + itemExpand=False + ancien=False + if item in self.listeItemExpanded : itemExpand=True; ancien=True + if item in self.listeItemPlie : itemExpand=False; ancien=True + nouvelItem=item.itemNode(self,item,itemExpand,ancien) self.children.append(nouvelItem) - #print " J ajoute ", nouvelItem ,nouvelItem.item.GetLabelText(),"dans" ,self.item.GetLabelText() - #print item - #if ind in listeExpanded : nouvelItem.setExpanded(1) - - #if ind in listeExpanded : print "plie=0" - #else : print "plie=1" - #if ind in listeExpanded : nouvelItem.plie=0 - #else : nouvelItem.plie=1 - #ind=ind+1 - #print "*********** fin build_children ",self.item, self.item.GetLabelText() + #print "fin *********** build_children ",self,self.item, self.item.nom, self.children + def chercheNoeudCorrespondant(self,objSimp): sublist = self.item._GetSubList() @@ -294,48 +320,47 @@ class JDCNode(QTreeWidgetItem): if node.item.object==objSimp : return node return None + def affichePanneau(self) : - #print "dans affichePanneau appel getPanel2", self.item.GetLabelText() - 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 + #print( 'debut affichePanneau pour', self.item.nom) + if not(self.item.isactif()) : + from .monWidgetInactif import MonWidgetInactif + self.fenetre = MonWidgetInactif(self,self.editor) + else: itemParent=self - #print self - #print self.getPanel2 - while not (hasattr (itemParent,'getPanel2')) : - itemParent=itemParent.treeParent + while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent if itemParent!=self : itemParent.affichePanneau() return - #print self.getPanel2 - self.fenetre=self.getPanel2() - else: - from monInactifPanel import PanelInactif - self.fenetre = PanelInactif(self,self.editor) + self.fenetre=self.getPanel() + #self.editor.restoreSplitterSizes() - self.editor.widgetCentraleLayout.addWidget(self.fenetre) - #print "widgetCentraleLayout = ", self.editor.widgetCentraleLayout - #print "nouvelle fenetre ", self.fenetre, " associee a ", self + 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 + if self.editor.fenetreCentraleAffichee != None : + self.editor.widgetCentraleLayout.removeWidget(self.editor.fenetreCentraleAffichee) + self.editor.fenetreCentraleAffichee.setParent(None) + self.editor.fenetreCentraleAffichee.close() + self.editor.fenetreCentraleAffichee.deleteLater() - self.editor.anciennefenetre=self.editor.fenetreCentraleAffichee - #print "ancienne fenetre ", self.editor.anciennefenetre + 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() - #print "je ferme ", self.editor.anciennefenetre - - if self.editor.widgetTree !=None : index=1 - else : index=0 - 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" - #print "______________________________" + #print( 'fin affichePanneau pour', self.item.nom) def createPopUpMenu(self): @@ -346,7 +371,7 @@ class JDCNode(QTreeWidgetItem): """ 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) @@ -356,7 +381,7 @@ class JDCNode(QTreeWidgetItem): 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)) @@ -371,7 +396,7 @@ class JDCNode(QTreeWidgetItem): 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 ): @@ -401,13 +426,10 @@ class JDCNode(QTreeWidgetItem): Rend le noeud courant (self) selectionne et deselectionne tous les autres """ - #print "je suis sur select" + #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 @@ -421,33 +443,34 @@ class JDCNode(QTreeWidgetItem): """ self.editor.init_modif() - verifiePosition=self.verifiePosition(name,pos) - if not verifiePosition : 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) - - def verifiePosition(self,name,pos): from InterfaceQT4 import compojdc - if not (isinstance(self.treeParent, compojdc.Node)) : return True + if (isinstance(self.treeParent, compojdc.Node)) and not self.verifiePosition(name,pos) : return 0 + + 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 indexName=self.editor.Classement_Commandes_Ds_Arbre.index(name) - etapes=self.item.jdc.etapes + etapes=self.item.get_jdc().etapes if etapes == [] : return True - indexOu=etapes.index(self.item.object) + if aLaRacine == False :indexOu=etapes.index(self.item.object) + else : indexOu=0 + if pos=="after" : indexOu = indexOu+1 - #print self.editor.Classement_Commandes_Ds_Arbre - #print indexOu - #print indexName - #print name - #print etapes for e in etapes[:indexOu] : nom=e.nom if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue @@ -473,13 +496,17 @@ class JDCNode(QTreeWidgetItem): ou en position intermediaire. Si pos vaut None, on le place a la position du catalogue. """ - #print "************** append_child ",self.item.GetLabelText(), plier + #print ("************** append_child ",self.item.GetLabelText(), plier) + #import traceback + #traceback.print_stack() + + self.editor.init_modif() if pos == 'first': 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: @@ -489,36 +516,24 @@ class JDCNode(QTreeWidgetItem): index = self.item.get_index_child(name.nom) else: index = self.item.get_index_child(name) + + # si on essaye d inserer a la racine + if (isinstance(self.treeParent,JDCTree) and index==0) : + verifiePosition=self.verifiePosition(name,'first',aLaRacine=True) + 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 : - # old_obj = self.item.object.get_child(name.nom,restreint = 'oui') - # child=old_obj[-1] - # if plier : child.plieToutEtReaffiche() - # else : child.affichePanneau() - # print "dans le 1er Try" - #else : - #except: - # Souci pour gerer les copies des AFFE d'une commande à l autre - # try : - # child=self.children[index] - # if plier == True : child.setPlie() - # else : child.setDeplie() - # print "dans le 2nd Try" - # except : - # child=self.children[index] - # print "dans le except" try : - #if 1: child=self.children[index] if plier == True : child.setPlie() else : child.setDeplie() except : child=self.children[index] - #print "dans le except" self.tree.inhibeExpand=False + #print (" fin append child") return child def deplace(self): @@ -538,11 +553,21 @@ class JDCNode(QTreeWidgetItem): if self.item.nom == "VARIABLE" : recalcule=1 jdc=self.item.jdc - ret=self.vraiParent.item.suppitem(self.item) + ret,commentaire=self.vraiParent.item.suppitem(self.item) + if ret==0 : + self.editor.affiche_infos(commentaire,Qt.red) + else : + self.editor.affiche_infos(commentaire) self.treeParent.build_children() 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) : @@ -570,7 +595,7 @@ class JDCNode(QTreeWidgetItem): 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)): @@ -591,9 +616,15 @@ class JDCNode(QTreeWidgetItem): def onValid(self): #print "onValid pour ", self.item.nom + if self.JESUISOFF==1 : return if hasattr(self,'fenetre') and self.fenetre: - self.fenetre.setValide() - if self.item.nom == "VARIABLE" and self.item.isvalid(): + 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'): self.forceRecalculChildren(self.item.forceRecalcul) @@ -604,34 +635,28 @@ class JDCNode(QTreeWidgetItem): self.update_node_texte() def onAdd(self,object): - #print "onAdd pour ", self.item.nom + if self.JESUISOFF==1 : return + #print "onAdd pour ", self.item.nom, object.nom self.editor.init_modif() self.update_nodes() - #print "dans onAdd" ,self.item # PN -- non necessaire si item=jdc if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True def onSupp(self,object): - #print "onSupp pour ", self.item.nom + if self.JESUISOFF==1 : return + #print "onSup pour ", self.item.nom, object.nom self.editor.init_modif() self.update_nodes() # PN -- non necessaire si item=jdc if hasattr(self.item,'jdc'): self.item.jdc.aReafficher=True - def detruit_les_noeuds_issus_de_blocs(self,bloc): - from InterfaceQT4 import compobloc - if (isinstance(bloc,compobloc.Node)) : - for node in bloc.childrenComplete : - self.detruit_les_noeuds_issus_de_blocs(node) - parent=node.treeParent - #print "je detruit " , node.item.GetLabelText() - parent.removeChild(node) + def update_node_valid(self): """Cette methode remet a jour la validite du noeud (icone) Elle appelle isvalid """ - repIcon=QString(self.appliEficas.repIcon) + repIcon=self.appliEficas.repIcon monIcone = QIcon(repIcon+"/" +self.item.GetIconName() + ".png") self.setIcon(0,monIcone) @@ -641,14 +666,16 @@ class JDCNode(QTreeWidgetItem): #print "NODE update_node_label", self.item.GetLabelText() labeltext,fonte,couleur = self.item.GetLabelText() # PNPN a reflechir - #self.setText(0, labeltext) + self.setText(0, labeltext) + def update_node_label_in_black(self): + if hasattr(self.appliEficas,'noeudColore'): + self.appliEficas.noeudColore.setForeground(0,Qt.black) + self.appliEficas.noeudColore.update_node_label 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 @@ -675,6 +702,7 @@ class JDCNode(QTreeWidgetItem): """ Met a jour les noms des SD et valeurs des mots-cles """ value = self.item.GetText() self.setText(1, value) + def update_node_texte_in_blue(self): self.setTextColor( 1,Qt.blue ) @@ -719,21 +747,23 @@ class JDCNode(QTreeWidgetItem): 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() child=node_selected.doPasteCommande(objet_a_copier,pos) + if self.editor.fenetreCentraleAffichee : self.editor.fenetreCentraleAffichee.node.affichePanneau() + self.update_node_label_in_black() return child def doPasteCommande(self,objet_a_copier,pos='after'): """ - Réalise la copie de l'objet passé en argument qui est nécessairement - une commande + Realise la copie de l'objet passe en argument qui est necessairement + un onjet """ child=None try : + #if 1 : child = self.append_brother(objet_a_copier,pos) except : pass @@ -741,17 +771,40 @@ class JDCNode(QTreeWidgetItem): 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') return child + 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() + self.inhibeExpand=False + 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() + 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 + from InterfaceQT4 import compobloc + if (isinstance(item,compobloc.Node)) : continue item.setPlie() self.affichePanneau() @@ -764,7 +817,7 @@ class JDCNode(QTreeWidgetItem): 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 @@ -780,12 +833,14 @@ class JDCNode(QTreeWidgetItem): # item.appartientAUnNoeudPlie=False def setPlieChildren(self): + #print "dans setPlieChildren pour", self.item.nom self.plie=True for c in self.children : c.setPlieChildren() #print "dans setPlieChildren appartientAUnNoeudPlie=True ", c, c.item.GetLabelText()[0] c.appartientAUnNoeudPlie=True c.plie=True + #print "dans setPlieChildren plie", c.item.nom c.setExpanded(False) # Pour les blocs et les motcles list @@ -798,6 +853,7 @@ class JDCNode(QTreeWidgetItem): 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 @@ -810,6 +866,7 @@ class JDCNode(QTreeWidgetItem): # c.appartientAUnNoeudPlie=niveauPere.appartientAUnNoeudPlie def setDeplie(self): + #print "dans setPlieChildren pour", self.item.nom #print "je mets inhibeExpand a true dans setDeplie" self.tree.inhibeExpand=True self.plie=False @@ -822,7 +879,7 @@ class JDCNode(QTreeWidgetItem): #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", self.item.GetLabelText() for c in self.children : c.setDeplieChildren() - #print "dans setDeplieChildren appartientAUnNoeudPlie=False ", c.item.GetLabelText() + #print "dans setDeplieChildren ", c.item.nom c.appartientAUnNoeudPlie=False c.setExpanded(True) c.plie=False @@ -838,7 +895,9 @@ class JDCNode(QTreeWidgetItem): 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) @@ -851,4 +910,16 @@ class JDCNode(QTreeWidgetItem): if i.item.object== cherche : node=i break - if node : node.affichePanneau() + 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