1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 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
24 from Editeur import Objecttreeitem
26 from . import typeNode
27 from Extensions.i18n import tr
28 from Extensions.eficas_exception import EficasException
31 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
35 from .monWidgetCommentaire import MonWidgetCommentaire
36 return MonWidgetCommentaire(self,self.editor,self.item.object)
38 def createPopUpMenu(self):
39 typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
40 from PyQt5.QtWidgets import QAction
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))
59 class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
63 self.setFunction = self.setValeur
65 def getIconName(self):
67 Retourne le nom de l'icone associee au noeud qui porte self,
68 dependant de la validite de l'objet
69 NB : un commentaire est toujours valide ...
71 return "ast-white-percent"
73 def getLabelText(self):
74 """ Retourne 3 valeurs :
75 - le texte a afficher dans le noeud representant l'item
76 - la fonte dans laquelle afficher ce texte
79 return tr('Commentaire'),None,None
83 Retourne la valeur de l'objet Commentaire cad son texte
85 return self.object.getValeur() or ''
88 texte = self.object.valeur
89 texte = texte.split('\n')[0]
95 def setValeur(self,valeur):
97 Affecte valeur a l'objet COMMENTAIRE
99 self.object.setValeur(valeur)
101 def getSubList(self):
103 Retourne la liste des fils de self
108 def getObjetCommentarise(self):
110 La methode getObjetCommentarise() de la classe compocomm.COMMTreeItem
111 surcharge la methode getObjetCommentarise de la classe Objecttreeitem.ObjectTreeItem
112 elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
114 raise EficasException( 'Impossible de commentariser un commentaire' )
117 treeitem =COMMTreeItem
118 objet = Extensions.commentaire.COMMENTAIRE