Qt 4.8
Classes | Public Functions | Public Variables | List of all members
QTextBrowserPrivate Class Reference
Inheritance diagram for QTextBrowserPrivate:
QTextEditPrivate QAbstractScrollAreaPrivate QFramePrivate QWidgetPrivate QObjectPrivate QObjectData

Classes

struct  HistoryEntry
 

Public Functions

void _q_activateAnchor (const QString &href)
 
void _q_documentModified ()
 
void _q_highlightLink (const QString &href)
 
HistoryEntry createHistoryEntry () const
 
QString findFile (const QUrl &name) const
 
HistoryEntry history (int i) const
 
void init ()
 
 QTextBrowserPrivate ()
 
virtual QUrl resolveUrl (const QUrl &url) const
 
QUrl resolveUrl (const QString &url) const
 
void restoreHistoryEntry (const HistoryEntry entry)
 
void setSource (const QUrl &url)
 
- Public Functions inherited from QTextEditPrivate
void _q_adjustScrollbars ()
 
void _q_currentCharFormatChanged (const QTextCharFormat &format)
 
void _q_ensureVisible (const QRectF &rect)
 
void _q_repaintContents (const QRectF &contentsRect)
 
void createAutoBulletList ()
 
int horizontalOffset () const
 
void init (const QString &html=QString())
 
QPoint mapToContents (const QPoint &point) const
 
void pageUpDown (QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode)
 
void paint (QPainter *p, QPaintEvent *e)
 
 QTextEditPrivate ()
 
void relayoutDocument ()
 
void sendControlEvent (QEvent *e)
 
void updateDefaultTextOption ()
 
int verticalOffset () const
 
- Public Functions inherited from QAbstractScrollAreaPrivate
void _q_hslide (int)
 
void _q_showOrHideScrollBars ()
 
void _q_vslide (int)
 
virtual QPoint contentsOffset () const
 
void init ()
 
void layoutChildren ()
 
 QAbstractScrollAreaPrivate ()
 
void replaceScrollBar (QScrollBar *scrollBar, Qt::Orientation orientation)
 
virtual void scrollBarPolicyChanged (Qt::Orientation, Qt::ScrollBarPolicy)
 
void setSingleFingerPanEnabled (bool on=true)
 
bool viewportEvent (QEvent *event)
 
- Public Functions inherited from QFramePrivate
void init ()
 
 QFramePrivate ()
 
void updateFrameWidth ()
 Updated the frameWidth parameter. More...
 
void updateStyledFrameWidths ()
 Updates the frame widths from the style. More...
 
- Public Functions inherited from QWidgetPrivate
void _q_showIfNotHidden ()
 
virtual void aboutToDestroy ()
 
void activateChildLayoutsRecursively ()
 
QSize adjustedSize () const
 
void adjustQuitOnCloseAttribute ()
 
QInputContextassignedInputContext () const
 
QPainterbeginSharedPainter ()
 
QWidgetchildAt_helper (const QPoint &, bool) const
 
QWidgetchildAtRecursiveHelper (const QPoint &p, bool, bool includeFrame=false) const
 
QRect clipRect () const
 
QRegion clipRegion () const
 
void clipToEffectiveMask (QRegion &region) const
 
bool close_helper (CloseMode mode)
 
void create_sys (WId window, bool initializeWindow, bool destroyOldWindow)
 
QWindowSurfacecreateDefaultWindowSurface ()
 
QWindowSurfacecreateDefaultWindowSurface_sys ()
 
void createExtra ()
 Creates the widget extra data. More...
 
void createRecursively ()
 
void createSysExtra ()
 
void createTLExtra ()
 
void createTLSysExtra ()
 
void createWinId (WId id=0)
 
void deactivateWidgetCleanup ()
 
void deleteExtra ()
 Deletes the widget extra data. More...
 
void deleteSysExtra ()
 
void deleteTLSysExtra ()
 
void drawWidget (QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter=0, QWidgetBackingStore *backingStore=0)
 
