KDeclarative

DeclarativeDropArea.h
1/*
2 SPDX-FileCopyrightText: 2010 BetterInbox <contact@betterinbox.com>
3 SPDX-FileContributor: Gregory Schlomoff <greg@betterinbox.com>
4
5 SPDX-License-Identifier: MIT
6*/
7
8#ifndef DECLARATIVEDROPAREA_H
9#define DECLARATIVEDROPAREA_H
10
11#include <QQuickItem>
12
13class DeclarativeDragDropEvent;
14
15class DeclarativeDropArea : public QQuickItem
16{
18 QML_NAMED_ELEMENT(DropArea)
19
20 /**
21 * If false the area will receive no drop events
22 */
23 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
24
25 /**
26 *
27 */
28 Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
29
30 Q_PROPERTY(bool containsDrag READ containsDrag NOTIFY containsDragChanged)
31
32public:
33 DeclarativeDropArea(QQuickItem *parent = nullptr);
34 bool isEnabled() const;
35 void setEnabled(bool enabled);
36
37 bool preventStealing() const;
38 void setPreventStealing(bool prevent);
39 bool containsDrag() const;
40
42 /**
43 * Emitted when the mouse cursor dragging something enters in the drag area
44 * @param event description of the dragged content
45 * @see DeclarativeDragDropEvent
46 */
47 void dragEnter(DeclarativeDragDropEvent *event);
48
49 /**
50 * Emitted when the mouse cursor dragging something leaves the drag area
51 * @param event description of the dragged content
52 * @see DeclarativeDragDropEvent
53 */
54 void dragLeave(DeclarativeDragDropEvent *event);
55
56 /**
57 * Emitted when the mouse cursor dragging something moves over the drag area
58 * @param event description of the dragged content
59 * @see DeclarativeDragDropEvent
60 */
61 void dragMove(DeclarativeDragDropEvent *event);
62
63 /**
64 * Emitted when the user drops something in the area
65 * @param event description of the dragged content
66 * @see DeclarativeDragDropEvent
67 */
68 void drop(DeclarativeDragDropEvent *event);
69
70 // Notifiers
71 void enabledChanged();
72
73 void preventStealingChanged();
74
75 void containsDragChanged(bool contained);
76
77protected:
78 void dragEnterEvent(QDragEnterEvent *event) override;
79 void dragLeaveEvent(QDragLeaveEvent *event) override;
80 void dragMoveEvent(QDragMoveEvent *event) override;
81 void dropEvent(QDropEvent *event) override;
82
83private Q_SLOTS:
84 void temporaryInhibitParent(bool inhibit);
85
86private:
87 void setContainsDrag(bool dragging);
88
89 bool m_enabled : 1;
90 bool m_preventStealing : 1;
91 bool m_temporaryInhibition : 1;
92 bool m_containsDrag : 1;
93 QPoint m_oldDragMovePos;
94};
95
96#endif
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QQuickItem(QQuickItem *parent)
virtual bool event(QEvent *ev) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 11:58:08 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.