# eric4.Helpviewer.HelpBrowserWV

Module implementing the helpbrowser using QWebView.

### Global Attributes

None

### Classes

HelpBrowser | Class implementing the helpbrowser widget.
HelpWebPage | Class implementing an enhanced web page.
JavaScriptEricObject | Class implementing an external javascript object to search via the startpage.
JavaScriptExternalObject | Class implementing an external javascript object to add search providers.
LinkedResource | Class defining a data structure for linked resources.

### Functions

None

## HelpBrowser

Class implementing the helpbrowser widget.

This is a subclass of the Qt QWebView to implement an interface compatible with the QTextBrowser based variant.

### Signals

backwardAvailable(bool)
  emitted after the current URL has changed
forwardAvailable(bool)
  emitted after the current URL has changed
highlighted(const QString&)
  emitted, when the mouse hovers over a link
search(const QUrl &)
  emitted, when a search is requested
sourceChanged(const QUrl &)
  emitted after the current URL has changed

### Derived from

QWebView

### Class Attributes

None

### Class Methods

None

### Methods

HelpBrowser | Constructor
__addBookmark | Private slot to bookmark the current link.
__addExternalBinding | Private slot to add javascript bindings for adding search providers.
__applyZoom | Private slot to apply the current zoom factor.
__blockImage | Private slot to add a block rule for an image URL.
__bookmarkLink | Private slot to bookmark a link via the context menu.
__copyImage | Private slot to copy an image to the clipboard.
__copyImageLocation | Private slot to copy an image location to the clipboard.
__copyLink | Private slot to copy a link to the clipboard.
__currentEngineChanged | Private slot to track a change of the current search engine.
__downloadDone | Private slot to handle the done signal of the download dialogs.
__downloadImage | Private slot to download an image and save it to disk.
__downloadLink | Private slot to download a link and save it to disk.
__downloadRequested | Private slot to handle a download request.
__iconChanged | Private slot to handle the icon change.
__levelForZoom | Private method determining the zoom level index given a zoom factor.
__linkHovered | Private slot to handle the linkHovered signal.
__loadFinished | Private method to handle the loadFinished signal.
__loadProgress | Private method to handle the loadProgress signal.
__loadStarted | Private method to handle the loadStarted signal.
__openLinkInNewTab | Private method called by the context menu to open a link in a new window.
__searchRequested | Private slot to search for some text with a selected search engine.
__statusBarMessage | Private slot to handle the statusBarMessage signal.
__unsupportedContent | Private slot to handle the unsupportedContent signal.
__urlChanged | Private slot to handle the urlChanged signal.
__webInspector | Private slot to show the web inspector window.
backward | Public slot to move backwards in history.
clearHistory | Public slot to clear the history.
contextMenuEvent | Protected method called to create a context menu.
copy | Public slot to copy the selected text.
createWindow | Protected method called, when a new window should be created.
documentTitle | Public method to return the title of the loaded page.
findNextPrev | Public slot to find the next occurrence of a text.
forward | Public slot to move forward in history.
hasSelection | Public method to determine, if there is some text selected.
home | Public slot to move to the first page loaded.
isBackwardAvailable | Public method to determine, if a backwards move in history is possible.
isForwardAvailable | Public method to determine, if a forward move in history is possible.
isLoading | Public method to get the loading state.
keyPressEvent | Protected method called by a key press.
keyReleaseEvent | Protected method called by a key release.
linkedResources | Public method to extract linked resources.
mousePressEvent | Protected method called by a mouse press event.
preferencesChanged | Public method to indicate a change of the settings.
reload | Public slot to reload the current page.
saveAs | Public method to save the current page to a file.
setSource | Public method used to set the source to be displayed.
source | Public method to return the URL of the loaded page.
wheelEvent | Protected method to handle wheel events.
zoomIn | Public slot to zoom into the page.
zoomOut | Public slot to zoom out of the page.
zoomReset | Public method to reset the zoom factor.

### Static Methods

None

#### HelpBrowser (Constructor)

HelpBrowser(parent = None, name = QString(""))

Constructor

parent
  parent widget of this window (QWidget)
name
  name of this window (string or QString)

#### HelpBrowser.__addBookmark

__addBookmark()

Private slot to bookmark the current link.

#### HelpBrowser.__addExternalBinding

__addExternalBinding(frame = None)

Private slot to add javascript bindings for adding search providers.

frame
  reference to the web frame (QWebFrame)

#### HelpBrowser.__applyZoom

__applyZoom()

Private slot to apply the current zoom factor.

#### HelpBrowser.__blockImage

__blockImage()

Private slot to add a block rule for an image URL.

#### HelpBrowser.__bookmarkLink

__bookmarkLink()

Private slot to bookmark a link via the context menu.

#### HelpBrowser.__copyImage

__copyImage()

Private slot to copy an image to the clipboard.

#### HelpBrowser.__copyImageLocation

__copyImageLocation()

Private slot to copy an image location to the clipboard.

#### HelpBrowser.__copyLink

__copyLink()

Private slot to copy a link to the clipboard.

