kernel/qdnd.cpp

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

Generated by Squish Coco Non-Commercial