Salome HOME
modif pour MT
[tools/eficas.git] / InterfaceQT4 / monWidgetCommentaire.py
1 # Copyright (C) 2007-2017   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 __future__ import absolute_import
23 try :
24    from builtins import str
25 except : pass
26
27 from PyQt5.QtWidgets import QWidget
28 from PyQt5.QtCore    import Qt
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
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       self.monOptionnel=None
53
54       self.commentaireTE.textChanged.connect(self.TexteCommentaireEntre)
55       if self.editor.code in ['MAP','CARMELCND'] : self.bCatalogue.close()
56       else : self.bCatalogue.clicked.connect(self.afficheCatalogue)
57       if self.editor.code in ['Adao','MAP','ADAO'] :
58            self.bAvant.close()
59            self.bApres.close()
60       else :
61            self.bAvant.clicked.connect(self.afficheAvant)
62            self.bApres.clicked.connect(self.afficheApres)
63       self.editor.fermeOptionnel()
64
65
66   def afficheApres(self):
67        self.node.selectApres()
68
69   def afficheAvant(self):
70        self.node.selectAvant()
71
72        
73   def afficheCatalogue(self):
74       self.node.tree.racine.affichePanneau()
75       if self.node : self.node.select()
76       else : self.node.tree.racine.select()
77
78   def remplitTexte(self):
79       texte=self.node.item.getValeur()
80       self.commentaireTE.setText(texte)
81       if self.editor.code == "CARMELCND" and texte[0:16]=="Cree - fichier :" :
82          self.commentaireTE.setReadOnly(True)
83          self.commentaireTE.setStyleSheet("background:rgb(244,244,244);\n" "border:0px;\n")
84          self.commentaireTE.setToolTip(tr("Valeur non modifiable"))
85       else :
86          self.commentaireTE.setReadOnly(False)
87
88   def donnePremier(self):
89       self.commentaireTE.setFocus(7)
90
91
92   def TexteCommentaireEntre(self):
93       texte=str(self.commentaireTE.toPlainText())
94       self.editor.initModif()
95       self.node.item.setValeur(texte)
96       self.node.updateNodeTexte()
97