From 9e5ea0ed745d6d22d5ccd9c8dab56340c46809d9 Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 2 Oct 2015 14:31:27 +0200 Subject: [PATCH] nettoyage des GetPanel et affichage pler deplier selon l ancien etat --- InterfaceQT4/browser.py | 69 +++++++++++++--------------- InterfaceQT4/compobloc.py | 5 --- InterfaceQT4/compocomm.py | 2 +- InterfaceQT4/compofact.py | 18 +++----- InterfaceQT4/compojdc.py | 10 +---- InterfaceQT4/compomacro.py | 19 +++----- InterfaceQT4/compomclist.py | 24 +++------- InterfaceQT4/compooper.py | 19 +++----- InterfaceQT4/compoparam.py | 2 +- InterfaceQT4/compoproc.py | 7 +-- InterfaceQT4/composimp.py | 77 -------------------------------- InterfaceQT4/editor.py | 5 +-- InterfaceQT4/groupe.py | 3 +- InterfaceQT4/monWidgetSimpTxt.py | 1 - 14 files changed, 63 insertions(+), 198 deletions(-) diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index 595a45c4..ef6657f8 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -108,7 +108,7 @@ class JDCTree( QTreeWidget,GereRegles ): 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) @@ -123,7 +123,7 @@ class JDCTree( QTreeWidget,GereRegles ): if self.inhibeExpand == True : return #print "apres if" itemParent=item - while not (hasattr (itemParent,'getPanel2')) : + while not (hasattr (itemParent,'getPanel')) : if itemParent.plie==True : itemParent.setDeplie() itemParent=itemParent.treeParent #print "apres if" @@ -141,7 +141,7 @@ class JDCTree( QTreeWidget,GereRegles ): 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.item.nom @@ -172,9 +172,9 @@ COMMENT = "COMMENTAIRE" PARAMETERS = "PARAMETRE" class JDCNode(QTreeWidgetItem,GereRegles): - def __init__( self, treeParent, item): + 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 @@ -202,6 +202,9 @@ class JDCNode(QTreeWidgetItem,GereRegles): else : self.plie = False self.appartientAUnNoeudPlie = False + if ancien and itemExpand : self.plie = False + if ancien and not itemExpand : self.plie = True + from InterfaceQT4 import compobloc from InterfaceQT4 import compomclist @@ -248,31 +251,34 @@ class JDCNode(QTreeWidgetItem,GereRegles): """ Se charge de remettre les noeuds Expanded dans le meme etat """ #print "*********** build_children ",self,self.item, self.item.nom - listeExpanded=[] + self.listeItemExpanded=[] + self.listeItemPlie=[] for enfant in self.childrenComplete : - #if enfant.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) - + if enfant.isExpanded() : self.listeItemExpanded.append(enfant.item) + if not(enfant.isExpanded()) : self.listeItemPlie.append(enfant.item) + for enfant in self.childrenComplete : p=enfant.vraiParent parent=enfant.treeParent parent.removeChild(enfant) - enfant.JESUISOFF=1 + - #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 "fin *********** build_children ",self,self.item, self.item.nom + def chercheNoeudCorrespondant(self,objSimp): sublist = self.item._GetSubList() @@ -282,14 +288,14 @@ class JDCNode(QTreeWidgetItem,GereRegles): def affichePanneau(self) : + #print " affichePanneau " , self.item.nom if self.item.isactif(): itemParent=self - while not (hasattr (itemParent,'getPanel2')) : - itemParent=itemParent.treeParent + while not (hasattr (itemParent,'getPanel')) : itemParent=itemParent.treeParent if itemParent!=self : itemParent.affichePanneau() return - self.fenetre=self.getPanel2() + self.fenetre=self.getPanel() else: from monInactifPanel import PanelInactif self.fenetre = PanelInactif(self,self.editor) @@ -474,32 +480,14 @@ class JDCNode(QTreeWidgetItem,GereRegles): obj=self.item.additem(name,index) #CS_pbruno 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): @@ -762,12 +750,14 @@ class JDCNode(QTreeWidgetItem,GereRegles): # 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 @@ -792,6 +782,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): # 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 @@ -804,7 +795,7 @@ class JDCNode(QTreeWidgetItem,GereRegles): #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 diff --git a/InterfaceQT4/compobloc.py b/InterfaceQT4/compobloc.py index 96c30c98..cd1c1e29 100644 --- a/InterfaceQT4/compobloc.py +++ b/InterfaceQT4/compobloc.py @@ -29,11 +29,6 @@ import typeNode class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): - def getPanel(self): - """ - """ - from monMCFactPanel import MonMCFactPanel - return MonMCFactPanel(self,parent=self.editor) def createPopUpMenu(self): typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self) diff --git a/InterfaceQT4/compocomm.py b/InterfaceQT4/compocomm.py index cff5e26a..a0c80372 100644 --- a/InterfaceQT4/compocomm.py +++ b/InterfaceQT4/compocomm.py @@ -30,7 +30,7 @@ from Extensions.eficas_exception import EficasException class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): - def getPanel2( self ): + def getPanel( self ): """ """ from monWidgetCommentaire import MonWidgetCommentaire diff --git a/InterfaceQT4/compofact.py b/InterfaceQT4/compofact.py index c34e700b..c5ee1cdd 100644 --- a/InterfaceQT4/compofact.py +++ b/InterfaceQT4/compofact.py @@ -30,11 +30,6 @@ from Editeur import Objecttreeitem class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): - def getPanel(self): - """ - """ - from monMCFactPanel import MonMCFactPanel - return MonMCFactPanel(self,parent=self.editor) def getPanelGroupe(self,parentQt,commande): maDefinition=self.item.get_definition() @@ -43,6 +38,7 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): maCommande=commande if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1 else : self.niveau=1 + if hasattr(self,'plie') :print self.item.nom, self.plie if hasattr(self,'plie') and self.plie==True : from monWidgetFactPlie import MonWidgetFactPlie widget=MonWidgetFactPlie(self,self.editor,parentQt,maDefinition,monObjet,self.niveau,maCommande) @@ -133,16 +129,16 @@ class FACTTreeItem(Objecttreeitem.ObjectTreeItem): """ itemobject=item.getObject() if itemobject.isoblig() : - self.editor.affiche_infos(tr('Impossible de supprimer un mot-cle obligatoire '),Qt.red) - return 0 + #self.editor.affiche_infos(tr('Impossible de supprimer un mot-cle obligatoire '),Qt.red) + return (0, tr('Impossible de supprimer un mot-cle obligatoire ')) if self.object.suppentite(itemobject): message = tr("Mot-cle %s supprime")+ unicode(itemobject.nom) - self.editor.affiche_commentaire(message) - return 1 + #self.editor.affiche_commentaire(message) + return (1, message) else: - self.editor.affiche_infos(tr('Pb interne : impossible de supprimer ce mot-cle'),Qt.red) - return 0 + #self.editor.affiche_infos(tr('Pb interne : impossible de supprimer ce mot-cle'),Qt.red) + return (0,tr('Pb interne : impossible de supprimer ce mot-cle')) import Accas objet = Accas.MCFACT diff --git a/InterfaceQT4/compojdc.py b/InterfaceQT4/compojdc.py index 26a0570b..e49949a0 100644 --- a/InterfaceQT4/compojdc.py +++ b/InterfaceQT4/compojdc.py @@ -25,16 +25,8 @@ from Extensions.i18n import tr class Node(browser.JDCNode,typeNode.PopUpMenuRacine): + def getPanel(self): - """ - """ - #if self.affichage_onglet==1 : - # from monRacinePanel_onglet import MonRacinePanel - # return MonRacinePanel(self,parent=self.editor) - from monRacinePanel import MonRacinePanel - return MonRacinePanel(self,parent=self.editor) - - def getPanel2(self): from monChoixCommande import MonChoixCommande return MonChoixCommande(self,self.item, self.editor) diff --git a/InterfaceQT4/compomacro.py b/InterfaceQT4/compomacro.py index 2d8e030a..2bba03e8 100644 --- a/InterfaceQT4/compomacro.py +++ b/InterfaceQT4/compomacro.py @@ -34,11 +34,8 @@ from PyQt4.QtCore import Qt, SIGNAL, QVariant class MACRONode(browser.JDCNode,typeNode.PopUpMenuNode): - def getPanel(self): - from monMacroPanel import MonMacroPanel - return MonMacroPanel (self,parent=self.editor ) - def getPanel2(self): + def getPanel(self): from monWidgetCommande import MonWidgetCommande return MonWidgetCommande (self,self.editor ,self.item.object) @@ -83,11 +80,8 @@ class INCLUDETreeItemBase(MACROTreeItem): class INCLUDENode(browser.JDCNode,typeNode.PopUpMenuNode): - def getPanel(self): - from monIncludePanel import MonIncludePanel - return MonIncludePanel (self,parent=self.editor ) - def getPanel2(self): + def getPanel(self): from monWidgetCommande import MonWidgetCommande return MonWidgetCommande (self,self.editor ,self.item.object) @@ -118,11 +112,8 @@ class INCLUDETreeItem(INCLUDETreeItemBase): # ------------------------------------ class POURSUITENode(browser.JDCNode, typeNode.PopUpMenuNode): - def getPanel(self): - from monPoursuitePanel import MonPoursuitePanel - return MonPoursuitePanel (self,parent=self.editor ) - def getPanel2(self): + def getPanel(self): from monWidgetCommande import MonWidgetCommande return MonWidgetCommande (self,self.editor ,self.item.object) @@ -155,8 +146,8 @@ class POURSUITETreeItem(INCLUDETreeItemBase): class MATERIAUNode(MACRONode): def getPanel(self): - from monMacroPanel import MonMacroPanel - return MonMacroPanel (self,parent=self.editor ) + from monWidgetCommande import MonWidgetCommande + return MonWidgetCommande (self,self.editor ,self.item.object) def createPopUpMenu(self): typeNode.PopUpMenuNode.createPopUpMenu(self) diff --git a/InterfaceQT4/compomclist.py b/InterfaceQT4/compomclist.py index d273cee5..23e232a9 100644 --- a/InterfaceQT4/compomclist.py +++ b/InterfaceQT4/compomclist.py @@ -31,20 +31,6 @@ from Noyau.N_OBJECT import ErrorObj class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): - def getPanel(self): - """ - """ - if self.item.isMCList() : - if self.item.ajout_possible(): - from monMCListAjoutPanel import MonMCListAjoutPanel - return MonMCListAjoutPanel(self,parent=self.editor) - else : - print "MCList" - elif self.item.isMCFact() : - from monMCFactPanel import MonMCFactPanel - return MonMCFactPanel(self,parent=self.editor) - else : - print "MCList" def createPopUpMenu(self): typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self) @@ -54,6 +40,9 @@ class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): monObjet=self.item.object monNom=self.item.nom maCommande=commande + #print "ds getPanelGroupe" , self.item.nom + #if hasattr(self,'plie'): print "self.plie", self.plie + # if self.item.nom == "BackgroundError" and not(self.plie): print i #print parentQt if hasattr(parentQt,'niveau'): self.niveau=parentQt.niveau+1 else : self.niveau=1 @@ -228,11 +217,10 @@ class MCListTreeItem(Objecttreeitem.SequenceTreeItem,compofact.FACTTreeItem): if self.object.suppentite(obj): if len(self._object) == 1: self.updateDelegate() message = "Mot-clef " + obj.nom + " supprime" - self.editor.affiche_commentaire(message) - return 1 + #self.editor.affiche_commentaire(message) + return (1,message) else: - self.editor.affiche_infos(tr('Impossible de supprimer ce mot-clef'),Qt.red) - return 0 + return (0,tr('Impossible de supprimer ce mot-clef')) import Accas diff --git a/InterfaceQT4/compooper.py b/InterfaceQT4/compooper.py index a65f566d..6c916b99 100644 --- a/InterfaceQT4/compooper.py +++ b/InterfaceQT4/compooper.py @@ -58,13 +58,8 @@ class Node(browser.JDCNode, typeNode.PopUpMenuNode): except : pass - def getPanel( self ): - """ - """ - from monCommandePanel import MonCommandePanel - return MonCommandePanel(self,parent=self.editor) - def getPanel2(self): + def getPanel(self): from monWidgetCommande import MonWidgetCommande return MonWidgetCommande(self,self.editor,self.item.object) @@ -204,15 +199,15 @@ class EtapeTreeItem(Objecttreeitem.ObjectTreeItem): # item.getObject() = MCSIMP, MCFACT, MCBLOC ou MCList itemobject=item.getObject() if itemobject.isoblig() : - self.editor.affiche_infos(tr('Impossible de supprimer un mot-clef obligatoire '),Qt.red) - return 0 + #self.editor.affiche_infos(tr('Impossible de supprimer un mot-clef obligatoire '),Qt.red) + return (0,tr('Impossible de supprimer un mot-clef obligatoire ')) if self.object.suppentite(itemobject): message = tr("Mot-clef %s supprime " , itemobject.nom) - self.editor.affiche_commentaire(message) - return 1 + #self.editor.affiche_commentaire(message) + return (1,message) else : - self.editor.affiche_commentaire(tr('Pb interne : impossible de supprimer ce mot-clef'),Qt.red) - return 0 + #self.editor.affiche_commentaire(tr('Pb interne : impossible de supprimer ce mot-clef'),Qt.red) + return (0,tr('Pb interne : impossible de supprimer ce mot-clef')) def GetText(self): try: diff --git a/InterfaceQT4/compoparam.py b/InterfaceQT4/compoparam.py index 3de6e90a..6689ea3d 100644 --- a/InterfaceQT4/compoparam.py +++ b/InterfaceQT4/compoparam.py @@ -34,7 +34,7 @@ import typeNode class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel): - def getPanel2(self): + def getPanel(self): """ """ from monWidgetParam import MonWidgetParam diff --git a/InterfaceQT4/compoproc.py b/InterfaceQT4/compoproc.py index e8bb4736..95e9bdfd 100644 --- a/InterfaceQT4/compoproc.py +++ b/InterfaceQT4/compoproc.py @@ -24,12 +24,9 @@ import typeNode class Node(browser.JDCNode,typeNode.PopUpMenuNode): - def getPanel(self): - from monMacroPanel import MonMacroPanel - return MonMacroPanel(self,parent=self.editor) - def getPanel2(self): - #print "getPanel2 de compoproc" + def getPanel(self): + #print "getPanel de compoproc" from monWidgetCommande import MonWidgetCommande return MonWidgetCommande(self,self.editor,self.item.object) diff --git a/InterfaceQT4/composimp.py b/InterfaceQT4/composimp.py index 173cc96e..ca8a572a 100644 --- a/InterfaceQT4/composimp.py +++ b/InterfaceQT4/composimp.py @@ -31,83 +31,6 @@ from Noyau.N_CR import justify_text from Accas import SalomeEntry class Node(browser.JDCNode,typeNode.PopUpMenuNodeMinimal): - def getPanel(self): - """ - """ - klass = None - # Attention l ordre des if est important - - if self.item.wait_matrice (): - from monMatricePanel import MonMatricePanel - klass=MonMatricePanel - # l'objet prend sa (ses) valeur(s) dans un ensemble discret de valeurs - elif self.item.has_into(): - if self.item.is_list() : - from monPlusieursIntoPanel import MonPlusieursIntoPanel - klass = MonPlusieursIntoPanel - else: - from monUniqueIntoPanel import MonUniqueIntoPanel - klass = MonUniqueIntoPanel - - # l'objet prend une ou des valeurs a priori quelconques - else: - # on attend une liste de valeurs - if self.item.is_list() : - # on attend une liste de SD - if self.item.wait_tuple() : - from monFonctionPanel import MonFonctionPanel - klass = MonFonctionPanel - elif self.item.wait_assd(): - from monPlusieursASSDPanel import MonPlusieursASSDPanel - klass = MonPlusieursASSDPanel - else: - # on attend une liste de valeurs de types debase (entiers, réels,...) - from monPlusieursBasePanel import MonPlusieursBasePanel - klass = MonPlusieursBasePanel - # on n'attend qu'une seule valeur - else: - # on attend une SD ou un objet de la classe CO (qui n'existe pas encore) - if self.item.wait_co(): - if len(self.item.get_sd_avant_du_bon_type()) != 0 : - from monUniqueSDCOIntoPanel import MonUniqueSDCOIntoPanel - klass = MonUniqueSDCOIntoPanel - else : - from monUniqueSDCOPanel import MonUniqueSDCOPanel - klass = MonUniqueSDCOPanel - - # on attend une SD - elif self.item.wait_assd(): - if 'R' in self.item.GetType(): - from monUniqueASSDPanel import MonUniqueASSDReelPanel - klass = MonUniqueASSDReelPanel - else : - from monUniqueASSDPanel import MonUniqueASSDPanel - klass = MonUniqueASSDPanel - - # on attend une valeur d'un type de base (entier,reel,...) - else: - # on attend un complexe - if self.item.wait_complex(): - from monUniqueCompPanel import MonUniqueCompPanel - klass = MonUniqueCompPanel - elif self.item.wait_bool() : - from monUniqueBoolPanel import MonUniqueBoolPanel - klass = MonUniqueBoolPanel - else : - from monUniqueBasePanel import MonUniqueBasePanel - klass = MonUniqueBasePanel - - # cas particulier des fonctions - genea = self.item.get_genealogie() - if "VALE" in genea or "VALE_C" in genea: - if "DEFI_FONCTION" in genea : - from monFonctionPanel import MonFonctionPanel - klass = MonFonctionPanel - - if not klass: - return None - return klass( self, self.editor ) - def createPopUpMenu(self): typeNode.PopUpMenuNodeMinimal.createPopUpMenu(self) diff --git a/InterfaceQT4/editor.py b/InterfaceQT4/editor.py index c385b6bc..e8bdbc89 100755 --- a/InterfaceQT4/editor.py +++ b/InterfaceQT4/editor.py @@ -222,9 +222,7 @@ class JDCEditor(Ui_baseWidget,QtGui.QWidget): #-------------------# Pour execution avec output et error dans le bash def runPSEN(self): #-------------------# - if self.modified or self.fichier==None : - QMessageBox.critical( self, tr( "Execution impossible "),tr("Sauvegarder SVP avant l'execution ")) - return + if self.modified or self.fichier==None : self.saveFile() #lancement avec le .bat path1 = os.path.abspath(os.path.join(os.path.abspath(__file__), '../','../','PSEN_Eficas','PSEN')) @@ -534,7 +532,6 @@ class JDCEditor(Ui_baseWidget,QtGui.QWidget): #---------------------# def handleDeplier(self): #---------------------# - print "je passe ici" if self.tree == None : return #self.tree.collapseAll() if self.deplier : diff --git a/InterfaceQT4/groupe.py b/InterfaceQT4/groupe.py index c165ebf0..d08afec9 100644 --- a/InterfaceQT4/groupe.py +++ b/InterfaceQT4/groupe.py @@ -73,7 +73,8 @@ class Groupe(QtGui.QWidget,FacultatifOuOptionnel): def afficheMots(self): #print "ds afficheMots ",self.node.item.nom for node in self.node.children: - #print "afficheMots ",node," " ,node.item.nom, " ",node.plie ," ", node.appartientAUnNoeudPlie + #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 diff --git a/InterfaceQT4/monWidgetSimpTxt.py b/InterfaceQT4/monWidgetSimpTxt.py index 3ded9c23..40231104 100644 --- a/InterfaceQT4/monWidgetSimpTxt.py +++ b/InterfaceQT4/monWidgetSimpTxt.py @@ -33,7 +33,6 @@ class MonWidgetSimpTxt (Ui_WidgetSimpTxt,MonWidgetSimpBase): # c est juste la taille des differents widgets de base qui change def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande): - print "MonWidgetSimpTxt", nom MonWidgetSimpBase.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande) -- 2.39.2