Salome HOME
pb d accent. on les enleve en français
[tools/eficas.git] / InterfaceQT4 / compocomm.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 from PyQt4.QtGui import *
22 from PyQt4.QtCore import *
23 import string
24
25 from Editeur     import Objecttreeitem
26 import browser
27 import typeNode
28 from Extensions.i18n import tr
29 from Extensions.eficas_exception import EficasException
30
31
32 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
33     def getPanel2( self ):
34         """
35         """
36         from monWidgetCommentaire import MonWidgetCommentaire
37         return MonWidgetCommentaire(self,self.editor,self.item.object)
38
39     def createPopUpMenu(self):
40         typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
41         self.Decommente = QAction(tr("Decommenter"),self.tree)
42         self.tree.connect(self.Decommente,SIGNAL("activated()"),self.Decommenter)
43         self.Decommente.setStatusTip(tr("Decommente la commande "))
44
45         if hasattr(self.item,'uncomment'):
46            self.menu.addAction(self.Decommente)
47
48     def Decommenter(self) :
49         item= self.tree.currentItem()
50         item.unCommentIt()
51
52     def update_node_label(self) :
53         """
54         """
55         debComm=self.item.GetText()
56         self.setText(1,debComm)
57
58
59     
60 class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
61     itemNode=Node    
62
63     def init(self):
64       self.setfunction = self.set_valeur
65
66     def GetIconName(self):
67       """
68       Retourne le nom de l'icône associée au noeud qui porte self,
69       dépendant de la validité de l'objet
70       NB : un commentaire est toujours valide ...
71       """
72       return "ast-white-percent"
73
74     def GetLabelText(self):
75         """ Retourne 3 valeurs :
76         - le texte à afficher dans le noeud représentant l'item
77         - la fonte dans laquelle afficher ce texte
78         - la couleur du texte
79         """
80         return 'c',None,None
81
82     def get_valeur(self):
83       """
84       Retourne la valeur de l'objet Commentaire cad son texte
85       """
86       return self.object.get_valeur() or ''
87     
88     def GetText(self):
89         texte = self.object.valeur
90         texte = string.split(texte,'\n')[0]
91         if len(texte) < 25 :
92             return texte
93         else :
94             return texte[0:24]
95
96     def set_valeur(self,valeur):
97       """
98       Afecte valeur à l'objet COMMENTAIRE
99       """
100       self.object.set_valeur(valeur)
101       
102     def GetSubList(self):
103       """
104       Retourne la liste des fils de self
105       """
106       return []
107
108
109     def get_objet_commentarise(self):
110        """
111            La méthode get_objet_commentarise() de la classe compocomm.COMMTreeItem
112            surcharge la méthode get_objet_commentarise de la classe Objecttreeitem.ObjectTreeItem
113            elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
114        """
115        raise EficasException( 'Impossible de commentariser un commentaire' )
116   
117 import Extensions
118 treeitem =COMMTreeItem
119 objet = Extensions.commentaire.COMMENTAIRE