QWidgeteffectiveFocusWidget ()
 
QRect effectiveRectFor (const QRect &rect) const
 
bool endSharedPainter ()
 
void enforceNativeChildren ()
 
QWExtraextraData () const
 
QRect frameStrut () const
 
void getLayoutItemMargins (int *left, int *top, int *right, int *bottom) const
 
const QRegiongetOpaqueChildren () const
 
void handleSoftwareInputPanel (Qt::MouseButton button, bool clickCausedFocus)
 
virtual bool hasHeightForWidth () const
 
void hide_helper ()
 
void hide_sys ()
 Platform-specific part of QWidget::hide(). More...
 
void hideChildren (bool spontaneous)
 
void inheritStyle ()
 
void init (QWidget *desktopWidget, Qt::WindowFlags f)
 
QInputContextinputContext () const
 
void invalidateBuffer (const QRegion &)
 Invalidates the rgn (in widget's coordinates) of the backing store, i.e. More...
 
void invalidateBuffer (const QRect &)
 This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but is more efficient as it eliminates QRegion operations/allocations and can use the rect more precisely for additional cut-offs. More...
 
void invalidateBuffer_resizeHelper (const QPoint &oldPos, const QSize &oldSize)
 Invalidates the buffer when the widget is resized. More...
 
void invalidateGraphicsEffectsRecursively ()
 
bool isAboutToShow () const
 
bool isBackgroundInherited () const
 
bool isOverlapped (const QRect &) const
 
void lower_sys ()
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QWidgetBackingStoremaybeBackingStore () const
 
QTLWExtramaybeTopData () const
 
void moveRect (const QRect &, int dx, int dy)
 
bool nativeChildrenForced () const
 
QFont naturalWidgetFont (uint inheritedMask) const
 
QPalette naturalWidgetPalette (uint inheritedMask) const
 Returns the palette that the widget w inherits from its ancestors and QApplication::palette. More...
 
void paintBackground (QPainter *, const QRegion &, int flags=DrawAsRoot) const
 
bool paintOnScreen () const
 
void paintSiblingsRecursive (QPaintDevice *pdev, const QObjectList &children, int index, const QRegion &rgn, const QPoint &offset, int flags, QPainter *sharedPainter, QWidgetBackingStore *backingStore)
 
bool pointInsideRectAndMask (const QPoint &) const
 
QRegion prepareToRender (const QRegion &region, QWidget::RenderFlags renderFlags)
 
void propagatePaletteChange ()
 Propagate this widget's palette to all children, except style sheet widgets, and windows that don't enable window propagation (palettes don't normally propagate to windows). More...
 
 QWidgetPrivate (int version=QObjectPrivateVersion)
 
void raise_sys ()
 
QPaintDeviceredirected (QPoint *offset) const
 
void registerDropSite (bool)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags, bool readyToRender)
 
void render_helper (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags)
 
void repaint_sys (const QRegion &rgn)
 
void reparentFocusWidgets (QWidget *oldtlw)
 
void resolveFont ()
 Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). More...
 
void resolveLayoutDirection ()
 
void resolveLocale ()
 
