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