PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/src/libtomahawk/utils/WidgetDragFilter.h

http://github.com/tomahawk-player/tomahawk
C Header | 51 lines | 22 code | 8 blank | 21 comment | 0 complexity | 6a57a67a0c7c3f2c936efceaa6662cfd MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 * 
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef WIDGET_DRAG_FILTER_H
20#define WIDGET_DRAG_FILTER_H
21
22#include "DllMacro.h"
23
24#include <QObject>
25#include <QPoint>
26#include <QWidget>
27#include <QPointer>
28
29class QMouseEvent;
30class QEvent;
31
32/**
33 * This class encapsulates an event filter on a widget that lets any drag events over the widget
34 *  translate into move events for the whole application.
35 */
36class DLLEXPORT WidgetDragFilter : public QObject
37{
38    Q_OBJECT
39public:
40    explicit WidgetDragFilter(QObject* parent = 0);  
41
42    virtual bool eventFilter(QObject* , QEvent* );
43private:
44    bool canDrag( QObject* obj, QMouseEvent* ev ) const;
45
46    QPointer<QWidget> m_target; // in case it's deleted under us
47    QPoint m_dragPoint;
48    bool m_dragStarted;
49};
50
51#endif