Cache Nepomuk tag information.
[kdepim.git] / knode / utils / scoped_cursor_override.h
blob332801d22b8c5a8ef3f13fbdb2f487be756872ab
1 /*
2 Copyright 2010 Olivier Trichet <nive@nivalis.org>
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both that the copyright notice and this
8 permission notice and warranty disclaimer appear in supporting
9 documentation, and that the name of the author not be used in
10 advertising or publicity pertaining to distribution of the
11 software without specific, written prior permission.
13 The author disclaim all warranties with regard to this
14 software, including all implied warranties of merchantability
15 and fitness. In no event shall the author be liable for any
16 special, indirect or consequential damages or any damages
17 whatsoever resulting from loss of use, data or profits, whether
18 in an action of contract, negligence or other tortious action,
19 arising out of or in connection with the use or performance of
20 this software.
23 #ifndef KNODE_SCOPEDCURSOROVERRIDE_H
24 #define KNODE_SCOPEDCURSOROVERRIDE_H
26 #include <QApplication>
28 namespace KNode {
29 namespace Utilities {
31 /**
32 This object change the application cursor to a given type and
33 then restore the previous cursor when it goes out of scope.
34 @see QApplication::setOverrideCursor()
36 class ScopedCursorOverride
38 public:
39 /**
40 Constructor: change the cursor shape to @p shape.
42 ScopedCursorOverride( Qt::CursorShape shape )
43 : restored( false )
45 QApplication::setOverrideCursor( QCursor( shape ) );
48 /**
49 Destructor: restore the previous cursor shape.
51 ~ScopedCursorOverride()
53 restore();
56 /**
57 Restore the previous cursor shape.
59 void restore()
61 if ( !restored ) {
62 restored = true;
63 QApplication::restoreOverrideCursor();
67 private:
68 bool restored;
71 } // namespace Utilities
72 } // namespace KNode
74 #endif // KNODE_SCOPEDCURSOROVERRIDE_H