org.kde.koala
public class KHTMLPart extends ReadOnlyPart
KURL url = "http://www.kde.org"; KHTMLPart w = new KHTMLPart(); w.openURL(url); w.view().resize(500, 400); w.show();Java and JavaScript are enabled by default depending on the user's settings. If you do not need them, and especially if you display unfiltered data from untrusted sources, it is strongly recommended to turn them off. In that case, you should also turn off the automatic redirect and plugins:
w.setJScriptEnabled(false); w.setJavaEnabled(false); w.setMetaRefreshEnabled(false); w.setPluginsEnabled(false);You may also wish to disable external references. This will prevent KHTML from loading images, frames, etc, or redirecting to external sites.
w.setOnlyLocalReferences(true);Some apps want to write their HTML code directly into the widget instead of opening an url. You can do this in the following way:
String myHTMLCode = ...; KHTMLPart w = new KHTMLPart(); w.begin(); w.write(myHTMLCode); ... w.end();You can do as many calls to write() as you wish. There are two write() methods, one accepting a String and one accepting a
char
argument.
You should use one or the other
(but not both) since the method using
the char
argument
does an additional decoding step to convert the
written data to Unicode.
It is also possible to write content to the HTML part using the
standard streaming API from KParts.ReadOnlyPart. The usage of
the API is similar to that of the begin(), write(), end() process
described above as the following example shows:
KHTMLPart doc = new KHTMLPart(); doc.openStream( "text/html", KURL() ); doc.writeStream( String( "See KHTMLPartSignals for signals emitted by KHTMLPartKHTML Rocks!
" ) ); doc.closeStream();
UNKNOWN: HTML Browser Widget.
Field Summary | |
---|---|
static int | Before |
static int | BrowserViewGUI |
static int | CaretBlink |
static int | CaretInvisible |
static int | CaretVisible
Enumeration for displaying the caret. |
static int | DefaultGUI |
static int | Encrypted |
static int | FindLinksOnly
Extra Find options that can be used when calling the extended findText(). |
static int | FindNoPopups |
static int | Mixed |
static int | NoNotification |
static int | NotCrypted |
static int | Only |
static int | Unused |
Constructor Summary | |
---|---|
protected | KHTMLPart(Class dummy) |
KHTMLPart(QWidget parentWidget, String widgetname, QObject parent, String name, int prof)
Constructs a new KHTMLPart.
| |
KHTMLPart(QWidget parentWidget, String widgetname, QObject parent, String name) | |
KHTMLPart(QWidget parentWidget, String widgetname, QObject parent) | |
KHTMLPart(QWidget parentWidget, String widgetname) | |
KHTMLPart(QWidget parentWidget) | |
KHTMLPart() | |
KHTMLPart(KHTMLView view, QObject parent, String name, int prof) | |
KHTMLPart(KHTMLView view, QObject parent, String name) | |
KHTMLPart(KHTMLView view, QObject parent) | |
KHTMLPart(KHTMLView view) |
Method Summary | |
---|---|
Node | activeNode()
Returns the node that has the keyboard focus. |
boolean | autoloadImages()
Returns whether images contained in the document are loaded automatically
or not. |
void | autoloadImages(boolean e) |
KURL | backgroundURL()
Returns the URL for the background Image (used by save background) |
String | baseTarget() |
KURL | baseURL() |
void | begin(KURL url, int xOffset, int yOffset)
Clears the widget and prepares it for new content.
|
void | begin(KURL url, int xOffset) |
void | begin(KURL url) |
void | begin() |
BrowserExtension | browserExtension()
Returns a pointer to the KParts.BrowserExtension. |
BrowserHostExtension | browserHostExtension() |
int | caretDisplayPolicyNonFocused()
Returns the current caret policy when the view is not focused. |
String | className() |
boolean | closeURL()
Stops loading the document and kills all data requests (for images, etc.) |
protected KURL | completeURL(String url)
returns a KURL object for the given url. |
protected ReadOnlyPart | createPart(QWidget parentWidget, String widgetName, QObject parent, String name, String mimetype, StringBuffer serviceName, String[] serviceTypes, String[] params)
This method is called when a new embedded object (include html frames) is to be created.
|
ReadOnlyPart | currentFrame()
Return the current frame (the one that has focus)
Not necessarily a direct child of ours, framesets can be nested.
|
protected void | customEvent(QCustomEvent event) |
String | dcopObjectId() |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
boolean | dndEnabled()
Returns whether Dragn'n'Drop support is enabled or not. |
Document | document()
Returns a reference to the DOM document. |
String | documentSource()
Returns the content of the source document. |
protected boolean | doCloseStream()
Implements the streaming API of KParts.ReadOnlyPart. |
protected boolean | doOpenStream(String mimeType)
Implements the streaming API of KParts.ReadOnlyPart. |
protected boolean | doWriteStream(byte[] data)
Implements the streaming API of KParts.ReadOnlyPart. |
void | enableJava(boolean e) |
void | enableJScript(boolean e) |
void | enableMetaRefresh(boolean e) |
void | enablePlugins(boolean e) |
String | encoding()
Returns the encoding the page currently uses.
|
void | end()
Call this after your last call to write(). |
QVariant | executeScript(Node n, String script)
Same as executeScript( String ) except with the Node parameter
specifying the 'this' value. |
protected void | finalize() Deletes the wrapped C++ instance |
KHTMLPart | findFrame(String f)
Finds a frame by name. |
KHTMLPart | findFrameParent(ReadOnlyPart callingPart, String f)
Recursively finds the part containing the frame with name f
and checks if it is accessible by callingPart
Returns null if no suitable frame can't be found.
|
ReadOnlyPart | findFramePart(String f)
Finds a frame by name. |
void | findText()
Starts a new search by popping up a dialog asking the user what he wants to
search for. |
void | findText(String str, long options, QWidget parent, KFindDialog findDialog)
Starts a new search, but bypasses the user dialog. |
void | findText(String str, long options, QWidget parent) |
void | findText(String str, long options) |
void | findTextBegin()
Initiates a text search. |
boolean | findTextNext()
Finds the next occurence of a string set by |
boolean | findTextNext(boolean reverse)
Finds the next occurence of a string set by |
int | formNotification()
Determine if signal should be emitted before, instead or never when a
submitForm() happens.
|
boolean | frameExists(String frameName)
Returns whether a frame with the specified name is exists or not.
|
ArrayList | frameNames()
Returns a list of names of all frame (including iframe) objects of
the current document. |
boolean | gotoAnchor(String name)
Finds the anchor named name.
If the anchor is found, the widget
scrolls to the closest position. |
protected void | guiActivateEvent(GUIActivateEvent event)
Internal reimplementation of KParts.Part.guiActivateEvent . |
boolean | hasSelection()
Has the user selected anything?
|
void | hide()
Convenience method to hide the document's view.
|
HTMLDocument | htmlDocument()
Returns a reference to the DOM HTML document (for non-HTML documents, returns null) |
protected void | htmlError(int errorCode, String text, KURL reqUrl)
presents a detailed error message to the user.
|
boolean | inProgress() |
boolean | isCaretMode() Returns whether caret mode is on/off. |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
boolean | isEditable()
Returns true if the document is editable, false otherwise. |
boolean | isModified()
Checks whether the page contains unsubmitted form changes. |
boolean | javaEnabled()
Return true if Java applet support is enabled, false if disabled |
String | jsDefaultStatusBarText()
Called by KJS.
|
String | jsStatusBarText()
Called by KJS.
|
boolean | jScriptEnabled()
Returns true if Javascript support is enabled or false
otherwise. |
String | lastModified()
Last-modified date (in raw string format), if received in the [HTTP] headers. |
QMetaObject | metaObject() |
boolean | metaRefreshEnabled()
Returns true if automatic forwarding is enabled. |
boolean | nextAnchor()
Go to the next anchor
This is useful to navigate from outside the navigator |
Node | nodeUnderMouse()
Returns the Node currently under the mouse.
|
Node | nonSharedNodeUnderMouse()
Returns the Node currently under the mouse that is not shared.
|
boolean | onlyLocalReferences()
Returns whether only file:/ or data:/ references are allowed
to be loaded ( default false ). |
protected boolean | openFile()
Internal empty reimplementation of KParts.ReadOnlyPart.openFile . |
boolean | openURL(KURL url)
Opens the specified URL url.
Reimplemented from KParts.ReadOnlyPart.openURL . |
String | pageReferrer()
Referrer used to obtain this page. |
void | paint(QPainter arg1, QRect arg2, int arg3, boolean[] arg4)
Paints the HTML page to a QPainter. |
void | paint(QPainter arg1, QRect arg2, int arg3) |
void | paint(QPainter arg1, QRect arg2) |
KHTMLPart | parentPart()
Returns a pointer to the parent KHTMLPart if the part is a frame
in an HTML frameset.
|
PartManager | partManager()
Returns a reference to the partmanager instance which
manages html frame objects. |
protected boolean | pluginPageQuestionAsked(String mimetype) |
boolean | pluginsEnabled()
Returns true if plugins are enabled/disabled. |
void | preloadScript(String url, String script)
Loads a script into the script cache. |
void | preloadStyleSheet(String url, String stylesheet)
Loads a style sheet into the stylesheet cache. |
boolean | prevAnchor()
Go to previous anchor |
String | referrer()
Referrer used for links in this page. |
boolean | restored() |
void | restoreState(QDataStream stream)
Restores the KHTMLPart's previously saved state (including
child frame objects) from the provided QDataStream.
|
void | saveState(QDataStream stream)
Saves the KHTMLPart's complete state (including child frame
objects) to the provided QDataStream.
|
void | scheduleRedirection(int delay, String url, boolean lockHistory)
Schedules a redirection after delay seconds. |
void | scheduleRedirection(int delay, String url) |
void | selectAll()
Marks all text in the document as selected. |
String | selectedText()
Returns the text the user has marked. |
String | selectedTextAsHTML()
Return the text the user has marked. |
Range | selection()
Returns the selected part of the HTML. |
void | selection(Node startNode, long startOffset, Node endNode, long endOffset)
Returns the selected part of the HTML by returning the starting and end
position.
|
void | setActiveNode(Node node)
Sets the focused node of the document to the specified node. |
void | setAutoloadImages(boolean enable)
Specifies whether images contained in the document should be loaded
automatically or not. |
void | setCaretDisplayPolicyNonFocused(int policy)
Sets the caret display policy when the view is not focused.
|
void | setCaretMode(boolean enable)
Enables/disables caret mode.
|
void | setCaretPosition(Node node, long offset, boolean extendSelection)
Sets the caret to the given position.
|
void | setCaretPosition(Node node, long offset) |
void | setCaretVisible(boolean show)
Sets the visibility of the caret.
|
boolean | setCharset(String arg1, boolean arg2) |
void | setDNDEnabled(boolean b)
Enables or disables Drag'n'Drop support. |
void | setEditable(boolean enable)
Makes the document editable.
|
boolean | setEncoding(String name, boolean override)
Sets the encoding the page uses.
|
boolean | setEncoding(String name) |
void | setFixedFont(String name)
Sets the fixed font style. |
void | setFormNotification(int fn)
Determine if signal should be emitted before, instead or never when a
submitForm() happens. |
void | setJavaEnabled(boolean enable)
Enables/disables Java applet support. |
void | setJScriptEnabled(boolean enable)
Enable/disable Javascript support. |
void | setJSDefaultStatusBarText(String text)
Called by KJS.
|
void | setJSStatusBarText(String text)
Called by KJS.
|
void | setMetaRefreshEnabled(boolean enable)
Enable/disable automatic forwarding by <meta http-equiv="refresh" ....> |
void | setOnlyLocalReferences(boolean enable)
Security option.
|
protected void | setPluginPageQuestionAsked(String mimetype) |
void | setPluginsEnabled(boolean enable)
Enables or disables plugins, default is enabled |
void | setSelection(Range arg1)
Sets the current selection. |
void | setStandardFont(String name)
Sets the standard font style. |
void | setStatusMessagesEnabled(boolean enable)
Enable/disable statusbar messages.
|
void | setSuppressedPopupIndicator(boolean enable, KHTMLPart originPart)
Shows or hides the suppressed popup indicator |
KHTMLSettings | settings() |
void | setURLCursor(QCursor c)
Sets the cursor to use when the cursor is on a link. |
void | setUserStyleSheet(KURL url)
Sets a user defined style sheet to be used on top of the HTML 4
default style sheet.
|
void | setUserStyleSheet(String styleSheet)
Sets a user defined style sheet to be used on top of the HTML 4
default style sheet.
|
void | setZoomFactor(int percent)
Sets the Zoom factor. |
void | show()
Convenience method to show the document's view.
|
void | showError(Job job)
Called when a certain error situation (i.e. connection timed out) occurred.
|
boolean | statusMessagesEnabled()
Returns true if status messages are enabled. |
void | stopAnimations()
Stops all animated images on the current and child pages |
void | submitFormProxy(String action, String url, byte[] formData, String target, String contentType, String boundary) |
void | submitFormProxy(String action, String url, byte[] formData, String target, String contentType) |
void | submitFormProxy(String action, String url, byte[] formData, String target) |
KURL | toplevelURL()
Returns the toplevel (origin) URL of this document, even if this
part is a frame or an iframe. |
QCursor | urlCursor()
Returns the cursor which is used when the cursor is on a link. |
protected void | urlSelected(String url, int button, int state, String _target, URLArgs args) |
protected void | urlSelected(String url, int button, int state, String _target) |
KHTMLView | view()
Returns a pointer to the HTML document's view. |
void | write(String str, int len)
Writes another part of the HTML code to the widget.
|
void | write(String str) |
int | zoomFactor()
Returns the current zoom factor. |
Parameters: Visible caret is displayed Invisible caret is not displayed Blink caret toggles between visible and invisible
UNKNOWN: Enumeration for displaying the caret.
UNKNOWN: Extra Find options that can be used when calling the extended findText().
parent
argument is null, then
parentWidget
is used as parent for both objects, the part and
the view.UNKNOWN: Constructs a new KHTMLPart.
UNKNOWN: Returns the node that has the keyboard focus.
UNKNOWN: that the returned information is unrelieable as long as no begin() was called. Returns whether images contained in the document are loaded automatically or not.
UNKNOWN: Returns the URL for the background Image (used by save background)
view.begin( KURL("file:/tmp/test.html" ) );
Parameters: url is the url of the document to be displayed. Even if you are generating the HTML on the fly, it may be useful to specify a directory so that any pixmaps are found. xOffset is the initial horizontal scrollbar value. Usually you don't want to use this. yOffset is the initial vertical scrollbar value. Usually you don't want to use this. All child frames and the old document are removed if you call this method.
UNKNOWN: Clears the widget and prepares it for new content.
UNKNOWN: Returns a pointer to the KParts.BrowserExtension.
UNKNOWN: Returns the current caret policy when the view is not focused.
UNKNOWN: Stops loading the document and kills all data requests (for images, etc.
UNKNOWN: returns a KURL object for the given url.
UNKNOWN: This method is called when a new embedded object (include html frames) is to be created.
UNKNOWN: Return the current frame (the one that has focus) Not necessarily a direct child of ours, framesets can be nested.
UNKNOWN: Returns whether Dragn'n'Drop support is enabled or not.
UNKNOWN: Returns a reference to the DOM document.
UNKNOWN: Returns the content of the source document.
UNKNOWN: Implements the streaming API of KParts.ReadOnlyPart.
UNKNOWN: Implements the streaming API of KParts.ReadOnlyPart.
UNKNOWN: Implements the streaming API of KParts.ReadOnlyPart.
UNKNOWN: Returns the encoding the page currently uses.
UNKNOWN: Call this after your last call to write().
UNKNOWN: Same as executeScript( String ) except with the Node parameter specifying the 'this' value.
UNKNOWN: Finds a frame by name.
f
and checks if it is accessible by callingPart
Returns null if no suitable frame can't be found.
Returns parent part if a suitable frame was found and
frame info in childFrame
UNKNOWN: Recursively finds the part containing the frame with name f
and checks if it is accessible by callingPart
Returns 0L if no suitable frame can't be found.
UNKNOWN: Finds a frame by name.
UNKNOWN: Starts a new search by popping up a dialog asking the user what he wants to search for.
Parameters: str The string to search for. options Find options. parent Parent used for centering popups like "string not found". findDialog Optionally, you can supply your own dialog.
UNKNOWN: Starts a new search, but bypasses the user dialog.
UNKNOWN: Initiates a text search.
Returns: true if a new match was found.
UNKNOWN: Finds the next occurence of a string set by @ref findText()
Parameters: reverse if true, revert seach direction (only if no find dialog is used)
Returns: true if a new match was found.
UNKNOWN: Finds the next occurence of a string set by @ref findText()
UNKNOWN: Determine if signal should be emitted before, instead or never when a submitForm() happens.
UNKNOWN: Returns whether a frame with the specified name is exists or not.
UNKNOWN: Returns a list of names of all frame (including iframe) objects of the current document.
name.
If the anchor is found, the widget
scrolls to the closest position. Returns if
the anchor has
been found.UNKNOWN: Finds the anchor named name.
UNKNOWN: Internal reimplementation of KParts.Part.guiActivateEvent .
Returns: true
if there is text selected.
UNKNOWN: Has the user selected anything?
UNKNOWN: Convenience method to hide the document's view.
UNKNOWN: Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
errorCode
kio error code, eg KIO.ERR_SERVER_TIMEOUT.
text
kio additional information text.
url
the url that triggered the error.UNKNOWN: presents a detailed error message to the user.
UNKNOWN:
UNKNOWN: Returns whether caret mode is on/off.
true
if the document is editable, false
otherwise.UNKNOWN: Returns true
if the document is editable, false
otherwise.
Returns: true if form changes exist
UNKNOWN: Checks whether the page contains unsubmitted form changes.
UNKNOWN: Return true if Java applet support is enabled, false if disabled
UNKNOWN: Called by KJS.
UNKNOWN: Called by KJS.
true
if Javascript support is enabled or false
otherwise.UNKNOWN: Returns true
if Javascript support is enabled or false
otherwise.
UNKNOWN: Last-modified date (in raw string format), if received in the [HTTP] headers.
true
if automatic forwarding is enabled.UNKNOWN: Returns true
if automatic forwarding is enabled.
UNKNOWN: Go to the next anchor
Node
currently under the mouse.
The returned node may be a shared node (e. g. an \ node if the
mouse is hovering over an image map).UNKNOWN: Returns the Node
currently under the mouse.
Node
currently under the mouse that is not shared.
The returned node is always the node that is physically under the mouse
pointer (irrespective of logically overlying elements like, e. g.,
\ on image maps).UNKNOWN: Returns the Node
currently under the mouse that is not shared.
UNKNOWN: Returns whether only file:/ or data:/ references are allowed to be loaded ( default false ).
UNKNOWN: Internal empty reimplementation of KParts.ReadOnlyPart.openFile .
url.
Reimplemented from KParts.ReadOnlyPart.openURL .UNKNOWN: Opens the specified URL url.
UNKNOWN: Referrer used to obtain this page.
UNKNOWN: Paints the HTML page to a QPainter.
UNKNOWN: Returns a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset.
UNKNOWN: Returns a reference to the partmanager instance which manages html frame objects.
UNKNOWN: Returns true if plugins are enabled/disabled.
UNKNOWN: Loads a script into the script cache.
UNKNOWN: Loads a style sheet into the stylesheet cache.
UNKNOWN: Go to previous anchor
UNKNOWN: Referrer used for links in this page.
UNKNOWN:
See Also: KHTMLPart
UNKNOWN: Restores the KHTMLPart's previously saved state (including child frame objects) from the provided QDataStream.
UNKNOWN: Saves the KHTMLPart's complete state (including child frame objects) to the provided QDataStream.
delay
seconds.UNKNOWN: Schedules a redirection after delay
seconds.
UNKNOWN: Marks all text in the document as selected.
UNKNOWN: Returns the text the user has marked.
UNKNOWN: Return the text the user has marked.
UNKNOWN: Returns the selected part of the HTML.
Parameters: startNode returns node selection starts in startOffset returns offset within starting node endNode returns node selection ends in endOffset returns offset within end node.
UNKNOWN: Returns the selected part of the HTML by returning the starting and end position.
Parameters: node The node to focus
UNKNOWN: Sets the focused node of the document to the specified node.
UNKNOWN: Request will be ignored if called before begin(). Specifies whether images contained in the document should be loaded automatically or not.
Parameters: policy new display policy
UNKNOWN: Sets the caret display policy when the view is not focused.
Parameters: enable true
to enable, false
to disable caret mode.
UNKNOWN: Enables/disables caret mode.
caretPositionChanged
signal
containing the effective position is emittedParameters: node node to set to offset zero-based offset within the node extendSelection If true
, a selection will be spanned from the
last caret position to the given one. Otherwise, any existing selection
will be deselected.
UNKNOWN: Sets the caret to the given position.
Parameters: show true
to make visible, false
to hide.
UNKNOWN: Sets the visibility of the caret.
UNKNOWN: Enables or disables Drag'n'Drop support.
true
makes the document, and its
subdocuments (such as frames, iframes, objects) editable as a whole.
FIXME: insert more information about navigation, features etc. as seen fitParameters: enable true
to set document editable, false
to set it
read-only.
UNKNOWN: Makes the document editable.
UNKNOWN: Sets the encoding the page uses.
Parameters: name The font name to use for fixed text, e.g. the <pre> tag.
UNKNOWN: Sets the fixed font style.
UNKNOWN: Determine if signal should be emitted before, instead or never when a submitForm() happens.
UNKNOWN: Enables/disables Java applet support.
UNKNOWN: Enable/disable Javascript support.
UNKNOWN: Called by KJS.
UNKNOWN: Called by KJS.
UNKNOWN: Enable/disable automatic forwarding by <meta http-equiv="refresh" .
UNKNOWN: Security option.
UNKNOWN: Enables or disables plugins, default is enabled
UNKNOWN: Sets the current selection.
Parameters: name The font name to use for standard text.
UNKNOWN: Sets the standard font style.
See Also: (
KHTMLPart KHTMLPart
UNKNOWN: Enable/disable statusbar messages.
UNKNOWN: Shows or hides the suppressed popup indicator
UNKNOWN:
UNKNOWN: Sets the cursor to use when the cursor is on a link.
UNKNOWN: Sets a user defined style sheet to be used on top of the HTML 4 default style sheet.
UNKNOWN: Sets a user defined style sheet to be used on top of the HTML 4 default style sheet.
UNKNOWN: Sets the Zoom factor.
UNKNOWN: Convenience method to show the document's view.
job
is the job that signaled the error situationUNKNOWN: Called when a certain error situation (i.
true
if status messages are enabled.UNKNOWN: Returns true
if status messages are enabled.
UNKNOWN: Stops all animated images on the current and child pages
Returns: the actual original url.
UNKNOWN: Returns the toplevel (origin) URL of this document, even if this part is a frame or an iframe.
UNKNOWN: Returns the cursor which is used when the cursor is on a link.
UNKNOWN: Returns a pointer to the HTML document's view.
len
parameter is needed for streams encoded in utf-16,
since these can have \\0 chars in them. In case the encoding
you're using isn't utf-16, you can safely leave out the length
parameter.
Attention: Don't mix calls to write( String ) with calls
to write( String ).
The result might not be what you want.UNKNOWN: Writes another part of the HTML code to the widget.
UNKNOWN: Returns the current zoom factor.