39 class Item :
public QQmlGuard<QQuickItem>
42 Item(QQuickItem *item) : QQmlGuard<QQuickItem>(Item::objectDestroyedImpl, item) {}
44 QIntrusiveListNode node;
46 static void objectDestroyedImpl(QQmlGuardImpl *guard) {
delete static_cast<Item *>(guard); }
49 typedef QIntrusiveList<Item, &Item::node> ItemList;
60 else if (!m_items.isEmpty())
61 return *m_items.first();
65 void setTarget(QObject *target) { m_target = target; }
68 bool isEmpty()
const {
return m_items.isEmpty(); }
74 void grab(QQuickItem *item) { m_items.insert(
new Item(item)); }
82 QVarLengthArray<QQuickItem *, 4> m_ignoreDragItems;
129 Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget FINAL)
130 Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged FINAL FINAL)
131 Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged FINAL)
132 Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged FINAL)
133 Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged FINAL)
134 Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged FINAL)
135 Q_PROPERTY(
bool active READ active NOTIFY activeChanged FINAL)
136 Q_PROPERTY(
bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged FINAL)
137 Q_PROPERTY(
bool smoothed READ smoothed WRITE setSmoothed NOTIFY smoothedChanged FINAL)
140 Q_PROPERTY(qreal threshold READ threshold WRITE setThreshold NOTIFY thresholdChanged RESET resetThreshold FINAL)
143 QML_NAMED_ELEMENT(Drag)
144 QML_ADDED_IN_VERSION(2, 0)
145 QML_UNCREATABLE(
"Drag is only available via attached properties.")
146 QML_ATTACHED(QQuickDragAttached)
149 QQuickDrag(QObject *parent=
nullptr);
152 enum DragType { None, Automatic, Internal };
155 QQuickItem *target()
const;
156 void setTarget(QQuickItem *target);
159 enum Axis { XAxis=0x01, YAxis=0x02, XAndYAxis=0x03, XandYAxis=XAndYAxis };
173 bool smoothed()
const;
174 void setSmoothed(
bool smooth);
176 qreal threshold()
const;
177 void setThreshold(qreal);
178 void resetThreshold();
181 void setActive(
bool);
183 bool filterChildren()
const;
184 void setFilterChildren(
bool);
186 static QQuickDragAttached *qmlAttachedProperties(QObject *obj);
189 void targetChanged();
191 void minimumXChanged();
192 void maximumXChanged();
193 void minimumYChanged();
194 void maximumYChanged();
195 void activeChanged();
196 void filterChildrenChanged();
197 void smoothedChanged();
198 void thresholdChanged();
208 bool _filterChildren: 1;
211 Q_DISABLE_COPY(QQuickDrag)
218 Q_DECLARE_PRIVATE(QQuickDragAttached)
220 Q_PROPERTY(
bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL)
221 Q_PROPERTY(QObject *source READ source WRITE setSource NOTIFY sourceChanged RESET resetSource FINAL)
222 Q_PROPERTY(QObject *target READ target NOTIFY targetChanged FINAL)
223 Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot NOTIFY hotSpotChanged FINAL)
224 Q_PROPERTY(QUrl imageSource READ imageSource WRITE setImageSource NOTIFY imageSourceChanged FINAL)
226 Q_PROPERTY(QSize imageSourceSize READ imageSourceSize WRITE setImageSourceSize NOTIFY imageSourceSizeChanged FINAL)
227 Q_PROPERTY(QStringList keys READ keys WRITE setKeys NOTIFY keysChanged FINAL)
228 Q_PROPERTY(QVariantMap mimeData READ mimeData WRITE setMimeData NOTIFY mimeDataChanged FINAL)
229 Q_PROPERTY(Qt::DropActions supportedActions READ supportedActions WRITE setSupportedActions NOTIFY supportedActionsChanged FINAL)
230 Q_PROPERTY(Qt::DropAction proposedAction READ proposedAction WRITE setProposedAction NOTIFY proposedActionChanged FINAL)
231 Q_PROPERTY(QQuickDrag::DragType dragType READ dragType WRITE setDragType NOTIFY dragTypeChanged FINAL)
234 QML_ADDED_IN_VERSION(2, 0)
237 QQuickDragAttached(QObject *parent);
238 ~QQuickDragAttached();
240 bool isActive()
const;
241 void setActive(
bool active);
243 QObject *source()
const;
244 void setSource(QObject *item);
247 QObject *target()
const;
249 QPointF hotSpot()
const;
250 void setHotSpot(
const QPointF &hotSpot);
252 QUrl imageSource()
const;
253 void setImageSource(
const QUrl &url);
255 QSize imageSourceSize()
const;
256 void setImageSourceSize(
const QSize &size);
258 QStringList keys()
const;
259 void setKeys(
const QStringList &keys);
261 QVariantMap mimeData()
const;
262 void setMimeData(
const QVariantMap &mimeData);
264 Qt::DropActions supportedActions()
const;
265 void setSupportedActions(Qt::DropActions actions);
267 Qt::DropAction proposedAction()
const;
268 void setProposedAction(Qt::DropAction action);
270 QQuickDrag::DragType dragType()
const;
271 void setDragType(QQuickDrag::DragType dragType);
273 Q_INVOKABLE
int drop();
275 bool event(QEvent *event) override;
278 void start(QQmlV4FunctionPtr);
279 void startDrag(QQmlV4FunctionPtr);
284 void dragFinished(Qt::DropAction dropAction);
286 void activeChanged();
287 void sourceChanged();
288 void targetChanged();
289 void hotSpotChanged();
290 void imageSourceChanged();
291 void imageSourceSizeChanged();
293 void mimeDataChanged();
294 void supportedActionsChanged();
295 void proposedActionChanged();
296 void dragTypeChanged();