qmimedata.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qmimedata.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qmimedata.h"-
41-
42#include "private/qobject_p.h"-
43#include "qurl.h"-
44#include "qstringlist.h"-
45#include "qtextcodec.h"-
46-
47QT_BEGIN_NAMESPACE-
48-
49static
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:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
executed 28 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
inline QString textUriListLiteral() { return QStringLiteral("text/uri-list"); }
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:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
executed 28 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
28
50static
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:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
executed 34 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
inline QString textHtmlLiteral() { return QStringLiteral("text/html"); }
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:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
executed 34 times by 3 tests: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
34
51static
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:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
executed 141 times by 9 tests: return qstring_literal_temp;
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
inline QString textPlainLiteral() { return QStringLiteral("text/plain"); }
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:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
executed 141 times by 9 tests: return qstring_literal_temp;
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
141
52static
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:
  • tst_QMimeData
executed 11 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
inline QString applicationXColorLiteral() { return QStringLiteral("application/x-color"); }
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:
  • tst_QMimeData
executed 11 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
11
53static
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:
  • tst_QMimeData
executed 10 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
inline QString applicationXQtImageLiteral() { return QStringLiteral("application/x-qt-image"); }
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:
  • tst_QMimeData
executed 10 times by 1 test: return qstring_literal_temp;
Executed by:
  • tst_QMimeData
