Salome HOME
mse a jour du 07/03/2016 pour sauvegarde
[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 import re
23 from determine import monEnvQT5
24 if monEnvQT5:
25    from PyQt5.QtWidgets import QToolButton
26 else :
27    from PyQt4.QtGui import *
28    from PyQt4.QtCore import *
29 from Extensions.i18n import tr
30
31 class MonBoutonValide(QToolButton) :
32
33      def __init__(self,parent):
34         QToolButton.__init__(self,parent)
35         while( not(hasattr(parent,'node'))): 
36           parent= parent.parent()
37         self.parent=parent
38
39      def mouseDoubleClickEvent(self, event):
40         #print "dans mouseDoubleClickEvent"
41         strRapport=unicode(self.parent.node.item.object.report())
42         self.parent.editor._viewText(strRapport, "JDC_RAPPORT")
43
44      def mousePressEvent(self, event):
45        #print "dans mousePressEvent"
46        if self.parent.node.item.object.isvalid() :
47           myToolTip=QString(tr("objet valide"))
48           QToolTip.showText(event.globalPos(),myToolTip )
49        else :
50           t=""
51           texte=unicode(self.parent.node.item.object.report())
52           deb=1
53           for l in texte.split('\n')[2:-2]:
54               if re.match('^[\t !]*$',l) : continue
55               if re.match('^ *Fin Mot-cl',l) : continue
56               if re.match('^ *D?but Mot-cl',l) : continue
57               if re.match('^ *Mot-cl',l) : continue
58               l=l.replace('!','')
59               if deb :
60                  deb=0
61                  t=l
62               else :
63                  t=t+'\n'+l
64           myToolTip=QString(t)
65        QToolTip.showText(event.globalPos(),myToolTip )
66
67