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 commande = self.editor.appliEficas.CONFIGURATION.exec_acrobat
52 texte="impossible de trouver la commande " + commande
53 QMessageBox.information( self.editor, "Lecteur PDF", texte)
57 fichier = os.path.abspath(os.path.join(self.editor.CONFIGURATION.path_doc,
62 texte="impossible d'ouvrir " + fichier
63 QMessageBox.information( self.editor, "Documentation Vide", texte)
66 os.spawnv(os.P_NOWAIT,commande,(commande,fichier,))
67 elif os.name == 'posix':
68 script ="#!/usr/bin/sh \n%s %s&" %(commande,fichier)
69 pid = os.system(script)
71 def addParametersApres(self):
72 item= self.tree.currentItem()
73 item.addParameters(True)
75 def addParametersAvant(self):
76 item= self.tree.currentItem()
77 item.addParameters(False)
79 def addCommApres(self):
80 item= self.tree.currentItem()
83 def addCommAvant(self):
84 item= self.tree.currentItem()
85 item.addComment(False)
87 #--------------------------------------------#
88 class PopUpMenuNodePartiel (PopUpMenuNodeMinimal):
89 #---------------------------------------------#
90 def createPopUpMenu(self):
91 PopUpMenuNodeMinimal.createPopUpMenu(self)
93 self.commentMenu=self.menu.addMenu('Commentaire')
94 self.commentMenu.addAction(self.CommApres)
95 self.commentMenu.addAction(self.CommAvant)
97 self.paramMenu =self.menu.addMenu('Parametre')
98 self.paramMenu.addAction(self.ParamApres)
99 self.paramMenu.addAction(self.ParamAvant)
100 self.menu.addAction(self.Documentation)
101 self.menu.removeAction(self.Supprime)
102 self.menu.addAction(self.Supprime)
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)
114 self.menu.removeAction(self.Supprime)
115 self.menu.addAction(self.Supprime)
118 item= self.tree.currentItem()