75QDrag::QDrag(QObject *dragSource)
76 : QObject(*
new QDragPrivate, dragSource)
79 d->source = dragSource;
82 d->hotspot = QPoint(-10, -10);
83 d->executed_action = Qt::IgnoreAction;
84 d->supported_actions = Qt::IgnoreAction;
85 d->default_action = Qt::IgnoreAction;
225Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction)
229 qWarning(
"QDrag: No mimedata set before starting the drag");
230 return d->executed_action;
232 Qt::DropAction transformedDefaultDropAction = Qt::IgnoreAction;
234 if (defaultDropAction == Qt::IgnoreAction) {
235 if (supportedActions & Qt::MoveAction) {
236 transformedDefaultDropAction = Qt::MoveAction;
237 }
else if (supportedActions & Qt::CopyAction) {
238 transformedDefaultDropAction = Qt::CopyAction;
239 }
else if (supportedActions & Qt::LinkAction) {
240 transformedDefaultDropAction = Qt::LinkAction;
243 transformedDefaultDropAction = defaultDropAction;
245 d->supported_actions = supportedActions;
246 d->default_action = transformedDefaultDropAction;
247 QPointer<QDrag> self =
this;
248 auto executed_action = QDragManager::self()->drag(self.data());
250 return Qt::IgnoreAction;
251 d->executed_action = executed_action;
252 return d->executed_action;
279QPixmap QDrag::dragCursor(Qt::DropAction action)
const
281 typedef QMap<Qt::DropAction, QPixmap>::const_iterator Iterator;
284 const Iterator it = d->customCursors.constFind(action);
285 if (it != d->customCursors.constEnd())
288 Qt::CursorShape shape = Qt::ForbiddenCursor;
291 shape = Qt::DragMoveCursor;
294 shape = Qt::DragCopyCursor;
297 shape = Qt::DragLinkCursor;
300 shape = Qt::ForbiddenCursor;
302 return QGuiApplicationPrivate::instance()->getPixmapCursor(shape);