Salome HOME
d1265c27130a4e4c3b52f1ff5997af49e6c8e2ef
[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     from PyQt5.QtCore    import Qt
26 else :
27     from PyQt4.QtGui  import *
28     from PyQt4.QtCore import *
29
30 from desWidgetCommentaire import Ui_WidgetCommentaire
31 from gereIcones import FacultatifOuOptionnel
32 from Extensions.i18n import tr
33 import Accas 
34 import os
35 import string
36
37     
38 # Import des panels
39
40 class MonWidgetCommentaire(QWidget,Ui_WidgetCommentaire,FacultatifOuOptionnel):
41   """
42   """
43   def __init__(self,node,editor,commentaire):
44       QWidget.__init__(self,None)
45       self.node=node
46       self.node.fenetre=self
47       self.setupUi(self)
48       self.editor=editor
49       self.appliEficas=self.editor.appliEficas
50       self.repIcon=self.appliEficas.repIcon
51       self.setIconePoubelle()
52       self.remplitTexte()
53       self.monOptionnel=None
54
55       if monEnvQT5 :
56          self.commentaireTE.textChanged.connect(self.TexteCommentaireEntre)
57          #if self.editor.code in ['MAP','CARMELCND','CF'] : self.bCatalogue.close()
58          if self.editor.code in ['MAP','CARMELCND'] : self.bCatalogue.close()
59          else : self.bCatalogue.clicked.connect(self.afficheCatalogue)
60          #if self.editor.code in ['Adao','MAP','CF'] :
61          if self.editor.code in ['Adao','MAP','ADAO'] :
62                self.bAvant.close()
63                self.bApres.close()
64          else :
65                self.bAvant.clicked.connect(self.afficheAvant)
66                self.bApres.clicked.connect(self.afficheApres)
67       else :
68          if self.editor.code in ['MAP','CARMELCND'] : self.bCatalogue.close()
69          else : self.connect(self.bCatalogue,SIGNAL("clicked()"), self.afficheCatalogue)
70          if self.editor.code in ['Adao','MAP','ADAO'] :
71                self.bAvant.close()
72                self.bApres.close()
73          else :
74                self.connect(self.bAvant,SIGNAL("clicked()"), self.afficheAvant)
75                self.connect(self.bApres,SIGNAL("clicked()"), self.afficheApres)
76       self.editor.fermeOptionnel()
77
78
79   def afficheApres(self):
80        self.node.selectApres()
81
82   def afficheAvant(self):
83        self.node.selectAvant()
84
85        
86   def afficheCatalogue(self):
87       self.node.tree.racine.affichePanneau()
88       if self.node : self.node.select()
89       else : self.node.tree.racine.select()
90
91   def remplitTexte(self):
92       texte=self.node.item.get_valeur()
93       self.commentaireTE.setText(texte)
94       if self.editor.code == "CARMELCND" and texte[0:16]=="Cree - fichier :" :
95          self.commentaireTE.setReadOnly(True)
96          self.commentaireTE.setStyleSheet("background:rgb(244,244,244);\n" "border:0px;\n")
97          self.commentaireTE.setToolTip(tr("Valeur non modifiable"))
98       else :
99          self.commentaireTE.setReadOnly(False)
100
101   def donnePremier(self):
102       self.commentaireTE.setFocus(7)
103
104
105   def TexteCommentaireEntre(self):
106       texte=str(self.commentaireTE.toPlainText())
107       self.editor.init_modif()
108       self.node.item.set_valeur(texte)
109       self.node.update_node_texte()
110