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