mouseGrabber.cpp
1 /****************************************************************************
2 
3  Copyright (C) 2002-2008 Gilles Debunne. All rights reserved.
4 
5  This file is part of the QGLViewer library version 2.3.10.
6 
7  http://www.libqglviewer.com - contact@libqglviewer.com
8 
9  This file may be used under the terms of the GNU General Public License
10  versions 2.0 or 3.0 as published by the Free Software Foundation and
11  appearing in the LICENSE file included in the packaging of this file.
12  In addition, as a special exception, Gilles Debunne gives you certain
13  additional rights, described in the file GPL_EXCEPTION in this package.
14 
15  libQGLViewer uses dual licensing. Commercial/proprietary software must
16  purchase a libQGLViewer Commercial License.
17 
18  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 
21 *****************************************************************************/
22 
23 #include "mouseGrabber.h"
24 
25 using namespace qglviewer;
26 
27 // Static private variable
28 #if QT_VERSION >= 0x040000
29 QList<MouseGrabber*> MouseGrabber::MouseGrabberPool_;
30 #else
31 QPtrList<MouseGrabber> MouseGrabber::MouseGrabberPool_;
32 #endif
33 
38  : grabsMouse_(false)
39 {
41 }
42 
52 {
53  if (!isInMouseGrabberPool())
54  MouseGrabber::MouseGrabberPool_.append(this);
55 }
56 
62 {
64 #if QT_VERSION >= 0x040000
65  MouseGrabber::MouseGrabberPool_.removeAll(const_cast<MouseGrabber*>(this));
66 #else
67  MouseGrabber::MouseGrabberPool_.removeRef(this);
68 #endif
69 }
70 
80 {
81 #if QT_VERSION >= 0x040000
82  if (autoDelete)
83  qDeleteAll(MouseGrabber::MouseGrabberPool_);
84 #else
85  MouseGrabber::MouseGrabberPool_.setAutoDelete(autoDelete);
86 #endif
87  MouseGrabber::MouseGrabberPool_.clear();
88 }