Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / SUIT / SUIT_OverrideCursor.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA 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 #include "SUIT_OverrideCursor.h"
20
21 /*!Constructor. Initialize wait cursor.*/
22 SUIT_OverrideCursor::SUIT_OverrideCursor()
23 {
24   QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
25 }
26
27 /*!Copy constructor.*/
28 SUIT_OverrideCursor::SUIT_OverrideCursor( const QCursor& cursor )
29 {
30   QApplication::setOverrideCursor( cursor );
31 }
32
33 /*!Destructor. restoring override cursor.*/
34 SUIT_OverrideCursor::~SUIT_OverrideCursor()
35 {
36   QApplication::restoreOverrideCursor();
37 }
38
39 /*! Check cursors is empty */
40 bool SUIT_OverrideCursor::isActive() const
41 {
42   return myCursors.isEmpty();
43 }
44
45 /*!Suspend cursors.*/
46 void SUIT_OverrideCursor::suspend()
47 {
48   if ( !isActive() )
49     return;
50
51   while ( QApplication::overrideCursor() )
52   {
53     myCursors.prepend( *QApplication::overrideCursor() );
54     QApplication::restoreOverrideCursor();
55   }
56 }
57
58 /*!Resume cursors.*/
59 void SUIT_OverrideCursor::resume()
60 {
61   if ( isActive() )
62     return;
63
64   for ( QValueList<QCursor>::const_iterator it = myCursors.begin(); it != myCursors.end(); ++it )
65     QApplication::setOverrideCursor( *it );
66
67   myCursors.clear();
68 }