Sayonara Player
Dragable.h
1 /* Dragable.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DRAGGABLE_H
22 #define DRAGGABLE_H
23 
24 #include "Utils/Pimpl.h"
25 #include <QObject>
26 
27 class QPoint;
28 class QPixmap;
29 class QMimeData;
30 class QWidget;
31 class QDrag;
32 class QMouseEvent;
33 class QAbstractItemView;
34 
35 namespace Gui
36 {
37  class Dragable;
38  class DragableConnector : public QObject
39  {
40  friend class Dragable;
41 
42  Q_OBJECT
43  PIMPL(DragableConnector)
44 
45  private:
46  DragableConnector(QAbstractItemView* widget, Dragable* dragable);
47  ~DragableConnector() override;
48 
49  private slots:
50  void mousePressed(QMouseEvent* e);
51  void mouseMoved(QMouseEvent* e);
52 
53  void dragDestroyed();
54  };
55 
60  class Dragable
61  {
62  PIMPL(Dragable)
63  friend class DragableConnector;
64 
65  public:
66  explicit Dragable(QAbstractItemView* parent);
67  virtual ~Dragable();
68 
69  enum class ReleaseReason : char
70  {
71  Dropped,
72  Destroyed
73  };
74 
75  private:
76  QDrag* createDrag() const;
77  QDrag* moveDrag(const QPoint& p);
78  void startDrag(const QPoint& p);
79  void releaseDrag();
80 
81  protected:
82  virtual bool isValidDragPosition(const QPoint& p) const;
83  virtual bool hasDragLabel() const;
84  virtual QString dragLabel() const;
85  };
86 }
87 
88 #endif // DRAGGABLE_H
Gui::Dragable
The Dragable class.
Definition: Dragable.h:61
Gui::DragableConnector
Definition: Dragable.h:39