Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qmimedata.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | static inline QString textUriListLiteral() { return executed 28 times by 3 tests: ([]() -> QString { enum { Size = sizeof(u"" "text/uri-list")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/uri-list" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" "text/uri-list")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/uri-list" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
executed 28 times by 3 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 28 times by 3 tests: }());return qstring_literal_temp; Executed by:
executed 28 times by 3 tests: }return ([]() -> QString { enum { Size = sizeof(u"" "text/uri-list")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/uri-list" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
| 28 | ||||||||||||
6 | static inline QString textHtmlLiteral() { return executed 34 times by 3 tests: ([]() -> QString { enum { Size = sizeof(u"" "text/html")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/html" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" "text/html")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/html" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
executed 34 times by 3 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 34 times by 3 tests: }());return qstring_literal_temp; Executed by:
executed 34 times by 3 tests: }return ([]() -> QString { enum { Size = sizeof(u"" "text/html")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/html" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
| 34 | ||||||||||||
7 | static inline QString textPlainLiteral() { return executed 141 times by 9 tests: ([]() -> QString { enum { Size = sizeof(u"" "text/plain")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/plain" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" "text/plain")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/plain" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
executed 141 times by 9 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 141 times by 9 tests: }());return qstring_literal_temp; Executed by:
executed 141 times by 9 tests: }return ([]() -> QString { enum { Size = sizeof(u"" "text/plain")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "text/plain" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
| 141 | ||||||||||||
8 | static inline QString applicationXColorLiteral() { return executed 11 times by 1 test: ([]() -> QString { enum { Size = sizeof(u"" "application/x-color")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-color" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" "application/x-color")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-color" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
executed 11 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 11 times by 1 test: }());return qstring_literal_temp; Executed by:
executed 11 times by 1 test: }return ([]() -> QString { enum { Size = sizeof(u"" "application/x-color")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-color" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
| 11 | ||||||||||||
9 | static inline QString applicationXQtImageLiteral() { return executed 10 times by 1 test: ([]() -> QString { enum { Size = sizeof(u"" "application/x-qt-image")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-qt-image" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn ([]() -> QString { enum { Size = sizeof(u"" "application/x-qt-image")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-qt-image" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
executed 10 times by 1 test: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 10 times by 1 test: }());return qstring_literal_temp; Executed by:
executed 10 times by 1 test: }return ([]() -> QString { enum { Size = sizeof(u"" "application/x-qt-image")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "application/x-qt-image" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); Executed by:
| 10 | ||||||||||||
10 | - | |||||||||||||
11 | struct QMimeDataStruct | - | ||||||||||||
12 | { | - | ||||||||||||
13 | QString format; | - | ||||||||||||
14 | QVariant data; | - | ||||||||||||
15 | }; | - | ||||||||||||
16 | template<> class QTypeInfo<QMimeDataStruct > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QMimeDataStruct)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QMimeDataStruct >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QMimeDataStruct) }; static inline const char *name() { return "QMimeDataStruct"; } }; | - | ||||||||||||
17 | - | |||||||||||||
18 | class QMimeDataPrivate : public QObjectPrivate | - | ||||||||||||
19 | { | - | ||||||||||||
20 | inline QMimeData* q_func() { return static_cast<QMimeData *>(q_ptr); } inline const QMimeData* q_func() const { return static_cast<const QMimeData *>(q_ptr); } friend class QMimeData; | - | ||||||||||||
21 | public: | - | ||||||||||||
22 | void removeData(const QString &format); | - | ||||||||||||
23 | void setData(const QString &format, const QVariant &data); | - | ||||||||||||
24 | QVariant getData(const QString &format) const; | - | ||||||||||||
25 | - | |||||||||||||
26 | QVariant retrieveTypedData(const QString &format, QVariant::Type type) const; | - | ||||||||||||
27 | - | |||||||||||||
28 | QVector<QMimeDataStruct> dataList; | - | ||||||||||||
29 | }; | - | ||||||||||||
30 | - | |||||||||||||
31 | void QMimeDataPrivate::removeData(const QString &format) | - | ||||||||||||
32 | { | - | ||||||||||||
33 | for (int i=0; i<dataList.size()
| 43-118 | ||||||||||||
34 | if (dataList.at(i).format == format
| 8-35 | ||||||||||||
35 | dataList.removeAt(i); | - | ||||||||||||
36 | return; executed 8 times by 2 tests: return; Executed by:
| 8 | ||||||||||||
37 | } | - | ||||||||||||
38 | } executed 35 times by 4 tests: end of block Executed by:
| 35 | ||||||||||||
39 | } executed 118 times by 12 tests: end of block Executed by:
| 118 | ||||||||||||
40 | - | |||||||||||||
41 | void QMimeDataPrivate::setData(const QString &format, const QVariant &data) | - | ||||||||||||
42 | { | - | ||||||||||||
43 | - | |||||||||||||
44 | removeData(format); | - | ||||||||||||
45 | QMimeDataStruct mimeData; | - | ||||||||||||
46 | mimeData.format = format; | - | ||||||||||||
47 | mimeData.data = data; | - | ||||||||||||
48 | dataList += mimeData; | - | ||||||||||||
49 | } executed 124 times by 12 tests: end of block Executed by:
| 124 | ||||||||||||
50 | - | |||||||||||||
51 | - | |||||||||||||
52 | QVariant QMimeDataPrivate::getData(const QString &format) const | - | ||||||||||||
53 | { | - | ||||||||||||
54 | QVariant data; | - | ||||||||||||
55 | for (int i=0; i<dataList.size()
| 9-173 | ||||||||||||
56 | if (dataList.at(i).format == format
| 45-128 | ||||||||||||
57 | data = dataList.at(i).data; | - | ||||||||||||
58 | break; executed 128 times by 16 tests: break; Executed by:
| 128 | ||||||||||||
59 | } | - | ||||||||||||
60 | } executed 45 times by 6 tests: end of block Executed by:
| 45 | ||||||||||||
61 | return executed 137 times by 16 tests: data;return data; Executed by:
executed 137 times by 16 tests: return data; Executed by:
| 137 | ||||||||||||
62 | } | - | ||||||||||||
63 | - | |||||||||||||
64 | QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Type type) const | - | ||||||||||||
65 | { | - | ||||||||||||
66 | const QMimeData * const q = q_func(); | - | ||||||||||||
67 | - | |||||||||||||
68 | QVariant data = q->retrieveData(format, type); | - | ||||||||||||
69 | - | |||||||||||||
70 | - | |||||||||||||
71 | if (format == QLatin1String("text/plain")
| 4-90 | ||||||||||||
72 | data = retrieveTypedData(textUriListLiteral(), QVariant::List); | - | ||||||||||||
73 | if (data.type() == QVariant::Url
| 0-4 | ||||||||||||
74 | data = QVariant(data.toUrl().toDisplayString()); | - | ||||||||||||
75 | } never executed: else if (data.type() == QVariant::Listend of block
| 0-2 | ||||||||||||
76 | QString text; | - | ||||||||||||
77 | int numUrls = 0; | - | ||||||||||||
78 | const QList<QVariant> list = data.toList(); | - | ||||||||||||
79 | for (int i = 0; i < list.size()
| 2-3 | ||||||||||||
80 | if (list.at(i).type() == QVariant::Url
| 0-3 | ||||||||||||
81 | text.append(list.at(i).toUrl().toDisplayString() + QLatin1Char('\n')); | - | ||||||||||||
82 | ++numUrls; | - | ||||||||||||
83 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
84 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
85 | if (numUrls == 1
| 1 | ||||||||||||
86 | text.chop(1); executed 1 time by 1 test: text.chop(1); Executed by:
| 1 | ||||||||||||
87 | data = QVariant(text); | - | ||||||||||||
88 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
89 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
90 | - | |||||||||||||
91 | if (data.type() == type
| 7-99 | ||||||||||||
92 | return executed 106 times by 15 tests: data;return data; Executed by:
executed 106 times by 15 tests: return data; Executed by:
| 106 | ||||||||||||
93 | - | |||||||||||||
94 | - | |||||||||||||
95 | - | |||||||||||||
96 | - | |||||||||||||
97 | if ((type == QVariant::Url
| 0-31 | ||||||||||||
98 | || (type == QVariant::List
| 0-31 | ||||||||||||
99 | return never executed: data;return data; never executed: return data; | 0 | ||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | if ((type == QVariant::Pixmap
| 0-31 | ||||||||||||
103 | || (type == QVariant::Image
| 0-31 | ||||||||||||
104 | return never executed: data;return data; never executed: return data; | 0 | ||||||||||||
105 | - | |||||||||||||
106 | if (data.type() == QVariant::ByteArray
| 8-23 | ||||||||||||
107 | - | |||||||||||||
108 | switch(type) { | - | ||||||||||||
109 | - | |||||||||||||
110 | case executed 8 times by 3 tests: QVariant::String:case QVariant::String: Executed by:
executed 8 times by 3 tests: {case QVariant::String: Executed by:
| 8 | ||||||||||||
111 | const QByteArray ba = data.toByteArray(); | - | ||||||||||||
112 | QTextCodec *codec = QTextCodec::codecForName("utf-8"); | - | ||||||||||||
113 | if (format == QLatin1String("text/html")
| 3-5 | ||||||||||||
114 | codec = QTextCodec::codecForHtml(ba, codec); executed 5 times by 2 tests: codec = QTextCodec::codecForHtml(ba, codec); Executed by:
| 5 | ||||||||||||
115 | return executed 8 times by 3 tests: codec->toUnicode(ba);return codec->toUnicode(ba); Executed by:
executed 8 times by 3 tests: return codec->toUnicode(ba); Executed by:
| 8 | ||||||||||||
116 | } | - | ||||||||||||
117 | - | |||||||||||||
118 | case never executed: QVariant::Color:case QVariant::Color: never executed: {case QVariant::Color: | 0 | ||||||||||||
119 | QVariant newData = data; | - | ||||||||||||
120 | newData.convert(QVariant::Color); | - | ||||||||||||
121 | return never executed: newData;return newData; never executed: return newData; | 0 | ||||||||||||
122 | } | - | ||||||||||||
123 | case never executed: QVariant::List:case QVariant::List: never executed: {case QVariant::List: | 0 | ||||||||||||
124 | if (format != QLatin1String("text/uri-list")
| 0 | ||||||||||||
125 | break; never executed: break; | 0 | ||||||||||||
126 | - | |||||||||||||
127 | } | - | ||||||||||||
128 | case never executed: QVariant::Url:case QVariant::Url: never executed: case QVariant::Url: code before this statement never executed: {case QVariant::Url: | 0 | ||||||||||||
129 | QByteArray ba = data.toByteArray(); | - | ||||||||||||
130 | - | |||||||||||||
131 | - | |||||||||||||
132 | - | |||||||||||||
133 | if (ba.endsWith('\0')
| 0 | ||||||||||||
134 | ba.chop(1); never executed: ba.chop(1); | 0 | ||||||||||||
135 | - | |||||||||||||
136 | QList<QByteArray> urls = ba.split('\n'); | - | ||||||||||||
137 | QList<QVariant> list; | - | ||||||||||||
138 | for (int i = 0; i < urls.size()
| 0 | ||||||||||||
139 | QByteArray ba = urls.at(i).trimmed(); | - | ||||||||||||
140 | if (!ba.isEmpty()
| 0 | ||||||||||||
141 | list.append(QUrl::fromEncoded(ba)); never executed: list.append(QUrl::fromEncoded(ba)); | 0 | ||||||||||||
142 | } never executed: end of block | 0 | ||||||||||||
143 | return never executed: list;return list; never executed: return list; | 0 | ||||||||||||
144 | } | - | ||||||||||||
145 | default never executed: :default: never executed: default: | 0 | ||||||||||||
146 | break; never executed: break; | 0 | ||||||||||||
147 | } | - | ||||||||||||
148 | - | |||||||||||||
149 | } else if (type == QVariant::ByteArray
| 0-23 | ||||||||||||
150 | - | |||||||||||||
151 | - | |||||||||||||
152 | switch(data.type()) { | - | ||||||||||||
153 | case never executed: QVariant::ByteArray:case QVariant::ByteArray: never executed: case QVariant::ByteArray: | 0 | ||||||||||||
154 | case never executed: QVariant::Color:case QVariant::Color: never executed: case QVariant::Color: | 0 | ||||||||||||
155 | return never executed: data.toByteArray();return data.toByteArray(); never executed: return data.toByteArray(); | 0 | ||||||||||||
156 | case executed 22 times by 6 tests: QVariant::String:case QVariant::String: Executed by:
executed 22 times by 6 tests: case QVariant::String: Executed by:
| 22 | ||||||||||||
157 | return executed 22 times by 6 tests: data.toString().toUtf8();return data.toString().toUtf8(); Executed by:
executed 22 times by 6 tests: return data.toString().toUtf8(); Executed by:
| 22 | ||||||||||||
158 | case never executed: QVariant::Url:case QVariant::Url: never executed: case QVariant::Url: | 0 | ||||||||||||
159 | return never executed: data.toUrl().toEncoded();return data.toUrl().toEncoded(); never executed: return data.toUrl().toEncoded(); | 0 | ||||||||||||
160 | case executed 1 time by 1 test: QVariant::List:case QVariant::List: Executed by:
executed 1 time by 1 test: {case QVariant::List: Executed by:
| 1 | ||||||||||||
161 | - | |||||||||||||
162 | QByteArray result; | - | ||||||||||||
163 | QList<QVariant> list = data.toList(); | - | ||||||||||||
164 | for (int i = 0; i < list.size()
| 1-2 | ||||||||||||
165 | if (list.at(i).type() == QVariant::Url
| 0-2 | ||||||||||||
166 | result += list.at(i).toUrl().toEncoded(); | - | ||||||||||||
167 | result += "\r\n"; | - | ||||||||||||
168 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
169 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
170 | if (!result.isEmpty()
| 0-1 | ||||||||||||
171 | return executed 1 time by 1 test: result;return result; Executed by:
executed 1 time by 1 test: return result; Executed by:
| 1 | ||||||||||||
172 | break; never executed: break; | 0 | ||||||||||||
173 | } | - | ||||||||||||
174 | default never executed: :default: never executed: default: | 0 | ||||||||||||
175 | break; never executed: break; | 0 | ||||||||||||
176 | } | - | ||||||||||||
177 | } | - | ||||||||||||
178 | return never executed: data;return data; never executed: return data; | 0 | ||||||||||||
179 | } | - | ||||||||||||
180 | QMimeData::QMimeData() | - | ||||||||||||
181 | : QObject(*new QMimeDataPrivate, 0) | - | ||||||||||||
182 | { | - | ||||||||||||
183 | } executed 237 times by 19 tests: end of block Executed by:
| 237 | ||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | QMimeData::~QMimeData() | - | ||||||||||||
189 | { | - | ||||||||||||
190 | } | - | ||||||||||||
191 | QList<QUrl> QMimeData::urls() const | - | ||||||||||||
192 | { | - | ||||||||||||
193 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
194 | QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List); | - | ||||||||||||
195 | QList<QUrl> urls; | - | ||||||||||||
196 | if (data.type() == QVariant::Url
| 0-2 | ||||||||||||
197 | urls.append(data.toUrl()); never executed: urls.append(data.toUrl()); | 0 | ||||||||||||
198 | else if (data.type() == QVariant::List
| 0-2 | ||||||||||||
199 | QList<QVariant> list = data.toList(); | - | ||||||||||||
200 | for (int i = 0; i < list.size()
| 2-3 | ||||||||||||
201 | if (list.at(i).type() == QVariant::Url
| 0-3 | ||||||||||||
202 | urls.append(list.at(i).toUrl()); executed 3 times by 1 test: urls.append(list.at(i).toUrl()); Executed by:
| 3 | ||||||||||||
203 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
204 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
205 | return executed 2 times by 1 test: urls;return urls; Executed by:
executed 2 times by 1 test: return urls; Executed by:
| 2 | ||||||||||||
206 | } | - | ||||||||||||
207 | void QMimeData::setUrls(const QList<QUrl> &urls) | - | ||||||||||||
208 | { | - | ||||||||||||
209 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
210 | QList<QVariant> list; | - | ||||||||||||
211 | const int numUrls = urls.size(); | - | ||||||||||||
212 | list.reserve(numUrls); | - | ||||||||||||
213 | for (int i = 0; i < numUrls
| 2-3 | ||||||||||||
214 | list.append(urls.at(i)); executed 3 times by 1 test: list.append(urls.at(i)); Executed by:
| 3 | ||||||||||||
215 | - | |||||||||||||
216 | d->setData(textUriListLiteral(), list); | - | ||||||||||||
217 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
218 | bool QMimeData::hasUrls() const | - | ||||||||||||
219 | { | - | ||||||||||||
220 | return executed 20 times by 3 tests: hasFormat(textUriListLiteral());return hasFormat(textUriListLiteral()); Executed by:
executed 20 times by 3 tests: return hasFormat(textUriListLiteral()); Executed by:
| 20 | ||||||||||||
221 | } | - | ||||||||||||
222 | QString QMimeData::text() const | - | ||||||||||||
223 | { | - | ||||||||||||
224 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
225 | QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String); | - | ||||||||||||
226 | return executed 66 times by 9 tests: data.toString();return data.toString(); Executed by:
executed 66 times by 9 tests: return data.toString(); Executed by:
| 66 | ||||||||||||
227 | } | - | ||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
230 | - | |||||||||||||
231 | - | |||||||||||||
232 | - | |||||||||||||
233 | - | |||||||||||||
234 | - | |||||||||||||
235 | void QMimeData::setText(const QString &text) | - | ||||||||||||
236 | { | - | ||||||||||||
237 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
238 | d->setData(textPlainLiteral(), text); | - | ||||||||||||
239 | } executed 45 times by 8 tests: end of block Executed by:
| 45 | ||||||||||||
240 | - | |||||||||||||
241 | - | |||||||||||||
242 | - | |||||||||||||
243 | - | |||||||||||||
244 | - | |||||||||||||
245 | - | |||||||||||||
246 | - | |||||||||||||
247 | bool QMimeData::hasText() const | - | ||||||||||||
248 | { | - | ||||||||||||
249 | return executed 30 times by 3 tests: hasFormat(textPlainLiteral()) || hasUrls();return hasFormat(textPlainLiteral()) || hasUrls(); Executed by:
executed 30 times by 3 tests: return hasFormat(textPlainLiteral()) || hasUrls(); Executed by:
| 30 | ||||||||||||
250 | } | - | ||||||||||||
251 | - | |||||||||||||
252 | - | |||||||||||||
253 | - | |||||||||||||
254 | - | |||||||||||||
255 | - | |||||||||||||
256 | - | |||||||||||||
257 | - | |||||||||||||
258 | QString QMimeData::html() const | - | ||||||||||||
259 | { | - | ||||||||||||
260 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
261 | QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String); | - | ||||||||||||
262 | return executed 7 times by 2 tests: data.toString();return data.toString(); Executed by:
executed 7 times by 2 tests: return data.toString(); Executed by:
| 7 | ||||||||||||
263 | } | - | ||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | - | |||||||||||||
269 | - | |||||||||||||
270 | - | |||||||||||||
271 | void QMimeData::setHtml(const QString &html) | - | ||||||||||||
272 | { | - | ||||||||||||
273 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
274 | d->setData(textHtmlLiteral(), html); | - | ||||||||||||
275 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
276 | - | |||||||||||||
277 | - | |||||||||||||
278 | - | |||||||||||||
279 | - | |||||||||||||
280 | - | |||||||||||||
281 | - | |||||||||||||
282 | - | |||||||||||||
283 | bool QMimeData::hasHtml() const | - | ||||||||||||
284 | { | - | ||||||||||||
285 | return executed 25 times by 3 tests: hasFormat(textHtmlLiteral());return hasFormat(textHtmlLiteral()); Executed by:
executed 25 times by 3 tests: return hasFormat(textHtmlLiteral()); Executed by:
| 25 | ||||||||||||
286 | } | - | ||||||||||||
287 | QVariant QMimeData::imageData() const | - | ||||||||||||
288 | { | - | ||||||||||||
289 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
290 | return executed 3 times by 1 test: d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image);return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image); Executed by:
executed 3 times by 1 test: return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image); Executed by:
| 3 | ||||||||||||
291 | } | - | ||||||||||||
292 | void QMimeData::setImageData(const QVariant &image) | - | ||||||||||||
293 | { | - | ||||||||||||
294 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
295 | d->setData(applicationXQtImageLiteral(), image); | - | ||||||||||||
296 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
297 | - | |||||||||||||
298 | - | |||||||||||||
299 | - | |||||||||||||
300 | - | |||||||||||||
301 | - | |||||||||||||
302 | - | |||||||||||||
303 | - | |||||||||||||
304 | bool QMimeData::hasImage() const | - | ||||||||||||
305 | { | - | ||||||||||||
306 | return executed 5 times by 1 test: hasFormat(applicationXQtImageLiteral());return hasFormat(applicationXQtImageLiteral()); Executed by:
executed 5 times by 1 test: return hasFormat(applicationXQtImageLiteral()); Executed by:
| 5 | ||||||||||||
307 | } | - | ||||||||||||
308 | QVariant QMimeData::colorData() const | - | ||||||||||||
309 | { | - | ||||||||||||
310 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
311 | return executed 2 times by 1 test: d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color);return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color); Executed by:
executed 2 times by 1 test: return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color); Executed by:
| 2 | ||||||||||||
312 | } | - | ||||||||||||
313 | void QMimeData::setColorData(const QVariant &color) | - | ||||||||||||
314 | { | - | ||||||||||||
315 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
316 | d->setData(applicationXColorLiteral(), color); | - | ||||||||||||
317 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
318 | bool QMimeData::hasColor() const | - | ||||||||||||
319 | { | - | ||||||||||||
320 | return executed 6 times by 1 test: hasFormat(applicationXColorLiteral());return hasFormat(applicationXColorLiteral()); Executed by:
executed 6 times by 1 test: return hasFormat(applicationXColorLiteral()); Executed by:
| 6 | ||||||||||||
321 | } | - | ||||||||||||
322 | - | |||||||||||||
323 | - | |||||||||||||
324 | - | |||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | QByteArray QMimeData::data(const QString &mimeType) const | - | ||||||||||||
328 | { | - | ||||||||||||
329 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
330 | QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray); | - | ||||||||||||
331 | return executed 53 times by 11 tests: data.toByteArray();return data.toByteArray(); Executed by:
executed 53 times by 11 tests: return data.toByteArray(); Executed by:
| 53 | ||||||||||||
332 | } | - | ||||||||||||
333 | void QMimeData::setData(const QString &mimeType, const QByteArray &data) | - | ||||||||||||
334 | { | - | ||||||||||||
335 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
336 | - | |||||||||||||
337 | if (mimeType == QLatin1String("text/uri-list")
| 1-69 | ||||||||||||
338 | QByteArray ba = data; | - | ||||||||||||
339 | if (ba.endsWith('\0')
| 0-1 | ||||||||||||
340 | ba.chop(1); never executed: ba.chop(1); | 0 | ||||||||||||
341 | QList<QByteArray> urls = ba.split('\n'); | - | ||||||||||||
342 | QList<QVariant> list; | - | ||||||||||||
343 | for (int i = 0; i < urls.size()
| 1-3 | ||||||||||||
344 | QByteArray ba = urls.at(i).trimmed(); | - | ||||||||||||
345 | if (!ba.isEmpty()
| 1-2 | ||||||||||||
346 | list.append(QUrl::fromEncoded(ba)); executed 2 times by 1 test: list.append(QUrl::fromEncoded(ba)); Executed by:
| 2 | ||||||||||||
347 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||
348 | d->setData(mimeType, list); | - | ||||||||||||
349 | } executed 1 time by 1 test: else {end of block Executed by:
| 1 | ||||||||||||
350 | d->setData(mimeType, QVariant(data)); | - | ||||||||||||
351 | } executed 69 times by 8 tests: end of block Executed by:
| 69 | ||||||||||||
352 | } | - | ||||||||||||
353 | bool QMimeData::hasFormat(const QString &mimeType) const | - | ||||||||||||
354 | { | - | ||||||||||||
355 | return executed 126 times by 13 tests: formats().contains(mimeType);return formats().contains(mimeType); Executed by:
executed 126 times by 13 tests: return formats().contains(mimeType); Executed by:
| 126 | ||||||||||||
356 | } | - | ||||||||||||
357 | QStringList QMimeData::formats() const | - | ||||||||||||
358 | { | - | ||||||||||||
359 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
360 | QStringList list; | - | ||||||||||||
361 | const int size = d->dataList.size(); | - | ||||||||||||
362 | list.reserve(size); | - | ||||||||||||
363 | for (int i = 0; i < size
| 124-152 | ||||||||||||
364 | list += d->dataList.at(i).format; executed 152 times by 13 tests: list += d->dataList.at(i).format; Executed by:
| 152 | ||||||||||||
365 | return executed 124 times by 13 tests: list;return list; Executed by:
executed 124 times by 13 tests: return list; Executed by:
| 124 | ||||||||||||
366 | } | - | ||||||||||||
367 | QVariant QMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const | - | ||||||||||||
368 | { | - | ||||||||||||
369 | (void)type;; | - | ||||||||||||
370 | const QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
371 | return executed 137 times by 16 tests: d->getData(mimeType);return d->getData(mimeType); Executed by:
executed 137 times by 16 tests: return d->getData(mimeType); Executed by:
| 137 | ||||||||||||
372 | } | - | ||||||||||||
373 | - | |||||||||||||
374 | - | |||||||||||||
375 | - | |||||||||||||
376 | - | |||||||||||||
377 | void QMimeData::clear() | - | ||||||||||||
378 | { | - | ||||||||||||
379 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
380 | d->dataList.clear(); | - | ||||||||||||
381 | } executed 12 times by 2 tests: end of block Executed by:
| 12 | ||||||||||||
382 | - | |||||||||||||
383 | - | |||||||||||||
384 | - | |||||||||||||
385 | - | |||||||||||||
386 | - | |||||||||||||
387 | - | |||||||||||||
388 | void QMimeData::removeFormat(const QString &mimeType) | - | ||||||||||||
389 | { | - | ||||||||||||
390 | QMimeDataPrivate * const d = d_func(); | - | ||||||||||||
391 | d->removeData(mimeType); | - | ||||||||||||
392 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
393 | - | |||||||||||||
394 | - | |||||||||||||
Switch to Source code | Preprocessed file |