1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from __future__ import absolute_import
23 from PyQt5.QtWidgets import QAction
25 from Editeur import Objecttreeitem
27 from . import typeNode
28 from Extensions.i18n import tr
29 from Extensions.eficas_exception import EficasException
32 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
36 from .monWidgetCommentaire import MonWidgetCommentaire
37 return MonWidgetCommentaire(self,self.editor,self.item.object)
39 def createPopUpMenu(self):
40 typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
41 self.Decommente = QAction(tr("decommenter"),self.tree)
42 self.Decommente.triggered.connect(self.decommenter)
43 self.Decommente.setStatusTip(tr("Decommente la commande "))
45 if hasattr(self.item,'unComment'):
46 self.menu.addAction(self.Decommente)
48 def decommenter(self) :
49 item= self.tree.currentItem()
52 def updateNodeLabel(self) :
55 debComm=self.item.getText()
56 self.setText(1,tr(debComm))
60 class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
64 self.setFunction = self.setValeur
66 def getIconName(self):
68 Retourne le nom de l'icone associee au noeud qui porte self,
69 dependant de la validite de l'objet
70 NB : un commentaire est toujours valide ...
72 return "ast-white-percent"
74 def getLabelText(self):
75 """ Retourne 3 valeurs :
76 - le texte a afficher dans le noeud representant l'item
77 - la fonte dans laquelle afficher ce texte
80 return tr('Commentaire'),None,None
84 Retourne la valeur de l'objet Commentaire cad son texte
86 return self.object.getValeur() or ''
89 texte = self.object.valeur
90 texte = texte.split('\n')[0]
96 def setValeur(self,valeur):
98 Affecte valeur a l'objet COMMENTAIRE
100 self.object.setValeur(valeur)
102 def getSubList(self):
104 Retourne la liste des fils de self
109 def getObjetCommentarise(self):
111 La methode getObjetCommentarise() de la classe compocomm.COMMTreeItem
112 surcharge la methode getObjetCommentarise de la classe Objecttreeitem.ObjectTreeItem
113 elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
115 raise EficasException( 'Impossible de commentariser un commentaire' )
118 treeitem =COMMTreeItem
119 objet = Extensions.commentaire.COMMENTAIRE