1 # -*- coding: utf-8 -*-
3 from PyQt4.QtGui import *
4 from PyQt4.QtCore import *
6 #---------------------------#
7 class PopUpMenuNodeMinimal :
8 #---------------------------#
9 def createPopUpMenu(self):
11 self.menu = QMenu(self.tree)
13 self.menu.addAction(self.Supprime)
15 def createActions(self):
16 self.CommApres = QAction('après',self.tree)
17 self.tree.connect(self.CommApres,SIGNAL("activated()"),self.addCommApres)
18 self.CommApres.setStatusTip("Insere un commentaire apres la commande ")
19 self.CommAvant = QAction('avant',self.tree)
20 self.tree.connect(self.CommAvant,SIGNAL("activated()"),self.addCommAvant)
21 self.CommAvant.setStatusTip("Insere un commentaire avant la commande ")
23 self.ParamApres = QAction('après',self.tree)
24 self.tree.connect(self.ParamApres,SIGNAL("activated()"),self.addParametersApres)
25 self.ParamApres.setStatusTip("Insere un parametre apres la commande ")
26 self.ParamAvant = QAction('avant',self.tree)
27 self.tree.connect(self.ParamAvant,SIGNAL("activated()"),self.addParametersAvant)
28 self.ParamAvant.setStatusTip("Insere un parametre avant la commande ")
30 self.Supprime = QAction('Supprimer',self.tree)
31 self.tree.connect(self.Supprime,SIGNAL("activated()"),self.supprimeNoeud)
32 self.Supprime.setStatusTip("supprime le mot clef ")
33 self.Documentation = QAction('Documentation',self.tree)
34 self.tree.connect(self.Documentation,SIGNAL("activated()"),self.viewDoc)
35 self.Documentation.setStatusTip("documentation sur la commande ")
37 def supprimeNoeud(self):
38 item= self.tree.currentItem()
42 self.node=self.tree.currentItem()
43 cle_doc = self.node.item.get_docu()
45 QMessageBox.information( self.editor, "Documentation Vide", \
46 "Aucune documentation Aster n'est associée à ce noeud")
48 #cle_doc = string.replace(cle_doc,'.','')
49 #cle_doc = string.replace(cle_doc,'-','')
51 commande = self.editor.appliEficas.CONFIGURATION.exec_acrobat
55 texte="impossible de trouver la commande " + commande
56 QMessageBox.information( self.editor, "Lecteur PDF", texte)
58 nom_fichier = cle_doc+".pdf"
59 fichier = os.path.abspath(os.path.join(self.editor.CONFIGURATION.path_doc,
64 texte="impossible d'ouvrir " + fichier
65 QMessageBox.information( self.editor, "Documentation Vide", texte)
68 os.spawnv(os.P_NOWAIT,commande,(commande,fichier,))
69 elif os.name == 'posix':
70 script ="#!/usr/bin/sh \n%s %s&" %(commande,fichier)
71 pid = os.system(script)
73 def addParametersApres(self):
74 item= self.tree.currentItem()
75 item.addParameters(True)
77 def addParametersAvant(self):
78 item= self.tree.currentItem()
79 item.addParameters(False)
81 def addCommApres(self):
82 item= self.tree.currentItem()
85 def addCommAvant(self):
86 item= self.tree.currentItem()
87 item.addComment(False)
89 #--------------------------------------------#
90 class PopUpMenuNodePartiel (PopUpMenuNodeMinimal):
91 #---------------------------------------------#
92 def createPopUpMenu(self):
93 PopUpMenuNodeMinimal.createPopUpMenu(self)
95 self.commentMenu=self.menu.addMenu('Commentaire')
96 self.commentMenu.addAction(self.CommApres)
97 self.commentMenu.addAction(self.CommAvant)
99 self.paramMenu =self.menu.addMenu('Parametre')
100 self.paramMenu.addAction(self.ParamApres)
101 self.paramMenu.addAction(self.ParamAvant)
102 self.menu.addAction(self.Documentation)
105 #-----------------------------------------#
106 class PopUpMenuNode(PopUpMenuNodePartiel) :
107 #-----------------------------------------#
108 def createPopUpMenu(self):
109 PopUpMenuNodePartiel.createPopUpMenu(self)
110 self.Commente = QAction('ce noeud',self.tree)
111 self.tree.connect(self.Commente,SIGNAL("activated()"),self.Commenter)
112 self.Commente.setStatusTip("commente le noeud ")
113 self.commentMenu.addAction(self.Commente)
116 item= self.tree.currentItem()