/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. #ifndef WIDGET_DRAG_FILTER_H
  19. #define WIDGET_DRAG_FILTER_H
  20. #include "DllMacro.h"
  21. #include <QObject>
  22. #include <QPoint>
  23. #include <QWidget>
  24. #include <QPointer>
  25. class QMouseEvent;
  26. class QEvent;
  27. /**
  28. * This class encapsulates an event filter on a widget that lets any drag events over the widget
  29. * translate into move events for the whole application.
  30. */
  31. class DLLEXPORT WidgetDragFilter : public QObject
  32. {
  33. Q_OBJECT
  34. public:
  35. explicit WidgetDragFilter(QObject* parent = 0);
  36. virtual bool eventFilter(QObject* , QEvent* );
  37. private:
  38. bool canDrag( QObject* obj, QMouseEvent* ev ) const;
  39. QPointer<QWidget> m_target; // in case it's deleted under us
  40. QPoint m_dragPoint;
  41. bool m_dragStarted;
  42. };
  43. #endif