]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/monBoutonValide.py
Salome HOME
update version
[tools/eficas.git] / InterfaceQT4 / monBoutonValide.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2021   EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 from __future__ import absolute_import
23 import re
24 import os
25
26
27 from PyQt5.QtWidgets import QToolButton, QToolTip
28 from Extensions.i18n import tr
29
30 class MonBoutonValide(QToolButton) :
31
32     def __init__(self,parent):
33         QToolButton.__init__(self,parent)
34         while( not(hasattr(parent,'node'))):
35             parent= parent.parent()
36         self.parent=parent
37
38     def mouseDoubleClickEvent(self, event):
39         #print "dans mouseDoubleClickEvent"
40         strAide=self.parent.node.item.object.getFr()
41         if hasattr(self.parent.node.item.object.definition, 'defaut') :
42             strAide+='\ndefaut : \n'+str(self.parent.node.item.object.definition.defaut)
43         strRapport=str(self.parent.node.item.object.report())
44         self.parent.editor._viewText(strAide+"\n"+strRapport, "JDC_RAPPORT")
45
46     def mousePressEvent(self, event):
47         #print "dans mousePressEvent"
48         if self.parent.node.item.object.isValid() :
49             myToolTip=tr("objet valide")
50             if self.parent.editor.maConfiguration.differencieSiDefaut :
51                 if hasattr(self.parent.node.item.object.definition, 'defaut') :
52                     if self.parent.node.item.object.valeur != self.parent.node.item.object.definition.defaut :
53                         myToolTip+='\ndefaut : \n'+str(self.parent.node.item.object.definition.defaut)
54
55             QToolTip.showText(event.globalPos(),myToolTip )
56         else :
57             t=""
58             texte=self.parent.node.item.object.report().report()
59             deb=1
60             for l in texte.split('\n')[2:-2]:
61                 if re.match('^[\t !]*$',l) : continue
62                 if re.match('^ *Fin Mot-cl',l) : continue
63                 if re.match('^ *D?but Mot-cl',l) : continue
64                 if re.match('^ *Mot-cl',l) : continue
65                 l=l.replace('!','')
66                 if deb :
67                     deb=0
68                     t=l
69                 else :
70                     t=t+'\n'+l
71             myToolTip=tr(t)
72         QToolTip.showText(event.globalPos(),myToolTip )