Salome HOME
legere difference ds VARIABLES_TO_BE...
[tools/eficas.git] / InterfaceQT4 / monBoutonValide.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2013   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 six
25
26 import os
27
28
29 from PyQt5.QtWidgets import QToolButton, QToolTip
30 from Extensions.i18n import tr
31
32 class MonBoutonValide(QToolButton) :
33
34      def __init__(self,parent):
35         QToolButton.__init__(self,parent)
36         while( not(hasattr(parent,'node'))): 
37           parent= parent.parent()
38         self.parent=parent
39
40      def mouseDoubleClickEvent(self, event):
41         #print "dans mouseDoubleClickEvent"
42         strRapport=six.text_type(self.parent.node.item.object.report())
43         self.parent.editor._viewText(strRapport, "JDC_RAPPORT")
44
45      def mousePressEvent(self, event):
46        #print "dans mousePressEvent"
47        if self.parent.node.item.object.isvalid() :
48           myToolTip=tr("objet valide")
49           QToolTip.showText(event.globalPos(),myToolTip )
50        else :
51           t=""
52           texte=six.text_type(self.parent.node.item.object.report())
53           deb=1
54           for l in texte.split('\n')[2:-2]:
55               if re.match('^[\t !]*$',l) : continue
56               if re.match('^ *Fin Mot-cl',l) : continue
57               if re.match('^ *D?but Mot-cl',l) : continue
58               if re.match('^ *Mot-cl',l) : continue
59               l=l.replace('!','')
60               if deb :
61                  deb=0
62                  t=l
63               else :
64                  t=t+'\n'+l
65           myToolTip=tr(t)
66        QToolTip.showText(event.globalPos(),myToolTip )
67
68