• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

DragAndDrop

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • draganddrop
DeclarativeDragArea.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 by BetterInbox <contact@betterinbox.com>
3  Original author: Gregory Schlomoff <greg@betterinbox.com>
4 
5  Permission is hereby granted, free of charge, to any person obtaining a copy
6  of this software and associated documentation files (the "Software"), to deal
7  in the Software without restriction, including without limitation the rights
8  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  copies of the Software, and to permit persons to whom the Software is
10  furnished to do so, subject to the following conditions:
11 
12  The above copyright notice and this permission notice shall be included in
13  all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21  THE SOFTWARE.
22 */
23 
24 #ifndef DECLARATIVEDRAGAREA_H
25 #define DECLARATIVEDRAGAREA_H
26 
27 #include <QDeclarativeItem>
28 
29 class QDeclarativeComponent;
30 class DeclarativeMimeData;
31 
32 class DeclarativeDragArea : public QDeclarativeItem
33 {
34  Q_OBJECT
35 
40  Q_PROPERTY(QDeclarativeComponent* delegate READ delegate WRITE setDelegate NOTIFY delegateChanged RESET resetDelegate)
41 
42 
46  Q_PROPERTY(QDeclarativeItem* source READ source WRITE setSource NOTIFY sourceChanged RESET resetSource)
47 
48  //TODO: to be implemented
49  Q_PROPERTY(QDeclarativeItem* target READ source NOTIFY targetChanged)
50 
55  Q_PROPERTY(DeclarativeMimeData* mimeData READ mimeData CONSTANT)
56 
60  Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) //TODO: Should call setAcceptDrops()
61 
71  Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged)
72 
76  Q_PROPERTY(Qt::DropAction defaultAction READ defaultAction WRITE setDefaultAction NOTIFY defaultActionChanged)
77 
81  Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance NOTIFY startDragDistanceChanged)
82 
86  Q_PROPERTY(QVariant delegateImage READ delegateImage WRITE setDelegateImage NOTIFY delegateImageChanged)
87 
88 public:
89  DeclarativeDragArea(QDeclarativeItem *parent=0);
90  ~DeclarativeDragArea();
91 
92  QDeclarativeComponent *delegate() const;
93  void setDelegate(QDeclarativeComponent* delegate);
94  void resetDelegate();
95 
96  QVariant delegateImage() const;
97  void setDelegateImage(const QVariant &image);
98  QDeclarativeItem* target() const;
99  QDeclarativeItem* source() const;
100  void setSource(QDeclarativeItem* source);
101  void resetSource();
102 
103  bool isEnabled() const;
104  void setEnabled(bool enabled);
105 
106  int startDragDistance() const;
107  void setStartDragDistance(int distance);
108 
109  //supported actions
110  Qt::DropActions supportedActions() const;
111  void setSupportedActions(Qt::DropActions actions);
112 
113  //default action
114  Qt::DropAction defaultAction() const;
115  void setDefaultAction(Qt::DropAction action);
116 
117  DeclarativeMimeData* mimeData() const;
118 
119 signals:
120  void dragStarted();
121  void delegateChanged();
122  void sourceChanged();
123  void targetChanged();
124  void dataChanged();
125  void enabledChanged();
126  void drop(int action);
127  void supportedActionsChanged();
128  void defaultActionChanged();
129  void startDragDistanceChanged();
130  void delegateImageChanged();
131 
132 protected:
133  void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
134  void mousePressEvent(QGraphicsSceneMouseEvent *) {}
135  void mouseReleaseEvent(QGraphicsSceneMouseEvent *) {}
136  bool sceneEventFilter(QGraphicsItem *item, QEvent *event);
137 
138 private:
139  QDeclarativeComponent* m_delegate;
140  QDeclarativeItem* m_source;
141  QDeclarativeItem* m_target;
142  bool m_enabled;
143  Qt::DropActions m_supportedActions;
144  Qt::DropAction m_defaultAction;
145  DeclarativeMimeData* const m_data;
146  QImage m_delegateImage;
147  int m_startDragDistance;
148 };
149 
150 #endif // DECLARATIVEDRAGAREA_H
QEvent
DeclarativeDragArea::resetDelegate
void resetDelegate()
Definition: DeclarativeDragArea.cpp:77
DeclarativeDragArea::supportedActionsChanged
void supportedActionsChanged()
DeclarativeDragArea::resetSource
void resetSource()
Definition: DeclarativeDragArea.cpp:99
DeclarativeDragArea::delegateImage
QVariant delegateImage() const
DeclarativeDragArea::mimeData
DeclarativeMimeData * mimeData() const
DeclarativeDragArea::source
QDeclarativeItem * source() const
DeclarativeDragArea::mouseReleaseEvent
void mouseReleaseEvent(QGraphicsSceneMouseEvent *)
Definition: DeclarativeDragArea.h:135
QGraphicsItem
DeclarativeDragArea::setSource
void setSource(QDeclarativeItem *source)
Definition: DeclarativeDragArea.cpp:91
QObject::event
virtual bool event(QEvent *e)
DeclarativeDragArea::sourceChanged
void sourceChanged()
DeclarativeDragArea::startDragDistanceChanged
void startDragDistanceChanged()
DeclarativeDragArea::enabledChanged
void enabledChanged()
DeclarativeDragArea::targetChanged
void targetChanged()
QGraphicsSceneMouseEvent
DeclarativeDragArea::drop
void drop(int action)
DeclarativeDragArea::defaultAction
Qt::DropAction defaultAction() const
DeclarativeDragArea::defaultActionChanged
void defaultActionChanged()
DeclarativeDragArea::setEnabled
void setEnabled(bool enabled)
Definition: DeclarativeDragArea.cpp:159
DeclarativeDragArea::target
QDeclarativeItem * target() const
DeclarativeDragArea::startDragDistance
int startDragDistance() const
DeclarativeDragArea::delegateImageChanged
void delegateImageChanged()
QDeclarativeComponent
DeclarativeDragArea::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *)
Definition: DeclarativeDragArea.h:134
DeclarativeDragArea::delegate
QDeclarativeComponent * delegate() const
DeclarativeDragArea::setSupportedActions
void setSupportedActions(Qt::DropActions actions)
Definition: DeclarativeDragArea.cpp:172
QImage
DeclarativeMimeData
Definition: DeclarativeMimeData.h:32
DeclarativeDragArea::supportedActions
Qt::DropActions supportedActions() const
DeclarativeDragArea::setDelegate
void setDelegate(QDeclarativeComponent *delegate)
Definition: DeclarativeDragArea.cpp:70
Qt::DropActions
typedef DropActions
DeclarativeDragArea::dragStarted
void dragStarted()
DeclarativeDragArea::setStartDragDistance
void setStartDragDistance(int distance)
Definition: DeclarativeDragArea.cpp:123
DeclarativeDragArea::dataChanged
void dataChanged()
DeclarativeDragArea::enabled
bool enabled
If false no drag operation will be generate.
Definition: DeclarativeDragArea.h:60
QDeclarativeItem
DeclarativeDragArea::isEnabled
bool isEnabled() const
Definition: DeclarativeDragArea.cpp:155
DeclarativeDragArea::mouseMoveEvent
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: DeclarativeDragArea.cpp:193
DeclarativeDragArea::setDefaultAction
void setDefaultAction(Qt::DropAction action)
Definition: DeclarativeDragArea.cpp:185
QObject::parent
QObject * parent() const
DeclarativeDragArea::setDelegateImage
void setDelegateImage(const QVariant &image)
Definition: DeclarativeDragArea.cpp:139
DeclarativeDragArea::delegateChanged
void delegateChanged()
DeclarativeDragArea
Definition: DeclarativeDragArea.h:32
DeclarativeDragArea::sceneEventFilter
bool sceneEventFilter(QGraphicsItem *item, QEvent *event)
Definition: DeclarativeDragArea.cpp:237
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:31 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

DragAndDrop

Skip menu "DragAndDrop"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal