qplatformdrag.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatformdrag.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10QPlatformDropQtResponse::QPlatformDropQtResponse(bool accepted, Qt::DropAction acceptedAction)-
11 : m_accepted(accepted)-
12 , m_accepted_action(acceptedAction)-
13{-
14}-
15-
16bool QPlatformDropQtResponse::isAccepted() const-
17{-
18 return m_accepted;-
19}-
20-
21Qt::DropAction QPlatformDropQtResponse::acceptedAction() const-
22{-
23 return m_accepted_action;-
24}-
25-
26QPlatformDragQtResponse::QPlatformDragQtResponse(bool accepted, Qt::DropAction acceptedAction, QRect answerRect)-
27 : QPlatformDropQtResponse(accepted,acceptedAction)-
28 , m_answer_rect(answerRect)-
29{-
30}-
31-
32QRect QPlatformDragQtResponse::answerRect() const-
33{-
34 return m_answer_rect;-
35}-
36-
37class QPlatformDragPrivate {-
38public:-
39 QPlatformDragPrivate() : cursor_drop_action(Qt::IgnoreAction) {}-
40-
41 Qt::DropAction cursor_drop_action;-
42};-
43QPlatformDrag::QPlatformDrag() : d_ptr(new QPlatformDragPrivate)-
44{-
45}-
46-
47QPlatformDrag::~QPlatformDrag()-
48{-
49 delete d_ptr;-
50}-
51-
52QDrag *QPlatformDrag::currentDrag() const-
53{-
54 return QDragManager::self()->object();-
55}-
56-
57Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,-
58 Qt::KeyboardModifiers modifiers) const-
59{-
60-
61-
62-
63-
64 Qt::DropAction default_action = Qt::IgnoreAction;-
65-
66 if (currentDrag()) {-
67 default_action = currentDrag()->defaultAction();-
68 }-
69-
70-
71 if (default_action == Qt::IgnoreAction) {-
72-
73-
74 default_action = Qt::CopyAction;-
75 }-
76-
77 if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)-
78 default_action = Qt::LinkAction;-
79 else if (modifiers & Qt::ControlModifier)-
80 default_action = Qt::CopyAction;-
81 else if (modifiers & Qt::ShiftModifier)-
82 default_action = Qt::MoveAction;-
83 else if (modifiers & Qt::AltModifier)-
84 default_action = Qt::LinkAction;-
85-
86-
87-
88-
89-
90-
91 if (!(possibleActions & default_action)) {-
92 if (possibleActions & Qt::CopyAction)-
93 default_action = Qt::CopyAction;-
94 else if (possibleActions & Qt::MoveAction)-
95 default_action = Qt::MoveAction;-
96 else if (possibleActions & Qt::LinkAction)-
97 default_action = Qt::LinkAction;-
98 else-
99 default_action = Qt::IgnoreAction;-
100 }-
101-
102-
103-
104-
105-
106 return default_action;-
107}-
108void QPlatformDrag::cancelDrag()-
109{-
110 QMessageLogger(__FILE__, 174, __PRETTY_FUNCTION__).warning("Unimplemented code.");-
111}
never executed: end of block
0
112-
113-
114-
115-
116-
117void QPlatformDrag::updateAction(Qt::DropAction action)-
118{-
119 QPlatformDragPrivate * const d = d_func();-
120 if (d->cursor_drop_action != action) {-
121 d->cursor_drop_action = action;-
122 currentDrag()->actionChanged(action);-
123 }-
124}-
125-
126static const char *const default_pm[] = {-
127"13 9 3 1",-
128". c None",-
129" c #000000",-
130"X c #FFFFFF",-
131"X X X X X X X",-
132" X X X X X X ",-
133"X ......... X",-
134" X.........X ",-
135"X ......... X",-
136" X.........X ",-
137"X ......... X",-
138" X X X X X X ",-
139"X X X X X X X",-
140};-
141-
142namespace { namespace Q_QGS_qt_drag_default_pixmap { typedef QPixmap Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type (default_pm))) : value (default_pm) { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QPixmap, Q_QGS_qt_drag_default_pixmap::innerFunction, Q_QGS_qt_drag_default_pixmap::guard> qt_drag_default_pixmap;-
143-
144QPixmap QPlatformDrag::defaultPixmap()-
145{-
146 return *qt_drag_default_pixmap();-
147}-
148bool QPlatformDrag::ownsDragObject() const-
149{-
150 return false;-
151}-
152-
153-
154-
155-
Switch to Source codePreprocessed file

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