• 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
DeclarativeDropArea.cpp
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 #include "DeclarativeDropArea.h"
25 #include "DeclarativeDragDropEvent.h"
26 
27 #include <QGraphicsSceneDragDropEvent>
28 #include <QMimeData>
29 
30 DeclarativeDropArea::DeclarativeDropArea(QDeclarativeItem *parent)
31  : QDeclarativeItem(parent),
32  m_enabled(true)
33 {
34  setAcceptDrops(m_enabled);
35 }
36 
37 void DeclarativeDropArea::dragEnterEvent(QGraphicsSceneDragDropEvent *event) {
38  DeclarativeDragDropEvent dde(event, this);
39  emit dragEnter(&dde);
40 }
41 
42 void DeclarativeDropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
43 {
44  DeclarativeDragDropEvent dde(event, this);
45  emit dragLeave(&dde);
46 }
47 
48 void DeclarativeDropArea::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
49 {
50  DeclarativeDragDropEvent dde(event, this);
51  emit dragMove(&dde);
52 }
53 
54 void DeclarativeDropArea::dropEvent(QGraphicsSceneDragDropEvent *event)
55 {
56  DeclarativeDragDropEvent dde(event, this);
57  emit drop(&dde);
58 }
59 
60 bool DeclarativeDropArea::isEnabled() const
61 {
62  return m_enabled;
63 }
64 
65 void DeclarativeDropArea::setEnabled(bool enabled)
66 {
67  if (enabled == m_enabled) {
68  return;
69  }
70 
71  m_enabled = enabled;
72  setAcceptDrops(m_enabled);
73  emit enabledChanged();
74 }
DeclarativeDropArea::dropEvent
void dropEvent(QGraphicsSceneDragDropEvent *event)
Definition: DeclarativeDropArea.cpp:54
DeclarativeDropArea::isEnabled
bool isEnabled() const
Definition: DeclarativeDropArea.cpp:60
DeclarativeDropArea::enabled
bool enabled
If false the area will receive no drop events.
Definition: DeclarativeDropArea.h:38
DeclarativeDropArea::enabledChanged
void enabledChanged()
DeclarativeDropArea::DeclarativeDropArea
DeclarativeDropArea(QDeclarativeItem *parent=0)
Definition: DeclarativeDropArea.cpp:30
DeclarativeDropArea::dragEnter
void dragEnter(DeclarativeDragDropEvent *event)
Emitted when the mouse cursor dragging something enters in the drag area.
DeclarativeDragDropEvent.h
DeclarativeDropArea::dragLeaveEvent
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
Definition: DeclarativeDropArea.cpp:42
DeclarativeDropArea::dragEnterEvent
void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
Definition: DeclarativeDropArea.cpp:37
QGraphicsItem::setAcceptDrops
void setAcceptDrops(bool on)
DeclarativeDropArea::dragLeave
void dragLeave(DeclarativeDragDropEvent *event)
Emitted when the mouse cursor dragging something leaves the drag area.
DeclarativeDropArea.h
DeclarativeDropArea::dragMoveEvent
void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
Definition: DeclarativeDropArea.cpp:48
DeclarativeDropArea::drop
void drop(DeclarativeDragDropEvent *event)
Emitted when the user drops something in the area.
DeclarativeDragDropEvent
Definition: DeclarativeDragDropEvent.h:32
DeclarativeDropArea::setEnabled
void setEnabled(bool enabled)
Definition: DeclarativeDropArea.cpp:65
QDeclarativeItem
QGraphicsSceneDragDropEvent
DeclarativeDropArea::dragMove
void dragMove(DeclarativeDragDropEvent *event)
Emitted when the mouse cursor dragging something moves over the drag area.
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