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