X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FtypeNode.py;h=7ea4b363f97170a0a91c0594a9eed7d471567d30;hb=9bf98fc1cb51814c31679120598dc309e0802e31;hp=f19f512635588208e101b4b7d235c65848d9ecbe;hpb=1ef6f82e922819d11fc326c6dfdd578999f7fa5d;p=tools%2Feficas.git diff --git a/InterfaceQT4/typeNode.py b/InterfaceQT4/typeNode.py index f19f5126..7ea4b363 100644 --- a/InterfaceQT4/typeNode.py +++ b/InterfaceQT4/typeNode.py @@ -17,12 +17,12 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from determine import monEnvQT5 -if monEnvQT5: - from PyQt5.QtWidgets import QAction, QMenu -else : - 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 @@ -30,17 +30,14 @@ import types #---------------------------# -class PopUpMenuRacine : +class PopUpMenuRacine(object) : #---------------------------# def createPopUpMenu(self): #print "createPopUpMenu" self.ParamApres = QAction(tr('Parametre'),self.tree) - if monEnvQT5 : - self.ParamApres.triggered.connect(self.addParametersApres) - else : - 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) @@ -52,14 +49,13 @@ class PopUpMenuRacine : item.addParameters(True) #---------------------------# -class PopUpMenuNodeMinimal : +class PopUpMenuNodeMinimal(object) : #---------------------------# def createPopUpMenu(self): #print "createPopUpMenu" #self.appliEficas.salome=True - if monEnvQT5 : self.createActions() - else : self.createActionsQT4() + self.createActions() self.menu = QMenu(self.tree) #self.menu.setStyleSheet("background:rgb(235,235,235); QMenu::item:selected { background-color: red; }") #ne fonctionne pas --> la ligne de commentaire devient rouge @@ -67,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] @@ -82,36 +89,11 @@ class PopUpMenuNodeMinimal : tip=commande[5] self.action=QAction(label,self.tree) self.action.setStatusTip(tip) - if monEnvQT5 : - 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 - else: - 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) @@ -131,26 +113,41 @@ 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"),) - return + 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 createActionsQT4(self):