void resolvePalette ()
 Determine which palette is inherited from this widget's ancestors and QApplication::palette, resolve this against this widget's palette (attributes from the inherited palette are copied over this widget's palette). More...
 
void restoreRedirected ()
 
void scroll_sys (int dx, int dy)
 
void scroll_sys (int dx, int dy, const QRect &r)
 
void scrollChildren (int dx, int dy)
 
void scrollRect (const QRect &, int dx, int dy)
 
void sendPendingMoveAndResizeEvents (bool recursive=false, bool disableUpdates=false)
 
void sendStartupMessage (const char *message) const
 Platform-specific part of QWidget::show(). More...
 
void setConstraints_sys ()
 
void setCursor_sys (const QCursor &cursor)
 
void setDirtyOpaqueRegion ()
 
void setEnabled_helper (bool)
 
void setFocus_sys ()
 
void setFont_helper (const QFont &font)
 
void setGeometry_sys (int, int, int, int, bool)
 
void setLayoutDirection_helper (Qt::LayoutDirection)
 
void setLayoutItemMargins (int left, int top, int right, int bottom)
 
void setLayoutItemMargins (QStyle::SubElement element, const QStyleOption *opt=0)
 
void setLocale_helper (const QLocale &l, bool forceUpdate=false)
 
void setMask_sys (const QRegion &)
 
bool setMaximumSize_helper (int &maxw, int &maxh)
 
bool setMinimumSize_helper (int &minw, int &minh)
 
void setModal_sys ()
 
void setNetWmWindowTypes ()
 
void setOpaque (bool opaque)
 
void setPalette_helper (const QPalette &)
 
void setParent_sys (QWidget *parent, Qt::WindowFlags)
 
void setRedirected (QPaintDevice *replacement, const QPoint &offset)
 
void setSharedPainter (QPainter *painter)
 
void setStyle_helper (QStyle *newStyle, bool propagate, bool metalHack=false)
 
void setUpdatesEnabled_helper (bool)
 
void setWindowFilePath_helper (const QString &filePath)
 
void setWindowIcon_helper ()
 
void setWindowIcon_sys (bool forceReset=false)
 
void setWindowIconText_helper (const QString &cap)
 
void setWindowIconText_sys (const QString &cap)
 
void setWindowOpacity_sys (qreal opacity)
 
void setWindowRole ()
 
void setWindowTitle_helper (const QString &cap)
 
void setWindowTitle_sys (const QString &cap)
 
void setWinId (WId)
 
QPaintersharedPainter () const
 
void show_helper ()
 
void show_recursive ()
 Makes the widget visible in the isVisible() meaning of the word. More...
 
void show_sys ()
 Platform-specific part of QWidget::show(). More...
 
void showChildren (bool spontaneous)
 
void stackUnder_sys (QWidget *)
 
void subtractOpaqueChildren (QRegion &rgn, const QRect &clipRect) const
 
void subtractOpaqueSiblings (QRegion &source, bool *hasDirtySiblingsAbove=0, bool alsoNonOpaque=false) const
 
void syncBackingStore ()
 
void syncBackingStore (const QRegion &region)
 
QTLWExtratopData () const
 
void unsetCursor_sys ()
 
void updateFont (const QFont &)
 Assign font to this widget, and propagate it to all children, except style sheet widgets (handled differently) and windows that don't enable window propagation. More...
 
void updateFrameStrut ()
 Computes the frame rectangle when needed. More...
 
void updateGeometry_helper (bool forceUpdate)
 
void updateIsOpaque ()
 
void updateIsTranslucent ()
 
void updateSystemBackground ()
 
void updateX11AcceptFocus ()
 
void x11UpdateIsOpaque ()
 
 ~QWidgetPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QUrl currentURL
 
bool forceLoadOnSourceChange
 
QStack< HistoryEntryforwardStack
 
QUrl home
 
QCursor oldCursor
 
bool openExternalLinks
 
bool openLinks
 
QStringList searchPaths
 
QStack< HistoryEntrystack
 
bool textOrSourceChanged
 
- Public Variables inherited from QTextEditPrivate
QString anchorToScrollToWhenVisible
 
QTextEdit::AutoFormatting autoFormatting
 
QPoint autoScrollDragPos
 
QBasicTimer autoScrollTimer
 
uint clickCausedFocus: 1
 
QTextControlcontrol
 
uint ignoreAutomaticScrollbarAdjustment: 1
 
uint inDrag: 1
 
QTextEdit::LineWrapMode lineWrap
 
int lineWrapColumnOrWidth
 
uint preferRichText: 1
 
uint showCursorOnInitialShow: 1
 
bool tabChangesFocus
 
Qt::TextFormat textFormat
 
QTextOption::WrapMode wordWrap
 
- Public Variables inherited from QAbstractScrollAreaPrivate
int bottom
 
QRect cornerPaintingRect
 
QWidgetcornerWidget
 
QScrollBarhbar
 
Qt::ScrollBarPolicy hbarpolicy
 
int left
 
QRect reverseCornerPaintingRect
 
int right
 
QAbstractScrollAreaScrollBarContainerscrollBarContainers [Qt::Vertical+1]
 
bool singleFingerPanEnabled
 
int top
 
QScrollBarvbar
 
Qt::ScrollBarPolicy vbarpolicy
 
QWidgetviewport
 
QScopedPointer< QObjectviewportFilter
 
int xoffset
 
int yoffset
 
- Public Variables inherited from QFramePrivate
short bottomFrameWidth
 
int frameStyle
 
short frameWidth
 
QRect frect
 
short leftFrameWidth
 
short lineWidth
 
short midLineWidth
 
short rightFrameWidth
 
short topFrameWidth
 
- Public Variables inherited from QWidgetPrivate
QString accessibleDescription
 
QString accessibleName
 
QList< QAction * > actions
 
QPalette::ColorRole bg_role: 8
 
signed char bottomLayoutItemMargin
 
short bottommargin
 
QWidgetData data
 
QRegion dirty
 
uint dirtyOpaqueChildren: 1
 
QWExtraextra
 
QPaintEngineextraPaintEngine
 
QPalette::ColorRole fg_role: 8
 
QWidgetfocus_child
 
QWidgetfocus_next
 
QWidgetfocus_prev
 
QMap< Qt::GestureType, Qt::GestureFlags > gestureContext
 
QGraphicsEffectgraphicsEffect
 
Qt::HANDLE hd
 
uint high_attributes [4]
 
QPointer< QInputContextic
 
Qt::InputMethodHints imHints
 
uint inDirtyList: 1
 
uint inheritedFontResolveMask
 
uint inheritedPaletteResolveMask
 
uint inheritsInputMethodHints: 1
 
uint inSetParent: 1
 
uint isGLWidget: 1
 
uint isMoved: 1
 
uint isOpaque: 1
 
uint isScrolled: 1
 
QLayoutlayout
 
signed char leftLayoutItemMargin
 
short leftmargin
 
QLocale locale
 
QRegionneedsFlush
 
QRegion opaqueChildren
 
Qt::HANDLE picture
 
const QMetaObjectpolished
 
QPaintDeviceredirectDev
 
QPoint redirectOffset
 
signed char rightLayoutItemMargin
 
short rightmargin
 
QSizePolicy size_policy
 
QString statusTip
 
QString toolTip
 
signed char topLayoutItemMargin
 
short topmargin
 
uint usesDoubleBufferedGLContext: 1
 
QString whatsThis
 
QWidgetItemV2widgetItem
 
QX11Info xinfo
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QWidgetPrivate
enum  CloseMode { CloseNoEvent, CloseWithEvent, CloseWithSpontaneousEvent }
 
enum  Direction { DirectionNorth = 0x01, DirectionEast = 0x10, DirectionSouth = 0x02, DirectionWest = 0x20 }
 
enum  DrawWidgetFlags {
  DrawAsRoot = 0x01, DrawPaintOnScreen = 0x02, DrawRecursive = 0x04, DrawInvisible = 0x08,
  DontSubtractOpaqueChildren = 0x10, DontSetCompositionMode = 0x20, DontDrawOpaqueChildren = 0x40, DontDrawNativeChildren = 0x80
}
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QWidgetPrivate
static void adjustFlags (Qt::WindowFlags &flags, QWidget *w=0)
 
static QGraphicsProxyWidgetnearestGraphicsProxyWidget (const QWidget *origin)
 Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this widget and its ancestors. More...
 
static int pointToRect (const QPoint &p, const QRect &r)
 
static QRect screenGeometry (const QWidget *widget)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 
- Static Public Variables inherited from QWidgetPrivate
static QWidgetSetallWidgets = 0
 
static int instanceCounter = 0
 
static QWidgetkeyboardGrabber = 0
 
static QWidgetMappermapper = 0
 
static int maxInstances = 0
 
static QWidgetmouseGrabber = 0
 

Detailed Description

Definition at line 63 of file qtextbrowser.cpp.

Constructors and Destructors

◆ QTextBrowserPrivate()

QTextBrowserPrivate::QTextBrowserPrivate ( )
inline

Definition at line 67 of file qtextbrowser.cpp.

69  openLinks(true)
70 #ifdef QT_KEYPAD_NAVIGATION
71  , lastKeypadScrollValue(-1)
72 #endif
73  {}

Functions

◆ _q_activateAnchor()

void QTextBrowserPrivate::_q_activateAnchor ( const QString href)

Definition at line 198 of file qtextbrowser.cpp.

Referenced by _q_documentModified(), and init().

199 {
200  if (href.isEmpty())
201  return;
202  Q_Q(QTextBrowser);
203 
204 #ifndef QT_NO_CURSOR
206 #endif
207 
208  const QUrl url = resolveUrl(href);
209 
210  if (!openLinks) {
211  emit q->anchorClicked(url);
212  return;
213  }
214 
215  textOrSourceChanged = false;
216 
217 #ifndef QT_NO_DESKTOPSERVICES
218  if ((openExternalLinks
219  && url.scheme() != QLatin1String("file")
220  && url.scheme() != QLatin1String("qrc")
221  && !url.isRelative())
222  || (url.isRelative() && !currentURL.isRelative()
223  && currentURL.scheme() != QLatin1String("file")
224  && currentURL.scheme() != QLatin1String("qrc"))) {
226  return;
227  }
228 #endif
229 
230  emit q->anchorClicked(url);
231 
233  return;
234 
235  q->setSource(url);
236 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
#define Q_Q(Class)
Definition: qglobal.h:2483
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
virtual QUrl resolveUrl(const QUrl &url) const
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user&#39;s desktop environment, and returns true if successful; otherwise returns false.

◆ _q_documentModified()

void QTextBrowserPrivate::_q_documentModified ( )
inline

Definition at line 128 of file qtextbrowser.cpp.

Referenced by init().

129  {
130  textOrSourceChanged = true;
132  }
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704

◆ _q_highlightLink()

void QTextBrowserPrivate::_q_highlightLink ( const QString href)

Definition at line 238 of file qtextbrowser.cpp.

Referenced by _q_documentModified(), and init().

239 {
240  Q_Q(QTextBrowser);
241  if (anchor.isEmpty()) {
242 #ifndef QT_NO_CURSOR
246 #endif
247  emit q->highlighted(QUrl());
248  emit q->highlighted(QString());
249  } else {
250 #ifndef QT_NO_CURSOR
252 #endif
253 
254  const QUrl url = resolveUrl(anchor);
255  emit q->highlighted(url);
256  // convenience to ease connecting to QStatusBar::showMessage(const QString &)
257  emit q->highlighted(url.toString());
258  }
259 }
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
#define emit
Definition: qobjectdefs.h:76
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
virtual QUrl resolveUrl(const QUrl &url) const
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
Qt::CursorShape shape() const
Returns the cursor shape identifier.
Definition: qcursor.cpp:469

◆ createHistoryEntry()

QTextBrowserPrivate::HistoryEntry QTextBrowserPrivate::createHistoryEntry ( ) const

Definition at line 537 of file qtextbrowser.cpp.

Referenced by history().

538 {
539  HistoryEntry entry;
540  entry.url = q_func()->source();
541  entry.title = q_func()->documentTitle();
542  entry.hpos = hbar->value();
543  entry.vpos = vbar->value();
544 
545  const QTextCursor cursor = control->textCursor();
547  && cursor.hasSelection()) {
548 
549  entry.focusIndicatorPosition = cursor.position();
550  entry.focusIndicatorAnchor = cursor.anchor();
551  }
552  return entry;
553 }
int anchor() const
Returns the anchor position; this is the same as position() unless there is a selection in which case...
QTextCursor textCursor() const
int value() const
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
int position() const
Returns the absolute position of the cursor within the document.
QTextControl * control
Definition: qtextedit_p.h:109
bool cursorIsFocusIndicator() const

◆ findFile()

QString QTextBrowserPrivate::findFile ( const QUrl name) const

Definition at line 151 of file qtextbrowser.cpp.

152 {
154  if (name.scheme() == QLatin1String("qrc"))
155  fileName = QLatin1String(":/") + name.path();
156  else
157  fileName = name.toLocalFile();
158 
159  if (QFileInfo(fileName).isAbsolute())
160  return fileName;
161 
162  foreach (QString path, searchPaths) {
163  if (!path.endsWith(QLatin1Char('/')))
164  path.append(QLatin1Char('/'));
165  path.append(fileName);
166  if (QFileInfo(path).isReadable())
167  return path;
168  }
169 
170  return fileName;
171 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QStringList searchPaths
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
QString & append(QChar c)
Definition: qstring.cpp:1777
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
static QString fileName(const QString &fileUrl)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ history()

HistoryEntry QTextBrowserPrivate::history ( int  i) const
inline

Definition at line 88 of file qtextbrowser.cpp.

89  {
90  if (i <= 0)
91  if (-i < stack.count())
92  return stack[stack.count()+i-1];
93  else
94  return HistoryEntry();
95  else
96  if (i <= forwardStack.count())
97  return forwardStack[forwardStack.count()-i];
98  else
99  return HistoryEntry();
100  }
QStack< HistoryEntry > stack
QStack< HistoryEntry > forwardStack

◆ init()

void QTextBrowserPrivate::init ( )

Definition at line 659 of file qtextbrowser.cpp.

Referenced by QTextBrowserPrivate().

660 {
661  Q_Q(QTextBrowser);
663 #ifndef QT_NO_CURSOR
665 #endif
666  q->setUndoRedoEnabled(false);
667  viewport->setMouseTracking(true);
668  QObject::connect(q->document(), SIGNAL(contentsChanged()), q, SLOT(_q_documentModified()));
669  QObject::connect(control, SIGNAL(linkActivated(QString)),
671  QObject::connect(control, SIGNAL(linkHovered(QString)),
673 }
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_Q(Class)
Definition: qglobal.h:2483
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void _q_highlightLink(const QString &href)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
void setMouseTracking(bool enable)
Definition: qwidget.h:990
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
void _q_activateAnchor(const QString &href)
QTextControl * control
Definition: qtextedit_p.h:109

◆ resolveUrl() [1/2]

QUrl QTextBrowserPrivate::resolveUrl ( const QUrl url) const
virtual

Reimplemented from QTextEditPrivate.

Definition at line 173 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor(), _q_documentModified(), _q_highlightLink(), resolveUrl(), restoreHistoryEntry(), and setSource().

174 {
175  if (!url.isRelative())
176  return url;
177 
178  // For the second case QUrl can merge "#someanchor" with "foo.html"
179  // correctly to "foo.html#someanchor"
180  if (!(currentURL.isRelative()
181  || (currentURL.scheme() == QLatin1String("file")
182  && !QFileInfo(currentURL.toLocalFile()).isAbsolute()))
183  || (url.hasFragment() && url.path().isEmpty())) {
184  return currentURL.resolved(url);
185  }
186 
187  // this is our last resort when current url and new url are both relative
188  // we try to resolve against the current working directory in the local
189  // file system.
191  if (fi.exists()) {
192  return QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(url);
193  }
194 
195  return url;
196 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
QString path() const
Returns the path of the URL.
Definition: qurl.cpp:4977
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
Definition: qurl.cpp:6412
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
bool hasFragment() const
Returns true if this URL contains a fragment (i.
Definition: qurl.cpp:5773
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition: qurl.cpp:6374
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition: qurl.cpp:5819
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ resolveUrl() [2/2]

QUrl QTextBrowserPrivate::resolveUrl ( const QString url) const
inline

Definition at line 141 of file qtextbrowser.cpp.

142  { return resolveUrl(QUrl::fromEncoded(url.toUtf8())); }
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
virtual QUrl resolveUrl(const QUrl &url) const
static QUrl fromEncoded(const QByteArray &url)
Parses input and returns the corresponding QUrl.
Definition: qurl.cpp:5964

◆ restoreHistoryEntry()

void QTextBrowserPrivate::restoreHistoryEntry ( const HistoryEntry  entry)

Definition at line 555 of file qtextbrowser.cpp.

Referenced by history().

556 {
557  setSource(entry.url);
558  hbar->setValue(entry.hpos);
559  vbar->setValue(entry.vpos);
560  if (entry.focusIndicatorAnchor != -1 && entry.focusIndicatorPosition != -1) {
561  QTextCursor cursor(control->document());
562  cursor.setPosition(entry.focusIndicatorAnchor);
563  cursor.setPosition(entry.focusIndicatorPosition, QTextCursor::KeepAnchor);
564  control->setTextCursor(cursor);
566  }
567 #ifdef QT_KEYPAD_NAVIGATION
568  lastKeypadScrollValue = vbar->value();
569  prevFocus = control->textCursor();
570 
571  Q_Q(QTextBrowser);
572  const QString href = prevFocus.charFormat().anchorHref();
573  QUrl url = resolveUrl(href);
574  emit q->highlighted(url);
575  emit q->highlighted(url.toString());
576 #endif
577 }
void setTextCursor(const QTextCursor &cursor)
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setSource(const QUrl &url)
QTextCursor textCursor() const
#define Q_Q(Class)
Definition: qglobal.h:2483
int value() const
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
#define emit
Definition: qobjectdefs.h:76
virtual QUrl resolveUrl(const QUrl &url) const
QTextDocument * document() const
void setCursorIsFocusIndicator(bool b)
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
QTextControl * control
Definition: qtextedit_p.h:109
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...

◆ setSource()

void QTextBrowserPrivate::setSource ( const QUrl url)

Definition at line 261 of file qtextbrowser.cpp.

Referenced by _q_documentModified(), and restoreHistoryEntry().

262 {
263  Q_Q(QTextBrowser);
264 #ifndef QT_NO_CURSOR
265  if (q->isVisible())
267 #endif
268  textOrSourceChanged = true;
269 
270  QString txt;
271 
272  bool doSetText = false;
273 
274  QUrl currentUrlWithoutFragment = currentURL;
275  currentUrlWithoutFragment.setFragment(QString());
276  QUrl newUrlWithoutFragment = currentURL.resolved(url);
277  newUrlWithoutFragment.setFragment(QString());
278 
279  if (url.isValid()
280  && (newUrlWithoutFragment != currentUrlWithoutFragment || forceLoadOnSourceChange)) {
281  QVariant data = q->loadResource(QTextDocument::HtmlResource, resolveUrl(url));
282  if (data.type() == QVariant::String) {
283  txt = data.toString();
284  } else if (data.type() == QVariant::ByteArray) {
285 #ifndef QT_NO_TEXTCODEC
286  QByteArray ba = data.toByteArray();
288  txt = codec->toUnicode(ba);
289 #else
290  txt = data.toString();
291 #endif
292  }
293  if (txt.isEmpty())
294  qWarning("QTextBrowser: No document for %s", url.toString().toLatin1().constData());
295 
296  if (q->isVisible()) {
297  QString firstTag = txt.left(txt.indexOf(QLatin1Char('>')) + 1);
298  if (firstTag.startsWith(QLatin1String("<qt")) && firstTag.contains(QLatin1String("type")) && firstTag.contains(QLatin1String("detail"))) {
299 #ifndef QT_NO_CURSOR
301 #endif
302 #ifndef QT_NO_WHATSTHIS
304 #endif
305  return;
306  }
307  }
308 
309  currentURL = resolveUrl(url);
310  doSetText = true;
311  }
312 
313  if (!home.isValid())
314  home = url;
315 
316  if (doSetText) {
317 #ifndef QT_NO_TEXTHTMLPARSER
318  q->QTextEdit::setHtml(txt);
319  q->document()->setMetaInformation(QTextDocument::DocumentUrl, currentURL.toString());
320 #else
321  q->QTextEdit::setPlainText(txt);
322 #endif
323 
324 #ifdef QT_KEYPAD_NAVIGATION
325  prevFocus.movePosition(QTextCursor::Start);
326 #endif
327  }
328 
329  forceLoadOnSourceChange = false;
330 
331  if (!url.fragment().isEmpty()) {
332  q->scrollToAnchor(url.fragment());
333  } else {
334  hbar->setValue(0);
335  vbar->setValue(0);
336  }
337 #ifdef QT_KEYPAD_NAVIGATION
338  lastKeypadScrollValue = vbar->value();
339  emit q->highlighted(QUrl());
340  emit q->highlighted(QString());
341 #endif
342 
343 #ifndef QT_NO_CURSOR
344  if (q->isVisible())
346 #endif
347  emit q->sourceChanged(url);
348 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString fragment() const
Returns the fragment of the URL.
Definition: qurl.cpp:5687
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
#define Q_Q(Class)
Definition: qglobal.h:2483
QWidgetData data
Definition: qwidget_p.h:755
int value() const
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define emit
Definition: qobjectdefs.h:76
Q_CORE_EXPORT void qWarning(const char *,...)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
static QTextCodec * codec(MYSQL *mysql)
Definition: qsql_mysql.cpp:220
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
virtual QUrl resolveUrl(const QUrl &url) const
void setFragment(const QString &fragment)
Sets the fragment of the URL to fragment.
Definition: qurl.cpp:5669
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
static void setOverrideCursor(const QCursor &)
Use changeOverrideCursor(cursor) (if replace is true) or setOverrideCursor(cursor) (if replace is fal...
static void restoreOverrideCursor()
Undoes the last setOverrideCursor().
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static void showText(const QPoint &pos, const QString &text, QWidget *w=0)
Shows text as a "What&#39;s This?" window, at global position pos.
Definition: qwhatsthis.cpp:754
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition: qurl.cpp:5819
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
Q_GUI_EXPORT QTextCodec * codecForHtml(const QByteArray &ba)
This function is defined in the <QTextDocument> header file.

Properties

◆ currentURL

QUrl QTextBrowserPrivate::currentURL

Definition at line 109 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor(), resolveUrl(), and setSource().

◆ forceLoadOnSourceChange

bool QTextBrowserPrivate::forceLoadOnSourceChange

Definition at line 117 of file qtextbrowser.cpp.

Referenced by setSource().

◆ forwardStack

QStack<HistoryEntry> QTextBrowserPrivate::forwardStack

Definition at line 107 of file qtextbrowser.cpp.

Referenced by history().

◆ home

QUrl QTextBrowserPrivate::home

Definition at line 108 of file qtextbrowser.cpp.

Referenced by setSource().

◆ oldCursor

QCursor QTextBrowserPrivate::oldCursor

Definition at line 123 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor(), _q_highlightLink(), and init().

◆ openExternalLinks

bool QTextBrowserPrivate::openExternalLinks

Definition at line 119 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor().

◆ openLinks

bool QTextBrowserPrivate::openLinks

Definition at line 120 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor().

◆ searchPaths

QStringList QTextBrowserPrivate::searchPaths

Definition at line 111 of file qtextbrowser.cpp.

Referenced by findFile().

◆ stack

QStack<HistoryEntry> QTextBrowserPrivate::stack

Definition at line 106 of file qtextbrowser.cpp.

Referenced by history().

◆ textOrSourceChanged

bool QTextBrowserPrivate::textOrSourceChanged

Definition at line 116 of file qtextbrowser.cpp.

Referenced by _q_activateAnchor(), and setSource().


The documentation for this class was generated from the following file: