8#include "DeclarativeDropArea.h"
9#include "DeclarativeDragDropEvent.h"
11DeclarativeDropArea::DeclarativeDropArea(
QQuickItem *parent)
14 , m_preventStealing(false)
15 , m_temporaryInhibition(false)
16 , m_containsDrag(false)
18 setFlag(ItemAcceptsDrops, m_enabled);
21void DeclarativeDropArea::temporaryInhibitParent(
bool inhibit)
27 da->m_temporaryInhibition = inhibit;
29 Q_EMIT da->dragLeaveEvent(
nullptr);
38 if (!m_enabled || m_temporaryInhibition) {
42 DeclarativeDragDropEvent dde(
event,
this);
47 if (!
event->isAccepted()) {
51 if (m_preventStealing) {
52 temporaryInhibitParent(
true);
55 m_oldDragMovePos =
event->position().toPoint();
56 setContainsDrag(
true);
63 temporaryInhibitParent(
false);
65 m_oldDragMovePos =
QPoint(-1, -1);
66 DeclarativeDragDropEvent dde(
event,
this);
68 setContainsDrag(
false);
73 if (!m_enabled || m_temporaryInhibition) {
79 if (
event->position() == m_oldDragMovePos) {
83 m_oldDragMovePos =
event->position().toPoint();
84 DeclarativeDragDropEvent dde(
event,
this);
88void DeclarativeDropArea::dropEvent(
QDropEvent *event)
95 m_oldDragMovePos =
QPoint(-1, -1);
97 if (!m_enabled || m_temporaryInhibition) {
101 DeclarativeDragDropEvent dde(
event,
this);
103 setContainsDrag(
false);
106bool DeclarativeDropArea::isEnabled()
const
111void DeclarativeDropArea::setEnabled(
bool enabled)
113 if (enabled == m_enabled) {
122bool DeclarativeDropArea::preventStealing()
const
124 return m_preventStealing;
127void DeclarativeDropArea::setPreventStealing(
bool prevent)
129 if (prevent == m_preventStealing) {
133 m_preventStealing = prevent;
134 Q_EMIT preventStealingChanged();
137void DeclarativeDropArea::setContainsDrag(
bool dragging)
139 if (m_containsDrag != dragging) {
140 m_containsDrag = dragging;
141 Q_EMIT containsDragChanged(m_containsDrag);
145bool DeclarativeDropArea::containsDrag()
const
147 return m_containsDrag;
150#include "moc_DeclarativeDropArea.cpp"
T qobject_cast(QObject *object)
virtual bool event(QEvent *ev) override
QQuickItem * parentItem() const const
void setFlag(Flag flag, bool enabled)