Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | class QTextBrowserPrivate : public QTextEditPrivate | - |
8 | { | - |
9 | inline QTextBrowser* q_func() { return static_cast<QTextBrowser *>(q_ptr); } inline const QTextBrowser* q_func() const { return static_cast<const QTextBrowser *>(q_ptr); } friend class QTextBrowser; | - |
10 | public: | - |
11 | inline QTextBrowserPrivate() | - |
12 | : textOrSourceChanged(false), forceLoadOnSourceChange(false), openExternalLinks(false), | - |
13 | openLinks(true) | - |
14 | | - |
15 | | - |
16 | | - |
17 | {} executed: } Execution Count:24 | 24 |
18 | | - |
19 | void init(); | - |
20 | | - |
21 | struct HistoryEntry { | - |
22 | inline HistoryEntry() | - |
23 | : hpos(0), vpos(0), focusIndicatorPosition(-1), | - |
24 | focusIndicatorAnchor(-1) {} executed: } Execution Count:103 | 103 |
25 | QUrl url; | - |
26 | QString title; | - |
27 | int hpos; | - |
28 | int vpos; | - |
29 | int focusIndicatorPosition, focusIndicatorAnchor; | - |
30 | }; | - |
31 | | - |
32 | HistoryEntry history(int i) const | - |
33 | { | - |
34 | if (i <= 0) evaluated: i <= 0 yes Evaluation Count:12 | yes Evaluation Count:6 |
| 6-12 |
35 | if (-i < stack.count()) evaluated: -i < stack.count() yes Evaluation Count:5 | yes Evaluation Count:7 |
| 5-7 |
36 | return stack[stack.count()+i-1]; executed: return stack[stack.count()+i-1]; Execution Count:5 | 5 |
37 | else | - |
38 | return HistoryEntry(); executed: return HistoryEntry(); Execution Count:7 | 7 |
39 | else | - |
40 | if (i <= forwardStack.count()) evaluated: i <= forwardStack.count() yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
41 | return forwardStack[forwardStack.count()-i]; executed: return forwardStack[forwardStack.count()-i]; Execution Count:1 | 1 |
42 | else | - |
43 | return HistoryEntry(); executed: return HistoryEntry(); Execution Count:5 | 5 |
44 | } | - |
45 | | - |
46 | | - |
47 | HistoryEntry createHistoryEntry() const; | - |
48 | void restoreHistoryEntry(const HistoryEntry entry); | - |
49 | | - |
50 | QStack<HistoryEntry> stack; | - |
51 | QStack<HistoryEntry> forwardStack; | - |
52 | QUrl home; | - |
53 | QUrl currentURL; | - |
54 | | - |
55 | QStringList searchPaths; | - |
56 | | - |
57 | | - |
58 | | - |
59 | | - |
60 | bool textOrSourceChanged; | - |
61 | bool forceLoadOnSourceChange; | - |
62 | | - |
63 | bool openExternalLinks; | - |
64 | bool openLinks; | - |
65 | | - |
66 | | - |
67 | QCursor oldCursor; | - |
68 | | - |
69 | | - |
70 | QString findFile(const QUrl &name) const; | - |
71 | | - |
72 | inline void _q_documentModified() | - |
73 | { | - |
74 | textOrSourceChanged = true; | - |
75 | forceLoadOnSourceChange = !currentURL.path().isEmpty(); | - |
76 | } executed: } Execution Count:53 | 53 |
77 | | - |
78 | void _q_activateAnchor(const QString &href); | - |
79 | void _q_highlightLink(const QString &href); | - |
80 | | - |
81 | void setSource(const QUrl &url); | - |
82 | | - |
83 | | - |
84 | virtual QUrl resolveUrl(const QUrl &url) const; | - |
85 | inline QUrl resolveUrl(const QString &url) const | - |
86 | { return resolveUrl(QUrl(url)); } executed: return resolveUrl(QUrl(url)); Execution Count:6 | 6 |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | | - |
93 | }; | - |
94 | | - |
95 | QString QTextBrowserPrivate::findFile(const QUrl &name) const | - |
96 | { | - |
97 | QString fileName; | - |
98 | if (name.scheme() == QLatin1String("qrc")) evaluated: name.scheme() == QLatin1String("qrc") yes Evaluation Count:3 | yes Evaluation Count:49 |
| 3-49 |
99 | fileName = QLatin1String(":/") + name.path(); executed: fileName = QLatin1String(":/") + name.path(); Execution Count:3 | 3 |
100 | else if (name.scheme().isEmpty()) evaluated: name.scheme().isEmpty() yes Evaluation Count:4 | yes Evaluation Count:45 |
| 4-45 |
101 | fileName = name.path(); executed: fileName = name.path(); Execution Count:4 | 4 |
102 | else | - |
103 | fileName = name.toLocalFile(); executed: fileName = name.toLocalFile(); Execution Count:45 | 45 |
104 | | - |
105 | if (QFileInfo(fileName).isAbsolute()) evaluated: QFileInfo(fileName).isAbsolute() yes Evaluation Count:19 | yes Evaluation Count:33 |
| 19-33 |
106 | return fileName; executed: return fileName; Execution Count:19 | 19 |
107 | | - |
108 | for (QForeachContainer<__typeof__(searchPaths)> _container_(searchPaths); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QString path = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
109 | if (!path.endsWith(QLatin1Char('/'))) never evaluated: !path.endsWith(QLatin1Char('/')) | 0 |
110 | path.append(QLatin1Char('/')); never executed: path.append(QLatin1Char('/')); | 0 |
111 | path.append(fileName); | - |
112 | if (QFileInfo(path).isReadable()) never evaluated: QFileInfo(path).isReadable() | 0 |
113 | return path; never executed: return path; | 0 |
114 | } | 0 |
115 | | - |
116 | return fileName; executed: return fileName; Execution Count:33 | 33 |
117 | } | - |
118 | | - |
119 | QUrl QTextBrowserPrivate::resolveUrl(const QUrl &url) const | - |
120 | { | - |
121 | if (!url.isRelative()) evaluated: !url.isRelative() yes Evaluation Count:131 | yes Evaluation Count:29 |
| 29-131 |
122 | return url; executed: return url; Execution Count:131 | 131 |
123 | | - |
124 | | - |
125 | | - |
126 | if (!(currentURL.isRelative() evaluated: currentURL.isRelative() yes Evaluation Count:12 | yes Evaluation Count:17 |
| 12-17 |
127 | || (currentURL.scheme() == QLatin1String("file") evaluated: currentURL.scheme() == QLatin1String("file") yes Evaluation Count:13 | yes Evaluation Count:4 |
| 4-13 |
128 | && !QFileInfo(currentURL.toLocalFile()).isAbsolute())) evaluated: !QFileInfo(currentURL.toLocalFile()).isAbsolute() yes Evaluation Count:11 | yes Evaluation Count:2 |
| 2-11 |
129 | || (url.hasFragment() && url.path().isEmpty())) { partially evaluated: url.hasFragment() no Evaluation Count:0 | yes Evaluation Count:23 |
never evaluated: url.path().isEmpty() | 0-23 |
130 | return currentURL.resolved(url); executed: return currentURL.resolved(url); Execution Count:6 | 6 |
131 | } | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | QFileInfo fi(currentURL.toLocalFile()); | - |
137 | if (fi.exists()) { evaluated: fi.exists() yes Evaluation Count:11 | yes Evaluation Count:12 |
| 11-12 |
138 | return QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(url); executed: return QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(url); Execution Count:11 | 11 |
139 | } | - |
140 | | - |
141 | return url; executed: return url; Execution Count:12 | 12 |
142 | } | - |
143 | | - |
144 | void QTextBrowserPrivate::_q_activateAnchor(const QString &href) | - |
145 | { | - |
146 | if (href.isEmpty()) partially evaluated: href.isEmpty() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
147 | return; | 0 |
148 | QTextBrowser * const q = q_func(); | - |
149 | | - |
150 | | - |
151 | viewport->setCursor(oldCursor); | - |
152 | | - |
153 | | - |
154 | const QUrl url = resolveUrl(href); | - |
155 | | - |
156 | if (!openLinks) { evaluated: !openLinks yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
157 | q->anchorClicked(url); | - |
158 | return; executed: return; Execution Count:1 | 1 |
159 | } | - |
160 | | - |
161 | textOrSourceChanged = false; | - |
162 | | - |
163 | | - |
164 | if ((openExternalLinks partially evaluated: openExternalLinks no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
165 | && url.scheme() != QLatin1String("file") never evaluated: url.scheme() != QLatin1String("file") | 0 |
166 | && url.scheme() != QLatin1String("qrc") never evaluated: url.scheme() != QLatin1String("qrc") | 0 |
167 | && !url.isRelative()) never evaluated: !url.isRelative() | 0 |
168 | || (url.isRelative() && !currentURL.isRelative() partially evaluated: url.isRelative() no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: !currentURL.isRelative() | 0-5 |
169 | && currentURL.scheme() != QLatin1String("file") never evaluated: currentURL.scheme() != QLatin1String("file") | 0 |
170 | && currentURL.scheme() != QLatin1String("qrc"))) { never evaluated: currentURL.scheme() != QLatin1String("qrc") | 0 |
171 | QDesktopServices::openUrl(url); | - |
172 | return; | 0 |
173 | } | - |
174 | | - |
175 | | - |
176 | q->anchorClicked(url); | - |
177 | | - |
178 | if (textOrSourceChanged) partially evaluated: textOrSourceChanged no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
179 | return; | 0 |
180 | | - |
181 | q->setSource(url); | - |
182 | } executed: } Execution Count:5 | 5 |
183 | | - |
184 | void QTextBrowserPrivate::_q_highlightLink(const QString &anchor) | - |
185 | { | - |
186 | QTextBrowser * const q = q_func(); | - |
187 | if (anchor.isEmpty()) { never evaluated: anchor.isEmpty() | 0 |
188 | | - |
189 | if (viewport->cursor().shape() != Qt::PointingHandCursor) never evaluated: viewport->cursor().shape() != Qt::PointingHandCursor | 0 |
190 | oldCursor = viewport->cursor(); never executed: oldCursor = viewport->cursor(); | 0 |
191 | viewport->setCursor(oldCursor); | - |
192 | | - |
193 | q->highlighted(QUrl()); | - |
194 | q->highlighted(QString()); | - |
195 | } else { | 0 |
196 | | - |
197 | viewport->setCursor(Qt::PointingHandCursor); | - |
198 | | - |
199 | | - |
200 | const QUrl url = resolveUrl(anchor); | - |
201 | q->highlighted(url); | - |
202 | | - |
203 | q->highlighted(url.toString()); | - |
204 | } | 0 |
205 | } | - |
206 | | - |
207 | void QTextBrowserPrivate::setSource(const QUrl &url) | - |
208 | { | - |
209 | QTextBrowser * const q = q_func(); | - |
210 | | - |
211 | if (q->isVisible()) evaluated: q->isVisible() yes Evaluation Count:51 | yes Evaluation Count:3 |
| 3-51 |
212 | QApplication::setOverrideCursor(Qt::WaitCursor); executed: QApplication::setOverrideCursor(Qt::WaitCursor); Execution Count:51 | 51 |
213 | | - |
214 | textOrSourceChanged = true; | - |
215 | | - |
216 | QString txt; | - |
217 | | - |
218 | bool doSetText = false; | - |
219 | | - |
220 | QUrl currentUrlWithoutFragment = currentURL; | - |
221 | currentUrlWithoutFragment.setFragment(QString()); | - |
222 | QUrl newUrlWithoutFragment = currentURL.resolved(url); | - |
223 | newUrlWithoutFragment.setFragment(QString()); | - |
224 | | - |
225 | if (url.isValid() partially evaluated: url.isValid() yes Evaluation Count:54 | no Evaluation Count:0 |
| 0-54 |
226 | && (newUrlWithoutFragment != currentUrlWithoutFragment || forceLoadOnSourceChange)) { evaluated: newUrlWithoutFragment != currentUrlWithoutFragment yes Evaluation Count:48 | yes Evaluation Count:6 |
partially evaluated: forceLoadOnSourceChange no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-48 |
227 | QVariant data = q->loadResource(QTextDocument::HtmlResource, resolveUrl(url)); | - |
228 | if (data.type() == QVariant::String) { evaluated: data.type() == QVariant::String yes Evaluation Count:3 | yes Evaluation Count:45 |
| 3-45 |
229 | txt = data.toString(); | - |
230 | } else if (data.type() == QVariant::ByteArray) { partially evaluated: data.type() == QVariant::ByteArray yes Evaluation Count:45 | no Evaluation Count:0 |
executed: } Execution Count:3 | 0-45 |
231 | | - |
232 | QByteArray ba = data.toByteArray(); | - |
233 | QTextCodec *codec = Qt::codecForHtml(ba); | - |
234 | txt = codec->toUnicode(ba); | - |
235 | | - |
236 | | - |
237 | | - |
238 | } executed: } Execution Count:45 | 45 |
239 | if (txt.isEmpty()) partially evaluated: txt.isEmpty() no Evaluation Count:0 | yes Evaluation Count:48 |
| 0-48 |
240 | QMessageLogger("widgets/qtextbrowser.cpp", 296, __PRETTY_FUNCTION__).warning("QTextBrowser: No document for %s", url.toString().toLatin1().constData()); never executed: QMessageLogger("widgets/qtextbrowser.cpp", 296, __PRETTY_FUNCTION__).warning("QTextBrowser: No document for %s", url.toString().toLatin1().constData()); | 0 |
241 | | - |
242 | if (q->isVisible()) { evaluated: q->isVisible() yes Evaluation Count:45 | yes Evaluation Count:3 |
| 3-45 |
243 | QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1); | - |
244 | if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) { partially evaluated: firstTag.startsWith(QLatin1String("<qt")) no Evaluation Count:0 | yes Evaluation Count:45 |
never evaluated: firstTag.contains(QLatin1String("type")) never evaluated: firstTag.contains(QLatin1String("detail")) | 0-45 |
245 | | - |
246 | QApplication::restoreOverrideCursor(); | - |
247 | | - |
248 | | - |
249 | QWhatsThis::showText(QCursor::pos(), txt, q); | - |
250 | | - |
251 | return; | 0 |
252 | } | - |
253 | } executed: } Execution Count:45 | 45 |
254 | | - |
255 | currentURL = resolveUrl(url); | - |
256 | doSetText = true; | - |
257 | } executed: } Execution Count:48 | 48 |
258 | | - |
259 | if (!home.isValid()) evaluated: !home.isValid() yes Evaluation Count:14 | yes Evaluation Count:40 |
| 14-40 |
260 | home = url; executed: home = url; Execution Count:14 | 14 |
261 | | - |
262 | if (doSetText) { evaluated: doSetText yes Evaluation Count:48 | yes Evaluation Count:6 |
| 6-48 |
263 | | - |
264 | q->QTextEdit::setHtml(txt); | - |
265 | q->document()->setMetaInformation(QTextDocument::DocumentUrl, currentURL.toString()); | - |
266 | | - |
267 | | - |
268 | | - |
269 | | - |
270 | | - |
271 | | - |
272 | | - |
273 | } executed: } Execution Count:48 | 48 |
274 | | - |
275 | forceLoadOnSourceChange = false; | - |
276 | | - |
277 | if (!url.fragment().isEmpty()) { evaluated: !url.fragment().isEmpty() yes Evaluation Count:4 | yes Evaluation Count:50 |
| 4-50 |
278 | q->scrollToAnchor(url.fragment()); | - |
279 | } else { executed: } Execution Count:4 | 4 |
280 | hbar->setValue(0); | - |
281 | vbar->setValue(0); | - |
282 | } executed: } Execution Count:50 | 50 |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | if (q->isVisible()) evaluated: q->isVisible() yes Evaluation Count:51 | yes Evaluation Count:3 |
| 3-51 |
291 | QApplication::restoreOverrideCursor(); executed: QApplication::restoreOverrideCursor(); Execution Count:51 | 51 |
292 | | - |
293 | q->sourceChanged(url); | - |
294 | } executed: } Execution Count:54 | 54 |
295 | QTextBrowserPrivate::HistoryEntry QTextBrowserPrivate::createHistoryEntry() const | - |
296 | { | - |
297 | HistoryEntry entry; | - |
298 | entry.url = q_func()->source(); | - |
299 | entry.title = q_func()->documentTitle(); | - |
300 | entry.hpos = hbar->value(); | - |
301 | entry.vpos = vbar->value(); | - |
302 | | - |
303 | const QTextCursor cursor = control->textCursor(); | - |
304 | if (control->cursorIsFocusIndicator() evaluated: control->cursorIsFocusIndicator() yes Evaluation Count:15 | yes Evaluation Count:39 |
| 15-39 |
305 | && cursor.hasSelection()) { evaluated: cursor.hasSelection() yes Evaluation Count:13 | yes Evaluation Count:2 |
| 2-13 |
306 | | - |
307 | entry.focusIndicatorPosition = cursor.position(); | - |
308 | entry.focusIndicatorAnchor = cursor.anchor(); | - |
309 | } executed: } Execution Count:13 | 13 |
310 | return entry; executed: return entry; Execution Count:54 | 54 |
311 | } | - |
312 | | - |
313 | void QTextBrowserPrivate::restoreHistoryEntry(const HistoryEntry entry) | - |
314 | { | - |
315 | setSource(entry.url); | - |
316 | hbar->setValue(entry.hpos); | - |
317 | vbar->setValue(entry.vpos); | - |
318 | if (entry.focusIndicatorAnchor != -1 && entry.focusIndicatorPosition != -1) { evaluated: entry.focusIndicatorAnchor != -1 yes Evaluation Count:10 | yes Evaluation Count:6 |
partially evaluated: entry.focusIndicatorPosition != -1 yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
319 | QTextCursor cursor(control->document()); | - |
320 | cursor.setPosition(entry.focusIndicatorAnchor); | - |
321 | cursor.setPosition(entry.focusIndicatorPosition, QTextCursor::KeepAnchor); | - |
322 | control->setTextCursor(cursor); | - |
323 | control->setCursorIsFocusIndicator(true); | - |
324 | } executed: } Execution Count:10 | 10 |
325 | } executed: } Execution Count:16 | 16 |
326 | void QTextBrowserPrivate::init() | - |
327 | { | - |
328 | QTextBrowser * const q = q_func(); | - |
329 | control->setTextInteractionFlags(Qt::TextBrowserInteraction); | - |
330 | | - |
331 | viewport->setCursor(oldCursor); | - |
332 | | - |
333 | q->setUndoRedoEnabled(false); | - |
334 | viewport->setMouseTracking(true); | - |
335 | QObject::connect(q->document(), "2""contentsChanged()", q, "1""_q_documentModified()"); | - |
336 | QObject::connect(control, "2""linkActivated(QString)", | - |
337 | q, "1""_q_activateAnchor(QString)"); | - |
338 | QObject::connect(control, "2""linkHovered(QString)", | - |
339 | q, "1""_q_highlightLink(QString)"); | - |
340 | } executed: } Execution Count:24 | 24 |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | QTextBrowser::QTextBrowser(QWidget *parent) | - |
346 | : QTextEdit(*new QTextBrowserPrivate, parent) | - |
347 | { | - |
348 | QTextBrowserPrivate * const d = d_func(); | - |
349 | d->init(); | - |
350 | } executed: } Execution Count:24 | 24 |
351 | | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | QTextBrowser::~QTextBrowser() | - |
357 | { | - |
358 | } | - |
359 | QUrl QTextBrowser::source() const | - |
360 | { | - |
361 | const QTextBrowserPrivate * const d = d_func(); | - |
362 | if (d->stack.isEmpty()) evaluated: d->stack.isEmpty() yes Evaluation Count:32 | yes Evaluation Count:78 |
| 32-78 |
363 | return QUrl(); executed: return QUrl(); Execution Count:32 | 32 |
364 | else | - |
365 | return d->stack.top().url; executed: return d->stack.top().url; Execution Count:78 | 78 |
366 | } | - |
367 | QStringList QTextBrowser::searchPaths() const | - |
368 | { | - |
369 | const QTextBrowserPrivate * const d = d_func(); | - |
370 | return d->searchPaths; never executed: return d->searchPaths; | 0 |
371 | } | - |
372 | | - |
373 | void QTextBrowser::setSearchPaths(const QStringList &paths) | - |
374 | { | - |
375 | QTextBrowserPrivate * const d = d_func(); | - |
376 | d->searchPaths = paths; | - |
377 | } | 0 |
378 | | - |
379 | | - |
380 | | - |
381 | | - |
382 | void QTextBrowser::reload() | - |
383 | { | - |
384 | QTextBrowserPrivate * const d = d_func(); | - |
385 | QUrl s = d->currentURL; | - |
386 | d->currentURL = QUrl(); | - |
387 | setSource(s); | - |
388 | } | 0 |
389 | | - |
390 | void QTextBrowser::setSource(const QUrl &url) | - |
391 | { | - |
392 | QTextBrowserPrivate * const d = d_func(); | - |
393 | | - |
394 | const QTextBrowserPrivate::HistoryEntry historyEntry = d->createHistoryEntry(); | - |
395 | | - |
396 | d->setSource(url); | - |
397 | | - |
398 | if (!url.isValid()) partially evaluated: !url.isValid() no Evaluation Count:0 | yes Evaluation Count:38 |
| 0-38 |
399 | return; | 0 |
400 | | - |
401 | | - |
402 | if (!d->stack.isEmpty() && d->stack.top().url == url) evaluated: !d->stack.isEmpty() yes Evaluation Count:24 | yes Evaluation Count:14 |
evaluated: d->stack.top().url == url yes Evaluation Count:1 | yes Evaluation Count:23 |
| 1-24 |
403 | return; executed: return; Execution Count:1 | 1 |
404 | | - |
405 | if (!d->stack.isEmpty()) evaluated: !d->stack.isEmpty() yes Evaluation Count:23 | yes Evaluation Count:14 |
| 14-23 |
406 | d->stack.top() = historyEntry; executed: d->stack.top() = historyEntry; Execution Count:23 | 23 |
407 | | - |
408 | QTextBrowserPrivate::HistoryEntry entry; | - |
409 | entry.url = url; | - |
410 | entry.title = documentTitle(); | - |
411 | entry.hpos = 0; | - |
412 | entry.vpos = 0; | - |
413 | d->stack.push(entry); | - |
414 | | - |
415 | backwardAvailable(d->stack.count() > 1); | - |
416 | | - |
417 | if (!d->forwardStack.isEmpty() && d->forwardStack.top().url == url) { evaluated: !d->forwardStack.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:35 |
evaluated: d->forwardStack.top().url == url yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-35 |
418 | d->forwardStack.pop(); | - |
419 | forwardAvailable(d->forwardStack.count() > 0); | - |
420 | } else { executed: } Execution Count:1 | 1 |
421 | d->forwardStack.clear(); | - |
422 | forwardAvailable(false); | - |
423 | } executed: } Execution Count:36 | 36 |
424 | | - |
425 | historyChanged(); | - |
426 | } executed: } Execution Count:37 | 37 |
427 | void QTextBrowser::backward() | - |
428 | { | - |
429 | QTextBrowserPrivate * const d = d_func(); | - |
430 | if (d->stack.count() <= 1) evaluated: d->stack.count() <= 1 yes Evaluation Count:2 | yes Evaluation Count:11 |
| 2-11 |
431 | return; executed: return; Execution Count:2 | 2 |
432 | | - |
433 | | - |
434 | d->forwardStack.push(d->createHistoryEntry()); | - |
435 | d->stack.pop(); | - |
436 | d->restoreHistoryEntry(d->stack.top()); | - |
437 | backwardAvailable(d->stack.count() > 1); | - |
438 | forwardAvailable(true); | - |
439 | historyChanged(); | - |
440 | } executed: } Execution Count:11 | 11 |
441 | void QTextBrowser::forward() | - |
442 | { | - |
443 | QTextBrowserPrivate * const d = d_func(); | - |
444 | if (d->forwardStack.isEmpty()) partially evaluated: d->forwardStack.isEmpty() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
445 | return; | 0 |
446 | if (!d->stack.isEmpty()) { partially evaluated: !d->stack.isEmpty() yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
447 | | - |
448 | d->stack.top() = d->createHistoryEntry(); | - |
449 | } executed: } Execution Count:5 | 5 |
450 | d->stack.push(d->forwardStack.pop()); | - |
451 | d->restoreHistoryEntry(d->stack.top()); | - |
452 | backwardAvailable(true); | - |
453 | forwardAvailable(!d->forwardStack.isEmpty()); | - |
454 | historyChanged(); | - |
455 | } executed: } Execution Count:5 | 5 |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | void QTextBrowser::home() | - |
462 | { | - |
463 | QTextBrowserPrivate * const d = d_func(); | - |
464 | if (d->home.isValid()) partially evaluated: d->home.isValid() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
465 | setSource(d->home); executed: setSource(d->home); Execution Count:1 | 1 |
466 | } executed: } Execution Count:1 | 1 |
467 | void QTextBrowser::keyPressEvent(QKeyEvent *ev) | - |
468 | { | - |
469 | if (ev->modifiers() & Qt::AltModifier) { partially evaluated: ev->modifiers() & Qt::AltModifier no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
470 | switch (ev->key()) { | - |
471 | case Qt::Key_Right: | - |
472 | forward(); | - |
473 | ev->accept(); | - |
474 | return; | 0 |
475 | case Qt::Key_Left: | - |
476 | backward(); | - |
477 | ev->accept(); | - |
478 | return; | 0 |
479 | case Qt::Key_Up: | - |
480 | home(); | - |
481 | ev->accept(); | - |
482 | return; | 0 |
483 | } | - |
484 | } | 0 |
485 | QTextEdit::keyPressEvent(ev); | - |
486 | } executed: } Execution Count:6 | 6 |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | void QTextBrowser::mouseMoveEvent(QMouseEvent *e) | - |
492 | { | - |
493 | QTextEdit::mouseMoveEvent(e); | - |
494 | } | 0 |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | void QTextBrowser::mousePressEvent(QMouseEvent *e) | - |
500 | { | - |
501 | QTextEdit::mousePressEvent(e); | - |
502 | } | 0 |
503 | | - |
504 | | - |
505 | | - |
506 | | - |
507 | void QTextBrowser::mouseReleaseEvent(QMouseEvent *e) | - |
508 | { | - |
509 | QTextEdit::mouseReleaseEvent(e); | - |
510 | } | 0 |
511 | | - |
512 | | - |
513 | | - |
514 | | - |
515 | void QTextBrowser::focusOutEvent(QFocusEvent *ev) | - |
516 | { | - |
517 | | - |
518 | QTextBrowserPrivate * const d = d_func(); | - |
519 | d->viewport->setCursor((!(d->control->textInteractionFlags() & Qt::TextEditable)) ? d->oldCursor : Qt::IBeamCursor); | - |
520 | | - |
521 | QTextEdit::focusOutEvent(ev); | - |
522 | } executed: } Execution Count:4 | 4 |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | bool QTextBrowser::focusNextPrevChild(bool next) | - |
528 | { | - |
529 | QTextBrowserPrivate * const d = d_func(); | - |
530 | if (d->control->setFocusToNextOrPreviousAnchor(next)) { evaluated: d->control->setFocusToNextOrPreviousAnchor(next) yes Evaluation Count:10 | yes Evaluation Count:1 |
| 1-10 |
531 | return true; executed: return true; Execution Count:10 | 10 |
532 | } else { | - |
533 | | - |
534 | | - |
535 | | - |
536 | | - |
537 | | - |
538 | } executed: } Execution Count:1 | 1 |
539 | return QTextEdit::focusNextPrevChild(next); executed: return QTextEdit::focusNextPrevChild(next); Execution Count:1 | 1 |
540 | } | - |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | void QTextBrowser::paintEvent(QPaintEvent *e) | - |
546 | { | - |
547 | QTextBrowserPrivate * const d = d_func(); | - |
548 | QPainter p(d->viewport); | - |
549 | d->paint(&p, e); | - |
550 | } executed: } Execution Count:26 | 26 |
551 | QVariant QTextBrowser::loadResource(int , const QUrl &name) | - |
552 | { | - |
553 | QTextBrowserPrivate * const d = d_func(); | - |
554 | | - |
555 | QByteArray data; | - |
556 | QString fileName = d->findFile(d->resolveUrl(name)); | - |
557 | QFile f(fileName); | - |
558 | if (f.open(QFile::ReadOnly)) { evaluated: f.open(QFile::ReadOnly) yes Evaluation Count:46 | yes Evaluation Count:6 |
| 6-46 |
559 | data = f.readAll(); | - |
560 | f.close(); | - |
561 | } else { executed: } Execution Count:46 | 46 |
562 | return QVariant(); executed: return QVariant(); Execution Count:6 | 6 |
563 | } | - |
564 | | - |
565 | return data; executed: return data; Execution Count:46 | 46 |
566 | } | - |
567 | bool QTextBrowser::isBackwardAvailable() const | - |
568 | { | - |
569 | const QTextBrowserPrivate * const d = d_func(); | - |
570 | return d->stack.count() > 1; executed: return d->stack.count() > 1; Execution Count:13 | 13 |
571 | } | - |
572 | bool QTextBrowser::isForwardAvailable() const | - |
573 | { | - |
574 | const QTextBrowserPrivate * const d = d_func(); | - |
575 | return !d->forwardStack.isEmpty(); executed: return !d->forwardStack.isEmpty(); Execution Count:13 | 13 |
576 | } | - |
577 | void QTextBrowser::clearHistory() | - |
578 | { | - |
579 | QTextBrowserPrivate * const d = d_func(); | - |
580 | d->forwardStack.clear(); | - |
581 | if (!d->stack.isEmpty()) { evaluated: !d->stack.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
582 | QTextBrowserPrivate::HistoryEntry historyEntry = d->stack.top(); | - |
583 | d->stack.resize(0); | - |
584 | d->stack.push(historyEntry); | - |
585 | d->home = historyEntry.url; | - |
586 | } executed: } Execution Count:1 | 1 |
587 | forwardAvailable(false); | - |
588 | backwardAvailable(false); | - |
589 | historyChanged(); | - |
590 | } executed: } Execution Count:2 | 2 |
591 | QUrl QTextBrowser::historyUrl(int i) const | - |
592 | { | - |
593 | const QTextBrowserPrivate * const d = d_func(); | - |
594 | return d->history(i).url; executed: return d->history(i).url; Execution Count:1 | 1 |
595 | } | - |
596 | QString QTextBrowser::historyTitle(int i) const | - |
597 | { | - |
598 | const QTextBrowserPrivate * const d = d_func(); | - |
599 | return d->history(i).title; executed: return d->history(i).title; Execution Count:17 | 17 |
600 | } | - |
601 | | - |
602 | | - |
603 | | - |
604 | | - |
605 | | - |
606 | | - |
607 | | - |
608 | int QTextBrowser::forwardHistoryCount() const | - |
609 | { | - |
610 | const QTextBrowserPrivate * const d = d_func(); | - |
611 | return d->forwardStack.count(); never executed: return d->forwardStack.count(); | 0 |
612 | } | - |
613 | | - |
614 | | - |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
619 | int QTextBrowser::backwardHistoryCount() const | - |
620 | { | - |
621 | const QTextBrowserPrivate * const d = d_func(); | - |
622 | return d->stack.count()-1; never executed: return d->stack.count()-1; | 0 |
623 | } | - |
624 | bool QTextBrowser::openExternalLinks() const | - |
625 | { | - |
626 | const QTextBrowserPrivate * const d = d_func(); | - |
627 | return d->openExternalLinks; never executed: return d->openExternalLinks; | 0 |
628 | } | - |
629 | | - |
630 | void QTextBrowser::setOpenExternalLinks(bool open) | - |
631 | { | - |
632 | QTextBrowserPrivate * const d = d_func(); | - |
633 | d->openExternalLinks = open; | - |
634 | } | 0 |
635 | bool QTextBrowser::openLinks() const | - |
636 | { | - |
637 | const QTextBrowserPrivate * const d = d_func(); | - |
638 | return d->openLinks; never executed: return d->openLinks; | 0 |
639 | } | - |
640 | | - |
641 | void QTextBrowser::setOpenLinks(bool open) | - |
642 | { | - |
643 | QTextBrowserPrivate * const d = d_func(); | - |
644 | d->openLinks = open; | - |
645 | } executed: } Execution Count:1 | 1 |
646 | | - |
647 | | - |
648 | bool QTextBrowser::event(QEvent *e) | - |
649 | { | - |
650 | return QTextEdit::event(e); executed: return QTextEdit::event(e); Execution Count:828 | 828 |
651 | } | - |
652 | | - |
653 | | - |
654 | | - |
655 | | - |
| | |