|
|
This class is khtml's main class. It features an almost complete web browser, and html renderer.
The easiest way to use this class (if you just want to display a an HTML page at some URL) is the following:
KURL url = "http://www.kde.org"; KHTMLPart *w = new KHTMLPart(); w->openURL(url); w->view()->resize(500, 400); w->show(); |
By default Java and JavaScript support are disabled. You can enable them by using the enableJava() and enableJScript() methods.
Some apps want to write their HTML code directly into the widget instead of it opening an url. You can also do that in the following way:
QString myHTMLCode = ...; KHTMLPart *w = new KHTMLPart(); w->begin(); w->write(myHTMLCode); ... w->end(); |
You can do as many calls to write as you want. But there are two
write() methods, one accepting a QString 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.
enum |
|
Construct a new KHTMLPart.
KHTML basically consists of two objects: The KHTMLPart itself,
holding the document data (DOM document), and the KHTMLView,
derived from QScrollview, in which the document content is
rendered in. You can specify two different parent objects for a
KHTMLPart, one parent for the KHTMLPart document and on parent
for the KHTMLView. If the second parent
argument is 0L, then
parentWidget
is used as parent for both objects, the part and
the view.
|
~ |
[virtual]
Destructor.
bool |
[virtual]
Opens the specified URL url.
Reimplemented from KParts::ReadOnlyPart::openURL .
Reimplemented from ReadOnlyPart.
bool |
[virtual]
Stop loading the document and kill all data requests (for images, etc.)
Reimplemented from ReadOnlyPart.
DOM::HTMLDocument |
[const]
Retrieve a reference to the DOM document.
KParts::BrowserExtension * |
[const]
Retrieve a pointer to the KParts::BrowserExtension
KHTMLView * |
[const]
Retrieve a pointer to the HTML document's view.
void |
Enable/disable Javascript support. Note that this will in either case permanently override the default usersetting. If you want to have the default UserSettings, don't call this method.
bool |
[const]
Returns true
if Javascript support is enabled or false
otherwise.
QVariant |
Execute the specified snippet of JavaScript code.
Returns true
if JavaScript was enabled, no error occured
and the code returned true itself or false
otherwise.
QVariant |
Same as above except the Node parameter specifying the 'this' value.
void |
bool |
[const]
void |
Enable/disable Java applet support. Note that calling this function will permanently override the User settings about Java applet support. Not calling this function is the only way to let the default settings apply.
bool |
[const]
Return if Java applet support is enabled/disabled.
KJavaAppletContext * |
Return the java context of the applets. If no applet exists, 0 is returned.
KJavaAppletContext * |
Return the java context of the applets. If no context exists yet, a new one is created.
void |
Should images be loaded automatically? Default is true.
(not implemented at the moment)
bool |
[const]
void |
[virtual]
Clear the widget and prepares it for new content.
If you want url() to return for example "file:/tmp/test.html", you can use the following code:
view->begin( KURL("file:/tmp/test.html" ) ); |
All child frames and the old document are removed if you call this method.
Parameters:
void |
[virtual]
Write another part of the HTML code to the widget.
You may call this function many times in sequence. But remember: The fewer calls you make, the faster the widget will be.
The HTML code is send through a decoder which decodes the stream to Unicode.
The 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( const char *) with calls to write( const QString & ).
The result might not be what you want.
void |
[virtual]
Write another part of the HTML code to the widget.
You may call this function many times in sequence. But remember: The fewer calls you make, the faster the widget will be.
void |
[virtual]
Call this after your last call to write().
void |
Mainly used internally.
Sets the document's base URL.
KURL |
[const]
Retrieve the base URL of this document
The base URL is ususally set by a <base url=...> tag in the document head.
void |
Mainly used internally.
Sets the document's base target.
QString |
[const]
Retrieve the base target of this document.
The base target is ususally set by a <base target=...> tag in the document head.
KURL |
void |
bool |
Set the charset to use for displaying HTML pages.
If override is true,
it will override charset specifications of the document.
bool |
Set the encoding the page uses.
This can be different from the charset. The widget will try to reload the current page in the new encoding, if url() is not empty.
QString |
return the encoding the page currently uses.
Note that the encoding might be different from the charset.
void |
Set a user defined style sheet to be used on top of the HTML 4 default style sheet.
This gives a wide range of possibilities to change the layout of the page.
void |
Set a user defined style sheet to be used on top of the HTML 4 default style sheet.
This gives a wide range of possibilities to change the layout of the page.
void |
Set point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size>
Html-Font-Sizes range from 0 (smallest) to 6 (biggest), but you can specify up to 15 font sizes, the bigger ones will get used, if <font size=+1> extends over 7, or if a 'font-size: larger' style declaration gets into this region.
They are related to the CSS font sizes by 0 == xx-small to 6 == xx-large.
QValueList |
[const]
Get point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size>
Html-Font-Sizes range from 0 (smallest) to 6 (biggest).
They are related to the CSS font sizes by 0 == xx-small to 6 == xx-large.
void |
Reset the point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size> to their default.
Html-Font-Sizes range from 1 (smallest) to 7 (biggest).
void |
Set the standard font style.
Parameters:
void |
Set the fixed font style.
Parameters:
bool |
Find the anchor named name.
If the anchor is found, the widget
scrolls to the closest position. Returns if
the anchor has
been found.
void |
Set the cursor to use when the cursor is on a link.
const QCursor& |
[const]
Retrieve the cursor which is used when the cursor is on a link.
void |
Initiate a text search.
bool |
Find the next occurrance of the expression.
bool |
Find the next occurence of the string.
QString |
[const virtual]
Get the text the user has marked.
DOM::Range |
[const]
Retrieve the selected part of the HTML.
bool |
[const]
Has the user selected anything?
Call selectedText() to retrieve the selected text.
Returns: true
if there is text selected.
void |
void |
Convenience method to show the document's view.
Equivalent to widget()->show() or view()->show() .
void |
Convenience method to hide the document's view.
Equivalent to widget()->hide() or view()->hide().
KParts::PartManager * |
void |
[virtual]
Save the KHTMLPart's complete state (including child frame objects) to the provided QDataStream.
You can use this method to provide history functionality.
This is called from the saveState() method of the browserExtension().
void |
[virtual]
Restore the KHTMLPart's previously saved state (including child frame objects) from the provided QDataStream.
This is called from the restoreState() method of the browserExtension() .
bool |
DOM::Node |
[const]
Retrieve the Node
currently under the mouse
const KHTMLSettings * |
[const]
KHTMLPart * |
Retrieve a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset.
Returns 0L otherwise.
QStringList |
[const]
const QList<KParts::ReadOnlyPart> |
[const]
KHTMLPart * |
Find a frame by name. Returns 0L if frame can't be found.
bool |
Returns whether a frame with the specified name is exists or not. In contrary to the @findFrame method this one also returns true if the frame is defined but no displaying component has been found/loaded, yet.
bool |
void |
[signal]
Eemitted if the cursor is moved over an URL.
void |
[signal]
Emitted when the user clicks the right mouse button on the document.
void |
[signal]
bool |
[protected virtual]
void |
[protected virtual]
void |
[protected virtual]
void |
[protected virtual]
void |
[protected virtual]
void |
[protected virtual]
void |
[protected virtual]
Reimplemented from ReadOnlyPart.
bool |
[protected virtual]
Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
Reimplemented from ReadOnlyPart.
void |
[protected virtual]
void |
[protected virtual]
bool |
[protected]
void |
[protected virtual]
void |
[protected virtual]
KParts::ReadOnlyPart * |
[protected virtual]
void |
[protected]
void |
[protected]
void |
[protected slot]
Internal. Called by the BrowserExtension .