#### HelpBrowser.__currentEngineChanged

__currentEngineChanged()

Private slot to track a change of the current search engine.

#### HelpBrowser.__downloadDone

__downloadDone()

Private slot to handle the done signal of the download dialogs.

#### HelpBrowser.__downloadImage

__downloadImage()

Private slot to download an image and save it to disk.

#### HelpBrowser.__downloadLink

__downloadLink()

Private slot to download a link and save it to disk.

#### HelpBrowser.__downloadRequested

__downloadRequested(request)

Private slot to handle a download request.

request
  reference to the request object (QNetworkRequest)

#### HelpBrowser.__iconChanged

__iconChanged()

Private slot to handle the icon change.

#### HelpBrowser.__levelForZoom

__levelForZoom(zoom)

Private method determining the zoom level index given a zoom factor.

zoom
  zoom factor (integer)

Returns:
  index of zoom factor (integer)

#### HelpBrowser.__linkHovered

__linkHovered(link, title, textContent)

Private slot to handle the linkHovered signal.

link
  the URL of the link (QString)
title
  the link title (QString)
textContent
  text content of the link (QString)

#### HelpBrowser.__loadFinished

__loadFinished(ok)

Private method to handle the loadFinished signal.

ok
  flag indicating the result (boolean)

#### HelpBrowser.__loadProgress

__loadProgress(progress)

Private method to handle the loadProgress signal.

progress
  progress value (integer)

#### HelpBrowser.__loadStarted

__loadStarted()

Private method to handle the loadStarted signal.

#### HelpBrowser.__openLinkInNewTab

__openLinkInNewTab()

Private method called by the context menu to open a link in a new window.

#### HelpBrowser.__searchRequested

__searchRequested(act)

Private slot to search for some text with a selected search engine.

act
  reference to the action that triggered this slot (QAction)

#### HelpBrowser.__statusBarMessage

__statusBarMessage(text)

Private slot to handle the statusBarMessage signal.

text
  text to be shown in the status bar (QString)

#### HelpBrowser.__unsupportedContent

__unsupportedContent(reply, requestFilename = None, download = False)

Private slot to handle the unsupportedContent signal.

reply
  reference to the reply object (QNetworkReply)
requestFilename=
  indicating to ask for a filename (boolean or None). If it is None, the behavior is determined by a configuration option.
download=
  flag indicating a download operation (boolean)

#### HelpBrowser.__urlChanged

__urlChanged(url)

Private slot to handle the urlChanged signal.

url
  the new url (QUrl)

#### HelpBrowser.__webInspector

__webInspector()

Private slot to show the web inspector window.

#### HelpBrowser.backward

backward()

Public slot to move backwards in history.

#### HelpBrowser.clearHistory

clearHistory()

Public slot to clear the history.

#### HelpBrowser.contextMenuEvent

contextMenuEvent(evt)

Protected method called to create a context menu.

This method is overridden from QWebView.

evt
  reference to the context menu event object (QContextMenuEvent)

#### HelpBrowser.copy

copy()

Public slot to copy the selected text.

#### HelpBrowser.createWindow

createWindow(windowType)

Protected method called, when a new window should be created.

windowType
  type of the requested window (QWebPage.WebWindowType)

#### HelpBrowser.documentTitle

documentTitle()

Public method to return the title of the loaded page.

Returns:
  title (QString)

#### HelpBrowser.findNextPrev

findNextPrev(txt, case, backwards, wrap)

Public slot to find the next occurrence of a text.

txt
  text to search for (QString)
case
  flag indicating a case sensitive search (boolean)
backwards
  flag indicating a backwards search (boolean)
wrap
  flag indicating to wrap around (boolean)

#### HelpBrowser.forward

forward()

Public slot to move forward in history.

#### HelpBrowser.hasSelection

hasSelection()

Public method to determine, if there is some text selected.

Returns:
  flag indicating text has been selected (boolean)

#### HelpBrowser.home

home()

Public slot to move to the first page loaded.

#### HelpBrowser.isBackwardAvailable

isBackwardAvailable()

Public method to determine, if a backwards move in history is possible.

Returns:
  flag indicating move backwards is possible (boolean)

#### HelpBrowser.isForwardAvailable

isForwardAvailable()

Public method to determine, if a forward move in history is possible.

Returns:
  flag indicating move forward is possible (boolean)

#### HelpBrowser.isLoading

isLoading()

Public method to get the loading state.

Returns:
  flag indicating the loading state (boolean)

#### HelpBrowser.keyPressEvent

keyPressEvent(evt)

Protected method called by a key press.

This method is overridden from QTextBrowser.

evt
  the key event (QKeyEvent)

#### HelpBrowser.keyReleaseEvent

keyReleaseEvent(evt)

Protected method called by a key release.

This method is overridden from QTextBrowser.

evt
  the key event (QKeyEvent)

#### HelpBrowser.linkedResources

linkedResources(relation = QString())

Public method to extract linked resources.

relation
  relation to extract (QString)

Returns:
  list of linked resources (list of LinkedResource)

#### HelpBrowser.mousePressEvent

