qdnd.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qdnd.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10QDragManager *QDragManager::m_instance = 0;-
11-
12-
13QDragManager::QDragManager()-
14 : QObject((static_cast<QGuiApplication *>(QCoreApplication::instance()))), m_platformDropData(0), m_currentDropTarget(0),-
15 m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()),-
16 m_object(0)-
17{-
18 ((!(!m_instance)) ? qt_assert("!m_instance",__FILE__,78) : qt_noop());-
19-
20 if (m_platformDrag
m_platformDragDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
21 m_platformDropData = m_platformDrag->platformDropData();
never executed: m_platformDropData = m_platformDrag->platformDropData();
0
22}
never executed: end of block
0
23-
24-
25QDragManager::~QDragManager()-
26{-
27 m_instance = 0;-
28}
never executed: end of block
0
29-
30QDragManager *QDragManager::self()-
31{-
32 if (!m_instance
!m_instanceDescription
TRUEnever evaluated
FALSEnever evaluated
&& !QGuiApplication::closingDown()
!QGuiApplicati...:closingDown()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
33 m_instance = new QDragManager;
never executed: m_instance = new QDragManager;
0
34 return
never executed: return m_instance;
m_instance;
never executed: return m_instance;
0
35}-
36-
37QObject *QDragManager::source() const-
38{-
39 if (m_object
m_objectDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
40 return
never executed: return m_object->source();
m_object->source();
never executed: return m_object->source();
0
41 return
never executed: return 0;
0;
never executed: return 0;
0
42}-
43-
44void QDragManager::setCurrentTarget(QObject *target, bool dropped)-
45{-
46 if (m_currentDropTarget == target
m_currentDropTarget == targetDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
47 return;
never executed: return;
0
48-
49 m_currentDropTarget = target;-
50 if (!dropped
!droppedDescription
TRUEnever evaluated
FALSEnever evaluated
&& m_object
m_objectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
51 m_object->d_func()->target = target;-
52 m_object->targetChanged(target);-
53 }
never executed: end of block
0
54}
never executed: end of block
0
55-
56QObject *QDragManager::currentTarget() const-
57{-
58 return
never executed: return m_currentDropTarget;
m_currentDropTarget;
never executed: return m_currentDropTarget;
0
59}-
60-
61Qt::DropAction QDragManager::drag(QDrag *o)-
62{-
63 if (!o
!oDescription
TRUEnever evaluated
FALSEnever evaluated
|| m_object == o
m_object == oDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
64 return
never executed: return Qt::IgnoreAction;
Qt::IgnoreAction;
never executed: return Qt::IgnoreAction;
0
65-
66 if (!m_platformDrag
!m_platformDragDescription
TRUEnever evaluated
FALSEnever evaluated
|| !o->source()
!o->source()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
67 o->deleteLater();-
68 return
never executed: return Qt::IgnoreAction;
Qt::IgnoreAction;
never executed: return Qt::IgnoreAction;
0
69 }-
70-
71 if (m_object
m_objectDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
72 QMessageLogger(__FILE__, 132, __PRETTY_FUNCTION__).warning("QDragManager::drag in possibly invalid state");-
73 return
never executed: return Qt::IgnoreAction;
Qt::IgnoreAction;
never executed: return Qt::IgnoreAction;
0
74 }-
75-
76 m_object = o;-
77-
78 m_object->d_func()->target = 0;-
79-
80 QGuiApplicationPrivate::instance()->notifyDragStarted(o);-
81 const Qt::DropAction result = m_platformDrag->drag(m_object);-
82 m_object = 0;-
83 if (!m_platformDrag->ownsDragObject()
!m_platformDra...nsDragObject()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
84 o->deleteLater();
never executed: o->deleteLater();
0
85 return
never executed: return result;
result;
never executed: return result;
0
86}-
87-
88-
89-
90-
91-
92static QStringList imageReadMimeFormats()-
93{-
94 QStringList formats;-
95 QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();-
96 const int numImageFormats = imageFormats.size();-
97 formats.reserve(numImageFormats);-
98 for (int i = 0; i < numImageFormats
i < numImageFormatsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
99 QString format = QLatin1String("image/");-
100 format += QString::fromLatin1(imageFormats.at(i).toLower());-
101 formats.append(format);-
102 }
never executed: end of block
0
103-
104-
105 int pngIndex = formats.indexOf(QLatin1String("image/png"));-
106 if (pngIndex != -1
pngIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& pngIndex != 0
pngIndex != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
107 formats.move(pngIndex, 0);
never executed: formats.move(pngIndex, 0);
0
108-
109 return
never executed: return formats;
formats;
never executed: return formats;
0
110}-
111-
112-
113static QStringList imageWriteMimeFormats()-
114{-
115 QStringList formats;-
116 QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();-
117 const int numImageFormats = imageFormats.size();-
118 formats.reserve(numImageFormats);-
119 for (int i = 0; i < numImageFormats
i < numImageFormatsDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
120 QString format = QLatin1String("image/");-
121 format += QString::fromLatin1(imageFormats.at(i).toLower());-
122 formats.append(format);-
123 }
never executed: end of block
0
124-
125-
126 int pngIndex = formats.indexOf(QLatin1String("image/png"));-
127 if (pngIndex != -1
pngIndex != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& pngIndex != 0
pngIndex != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
128 formats.move(pngIndex, 0);
never executed: formats.move(pngIndex, 0);
0
129-
130 return
never executed: return formats;
formats;
never executed: return formats;
0
131}-
132-
133QInternalMimeData::QInternalMimeData()-
134 : QMimeData()-
135{-
136}
never executed: end of block
0
137-
138QInternalMimeData::~QInternalMimeData()-
139{-
140}-
141-
142bool QInternalMimeData::hasFormat(const QString &mimeType) const-
143{-
144 bool foundFormat = hasFormat_sys(mimeType);-
145 if (!foundFormat
!foundFormatDescription
TRUEnever evaluated
FALSEnever evaluated
&& mimeType == QLatin1String("application/x-qt-image")
mimeType == QL...n/x-qt-image")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
146 QStringList imageFormats = imageReadMimeFormats();-
147 for (int i = 0; i < imageFormats.size()
i < imageFormats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
148 if ((
(foundFormat =...ormats.at(i)))Description
TRUEnever evaluated
FALSEnever evaluated
foundFormat = hasFormat_sys(imageFormats.at(i)))
(foundFormat =...ormats.at(i)))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
149 break;
never executed: break;
0
150 }
never executed: end of block
0
151 }
never executed: end of block
0
152 return
never executed: return foundFormat;
foundFormat;
never executed: return foundFormat;
0
153}-
154-
155QStringList QInternalMimeData::formats() const-
156{-
157 QStringList realFormats = formats_sys();-
158 if (!realFormats.contains(QLatin1String("application/x-qt-image"))
!realFormats.c.../x-qt-image"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
159 QStringList imageFormats = imageReadMimeFormats();-
160 for (int i = 0; i < imageFormats.size()
i < imageFormats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
161 if (realFormats.contains(imageFormats.at(i))
realFormats.co...Formats.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
162 realFormats += QLatin1String("application/x-qt-image");-
163 break;
never executed: break;
0
164 }-
165 }
never executed: end of block
0
166 }
never executed: end of block
0
167 return
never executed: return realFormats;
realFormats;
never executed: return realFormats;
0
168}-
169-
170QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const-
171{-
172 QVariant data = retrieveData_sys(mimeType, type);-
173 if (mimeType == QLatin1String("application/x-qt-image")
mimeType == QL...n/x-qt-image")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 if (data.isNull()
data.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| (data.type() == QVariant::ByteArray
data.type() ==...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
&& data.toByteArray().isEmpty()
data.toByteArray().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
175-
176 QStringList imageFormats = imageReadMimeFormats();-
177 for (int i = 0; i < imageFormats.size()
i < imageFormats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
178 data = retrieveData_sys(imageFormats.at(i), type);-
179 if (data.isNull()
data.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| (data.type() == QVariant::ByteArray
data.type() ==...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
&& data.toByteArray().isEmpty()
data.toByteArray().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
180 continue;
never executed: continue;
0
181 break;
never executed: break;
0
182 }-
183 }
never executed: end of block
0
184-
185 if (data.type() == QVariant::ByteArray
data.type() ==...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
0
186 && (type == QVariant::Image
type == QVariant::ImageDescription
TRUEnever evaluated
FALSEnever evaluated
|| type == QVariant::Pixmap
type == QVariant::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
|| type == QVariant::Bitmap
type == QVariant::BitmapDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
187 data = QImage::fromData(data.toByteArray());
never executed: data = QImage::fromData(data.toByteArray());
0
188-
189 }
never executed: end of block
else if (mimeType == QLatin1String("application/x-color")
mimeType == QL...tion/x-color")Description
TRUEnever evaluated
FALSEnever evaluated
&& data.type() == QVariant::ByteArray
data.type() ==...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
190 QColor c;-
191 QByteArray ba = data.toByteArray();-
192 if (ba.size() == 8
ba.size() == 8Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
193 ushort * colBuf = (ushort *)ba.data();-
194 c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),-
195 qreal(colBuf[1]) / qreal(0xFFFF),-
196 qreal(colBuf[2]) / qreal(0xFFFF),-
197 qreal(colBuf[3]) / qreal(0xFFFF));-
198 data = c;-
199 }
never executed: end of block
else {
0
200 QMessageLogger(__FILE__, 260, __PRETTY_FUNCTION__).warning("Qt: Invalid color format");-
201 }
never executed: end of block
0
202 } else if (data.type() != type
data.type() != typeDescription
TRUEnever evaluated
FALSEnever evaluated
&& data.type() == QVariant::ByteArray
data.type() ==...ant::ByteArrayDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
203-
204 QInternalMimeData *that = const_cast<QInternalMimeData *>(this);-
205 that->setData(mimeType, data.toByteArray());-
206 data = QMimeData::retrieveData(mimeType, type);-
207 that->clear();-
208 }
never executed: end of block
0
209 return
never executed: return data;
data;
never executed: return data;
0
210}-
211-
212bool QInternalMimeData::canReadData(const QString &mimeType)-
213{-
214 return
never executed: return imageReadMimeFormats().contains(mimeType);
imageReadMimeFormats().contains(mimeType);
never executed: return imageReadMimeFormats().contains(mimeType);
0
215}-
216-
217-
218QStringList QInternalMimeData::formatsHelper(const QMimeData *data)-
219{-
220 QStringList realFormats = data->formats();-
221 if (realFormats.contains(QLatin1String("application/x-qt-image"))
realFormats.co.../x-qt-image"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
222-
223 QStringList imageFormats = imageWriteMimeFormats();-
224 for (int i = 0; i < imageFormats.size()
i < imageFormats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
225 if (!realFormats.contains(imageFormats.at(i))
!realFormats.c...Formats.at(i))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
226 realFormats.append(imageFormats.at(i));
never executed: realFormats.append(imageFormats.at(i));
0
227 }
never executed: end of block
0
228 }
never executed: end of block
0
229 return
never executed: return realFormats;
realFormats;
never executed: return realFormats;
0
230}-
231-
232bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)-
233{-
234-
235 bool foundFormat = data->hasFormat(mimeType);-
236 if (!foundFormat
!foundFormatDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
237 if (mimeType == QLatin1String("application/x-qt-image")
mimeType == QL...n/x-qt-image")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
238-
239 QStringList imageFormats = imageWriteMimeFormats();-
240 for (int i = 0; i < imageFormats.size()
i < imageFormats.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
241 if ((
(foundFormat =...ormats.at(i)))Description
TRUEnever evaluated
FALSEnever evaluated
foundFormat = data->hasFormat(imageFormats.at(i)))
(foundFormat =...ormats.at(i)))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
242 break;
never executed: break;
0
243 }
never executed: end of block
0
244 }
never executed: end of block
else if (mimeType.startsWith(QLatin1String("image/"))
mimeType.start...ing("image/"))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
245 return
never executed: return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
data->hasImage() && imageWriteMimeFormats().contains(mimeType);
never executed: return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
0
246 }-
247 }
never executed: end of block
0
248 return
never executed: return foundFormat;
foundFormat;
never executed: return foundFormat;
0
249}-
250-
251QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)-
252{-
253 QByteArray ba;-
254 if (mimeType == QLatin1String("application/x-color")
mimeType == QL...tion/x-color")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
255 ba.resize(8);-
256 ushort * colBuf = (ushort *)ba.data();-
257 QColor c = qvariant_cast<QColor>(data->colorData());-
258 colBuf[0] = ushort(c.redF() * 0xFFFF);-
259 colBuf[1] = ushort(c.greenF() * 0xFFFF);-
260 colBuf[2] = ushort(c.blueF() * 0xFFFF);-
261 colBuf[3] = ushort(c.alphaF() * 0xFFFF);-
262 }
never executed: end of block
else {
0
263 ba = data->data(mimeType);-
264 if (ba.isEmpty()
ba.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
265 if (mimeType == QLatin1String("application/x-qt-image")
mimeType == QL...n/x-qt-image")Description
TRUEnever evaluated
FALSEnever evaluated
&& data->hasImage()
data->hasImage()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 QImage image = qvariant_cast<QImage>(data->imageData());-
267 QBuffer buf(&ba);-
268 buf.open(QBuffer::WriteOnly);-
269-
270 image.save(&buf, "PNG");-
271 }
never executed: end of block
else if (mimeType.startsWith(QLatin1String("image/"))
mimeType.start...ing("image/"))Description
TRUEnever evaluated
FALSEnever evaluated
&& data->hasImage()
data->hasImage()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
272 QImage image = qvariant_cast<QImage>(data->imageData());-
273 QBuffer buf(&ba);-
274 buf.open(QBuffer::WriteOnly);-
275 image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());-
276 }
never executed: end of block
0
277 }
never executed: end of block
0
278 }
never executed: end of block
0
279 return
never executed: return ba;
ba;
never executed: return ba;
0
280}-
281-
282-
283-
284-
Switch to Source codePreprocessed file

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