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