mousePressEvent(evt)

Protected method called by a mouse press event.

evt
  reference to the mouse event (QMouseEvent)

#### HelpBrowser.preferencesChanged

preferencesChanged()

Public method to indicate a change of the settings.

#### HelpBrowser.reload

reload()

Public slot to reload the current page.

#### HelpBrowser.saveAs

saveAs()

Public method to save the current page to a file.

#### HelpBrowser.setSource

setSource(name)

Public method used to set the source to be displayed.

name
  filename to be shown (QUrl)

#### HelpBrowser.source

source()

Public method to return the URL of the loaded page.

Returns:
  URL loaded in the help browser (QUrl)

#### HelpBrowser.wheelEvent

wheelEvent(evt)

Protected method to handle wheel events.

evt
  reference to the wheel event (QWheelEvent)

#### HelpBrowser.zoomIn

zoomIn()

Public slot to zoom into the page.

#### HelpBrowser.zoomOut

zoomOut()

Public slot to zoom out of the page.

#### HelpBrowser.zoomReset

zoomReset()

Public method to reset the zoom factor.

Up

## HelpWebPage

Class implementing an enhanced web page.

### Derived from

QWebPage

### Class Attributes

None

### Class Methods

None

### Methods

HelpWebPage | Constructor
acceptNavigationRequest | Protected method to determine, if a request may be accepted.
extension | Public method to implement a specific extension.
pageAttributeId | Public method to get the attribute id of the page attribute.
populateNetworkRequest | Public method to add data to a network request.
supportsExtension | Public method to check the support for an extension.
userAgentForUrl | Protected method to determine the user agent for the given URL.

### Static Methods

None

#### HelpWebPage (Constructor)

HelpWebPage(parent = None)

Constructor

parent
  parent widget of this window (QWidget)

#### HelpWebPage.acceptNavigationRequest

acceptNavigationRequest(frame, request, type_)

Protected method to determine, if a request may be accepted.

frame
  reference to the frame sending the request (QWebFrame)
request
  reference to the request object (QNetworkRequest)
type_
  type of the navigation request (QWebPage.NavigationType)

Returns:
  flag indicating acceptance (boolean)

#### HelpWebPage.extension

extension(extension, option, output)

Public method to implement a specific extension.

extension
  extension to be executed (QWebPage.Extension)
option
  provides input to the extension (QWebPage.ExtensionOption)
output
  stores the output results (QWebPage.ExtensionReturn)

Returns:
  flag indicating a successful call of the extension (boolean)

#### HelpWebPage.pageAttributeId

pageAttributeId()

Public method to get the attribute id of the page attribute.

Returns:
  attribute id of the page attribute (integer)

#### HelpWebPage.populateNetworkRequest

populateNetworkRequest(request)

Public method to add data to a network request.

request
  reference to the network request object (QNetworkRequest)

#### HelpWebPage.supportsExtension

supportsExtension(extension)

Public method to check the support for an extension.

extension
  extension to test for (QWebPage.Extension)

Returns:
  flag indicating the support of extension (boolean)

#### HelpWebPage.userAgentForUrl

userAgentForUrl(url)

Protected method to determine the user agent for the given URL.

url
  URL to determine user agent for (QUrl)

Returns:
  user agent string (string)

Up

## JavaScriptEricObject

Class implementing an external javascript object to search via the startpage.

### Derived from

QObject

### Class Attributes

translations

### Class Methods

None

### Methods

JavaScriptEricObject | Constructor
providerString | Public method to get a string for the search provider.
searchUrl | Public method to get the search URL for the given search term.
translate | Public method to translate the given string.

### Static Methods

None

#### JavaScriptEricObject (Constructor)

JavaScriptEricObject(mw, parent = None)

Constructor

mw
  reference to the main window 8HelpWindow)
parent
  reference to the parent object (QObject)

#### JavaScriptEricObject.providerString

providerString()

Public method to get a string for the search provider.

Returns:
  string for the search provider (QString)

#### JavaScriptEricObject.searchUrl

searchUrl(searchStr)

Public method to get the search URL for the given search term.

searchStr
  search term (QString)

Returns:
  search URL (QString)

#### JavaScriptEricObject.translate

translate(trans)

Public method to translate the given string.

trans
  string to be translated (QString)

Returns:
  translation (QString)

Up

## JavaScriptExternalObject

Class implementing an external javascript object to add search providers.

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

JavaScriptExternalObject | Constructor
AddSearchProvider | Public slot to add a search provider.

### Static Methods

None

#### JavaScriptExternalObject (Constructor)

JavaScriptExternalObject(mw, parent = None)

Constructor

mw
  reference to the main window 8HelpWindow)
parent
  reference to the parent object (QObject)

#### JavaScriptExternalObject.AddSearchProvider

AddSearchProvider(url)

Public slot to add a search provider.

url
  url of the XML file defining the search provider (QString)

Up

## LinkedResource

Class defining a data structure for linked resources.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

LinkedResource | Constructor

### Static Methods

None

#### LinkedResource (Constructor)

LinkedResource()

Constructor

Up