Salome HOME
1d422a77448cbf1e8d8032d35ee6836b4f58d588
[tools/eficas.git] / InterfaceQT4 / monWidgetCommentaire.py
1 # Copyright (C) 2007-2013   EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Modules Python
20 # Modules Eficas
21
22 from determine import monEnvQT5
23 if monEnvQT5:
24     from PyQt5.QtWidgets  import QWidget
25 else :
26     from PyQt4.QtGui  import *
27     from PyQt4.QtCore import
28
29 from desWidgetCommentaire import Ui_WidgetCommentaire
30 from gereIcones import FacultatifOuOptionnel
31 from Extensions.i18n import tr
32 import Accas 
33 import os
34 import string
35
36     
37 # Import des panels
38
39 class MonWidgetCommentaire(QWidget,Ui_WidgetCommentaire,FacultatifOuOptionnel):
40   """
41   """
42   def __init__(self,node,editor,commentaire):
43       QWidget.__init__(self,None)
44       self.node=node
45       self.node.fenetre=self
46       self.setupUi(self)
47       self.editor=editor
48       self.appliEficas=self.editor.appliEficas
49       self.repIcon=self.appliEficas.repIcon
50       self.setIconePoubelle()
51       self.remplitTexte()
52       if self.editor.code in ['MAP','CARMELCND'] : self.bCatalogue.close()
53       elif monEnvQT5 : self.bCatalogue.clicked.connect(self.afficheCatalogue)
54       else : self.connect(self.bCatalogue,SIGNAL("clicked()"), self.afficheCatalogue)
55       if monEnvQT5 : self.commentaireLE.returnPressed(TexteCommentaireEntre)
56       else : self.connect(self.commentaireLE,SIGNAL("returnPressed()"),self.TexteCommentaireEntre)
57        
58   def afficheCatalogue(self):
59       if self.editor.code != "CARMELCND" : self.monOptionnel.hide()
60       self.node.tree.racine.affichePanneau()
61       if self.node : self.node.select()
62       else : self.node.tree.racine.select()
63
64   def remplitTexte(self):
65       texte=self.node.item.get_valeur()
66       self.commentaireLE.setText(texte)
67       if self.editor.code == "CARMELCND" and texte[0:16]=="Cree - fichier :" :
68          self.commentaireLE.setDisabled(True)
69          self.commentaireLE.setStyleSheet("background:rgb(244,244,244);\n" "border:0px;\n")
70          self.commentaireLE.setToolTip(tr("Valeur non modifiable"))
71
72   def donnePremier(self):
73       self.commentaireLE.setFocus(7)
74
75
76   def TexteCommentaireEntre(self):
77       texte=str(self.commentaireLE.text())
78       self.editor.init_modif()
79       self.node.item.set_valeur(texte)
80       self.node.update_node()
81