KHTMLPart Class Reference
#include <khtml_part.h>
Inheritance diagram for KHTMLPart:

Detailed Description
This class is khtml's main class.HTML Browser Widget.It features an almost complete web browser, and html renderer.
The easiest way to use this class (if you just want to display 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();
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:
QString 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 QString 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( QCString( "<html><body><p>KHTML Rocks!</p></body></html>" ) ); doc->closeStream();
- Author:
- Lars Knoll (knoll@kde.org)
Definition at line 184 of file khtml_part.h.
Member Enumeration Documentation
|
Enumeration for displaying the caret.
Definition at line 491 of file khtml_part.h. |
|
Extra Find options that can be used when calling the extended findText().
Definition at line 698 of file khtml_part.h. |
Constructor & Destructor Documentation
|
Constructs 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 Definition at line 206 of file khtml_part.cpp. |
|
Destructor.
Definition at line 468 of file khtml_part.cpp. |
Member Function Documentation
|
Returns the node that has the keyboard focus.
Definition at line 6933 of file khtml_part.cpp. |
|
Returns whether images contained in the document are loaded automatically or not.
|
|
Returns the URL for the background Image (used by save background).
Definition at line 4103 of file khtml_part.cpp. |
|
Clears 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:
Definition at line 1872 of file khtml_part.cpp. |
|
Returns a pointer to the KParts::BrowserExtension.
Definition at line 897 of file khtml_part.cpp. |
|
Returns the current caret policy when the view is not focused.
Definition at line 2689 of file khtml_part.cpp. |
|
This signal is emitted whenever the caret position has been changed. The signal transmits the position the DOM::Range way, the node and the zero-based offset within this node.
|
|
Stops loading the document and kills all data requests (for images, etc. ) Reimplemented from KParts::ReadOnlyPart. Definition at line 770 of file khtml_part.cpp. |
|
returns a KURL object for the given url. Use when you know what you're doing. Definition at line 2358 of file khtml_part.cpp. |
|
Returns the java context of the applets. If no context exists yet, a new one is created. Definition at line 1269 of file khtml_part.cpp. |
|
This method is called when a new embedded object (include html frames) is to be created. Reimplement it if you want to add support for certain embeddable objects without registering them in the KDE wide registry system (KSyCoCa) . Another reason for re-implementing this method could be if you want to derive from KTHMLPart and also want all html frame objects to be a object of your derived type, in which case you should return a new instance for the mimetype 'text/html' . Definition at line 4628 of file khtml_part.cpp. |
|
Return the current frame (the one that has focus) Not necessarily a direct child of ours, framesets can be nested. Returns "this" if this part isn't a frameset. Definition at line 5254 of file khtml_part.cpp. |
|
Returns whether Dragn'n'Drop support is enabled or not.
|
|
Implements the streaming API of KParts::ReadOnlyPart.
Definition at line 2029 of file khtml_part.cpp. |
|
Returns a reference to the DOM document.
Definition at line 860 of file khtml_part.cpp. |
|
Returns the content of the source document.
Definition at line 865 of file khtml_part.cpp. |
|
Implements the streaming API of KParts::ReadOnlyPart.
Definition at line 2012 of file khtml_part.cpp. |
|
Implements the streaming API of KParts::ReadOnlyPart.
Definition at line 2023 of file khtml_part.cpp. |
|
Returns the encoding the page currently uses. Note that the encoding might be different from the charset. Definition at line 2472 of file khtml_part.cpp. |
|
Call this after your last call to write().
Definition at line 2003 of file khtml_part.cpp. |
|
Execute the specified snippet of JavaScript code.
Returns
Definition at line 1182 of file khtml_part.cpp. |
|
Same as executeScript( const QString & ) except with the Node parameter specifying the 'this' value.
Definition at line 1187 of file khtml_part.cpp. |
|
Finds a frame by name. Returns 0L if frame can't be found. Definition at line 5235 of file khtml_part.cpp. |
|
Recursively finds the part containing the frame with name
Returns parent part if a suitable frame was found and frame info in
Definition at line 5194 of file khtml_part.cpp. |
|
Finds a frame by name. Returns 0L if frame can't be found. Definition at line 5248 of file khtml_part.cpp. |
|
Starts a new search, but bypasses the user dialog.
Definition at line 3022 of file khtml_part.cpp. |
|
Starts a new search by popping up a dialog asking the user what he wants to search for.
Definition at line 2983 of file khtml_part.cpp. |
|
Initiates a text search.
Definition at line 2724 of file khtml_part.cpp. |
|
Finds the next occurence of a string set by findText().
Definition at line 3056 of file khtml_part.cpp. |
|
Finds the next occurence of a string set by findText().
Definition at line 3050 of file khtml_part.cpp. |
|
Finds the next occurrence of the string or expression. If isRegExp is true then str is converted to a QRegExp, and caseSensitive is ignored.
Definition at line 2810 of file khtml_part.cpp. |
|
Determine if signal should be emitted before, instead or never when a submitForm() happens. ### KDE4 remove me
Definition at line 7329 of file khtml_part.cpp. |
|
If form notification is on, this will be emitted either for a form submit or before the form submit according to the setting.
|
|
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. Definition at line 5269 of file khtml_part.cpp. |
|
Returns child frame framePart its script interpreter.
Definition at line 5281 of file khtml_part.cpp. |
|
Returns a list of names of all frame (including iframe) objects of the current document. Note that this method is not working recursively for sub-frames. Definition at line 5867 of file khtml_part.cpp. |
|
Finds the anchor named
If the anchor is found, the widget scrolls to the closest position. Returns Definition at line 2508 of file khtml_part.cpp. |
|
Internal reimplementation of KParts::Part::guiActivateEvent .
Reimplemented from KParts::ReadOnlyPart. Definition at line 6612 of file khtml_part.cpp. |
|
Has the user selected anything? Call selectedText() to retrieve the selected text.
Definition at line 3582 of file khtml_part.cpp. |
|
Convenience method to hide the document's view. Equivalent to widget()->hide() or view()->hide(). Definition at line 5614 of file khtml_part.cpp. |
|
Returns a reference to the DOM HTML document (for non-HTML documents, returns null).
Definition at line 852 of file khtml_part.cpp. |
|
presents a detailed error message to the user.
Definition at line 1716 of file khtml_part.cpp. |
|
Returns whether caret mode is on/off.
Definition at line 2649 of file khtml_part.cpp. |
|
Returns
Definition at line 2670 of file khtml_part.cpp. |
|
Checks whether the page contains unsubmitted form changes.
Definition at line 7345 of file khtml_part.cpp. |
|
Returns the java context of the applets. If no applet exists, 0 is returned. Definition at line 1264 of file khtml_part.cpp. |
|
Return true if Java applet support is enabled, false if disabled.
|
|
Returns
Definition at line 940 of file khtml_part.cpp. |
|
Returns the JavaScript interpreter the part is using. This method is mainly intended for applications which embed and extend the part and provides a mechanism for adding additional native objects to the interpreter (or removing the built-ins). One thing people using this method to add things to the interpreter must consider, is that when you start writing new content to the part, the interpreter is cleared. This includes both use of the begin( const KURL &, int, int ) method, and the openURL( const KURL & ) method. If you want your objects to have a longer lifespan, then you must retain a KJS::Object yourself to ensure that the reference count of your custom objects never reaches 0. You will also need to re-add your bindings everytime this happens - one way to detect the need for this is to connect to the docCreated() signal, another is to reimplement the begin() method. Definition at line 917 of file khtml_part.cpp. |
|
Called by KJS. Returns the DefaultStatusBarText assigned via window.defaultStatus Definition at line 5780 of file khtml_part.cpp. |
|
Called by KJS. Returns the StatusBarText assigned via window.status Definition at line 5775 of file khtml_part.cpp. |
|
Eventhandler for the khtml::DrawContentsEvent.
Definition at line 6608 of file khtml_part.cpp. |
|
Eventhandler for the khtml::MouseDoubleClickEvent.
Definition at line 6105 of file khtml_part.cpp. |
|
Eventhandler for the khtml::MouseMouseMoveEvent.
Definition at line 6355 of file khtml_part.cpp. |
|
Eventhandler of the khtml::MousePressEvent.
Definition at line 6025 of file khtml_part.cpp. |
|
Eventhandler for the khtml::MouseMouseReleaseEvent.
Definition at line 6494 of file khtml_part.cpp. |
|
Last-modified date (in raw string format), if received in the [HTTP] headers.
Definition at line 5811 of file khtml_part.cpp. |
|
Returns
Definition at line 954 of file khtml_part.cpp. |
|
Go to the next anchor. This is useful to navigate from outside the navigator
Definition at line 2556 of file khtml_part.cpp. |
|
This signal is emitted when an element retrieves the keyboard focus. Note that the signal argument can be a null node if no element is active, meaning a node has explicitly been deactivated without a new one becoming active. |
|
Returns the The returned node may be a shared node (e. g. an <area> node if the mouse is hovering over an image map). Definition at line 5620 of file khtml_part.cpp. |
|
Returns the The returned node is always the node that is physically under the mouse pointer (irrespective of logically overlying elements like, e. g., <area> on image maps).
Definition at line 5625 of file khtml_part.cpp. |
|
Returns whether only file:/ or data:/ references are allowed to be loaded ( default false ). See setOnlyLocalReferences. |
|
Emitted if the cursor is moved over an URL.
|
|
Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
Implements KParts::ReadOnlyPart. Definition at line 1495 of file khtml_part.cpp. |
|
Opens the specified URL Reimplemented from KParts::ReadOnlyPart::openURL . Reimplemented from KParts::ReadOnlyPart. Definition at line 566 of file khtml_part.cpp. |
|
Referrer used to obtain this page.
Definition at line 5790 of file khtml_part.cpp. |
|
Paints the HTML page to a QPainter. See KHTMLView::paint for details Definition at line 2036 of file khtml_part.cpp. |
|
Returns a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset. Returns 0L otherwise. Definition at line 5299 of file khtml_part.cpp. |
|
Returns a reference to the partmanager instance which manages html frame objects.
Definition at line 4682 of file khtml_part.cpp. |
|
Returns true if plugins are enabled/disabled.
|
|
Emitted when the user clicks the right mouse button on the document.
|
|
Loads a script into the script cache.
Definition at line 6973 of file khtml_part.cpp. |
|
Loads a style sheet into the stylesheet cache.
Definition at line 6968 of file khtml_part.cpp. |
|
Go to previous anchor.
Definition at line 2565 of file khtml_part.cpp. |
|
Referrer used for links in this page.
Definition at line 5785 of file khtml_part.cpp. |
|
Restores the KHTMLPart's previously saved state (including child frame objects) from the provided QDataStream.
Definition at line 5422 of file khtml_part.cpp. |
|
Saves the KHTMLPart's complete state (including child frame objects) to the provided QDataStream. This is called from the saveState() method of the browserExtension(). Definition at line 5336 of file khtml_part.cpp. |
|
Schedules a redirection after
Definition at line 2370 of file khtml_part.cpp. |
|
Marks all text in the document as selected.
Definition at line 6744 of file khtml_part.cpp. |
|
Returns the text the user has marked.
Definition at line 3440 of file khtml_part.cpp. |
|
Return the text the user has marked. This is guaranteed to be valid xml, and to contain the <html> and <body> tags. FIXME probably should make virtual for 4.0 ?
Definition at line 3423 of file khtml_part.cpp. |
|
Returns the selected part of the HTML by returning the starting and end position. If there is no selection, both nodes and offsets are equal.
Definition at line 3646 of file khtml_part.cpp. |
|
Returns the selected part of the HTML.
Definition at line 3592 of file khtml_part.cpp. |
|
This signal is emitted when the selection changes.
|
|
Sets the focused node of the document to the specified node. If the node is a form control, the control will receive focus in the same way that it would if the user had clicked on it or tabbed to it with the keyboard. For most other types of elements, there is no visual indication of whether or not they are focused. See activeNode
Definition at line 6919 of file khtml_part.cpp. |
|
Specifies whether images contained in the document should be loaded automatically or not.
Definition at line 1336 of file khtml_part.cpp. |
|
Sets the caret display policy when the view is not focused. Whenever the caret is in use, this property determines how the caret should be displayed when the document view is not focused. The default policy is CaretInvisible.
Definition at line 2698 of file khtml_part.cpp. |
|
Enables/disables caret mode. Enabling caret mode displays a caret which can be used to navigate the document using the keyboard only. Caret mode is switched off by default.
Definition at line 2632 of file khtml_part.cpp. |
|
Sets the caret to the given position.
If the given location is invalid, it will snap to the nearest valid location. Immediately afterwards a
Definition at line 2675 of file khtml_part.cpp. |
|
Sets the visibility of the caret. This methods displays or hides the caret regardless of the current caret display policy (see setCaretDisplayNonFocused), and regardless of focus. The caret will be shown/hidden only under at least one of the following conditions:
Definition at line 2705 of file khtml_part.cpp. |
|
Enables or disables Drag'n'Drop support. A drag operation is started if the users drags a link. Definition at line 5910 of file khtml_part.cpp. |
|
Makes the document editable.
Setting this property to
Definition at line 2654 of file khtml_part.cpp. |
|
Sets 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. Definition at line 2454 of file khtml_part.cpp. |
|
Sets the fixed font style.
Definition at line 2579 of file khtml_part.cpp. |
|
Determine if signal should be emitted before, instead or never when a submitForm() happens.
Definition at line 7325 of file khtml_part.cpp. |
|
Enables/disables 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. Definition at line 1245 of file khtml_part.cpp. |
|
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. Definition at line 931 of file khtml_part.cpp. |
|
Called by KJS. Sets the DefaultStatusBarText assigned via window.defaultStatus Definition at line 5770 of file khtml_part.cpp. |
|
Called by KJS. Sets the StatusBarText assigned via window.status Definition at line 5765 of file khtml_part.cpp. |
|
Enable/disable automatic forwarding by <meta http-equiv="refresh" . ...> Definition at line 949 of file khtml_part.cpp. |
|
Security option. Specify whether only file:/ or data:/ urls are allowed to be loaded without user confirmation by KHTML. ( for example referenced by stylesheets, images, scripts, subdocuments, embedded elements ). This option is mainly intended for enabling the "mail reader mode", where you load untrusted content with a file:/ url. Please note that enabling this option currently automatically disables Javascript, Java and Plugins support. This might change in the future if the security model is becoming more sophisticated, so don't rely on this behaviour. ( default false - everything is loaded unless forbidden by KApplication::authorizeURLAction). Definition at line 2599 of file khtml_part.cpp. |
|
Enables or disables plugins, default is enabled.
Definition at line 1274 of file khtml_part.cpp. |
|
Sets the current selection.
Definition at line 3654 of file khtml_part.cpp. |
|
Sets the standard font style.
Definition at line 2574 of file khtml_part.cpp. |
|
Enable/disable statusbar messages. When this class wants to set the statusbar text, it emits setStatusBarText(const QString & text) If you want to catch this for your own statusbar, note that it returns back a rich text string, starting with "<qt>". This you need to either pass this into your own QLabel or to strip out the tags before passing it to QStatusBar::message(const QString & message)
Definition at line 912 of file khtml_part.cpp. |
|
Shows or hides the suppressed popup indicator.
Definition at line 7373 of file khtml_part.cpp. |
|
Shows or hides the suppressed popup indicator.
Definition at line 7368 of file khtml_part.cpp. |
|
Sets the cursor to use when the cursor is on a link.
Definition at line 2584 of file khtml_part.cpp. |
|
Sets 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. To have an effect this function has to be called after calling begin(). Definition at line 2502 of file khtml_part.cpp. |
|
Sets 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. To have an effect this function has to be called after calling begin(). Definition at line 2496 of file khtml_part.cpp. |
|
Sets the Zoom factor. The value is given in percent, larger values mean a generally larger font and larger page contents. It is not guaranteed that all parts of the page are scaled with the same factor though. The given value should be in the range of 20..300, values outside that range are not guaranteed to work. A value of 100 will disable all zooming and show the page with the sizes determined via the given lengths in the stylesheets. Definition at line 5704 of file khtml_part.cpp. |
|
Convenience method to show the document's view. Equivalent to widget()->show() or view()->show() . Definition at line 5608 of file khtml_part.cpp. |
|
Called when a certain error situation (i.e.
connection timed out) occurred. The default implementation either shows a KIO error dialog or loads a more verbose error description a as page, depending on the users configuration. Definition at line 1699 of file khtml_part.cpp. |
|
Returns
Definition at line 926 of file khtml_part.cpp. |
|
Stops all animated images on the current and child pages.
Definition at line 2042 of file khtml_part.cpp. |
|
Returns the toplevel (origin) URL of this document, even if this part is a frame or an iframe.
Definition at line 7333 of file khtml_part.cpp. |
|
Returns the cursor which is used when the cursor is on a link.
Definition at line 2589 of file khtml_part.cpp. |
|
Returns a pointer to the HTML document's view.
Definition at line 907 of file khtml_part.cpp. |
|
Writes 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. Definition at line 1988 of file khtml_part.cpp. |
|
Writes 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 Attention: Don't mix calls to write( const char *) with calls to write( const QString & ). The result might not be what you want. Definition at line 1956 of file khtml_part.cpp. |
|
Returns the current zoom factor.
Definition at line 5640 of file khtml_part.cpp. |
The documentation for this class was generated from the following files: