mouseGrabber.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  Copyright (C) 2002-2013 Gilles Debunne. All rights reserved.
00004 
00005  This file is part of the QGLViewer library version 2.4.0.
00006 
00007  http://www.libqglviewer.com - contact@libqglviewer.com
00008 
00009  This file may be used under the terms of the GNU General Public License 
00010  versions 2.0 or 3.0 as published by the Free Software Foundation and
00011  appearing in the LICENSE file included in the packaging of this file.
00012  In addition, as a special exception, Gilles Debunne gives you certain 
00013  additional rights, described in the file GPL_EXCEPTION in this package.
00014 
00015  libQGLViewer uses dual licensing. Commercial/proprietary software must
00016  purchase a libQGLViewer Commercial License.
00017 
00018  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020 
00021 *****************************************************************************/
00022 
00023 #include "mouseGrabber.h"
00024 
00025 using namespace qglviewer;
00026 
00027 // Static private variable
00028 #if QT_VERSION >= 0x040000
00029 QList<MouseGrabber*> MouseGrabber::MouseGrabberPool_;
00030 #else
00031 QPtrList<MouseGrabber> MouseGrabber::MouseGrabberPool_;
00032 #endif
00033 
00037 MouseGrabber::MouseGrabber()
00038   : grabsMouse_(false)
00039 {
00040   addInMouseGrabberPool();
00041 }
00042 
00051 void MouseGrabber::addInMouseGrabberPool()
00052 {
00053   if (!isInMouseGrabberPool())
00054     MouseGrabber::MouseGrabberPool_.append(this);
00055 }
00056 
00061 void MouseGrabber::removeFromMouseGrabberPool()
00062 {
00063   if (isInMouseGrabberPool())
00064 #if QT_VERSION >= 0x040000
00065     MouseGrabber::MouseGrabberPool_.removeAll(const_cast<MouseGrabber*>(this));
00066 #else
00067     MouseGrabber::MouseGrabberPool_.removeRef(this);
00068 #endif
00069 }
00070 
00079 void MouseGrabber::clearMouseGrabberPool(bool autoDelete)
00080 {
00081 #if QT_VERSION >= 0x040000
00082   if (autoDelete)
00083     qDeleteAll(MouseGrabber::MouseGrabberPool_);
00084 #else
00085   MouseGrabber::MouseGrabberPool_.setAutoDelete(autoDelete);
00086 #endif
00087   MouseGrabber::MouseGrabberPool_.clear();
00088 }


octovis
Author(s): Kai M. Wurm , Armin Hornung
autogenerated on Thu Aug 27 2015 14:13:26