Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qclipboard.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | QClipboard::QClipboard(QObject *parent) | - | ||||||
8 | : QObject(parent) | - | ||||||
9 | { | - | ||||||
10 | - | |||||||
11 | } never executed: end of block | 0 | ||||||
12 | QClipboard::~QClipboard() | - | ||||||
13 | { | - | ||||||
14 | } | - | ||||||
15 | QString QClipboard::text(QString &subtype, Mode mode) const | - | ||||||
16 | { | - | ||||||
17 | const QMimeData *const data = mimeData(mode); | - | ||||||
18 | if (!data
| 0 | ||||||
19 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||
20 | - | |||||||
21 | const QStringList formats = data->formats(); | - | ||||||
22 | if (subtype.isEmpty()
| 0 | ||||||
23 | if (formats.contains(QLatin1String("text/plain"))
| 0 | ||||||
24 | subtype = QLatin1String("plain"); never executed: subtype = QLatin1String("plain"); | 0 | ||||||
25 | else { | - | ||||||
26 | for (int i = 0; i < formats.size()
| 0 | ||||||
27 | if (formats.at(i).startsWith(QLatin1String("text/"))
| 0 | ||||||
28 | subtype = formats.at(i).mid(5); | - | ||||||
29 | break; never executed: break; | 0 | ||||||
30 | } | - | ||||||
31 | if (subtype.isEmpty()
| 0 | ||||||
32 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||
33 | } never executed: end of block | 0 | ||||||
34 | } else if (!formats.contains(QLatin1String("text/") + subtype)
| 0 | ||||||
35 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||
36 | } | - | ||||||
37 | - | |||||||
38 | const QByteArray rawData = data->data(QLatin1String("text/") + subtype); | - | ||||||
39 | - | |||||||
40 | - | |||||||
41 | QTextCodec* codec = QTextCodec::codecForMib(106); | - | ||||||
42 | if (subtype == QLatin1String("html")
| 0 | ||||||
43 | codec = QTextCodec::codecForHtml(rawData, codec); never executed: codec = QTextCodec::codecForHtml(rawData, codec); | 0 | ||||||
44 | else | - | ||||||
45 | codec = QTextCodec::codecForUtfText(rawData, codec); never executed: codec = QTextCodec::codecForUtfText(rawData, codec); | 0 | ||||||
46 | return never executed: codec->toUnicode(rawData);return codec->toUnicode(rawData); never executed: return codec->toUnicode(rawData); | 0 | ||||||
47 | - | |||||||
48 | - | |||||||
49 | - | |||||||
50 | } | - | ||||||
51 | QString QClipboard::text(Mode mode) const | - | ||||||
52 | { | - | ||||||
53 | const QMimeData *data = mimeData(mode); | - | ||||||
54 | return never executed: data ? data->text() : QString();return data ? data->text() : QString(); never executed: return data ? data->text() : QString(); | 0 | ||||||
55 | } | - | ||||||
56 | void QClipboard::setText(const QString &text, Mode mode) | - | ||||||
57 | { | - | ||||||
58 | QMimeData *data = new QMimeData; | - | ||||||
59 | data->setText(text); | - | ||||||
60 | setMimeData(data, mode); | - | ||||||
61 | } never executed: end of block | 0 | ||||||
62 | QImage QClipboard::image(Mode mode) const | - | ||||||
63 | { | - | ||||||
64 | const QMimeData *data = mimeData(mode); | - | ||||||
65 | if (!data
| 0 | ||||||
66 | return never executed: QImage();return QImage(); never executed: return QImage(); | 0 | ||||||
67 | return never executed: qvariant_cast<QImage>(data->imageData());return qvariant_cast<QImage>(data->imageData()); never executed: return qvariant_cast<QImage>(data->imageData()); | 0 | ||||||
68 | } | - | ||||||
69 | void QClipboard::setImage(const QImage &image, Mode mode) | - | ||||||
70 | { | - | ||||||
71 | QMimeData *data = new QMimeData; | - | ||||||
72 | data->setImageData(image); | - | ||||||
73 | setMimeData(data, mode); | - | ||||||
74 | } never executed: end of block | 0 | ||||||
75 | QPixmap QClipboard::pixmap(Mode mode) const | - | ||||||
76 | { | - | ||||||
77 | const QMimeData *data = mimeData(mode); | - | ||||||
78 | return never executed: data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap();return data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap(); never executed: return data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap(); | 0 | ||||||
79 | } | - | ||||||
80 | void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode) | - | ||||||
81 | { | - | ||||||
82 | QMimeData *data = new QMimeData; | - | ||||||
83 | data->setImageData(pixmap); | - | ||||||
84 | setMimeData(data, mode); | - | ||||||
85 | } never executed: end of block | 0 | ||||||
86 | const QMimeData* QClipboard::mimeData(Mode mode) const | - | ||||||
87 | { | - | ||||||
88 | QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); | - | ||||||
89 | if (!clipboard->supportsMode(mode)
never executed: 0;return 0; never executed: return 0; | 0 | ||||||
90 | return never executed: clipboard->mimeData(mode);return clipboard->mimeData(mode); never executed: return clipboard->mimeData(mode); | 0 | ||||||
91 | } | - | ||||||
92 | void QClipboard::setMimeData(QMimeData* src, Mode mode) | - | ||||||
93 | { | - | ||||||
94 | QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); | - | ||||||
95 | if (!clipboard->supportsMode(mode)
| 0 | ||||||
96 | if (src != 0
| 0 | ||||||
97 | QMessageLogger(__FILE__, 475, __PRETTY_FUNCTION__).warning("Data set on unsupported clipboard mode. QMimeData object will be deleted."); | - | ||||||
98 | src->deleteLater(); | - | ||||||
99 | } never executed: end of block | 0 | ||||||
100 | } never executed: else {end of block | 0 | ||||||
101 | clipboard->setMimeData(src,mode); | - | ||||||
102 | } never executed: end of block | 0 | ||||||
103 | } | - | ||||||
104 | void QClipboard::clear(Mode mode) | - | ||||||
105 | { | - | ||||||
106 | setMimeData(0, mode); | - | ||||||
107 | } never executed: end of block | 0 | ||||||
108 | - | |||||||
109 | - | |||||||
110 | - | |||||||
111 | - | |||||||
112 | - | |||||||
113 | bool QClipboard::supportsSelection() const | - | ||||||
114 | { | - | ||||||
115 | return never executed: supportsMode(Selection);return supportsMode(Selection); never executed: return supportsMode(Selection); | 0 | ||||||
116 | } | - | ||||||
117 | - | |||||||
118 | - | |||||||
119 | - | |||||||
120 | - | |||||||
121 | - | |||||||
122 | bool QClipboard::supportsFindBuffer() const | - | ||||||
123 | { | - | ||||||
124 | return never executed: supportsMode(FindBuffer);return supportsMode(FindBuffer); never executed: return supportsMode(FindBuffer); | 0 | ||||||
125 | } | - | ||||||
126 | - | |||||||
127 | - | |||||||
128 | - | |||||||
129 | - | |||||||
130 | - | |||||||
131 | bool QClipboard::ownsClipboard() const | - | ||||||
132 | { | - | ||||||
133 | return never executed: ownsMode(Clipboard);return ownsMode(Clipboard); never executed: return ownsMode(Clipboard); | 0 | ||||||
134 | } | - | ||||||
135 | - | |||||||
136 | - | |||||||
137 | - | |||||||
138 | - | |||||||
139 | - | |||||||
140 | bool QClipboard::ownsSelection() const | - | ||||||
141 | { | - | ||||||
142 | return never executed: ownsMode(Selection);return ownsMode(Selection); never executed: return ownsMode(Selection); | 0 | ||||||
143 | } | - | ||||||
144 | - | |||||||
145 | - | |||||||
146 | - | |||||||
147 | - | |||||||
148 | - | |||||||
149 | - | |||||||
150 | - | |||||||
151 | bool QClipboard::ownsFindBuffer() const | - | ||||||
152 | { | - | ||||||
153 | return never executed: ownsMode(FindBuffer);return ownsMode(FindBuffer); never executed: return ownsMode(FindBuffer); | 0 | ||||||
154 | } | - | ||||||
155 | - | |||||||
156 | - | |||||||
157 | - | |||||||
158 | - | |||||||
159 | - | |||||||
160 | - | |||||||
161 | - | |||||||
162 | bool QClipboard::supportsMode(Mode mode) const | - | ||||||
163 | { | - | ||||||
164 | QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); | - | ||||||
165 | return never executed: clipboard->supportsMode(mode);return clipboard->supportsMode(mode); never executed: return clipboard->supportsMode(mode); | 0 | ||||||
166 | } | - | ||||||
167 | - | |||||||
168 | - | |||||||
169 | - | |||||||
170 | - | |||||||
171 | - | |||||||
172 | - | |||||||
173 | - | |||||||
174 | bool QClipboard::ownsMode(Mode mode) const | - | ||||||
175 | { | - | ||||||
176 | QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard(); | - | ||||||
177 | return never executed: clipboard->ownsMode(mode);return clipboard->ownsMode(mode); never executed: return clipboard->ownsMode(mode); | 0 | ||||||
178 | } | - | ||||||
179 | - | |||||||
180 | - | |||||||
181 | - | |||||||
182 | - | |||||||
183 | - | |||||||
184 | void QClipboard::emitChanged(Mode mode) | - | ||||||
185 | { | - | ||||||
186 | switch (mode) { | - | ||||||
187 | case never executed: Clipboard:case Clipboard: never executed: case Clipboard: | 0 | ||||||
188 | dataChanged(); | - | ||||||
189 | break; never executed: break; | 0 | ||||||
190 | case never executed: Selection:case Selection: never executed: case Selection: | 0 | ||||||
191 | selectionChanged(); | - | ||||||
192 | break; never executed: break; | 0 | ||||||
193 | case never executed: FindBuffer:case FindBuffer: never executed: case FindBuffer: | 0 | ||||||
194 | findBufferChanged(); | - | ||||||
195 | break; never executed: break; | 0 | ||||||
196 | default never executed: :default: never executed: default: | 0 | ||||||
197 | break; never executed: break; | 0 | ||||||
198 | } | - | ||||||
199 | changed(mode); | - | ||||||
200 | } never executed: end of block | 0 | ||||||
201 | - | |||||||
202 | - | |||||||
Switch to Source code | Preprocessed file |