qdrag.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qdrag.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QDrag::QDrag(QObject *dragSource)-
6 : QObject(*new QDragPrivate, dragSource)-
7{-
8 QDragPrivate * const d = d_func();-
9 d->source = dragSource;-
10 d->target = 0;-
11 d->data = 0;-
12 d->hotspot = QPoint(-10, -10);-
13 d->executed_action = Qt::IgnoreAction;-
14 d->supported_actions = Qt::IgnoreAction;-
15 d->default_action = Qt::IgnoreAction;-
16}-
17-
18-
19-
20-
21QDrag::~QDrag()-
22{-
23 QDragPrivate * const d = d_func();-
24 delete d->data;-
25}-
26-
27-
28-
29-
30-
31void QDrag::setMimeData(QMimeData *data)-
32{-
33 QDragPrivate * const d = d_func();-
34 if (d->data == data)-
35 return;-
36 if (d->data != 0)-
37 delete d->data;-
38 d->data = data;-
39}-
40-
41-
42-
43-
44QMimeData *QDrag::mimeData() const-
45{-
46 const QDragPrivate * const d = d_func();-
47 return d->data;-
48}-
49-
50-
51-
52-
53-
54-
55void QDrag::setPixmap(const QPixmap &pixmap)-
56{-
57 QDragPrivate * const d = d_func();-
58 d->pixmap = pixmap;-
59}-
60-
61-
62-
63-
64QPixmap QDrag::pixmap() const-
65{-
66 const QDragPrivate * const d = d_func();-
67 return d->pixmap;-
68}-
69void QDrag::setHotSpot(const QPoint& hotspot)-
70{-
71 QDragPrivate * const d = d_func();-
72 d->hotspot = hotspot;-
73}-
74-
75-
76-
77-
78-
79QPoint QDrag::hotSpot() const-
80{-
81 const QDragPrivate * const d = d_func();-
82 return d->hotspot;-
83}-
84-
85-
86-
87-
88-
89QObject *QDrag::source() const-
90{-
91 const QDragPrivate * const d = d_func();-
92 return d->source;-
93}-
94-
95-
96-
97-
98-
99QObject *QDrag::target() const-
100{-
101 const QDragPrivate * const d = d_func();-
102 return d->target;-
103}-
104Qt::DropAction QDrag::exec(Qt::DropActions supportedActions)-
105{-
106 return exec(supportedActions, Qt::IgnoreAction);-
107}-
108Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defaultDropAction)-
109{-
110 QDragPrivate * const d = d_func();-
111 if (!d->data) {-
112 QMessageLogger(__FILE__, 256266, __PRETTY_FUNCTION__).warning("QDrag: No mimedata set before starting the drag");-
113 return d->executed_action;-
114 }-
115 Qt::DropAction transformedDefaultDropAction = Qt::IgnoreAction;-
116-
117 if (defaultDropAction == Qt::IgnoreAction) {-
118 if (supportedActions & Qt::MoveAction) {-
119 transformedDefaultDropAction = Qt::MoveAction;-
120 } else if (supportedActions & Qt::CopyAction) {-
121 transformedDefaultDropAction = Qt::CopyAction;-
122 } else if (supportedActions & Qt::LinkAction) {-
123 transformedDefaultDropAction = Qt::LinkAction;-
124 }-
125 } else {-
126 transformedDefaultDropAction = defaultDropAction;-
127 }-
128 d->supported_actions = supportedActions;-
129 d->default_action = transformedDefaultDropAction;-
130 d->executed_action = QDragManager::self()->drag(this);-
131-
132 return d->executed_action;-
133}-
134Qt::DropAction QDrag::start(Qt::DropActions request)-
135{-
136 QDragPrivate * const d = d_func();-
137 if (!d->data) {-
138 QMessageLogger(__FILE__, 298308, __PRETTY_FUNCTION__).warning("QDrag: No mimedata set before starting the drag");-
139 return d->executed_action;-
140 }-
141 d->supported_actions = request | Qt::CopyAction;-
142 d->default_action = Qt::IgnoreAction;-
143 d->executed_action = QDragManager::self()->drag(this);-
144 return d->executed_action;-
145}-
146void QDrag::setDragCursor(const QPixmap &cursor, Qt::DropAction action)-
147{-
148 QDragPrivate * const d = d_func();-
149 if (action != Qt::CopyAction && action != Qt::MoveAction && action != Qt::LinkAction)-
150 return;-
151 if (cursor.isNull())-
152 d->customCursors.remove(action);-
153 else-
154 d->customCursors[action] = cursor;-
155}-
156-
157-
158-
159-
160-
161-
162-
163QPixmap QDrag::dragCursor(Qt::DropAction action) const-
164{-
165 typedef QMap<Qt::DropAction, QPixmap>::const_iterator Iterator;-
166-
167 const QDragPrivate * const d = d_func();-
168 const Iterator it = d->customCursors.constFind(action);-
169 if (it != d->customCursors.constEnd())-
170 return it.value();-
171-
172 Qt::CursorShape shape = Qt::ForbiddenCursor;-
173 switch (action) {-
174 case Qt::MoveAction:-
175 shape = Qt::DragMoveCursor;-
176 break;-
177 case Qt::CopyAction:-
178 shape = Qt::DragCopyCursor;-
179 break;-
180 case Qt::LinkAction:-
181 shape = Qt::DragLinkCursor;-
182 break;-
183 default:-
184 shape = Qt::ForbiddenCursor;-
185 }-
186 return QGuiApplicationPrivate::instance()->getPixmapCursor(shape);-
187}-
188-
189-
190-
191-
192-
193-
194Qt::DropActions QDrag::supportedActions() const-
195{-
196 const QDragPrivate * const d = d_func();-
197 return d->supported_actions;-
198}-
199-
200-
201-
202-
203-
204-
205-
206Qt::DropAction QDrag::defaultAction() const-
207{-
208 const QDragPrivate * const d = d_func();-
209 return d->default_action;-
210}-
211void QDrag::cancel()-
212{-
213 if (QPlatformDrag *platformDrag = QGuiApplicationPrivate::platformIntegration()->drag()
QPlatformDrag ...tion()->drag()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
214 platformDrag->cancelDrag();
never executed: platformDrag->cancelDrag();
0
215}
never executed: end of block
0
216-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9