Salome HOME
CCAR: merge de la version 1.14 dans la branche principale
[tools/eficas.git] / InterfaceQT4 / compocomm.py
1 # -*- coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21
22 from PyQt4.QtGui import *
23 from PyQt4.QtCore import *
24 import string
25
26 from Editeur     import Objecttreeitem
27 import browser
28 import typeNode
29
30
31 class Node(browser.JDCNode,typeNode.PopUpMenuNodePartiel):
32     def getPanel( self ):
33         """
34         """
35         from monCommentairePanel import MonCommentairePanel
36         return MonCommentairePanel(self,parent=self.editor)
37
38     def createPopUpMenu(self):
39         typeNode.PopUpMenuNodePartiel.createPopUpMenu(self)
40         self.Decommente = QAction('Decommenter',self.tree)
41         self.tree.connect(self.Decommente,SIGNAL("activated()"),self.Decommenter)
42         self.Decommente.setStatusTip("Decommente la commande ")
43
44         if hasattr(self.item,'uncomment'):
45            self.menu.addAction(self.Decommente)
46
47     def Decommenter(self) :
48         item= self.tree.currentItem()
49         item.unCommentIt()
50
51     def update_node_label(self) :
52         """
53         """
54         debComm=self.item.GetText()
55         self.setText(1,debComm)
56
57     
58 class COMMTreeItem(Objecttreeitem.ObjectTreeItem):
59     itemNode=Node    
60
61     def init(self):
62       self.setfunction = self.set_valeur
63
64     def GetIconName(self):
65       """
66       Retourne le nom de l'icône associée au noeud qui porte self,
67       dépendant de la validité de l'objet
68       NB : un commentaire est toujours valide ...
69       """
70       return "ast-white-percent"
71
72     def GetLabelText(self):
73         """ Retourne 3 valeurs :
74         - le texte à afficher dans le noeud représentant l'item
75         - la fonte dans laquelle afficher ce texte
76         - la couleur du texte
77         """
78         return 'commentaire'   #CS_pbruno,Fonte_Commentaire,None
79
80     def get_valeur(self):
81       """
82       Retourne la valeur de l'objet Commentaire cad son texte
83       """
84       return self.object.get_valeur() or ''
85     
86     def GetText(self):
87         texte = self.object.valeur
88         texte = string.split(texte,'\n')[0]
89         if len(texte) < 25 :
90             return texte
91         else :
92             return texte[0:24]
93
94     def set_valeur(self,valeur):
95       """
96       Afecte valeur à l'objet COMMENTAIRE
97       """
98       self.object.set_valeur(valeur)
99       
100     def GetSubList(self):
101       """
102       Retourne la liste des fils de self
103       """
104       return []
105
106
107     def get_objet_commentarise(self):
108        """
109            La méthode get_objet_commentarise() de la classe compocomm.COMMTreeItem
110            surcharge la méthode get_objet_commentarise de la classe Objecttreeitem.ObjectTreeItem
111            elle a pour but d'empecher l'utilisateur final de commentariser un commentaire.
112        """
113        raise Exception( 'Impossible de commentariser un commentaire' )
114   
115 import Extensions
116 treeitem =COMMTreeItem
117 objet = Extensions.commentaire.COMMENTAIRE