X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FtypeNode.py;h=7ea4b363f97170a0a91c0594a9eed7d471567d30;hb=9bf98fc1cb51814c31679120598dc309e0802e31;hp=aab893dbced4d6b08e0bb641f1ed929b4bb415a2;hpb=e61aff6d6540bbc57004cc8276163587a4efb51b;p=tools%2Feficas.git diff --git a/InterfaceQT4/typeNode.py b/InterfaceQT4/typeNode.py index aab893db..7ea4b363 100644 --- a/InterfaceQT4/typeNode.py +++ b/InterfaceQT4/typeNode.py @@ -17,23 +17,27 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from PyQt4 import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from __future__ import absolute_import +try : + from builtins import object +except : pass + +from PyQt5.QtWidgets import QAction, QMenu, QMessageBox + from Extensions.i18n import tr import types #---------------------------# -class PopUpMenuRacine : +class PopUpMenuRacine(object) : #---------------------------# def createPopUpMenu(self): #print "createPopUpMenu" self.ParamApres = QAction(tr('Parametre'),self.tree) - self.tree.connect(self.ParamApres,SIGNAL("triggered()"),self.addParametersApres) + self.ParamApres.triggered.connect(self.addParametersApres) self.ParamApres.setStatusTip(tr("Insere un parametre")) self.menu = QMenu(self.tree) self.menu.addAction(self.ParamApres) @@ -45,7 +49,7 @@ class PopUpMenuRacine : item.addParameters(True) #---------------------------# -class PopUpMenuNodeMinimal : +class PopUpMenuNodeMinimal(object) : #---------------------------# def createPopUpMenu(self): @@ -59,13 +63,24 @@ class PopUpMenuNodeMinimal : #items du menu self.menu.addAction(self.Supprime) if hasattr(self.appliEficas, 'mesScripts'): - if self.tree.currentItem().item.get_nom() in self.appliEficas.mesScripts.dict_commandes.keys() : - self.ajoutScript() + if self.editor.code in self.editor.appliEficas.mesScripts : + self.dict_commandes_mesScripts=self.appliEficas.mesScripts[self.editor.code].dict_commandes + if self.tree.currentItem().item.get_nom() in self.dict_commandes_mesScripts : + self.ajoutScript() def ajoutScript(self): + # cochon mais je n arrive pas a faire mieux avec le mecanisme de plugin - listeCommandes=self.appliEficas.mesScripts.dict_commandes[self.tree.currentItem().item.get_nom()] - if type(listeCommandes) != types.TupleType: listeCommandes=(listeCommandes,) + if hasattr(self.appliEficas, 'mesScripts'): + if self.editor.code in self.editor.appliEficas.mesScripts : + self.dict_commandes_mesScripts=self.appliEficas.mesScripts[self.editor.code].dict_commandes + else : return + + from Extensions import jdc_include + if isinstance(self.item.jdc,jdc_include.JDC_INCLUDE) : return + + listeCommandes=self.dict_commandes_mesScripts[self.tree.currentItem().item.get_nom()] + if type(listeCommandes) != tuple: listeCommandes=(listeCommandes,) numero=0 for commande in listeCommandes : conditionSalome=commande[3] @@ -74,20 +89,11 @@ class PopUpMenuNodeMinimal : tip=commande[5] self.action=QAction(label,self.tree) self.action.setStatusTip(tip) - if numero==4: - self.tree.connect(self.action,SIGNAL("triggered()"),self.AppelleFonction4) - if numero==3: - self.tree.connect(self.action,SIGNAL("triggered()"),self.AppelleFonction3) - numero=4 - if numero==2: - self.tree.connect(self.action,SIGNAL("triggered()"),self.AppelleFonction2) - numero=3 - if numero==1: - self.tree.connect(self.action,SIGNAL("triggered()"),self.AppelleFonction1) - numero=2 - if numero==0: - self.tree.connect(self.action,SIGNAL("triggered()"),self.AppelleFonction0) - numero=1 + if numero==4: self.action.triggered.connect(self.AppelleFonction4) + if numero==3: self.action.triggered.connect(self.AppelleFonction3); numero=4 + if numero==2: self.action.triggered.connect(self.AppelleFonction2); numero=3 + if numero==1: self.action.triggered.connect(self.AppelleFonction1); numero=2 + if numero==0: self.action.triggered.connect(self.AppelleFonction0); numero=1 self.menu.addAction(self.action) @@ -107,30 +113,44 @@ class PopUpMenuNodeMinimal : self.AppelleFonction(4) - def AppelleFonction(self,numero): - listeCommandes=self.appliEficas.mesScripts.dict_commandes[self.tree.currentItem().item.get_nom()] + def AppelleFonction(self,numero,nodeTraite=None): + if nodeTraite==None : nodeTraite=self.tree.currentItem() + nomCmd=nodeTraite.item.get_nom() + if hasattr(self.appliEficas, 'mesScripts'): + if self.editor.code in self.editor.appliEficas.mesScripts : + self.dict_commandes_mesScripts=self.appliEficas.mesScripts[self.editor.code].dict_commandes + else : return + listeCommandes=self.dict_commandes_mesScripts[nomCmd] commande=listeCommandes[numero] conditionValid=commande[4] - if (self.tree.currentItem().item.isvalid() == 0 and conditionValid == True): + + + if (nodeTraite.item.isvalid() == 0 and conditionValid == True): QMessageBox.warning( None, tr("item invalide"), - tr("l item doit etre valide"), - tr("&Ok")) - return + tr("l item doit etre valide"),) + return fonction=commande[0] listenomparam=commande[2] listeparam=[] for p in listenomparam: - if hasattr(self.tree.currentItem(),p): - listeparam.append(getattr(self.tree.currentItem(),p)) + if hasattr(nodeTraite,p): + listeparam.append(getattr(nodeTraite,p)) if p=="self" : listeparam.append(self) + try : - fonction(listeparam,self.appliEficas) + res, commentaire= fonction(listeparam) + if not res : + QMessageBox.warning( None, + tr("echec de la fonction"), + tr(commentaire),) + return except : - fonction(listeparam) + pass + - def createActions(self): + def createActionsQT4(self): self.CommApres = QAction(tr('apres'),self.tree) self.tree.connect(self.CommApres,SIGNAL("triggered()"),self.addCommApres) self.CommApres.setStatusTip(tr("Insere un commentaire apres la commande ")) @@ -150,6 +170,27 @@ class PopUpMenuNodeMinimal : self.Supprime.setStatusTip(tr("supprime le mot clef ")) self.Documentation = QAction(tr('Documentation'),self.tree) self.tree.connect(self.Documentation,SIGNAL("triggered()"),self.viewDoc) + + def createActions(self): + self.CommApres = QAction(tr('apres'),self.tree) + self.CommApres.triggered.connect(self.addCommApres) + self.CommApres.setStatusTip(tr("Insere un commentaire apres la commande ")) + self.CommAvant = QAction(tr('avant'),self.tree) + self.CommAvant.triggered.connect(self.addCommAvant) + self.CommAvant.setStatusTip(tr("Insere un commentaire avant la commande ")) + + self.ParamApres = QAction(tr('apres'),self.tree) + self.ParamApres.triggered.connect(self.addParametersApres) + self.ParamApres.setStatusTip(tr("Insere un parametre apres la commande ")) + self.ParamAvant = QAction(tr('avant'),self.tree) + self.ParamAvant.triggered.connect(self.addParametersAvant) + self.ParamAvant.setStatusTip(tr("Insere un parametre avant la commande ")) + + self.Supprime = QAction(tr('Supprimer'),self.tree) + self.Supprime.triggered.connect(self.supprimeNoeud) + self.Supprime.setStatusTip(tr("supprime le mot clef ")) + self.Documentation = QAction(tr('Documentation'),self.tree) + self.Documentation.triggered.connect(self.viewDoc) self.Documentation.setStatusTip(tr("documentation sur la commande ")) def supprimeNoeud(self): @@ -230,7 +271,7 @@ class PopUpMenuNode(PopUpMenuNodePartiel) : def createPopUpMenu(self): PopUpMenuNodePartiel.createPopUpMenu(self) self.Commente = QAction(tr('ce noeud'),self.tree) - self.tree.connect(self.Commente,SIGNAL("triggered()"),self.Commenter) + self.Commente.triggered.connect(self.Commenter) self.Commente.setStatusTip(tr("commente le noeud ")) self.commentMenu.addAction(self.Commente) self.menu.removeAction(self.Supprime)