10
54-
55struct QMimeDataStruct-
56{-
57 QString format;-
58 QVariant data;-
59};-
60Q_DECLARE_TYPEINFO(QMimeDataStruct, Q_MOVABLE_TYPE);-
61-
62class QMimeDataPrivate : public QObjectPrivate-
63{-
64 Q_DECLARE_PUBLIC(QMimeData)-
65public:-
66 void removeData(const QString &format);-
67 void setData(const QString &format, const QVariant &data);-
68 QVariant getData(const QString &format) const;-
69-
70 QVariant retrieveTypedData(const QString &format, QVariant::Type type) const;-
71-
72 QVector<QMimeDataStruct> dataList;-
73};-
74-
75void QMimeDataPrivate::removeData(const QString &format)-
76{-
77 for (int i=0; i<dataList.size(); i++) {
i<dataList.size()Description
TRUEevaluated 43 times by 4 tests
Evaluated by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTextEdit
FALSEevaluated 118 times by 12 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
43-118
78 if (dataList.at(i).format == format) {
dataList.at(i)...rmat == formatDescription
TRUEevaluated 8 times by 2 tests
Evaluated by:
  • tst_QMimeData
  • tst_QTextEdit
FALSEevaluated 35 times by 4 tests
Evaluated by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTextEdit
8-35
79 dataList.removeAt(i);-
80 return;
executed 8 times by 2 tests: return;
Executed by:
  • tst_QMimeData
  • tst_QTextEdit
8
81 }-
82 }
executed 35 times by 4 tests: end of block
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTextEdit
35
83}
executed 118 times by 12 tests: end of block
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
118
84-
85void QMimeDataPrivate::setData(const QString &format, const QVariant &data)-
86{-
87 // remove it first if the format is already here.-
88 removeData(format);-
89 QMimeDataStruct mimeData;-
90 mimeData.format = format;-
91 mimeData.data = data;-
92 dataList += mimeData;-
93}
executed 124 times by 12 tests: end of block
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
124
94-
95-
96QVariant QMimeDataPrivate::getData(const QString &format) const-
97{-
98 QVariant data;-
99 for (int i=0; i<dataList.size(); i++) {
i<dataList.size()Description
TRUEevaluated 173 times by 16 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QMimeData
9-173
100 if (dataList.at(i).format == format) {
dataList.at(i)...rmat == formatDescription
TRUEevaluated 128 times by 16 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 45 times by 6 tests
Evaluated by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTextEdit
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
45-128
101 data = dataList.at(i).data;-
102 break;
executed 128 times by 16 tests: break;
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
128
103 }-
104 }
executed 45 times by 6 tests: end of block
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTextEdit
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
45
105 return data;
executed 137 times by 16 tests: return data;
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
137
106}-
107-
108QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Type type) const-
109{-
110 Q_Q(const QMimeData);-
111-
112 QVariant data = q->retrieveData(format, type);-
113-
114 // Text data requested: fallback to URL data if available-
115 if (format == QLatin1String("text/plain") && !data.isValid()) {
format == QLat...("text/plain")Description
TRUEevaluated 90 times by 13 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 47 times by 8 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QListWidget
  • tst_QMimeData
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
!data.isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 86 times by 13 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
4-90
116 data = retrieveTypedData(textUriListLiteral(), QVariant::List);-
117 if (data.type() == QVariant::Url) {
data.type() == QVariant::UrlDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMimeData
0-4
118 data = QVariant(data.toUrl().toDisplayString());-
119 } else if (data.type() == QVariant::List) {
never executed: end of block
data.type() == QVariant::ListDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
0-2
120 QString text;-
121 int numUrls = 0;-
122 const QList<QVariant> list = data.toList();-
123 for (int i = 0; i < list.size(); ++i) {
i < list.size()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
2-3
124 if (list.at(i).type() == QVariant::Url) {
list.at(i).typ... QVariant::UrlDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEnever evaluated
0-3
125 text.append(list.at(i).toUrl().toDisplayString() + QLatin1Char('\n'));-
126 ++numUrls;-
127 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeData
3
128 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeData
3
129 if (numUrls == 1)
numUrls == 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
1
130 text.chop(1); // no final '\n' if there's only one URL
executed 1 time by 1 test: text.chop(1);
Executed by:
  • tst_QMimeData
1
131 data = QVariant(text);-
132 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
133 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_QMimeData
4
134-
135 if (data.type() == type || !data.isValid())
data.type() == typeDescription
TRUEevaluated 99 times by 15 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QStyleSheetStyle
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 38 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
!data.isValid()Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 31 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
7-99
136 return data;
executed 106 times by 15 tests: return data;
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QStyleSheetStyle
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
106
137-
138 // provide more conversion possiblities than just what QVariant provides-
139-
140 // URLs can be lists as well...-
141 if ((type == QVariant::Url && data.type() == QVariant::List)
type == QVariant::UrlDescription
TRUEnever evaluated
FALSEevaluated 31 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
data.type() == QVariant::ListDescription
TRUEnever evaluated
FALSEnever evaluated
0-31
142 || (type == QVariant::List && data.type() == QVariant::Url))
type == QVariant::ListDescription
TRUEnever evaluated
FALSEevaluated 31 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
data.type() == QVariant::UrlDescription
TRUEnever evaluated
FALSEnever evaluated
0-31
143 return data;
never executed: return data;
0
144-
145 // images and pixmaps are interchangeable-
146 if ((type == QVariant::Pixmap && data.type() == QVariant::Image)
type == QVariant::PixmapDescription
TRUEnever evaluated
FALSEevaluated 31 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
data.type() == QVariant::ImageDescription
TRUEnever evaluated
FALSEnever evaluated
0-31
147 || (type == QVariant::Image && data.type() == QVariant::Pixmap))
type == QVariant::ImageDescription
TRUEnever evaluated
FALSEevaluated 31 times by 8 tests
Evaluated by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
data.type() ==...ariant::PixmapDescription
TRUEnever evaluated
FALSEnever evaluated
0-31
148 return data;
never executed: return data;
0
149-
150 if (data.type() == QVariant::ByteArray) {
data.type() ==...ant::ByteArrayDescription
TRUEevaluated 8 times by 3 tests
Evaluated by:
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
FALSEevaluated 23 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QMimeData
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
8-23
151 // see if we can convert to the requested type-
152 switch(type) {-
153#ifndef QT_NO_TEXTCODEC-
154 case QVariant::String: {
executed 8 times by 3 tests: case QVariant::String:
Executed by:
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
8
155 const QByteArray ba = data.toByteArray();-
156 QTextCodec *codec = QTextCodec::codecForName("utf-8");-
157 if (format == QLatin1String("text/html"))
format == QLat...g("text/html")Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • tst_QMimeData
  • tst_QTextEdit
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QClipboard
3-5
158 codec = QTextCodec::codecForHtml(ba, codec);
executed 5 times by 2 tests: codec = QTextCodec::codecForHtml(ba, codec);
Executed by:
  • tst_QMimeData
  • tst_QTextEdit
5
159 return codec->toUnicode(ba);
executed 8 times by 3 tests: return codec->toUnicode(ba);
Executed by:
  • tst_QClipboard
  • tst_QMimeData
  • tst_QTextEdit
8
160 }-
161#endif // QT_NO_TEXTCODEC-
162 case QVariant::Color: {
never executed: case QVariant::Color:
0
163 QVariant newData = data;-
164 newData.convert(QVariant::Color);-
165 return newData;
never executed: return newData;
0
166 }-
167 case QVariant::List: {
never executed: case QVariant::List:
0
168 if (format != QLatin1String("text/uri-list"))
format != QLat...ext/uri-list")Description
TRUEnever evaluated
FALSEnever evaluated
0
169 break;
never executed: break;
0
170 // fall through-
171 }-
172 case QVariant::Url: {
code before this statement never executed: case QVariant::Url:
never executed: case QVariant::Url:
0
173 QByteArray ba = data.toByteArray();-
174 // Qt 3.x will send text/uri-list with a trailing-
175 // null-terminator (that is *not* sent for any other-
176 // text/* mime-type), so chop it off-
177 if (ba.endsWith('\0'))
ba.endsWith('\0')Description
TRUEnever evaluated
FALSEnever evaluated
0
178 ba.chop(1);
never executed: ba.chop(1);
0
179-
180 QList<QByteArray> urls = ba.split('\n');-
181 QList<QVariant> list;-
182 for (int i = 0; i < urls.size(); ++i) {
i < urls.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
183 QByteArray ba = urls.at(i).trimmed();-
184 if (!ba.isEmpty())
!ba.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
185 list.append(QUrl::fromEncoded(ba));
never executed: list.append(QUrl::fromEncoded(ba));
0
186 }
never executed: end of block
0
187 return list;
never executed: return list;
0
188 }-
189 default:
never executed: default:
0
190 break;
never executed: break;
0
191 }-
192-
193 } else if (type == QVariant::ByteArray) {
type == QVariant::ByteArrayDescription
TRUEevaluated 23 times by 6 tests
Evaluated by:
  • tst_QApplication
  • tst_QMimeData
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEnever evaluated
0-23
194-
195 // try to convert to bytearray-
196 switch(data.type()) {-
197 case QVariant::ByteArray:
never executed: case QVariant::ByteArray:
0
198 case QVariant::Color:
never executed: case QVariant::Color:
0
199 return data.toByteArray();
never executed: return data.toByteArray();
0
200 case QVariant::String:
executed 22 times by 6 tests: case QVariant::String:
Executed by:
  • tst_QApplication
  • tst_QMimeData
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
22
201 return data.toString().toUtf8();
executed 22 times by 6 tests: return data.toString().toUtf8();
Executed by:
  • tst_QApplication
  • tst_QMimeData
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
22
202 case QVariant::Url:
never executed: case QVariant::Url:
0
203 return data.toUrl().toEncoded();
never executed: return data.toUrl().toEncoded();
0
204 case QVariant::List: {
executed 1 time by 1 test: case QVariant::List:
Executed by:
  • tst_QMimeData
1
205 // has to be list of URLs-
206 QByteArray result;-
207 QList<QVariant> list = data.toList();-
208 for (int i = 0; i < list.size(); ++i) {
i < list.size()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
1-2
209 if (list.at(i).type() == QVariant::Url) {
list.at(i).typ... QVariant::UrlDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEnever evaluated
0-2
210 result += list.at(i).toUrl().toEncoded();-
211 result += "\r\n";-
212 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
213 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
214 if (!result.isEmpty())
!result.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
FALSEnever evaluated
0-1
215 return result;
executed 1 time by 1 test: return result;
Executed by:
  • tst_QMimeData
1
216 break;
never executed: break;
0
217 }-
218 default:
never executed: default:
0
219 break;
never executed: break;
0
220 }-
221 }-
222 return data;
never executed: return data;
0
223}-
224-
225/*!-
226 \class QMimeData-
227 \inmodule QtCore-
228 \brief The QMimeData class provides a container for data that records information-
229 about its MIME type.-
230-
231 QMimeData is used to describe information that can be stored in-
232 the \l{QClipboard}{clipboard}, and transferred via the \l{drag-
233 and drop} mechanism. QMimeData objects associate the data that-
234 they hold with the corresponding MIME types to ensure that-
235 information can be safely transferred between applications, and-
236 copied around within the same application.-
237-
238 QMimeData objects are usually created using \c new and supplied-
239 to QDrag or QClipboard objects. This is to enable Qt to manage-
240 the memory that they use.-
241-
242 A single QMimeData object can store the same data using several-
243 different formats at the same time. The formats() function-
244 returns a list of the available formats in order of preference.-
245 The data() function returns the raw data associated with a MIME-
246 type, and setData() allows you to set the data for a MIME type.-
247-
248 For the most common MIME types, QMimeData provides convenience-
249 functions to access the data:-
250-
251 \table-
252 \header \li Tester \li Getter \li Setter \li MIME Types-
253 \row \li hasText() \li text() \li setText() \li \c text/plain-
254 \row \li hasHtml() \li html() \li setHtml() \li \c text/html-
255 \row \li hasUrls() \li urls() \li setUrls() \li \c text/uri-list-
256 \row \li hasImage() \li imageData() \li setImageData() \li \c image/ *-
257 \row \li hasColor() \li colorData() \li setColorData() \li \c application/x-color-
258 \endtable-
259-
260 For example, if your write a widget that accepts URL drags, you-
261 would end up writing code like this:-
262-
263 \snippet code/src_corelib_kernel_qmimedata.cpp 0-
264-
265 There are three approaches for storing custom data in a QMimeData-
266 object:-
267-
268 \list 1-
269 \li Custom data can be stored directly in a QMimeData object as a-
270 QByteArray using setData(). For example:-
271-
272 \snippet code/src_corelib_kernel_qmimedata.cpp 1-
273-
274 \li We can subclass QMimeData and reimplement hasFormat(),-
275 formats(), and retrieveData().-
276-
277 \li If the drag and drop operation occurs within a single-
278 application, we can subclass QMimeData and add extra data in-
279 it, and use a qobject_cast() in the receiver's drop event-
280 handler. For example:-
281-
282 \snippet code/src_corelib_kernel_qmimedata.cpp 2-
283 \endlist-
284-
285 \section1 Platform-Specific MIME Types-
286-
287 On Windows, formats() will also return custom formats available-
288 in the MIME data, using the \c{x-qt-windows-mime} subtype to-
289 indicate that they represent data in non-standard formats.-
290 The formats will take the following form:-
291-
292 \snippet code/src_corelib_kernel_qmimedata.cpp 3-
293-
294 The following are examples of custom MIME types:-
295-
296 \snippet code/src_corelib_kernel_qmimedata.cpp 4-
297-
298 The \c value declaration of each format describes the way in which the-
299 data is encoded.-
300-
301 In some cases (e.g. dropping multiple email attachments), multiple data-
302 values are available. They can be accessed by adding an \c index value:-
303-
304 \snippet code/src_corelib_kernel_qmimedata.cpp 8-
305-
306 On Windows, the MIME format does not always map directly to the-
307 clipboard formats. Qt provides QWinMime to map clipboard-
308 formats to open-standard MIME formats. Similarly, the-
309 QMacPasteboardMime maps MIME to Mac flavors.-
310-
311 \sa QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag,-
312 QMacPasteboardMime, {Drag and Drop}-
313*/-
314-
315/*!-
316 Constructs a new MIME data object with no data in it.-
317*/-
318QMimeData::QMimeData()-
319 : QObject(*new QMimeDataPrivate, 0)-
320{-
321}
executed 237 times by 19 tests: end of block
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QDrag
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QGuiApplication
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QStyleSheetStyle
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qapplication - unknown status
  • tst_qprocess - unknown status
  • tst_selftests - unknown status
237
322-
323/*!-
324 Destroys the MIME data object.-
325*/-
326QMimeData::~QMimeData()-
327{-
328}-
329-
330/*!-
331 Returns a list of URLs contained within the MIME data object.-
332-
333 URLs correspond to the MIME type \c text/uri-list.-
334-
335 \sa hasUrls(), data()-
336*/-
337QList<QUrl> QMimeData::urls() const-
338{-
339 Q_D(const QMimeData);-
340 QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List);-
341 QList<QUrl> urls;-
342 if (data.type() == QVariant::Url)
data.type() == QVariant::UrlDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
0-2
343 urls.append(data.toUrl());
never executed: urls.append(data.toUrl());
0
344 else if (data.type() == QVariant::List) {
data.type() == QVariant::ListDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEnever evaluated
0-2
345 QList<QVariant> list = data.toList();-
346 for (int i = 0; i < list.size(); ++i) {
i < list.size()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
2-3
347 if (list.at(i).type() == QVariant::Url)
list.at(i).typ... QVariant::UrlDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEnever evaluated
0-3
348 urls.append(list.at(i).toUrl());
executed 3 times by 1 test: urls.append(list.at(i).toUrl());
Executed by:
  • tst_QMimeData
3
349 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeData
3
350 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
351 return urls;
executed 2 times by 1 test: return urls;
Executed by:
  • tst_QMimeData
2
352}-
353-
354/*!-
355 Sets the URLs stored in the MIME data object to those specified by \a urls.-
356-
357 URLs correspond to the MIME type \c text/uri-list.-
358-
359 Since Qt 5.0, setUrls also exports the urls as plain text, if setText-
360 was not called before, to make it possible to drop them into any lineedit-
361 and text editor.-
362-
363 \sa hasUrls(), setData()-
364*/-
365void QMimeData::setUrls(const QList<QUrl> &urls)-
366{-
367 Q_D(QMimeData);-
368 QList<QVariant> list;-
369 const int numUrls = urls.size();-
370 list.reserve(numUrls);-
371 for (int i = 0; i < numUrls; ++i)
i < numUrlsDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
2-3
372 list.append(urls.at(i));
executed 3 times by 1 test: list.append(urls.at(i));
Executed by:
  • tst_QMimeData
3
373-
374 d->setData(textUriListLiteral(), list);-
375}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
376-
377/*!-
378 Returns \c true if the object can return a list of urls; otherwise-
379 returns \c false.-
380-
381 URLs correspond to the MIME type \c text/uri-list.-
382-
383 \sa setUrls(), urls(), hasFormat()-
384*/-
385bool QMimeData::hasUrls() const-
386{-
387 return hasFormat(textUriListLiteral());
executed 20 times by 3 tests: return hasFormat(textUriListLiteral());
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
20
388}-
389-
390-
391/*!-
392 Returns a plain text (MIME type \c text/plain) representation of-
393 the data.-
394-
395 \sa hasText(), html(), data()-
396*/-
397QString QMimeData::text() const-
398{-
399 Q_D(const QMimeData);-
400 QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String);-
401 return data.toString();
executed 66 times by 9 tests: return data.toString();
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStyleSheetStyle
  • tst_QTextEdit
  • tst_QWidget_window
66
402}-
403-
404/*!-
405 Sets \a text as the plain text (MIME type \c text/plain) used to-
406 represent the data.-
407-
408 \sa hasText(), setHtml(), setData()-
409*/-
410void QMimeData::setText(const QString &text)-
411{-
412 Q_D(QMimeData);-
413 d->setData(textPlainLiteral(), text);-
414}
executed 45 times by 8 tests: end of block
Executed by:
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
  • tst_QWidget_window
45
415-
416/*!-
417 Returns \c true if the object can return plain text (MIME type \c-
418 text/plain); otherwise returns \c false.-
419-
420 \sa setText(), text(), hasHtml(), hasFormat()-
421*/-
422bool QMimeData::hasText() const-
423{-
424 return hasFormat(textPlainLiteral()) || hasUrls();
executed 30 times by 3 tests: return hasFormat(textPlainLiteral()) || hasUrls();
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
30
425}-
426-
427/*!-
428 Returns a string if the data stored in the object is HTML (MIME-
429 type \c text/html); otherwise returns an empty string.-
430-
431 \sa hasHtml(), setData()-
432*/-
433QString QMimeData::html() const-
434{-
435 Q_D(const QMimeData);-
436 QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String);-
437 return data.toString();
executed 7 times by 2 tests: return data.toString();
Executed by:
  • tst_QMimeData
  • tst_QTextEdit
7
438}-
439-
440/*!-
441 Sets \a html as the HTML (MIME type \c text/html) used to-
442 represent the data.-
443-
444 \sa hasHtml(), setText(), setData()-
445*/-
446void QMimeData::setHtml(const QString &html)-
447{-
448 Q_D(QMimeData);-
449 d->setData(textHtmlLiteral(), html);-
450}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
451-
452/*!-
453 Returns \c true if the object can return HTML (MIME type \c-
454 text/html); otherwise returns \c false.-
455-
456 \sa setHtml(), html(), hasFormat()-
457*/-
458bool QMimeData::hasHtml() const-
459{-
460 return hasFormat(textHtmlLiteral());
executed 25 times by 3 tests: return hasFormat(textHtmlLiteral());
Executed by:
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QTextEdit
25
461}-
462-
463/*!-
464 Returns a QVariant storing a QImage if the object can return an-
465 image; otherwise returns a null variant.-
466-
467 A QVariant is used because QMimeData belongs to the Qt Core-
468 module, whereas QImage belongs to Qt GUI. To convert the-
469 QVariant to a QImage, simply use qvariant_cast(). For example:-
470-
471 \snippet code/src_corelib_kernel_qmimedata.cpp 5-
472-
473 \sa hasImage()-
474*/-
475QVariant QMimeData::imageData() const-
476{-
477 Q_D(const QMimeData);-
478 return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image);
executed 3 times by 1 test: return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image);
Executed by:
  • tst_QMimeData
3
479}-
480-
481/*!-
482 Sets the data in the object to the given \a image.-
483-
484 A QVariant is used because QMimeData belongs to the Qt Core-
485 module, whereas QImage belongs to Qt GUI. The conversion-
486 from QImage to QVariant is implicit. For example:-
487-
488 \snippet code/src_corelib_kernel_qmimedata.cpp 6-
489-
490 \sa hasImage(), setData()-
491*/-
492void QMimeData::setImageData(const QVariant &image)-
493{-
494 Q_D(QMimeData);-
495 d->setData(applicationXQtImageLiteral(), image);-
496}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
497-
498/*!-
499 Returns \c true if the object can return an image; otherwise returns-
500 false.-
501-
502 \sa setImageData(), imageData(), hasFormat()-
503*/-
504bool QMimeData::hasImage() const-
505{-
506 return hasFormat(applicationXQtImageLiteral());
executed 5 times by 1 test: return hasFormat(applicationXQtImageLiteral());
Executed by:
  • tst_QMimeData
5
507}-
508-
509/*!-
510 Returns a color if the data stored in the object represents a-
511 color (MIME type \c application/x-color); otherwise returns a-
512 null variant.-
513-
514 A QVariant is used because QMimeData belongs to the Qt Core-
515 module, whereas QColor belongs to Qt GUI. To convert the-
516 QVariant to a QColor, simply use qvariant_cast(). For example:-
517-
518 \snippet code/src_corelib_kernel_qmimedata.cpp 7-
519-
520 \sa hasColor(), setColorData(), data()-
521*/-
522QVariant QMimeData::colorData() const-
523{-
524 Q_D(const QMimeData);-
525 return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color);
executed 2 times by 1 test: return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color);
Executed by:
  • tst_QMimeData
2
526}-
527-
528/*!-
529 Sets the color data in the object to the given \a color.-
530-
531 Colors correspond to the MIME type \c application/x-color.-
532-
533 \sa hasColor(), setData()-
534*/-
535void QMimeData::setColorData(const QVariant &color)-
536{-
537 Q_D(QMimeData);-
538 d->setData(applicationXColorLiteral(), color);-
539}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeData
3
540-
541-
542/*!-
543 Returns \c true if the object can return a color (MIME type \c-
544 application/x-color); otherwise returns \c false.-
545-
546 \sa setColorData(), colorData(), hasFormat()-
547*/-
548bool QMimeData::hasColor() const-
549{-
550 return hasFormat(applicationXColorLiteral());
executed 6 times by 1 test: return hasFormat(applicationXColorLiteral());
Executed by:
  • tst_QMimeData
6
551}-
552-
553/*!-
554 Returns the data stored in the object in the format described by-
555 the MIME type specified by \a mimeType.-
556*/-
557QByteArray QMimeData::data(const QString &mimeType) const-
558{-
559 Q_D(const QMimeData);-
560 QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray);-
561 return data.toByteArray();
executed 53 times by 11 tests: return data.toByteArray();
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QListWidget
  • tst_QMimeData
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
53
562}-
563-
564/*!-
565 Sets the data associated with the MIME type given by \a mimeType-
566 to the specified \a data.-
567-
568 For the most common types of data, you can call the higher-level-
569 functions setText(), setHtml(), setUrls(), setImageData(), and-
570 setColorData() instead.-
571-
572 Note that if you want to use a custom data type in an item view drag and drop-
573 operation, you must register it as a Qt \l{QMetaType}{meta type}, using the-
574 Q_DECLARE_METATYPE() macro, and implement stream operators for it. The stream-
575 operators must then be registered with the qRegisterMetaTypeStreamOperators()-
576 function.-
577-
578 \sa hasFormat(), QMetaType, {QMetaType::}{qRegisterMetaTypeStreamOperators()}-
579*/-
580void QMimeData::setData(const QString &mimeType, const QByteArray &data)-
581{-
582 Q_D(QMimeData);-
583-
584 if (mimeType == QLatin1String("text/uri-list")) {
mimeType == QL...ext/uri-list")Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 69 times by 8 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QClipboard
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
1-69
585 QByteArray ba = data;-
586 if (ba.endsWith('\0'))
ba.endsWith('\0')Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
0-1
587 ba.chop(1);
never executed: ba.chop(1);
0
588 QList<QByteArray> urls = ba.split('\n');-
589 QList<QVariant> list;-
590 for (int i = 0; i < urls.size(); ++i) {
i < urls.size()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
1-3
591 QByteArray ba = urls.at(i).trimmed();-
592 if (!ba.isEmpty())
!ba.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMimeData
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QMimeData
1-2
593 list.append(QUrl::fromEncoded(ba));
executed 2 times by 1 test: list.append(QUrl::fromEncoded(ba));
Executed by:
  • tst_QMimeData
2
594 }
executed 3 times by 1 test: end of block
Executed by:
  • tst_QMimeData
3
595 d->setData(mimeType, list);-
596 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_QMimeData
1
597 d->setData(mimeType, QVariant(data));-
598 }
executed 69 times by 8 tests: end of block
Executed by:
  • tst_QAbstractItemModel
  • tst_QClipboard
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
69
599}-
600-
601/*!-
602 Returns \c true if the object can return data for the MIME type-
603 specified by \a mimeType; otherwise returns \c false.-
604-
605 For the most common types of data, you can call the higher-level-
606 functions hasText(), hasHtml(), hasUrls(), hasImage(), and-
607 hasColor() instead.-
608-
609 \sa formats(), setData(), data()-
610*/-
611bool QMimeData::hasFormat(const QString &mimeType) const-
612{-
613 return formats().contains(mimeType);
executed 126 times by 13 tests: return formats().contains(mimeType);
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QGraphicsProxyWidget
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
126
614}-
615-
616/*!-
617 Returns a list of formats supported by the object. This is a list-
618 of MIME types for which the object can return suitable data. The-
619 formats in the list are in a priority order.-
620-
621 For the most common types of data, you can call the higher-level-
622 functions hasText(), hasHtml(), hasUrls(), hasImage(), and-
623 hasColor() instead.-
624-
625 \sa hasFormat(), setData(), data()-
626*/-
627QStringList QMimeData::formats() const-
628{-
629 Q_D(const QMimeData);-
630 QStringList list;-
631 const int size = d->dataList.size();-
632 list.reserve(size);-
633 for (int i = 0; i < size; ++i)
i < sizeDescription
TRUEevaluated 152 times by 13 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QGraphicsProxyWidget
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
FALSEevaluated 124 times by 13 tests
Evaluated by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QGraphicsProxyWidget
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
124-152
634 list += d->dataList.at(i).format;
executed 152 times by 13 tests: list += d->dataList.at(i).format;
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QGraphicsProxyWidget
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
152
635 return list;
executed 124 times by 13 tests: return list;
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QGraphicsProxyWidget
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
124
636}-
637-
638/*!-
639 Returns a variant with the given \a type containing data for the-
640 MIME type specified by \a mimeType. If the object does not-
641 support the MIME type or variant type given, a null variant is-
642 returned instead.-
643-
644 This function is called by the general data() getter and by the-
645 convenience getters (text(), html(), urls(), imageData(), and-
646 colorData()). You can reimplement it if you want to store your-
647 data using a custom data structure (instead of a QByteArray,-
648 which is what setData() provides). You would then also need-
649 to reimplement hasFormat() and formats().-
650-
651 \sa data()-
652*/-
653QVariant QMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const-
654{-
655 Q_UNUSED(type);-
656 Q_D(const QMimeData);-
657 return d->getData(mimeType);
executed 137 times by 16 tests: return d->getData(mimeType);
Executed by:
  • tst_QAbstractItemModel
  • tst_QApplication
  • tst_QClipboard
  • tst_QGraphicsProxyWidget
  • tst_QLineEdit
  • tst_QListWidget
  • tst_QMimeData
  • tst_QPlainTextEdit
  • tst_QStandardItemModel
  • tst_QTableWidget
  • tst_QTextEdit
  • tst_QWidget_window
  • tst_qclipboard - unknown status
  • tst_qlineedit - unknown status
  • tst_qplaintextedit - unknown status
  • tst_qtextedit - unknown status
137
658}-
659-
660/*!-
661 Removes all the MIME type and data entries in the object.-
662*/-
663void QMimeData::clear()-
664{-
665 Q_D(QMimeData);-
666 d->dataList.clear();-
667}
executed 12 times by 2 tests: end of block
Executed by:
  • tst_QClipboard
  • tst_QMimeData
12
668-
669/*!-
670 \since 4.4-
671-
672 Removes the data entry for \a mimeType in the object.-
673*/-
674void QMimeData::removeFormat(const QString &mimeType)-
675{-
676 Q_D(QMimeData);-
677 d->removeData(mimeType);-
678}
executed 2 times by 1 test: end of block
Executed by:
  • tst_QMimeData
2
679-
680QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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