]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQSignalBlocker.h
don't create QObjects in ycp thread - make timeouts work
[duncan/yast2-qt4.git] / src / YQSignalBlocker.h
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQSignalBlocker.h
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19 #ifndef YQSignalBlocker_h
20 #define YQSignalBlocker_h
21
22 class QObject;
23
24 /**
25  * Helper class to block Qt signals for QWidgets or QObjects as long as this
26 Y * object exists. 
27  *
28  * This object will restore the old blocked state when it goes out of scope. 
29  **/
30 class YQSignalBlocker
31 {
32 public:
33
34     /**
35      * Constructor.
36      *
37      * Qt signals for 'qobject' will be blocked as long as this object exists.
38      * Remember that a QWidget is also a QObject.
39      **/
40     YQSignalBlocker( QObject * qobject );
41
42     /**
43      * Destructor.
44      *
45      * This will restore the old signal state.
46      **/
47     ~YQSignalBlocker();
48
49
50 private:
51
52     QObject *   _qobject;
53     bool        _oldBlockedState;
54 };
55
56
57 #endif // ifndef YQSignalBlocker_h