khtml Library API Documentation

KHTMLPart Class Reference

This class is khtml's main class. HTML Browser Widget. More...

#include <khtml_part.h>

Inheritance diagram for KHTMLPart:

KParts::ReadOnlyPart KParts::Part QObject KParts::PartBase KXMLGUIClient List of all members.

Public Types

enum  GUIProfile { DefaultGUI, BrowserViewGUI }
enum  CaretDisplayPolicy { CaretVisible, CaretInvisible, CaretBlink }
enum  FormNotification { NoNotification = 0, Before, Only, Unused = 255 }

Public Slots

void setActiveNode (const DOM::Node &node)
void stopAnimations ()
QCString dcopObjectId () const
QVariant executeScript (const QString &script)
void setCaretMode (bool enable)
void setEditable (bool enable)
void setCaretVisible (bool show)
void submitFormProxy (const char *action, const QString &url, const QByteArray &formData, const QString &target, const QString &contentType=QString::null, const QString &boundary=QString::null)

Signals

void onURL (const QString &url)
void popupMenu (const QString &url, const QPoint &point)
void selectionChanged ()
void nodeActivated (const DOM::Node &)
void docCreated ()
void caretPositionChanged (const DOM::Node &node, long offset)
void formSubmitNotification (const char *action, const QString &url, const QByteArray &formData, const QString &target, const QString &contentType, const QString &boundary)

Public Methods

 KHTMLPart (QWidget *parentWidget=0, const char *widgetname=0, QObject *parent=0, const char *name=0, GUIProfile prof=DefaultGUI)
 KHTMLPart (KHTMLView *view, QObject *parent=0, const char *name=0, GUIProfile prof=DefaultGUI)
virtual ~KHTMLPart ()
virtual bool openURL (const KURL &url)
virtual bool closeURL ()
virtual void showError (KIO::Job *job)
DOM::HTMLDocument htmlDocument () const
DOM::Document document () const
DOM::Node activeNode () const
KParts::BrowserExtensionbrowserExtension () const
KParts::LiveConnectExtensionliveConnectExtension (const khtml::RenderPart *) const
KHTMLViewview () const
void setJScriptEnabled (bool enable)
bool jScriptEnabled () const
KJS::Interpreter * jScriptInterpreter ()
void setStatusMessagesEnabled (bool enable)
bool statusMessagesEnabled () const
void setMetaRefreshEnabled (bool enable)
bool metaRefreshEnabled () const
QVariant executeScript (const DOM::Node &n, const QString &script)
void setDNDEnabled (bool b)
bool dndEnabled () const
void setJavaEnabled (bool enable)
bool javaEnabled () const
KJavaAppletContext * javaContext ()
KJavaAppletContext * createJavaContext ()
void setPluginsEnabled (bool enable)
bool pluginsEnabled () const
void setAutoloadImages (bool enable)
bool autoloadImages () const
void setOnlyLocalReferences (bool enable)
bool onlyLocalReferences () const
bool isCaretMode () const
bool isEditable () const
void setCaretPosition (DOM::Node node, long offset, bool extendSelection=false)
CaretDisplayPolicy caretDisplayPolicyNonFocused () const
void setCaretDisplayPolicyNonFocused (CaretDisplayPolicy policy)
void enableJScript (bool e)
void enableJava (bool e)
void enablePlugins (bool e)
void autoloadImages (bool e)
void enableMetaRefresh (bool e)
bool setCharset (const QString &, bool)
KURL baseURL () const
QString baseTarget () const
KURL backgroundURL () const
void scheduleRedirection (int delay, const QString &url, bool lockHistory=true)
virtual void begin (const KURL &url=KURL(), int xOffset=0, int yOffset=0)
virtual void write (const char *str, int len=-1)
virtual void write (const QString &str)
virtual void end ()
void paint (QPainter *, const QRect &, int=0, bool *=0)
bool setEncoding (const QString &name, bool override=false)
QString encoding () const
void setUserStyleSheet (const KURL &url)
void setUserStyleSheet (const QString &styleSheet)
void setStandardFont (const QString &name)
void setFixedFont (const QString &name)
bool gotoAnchor (const QString &name)
bool nextAnchor ()
bool prevAnchor ()
void setURLCursor (const QCursor &c)
QCursor urlCursor () const
void findTextBegin ()
bool findTextNext (const QString &str, bool forward, bool caseSensitive, bool isRegExp)
void setZoomFactor (int percent)
int zoomFactor () const
virtual QString selectedText () const
DOM::Range selection () const
void selection (DOM::Node &startNode, long &startOffset, DOM::Node &endNode, long &endOffset) const
void setSelection (const DOM::Range &)
bool hasSelection () const
void selectAll ()
void show ()
void hide ()
KParts::PartManagerpartManager ()
virtual void saveState (QDataStream &stream)
virtual void restoreState (QDataStream &stream)
DOM::Node nodeUnderMouse () const
const KHTMLSettingssettings () const
KHTMLPart * parentPart ()
QStringList frameNames () const
QPtrList< KParts::ReadOnlyPartframes () const
KHTMLPart * findFrame (const QString &f)
KParts::ReadOnlyPartcurrentFrame () const
bool frameExists (const QString &frameName)
void setJSStatusBarText (const QString &text)
void setJSDefaultStatusBarText (const QString &text)
QString jsStatusBarText () const
QString jsDefaultStatusBarText () const
QString referrer () const
QString pageReferrer () const
QString lastModified () const
void preloadStyleSheet (const QString &url, const QString &stylesheet)
void preloadScript (const QString &url, const QString &script)
bool restored () const
void setFormNotification (FormNotification fn)
FormNotification formNotification () const
KURL toplevelURL ()

Protected Types

enum  PageSecurity { NotCrypted, Encrypted, Mixed }

Protected Methods

KURL completeURL (const QString &url)
void htmlError (int errorCode, const QString &text, const KURL &reqUrl)
virtual void customEvent (QCustomEvent *event)
virtual void khtmlMousePressEvent (khtml::MousePressEvent *event)
virtual void khtmlMouseDoubleClickEvent (khtml::MouseDoubleClickEvent *)
virtual void khtmlMouseMoveEvent (khtml::MouseMoveEvent *event)
virtual void khtmlMouseReleaseEvent (khtml::MouseReleaseEvent *event)
virtual void khtmlDrawContentsEvent (khtml::DrawContentsEvent *)
virtual void guiActivateEvent (KParts::GUIActivateEvent *event)
virtual bool openFile ()
virtual void urlSelected (const QString &url, int button, int state, const QString &_target, KParts::URLArgs args=KParts::URLArgs())
virtual KParts::ReadOnlyPartcreatePart (QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QString &mimetype, QString &serviceName, QStringList &serviceTypes, const QStringList &params)
bool pluginPageQuestionAsked (const QString &mimetype) const
void setPluginPageQuestionAsked (const QString &mimetype)
void setPageSecurity (PageSecurity sec)
virtual bool doOpenStream (const QString &mimeType)
virtual bool doWriteStream (const QByteArray &data)
virtual bool doCloseStream ()

Friends

class DOM::HTMLTitleElementImpl
class DOM::HTMLFrameElementImpl
class DOM::HTMLIFrameElementImpl
class DOM::HTMLObjectElementImpl
class DOM::HTMLAnchorElementImpl
class DOM::HTMLMetaElementImpl
class DOM::NodeImpl
class KHTMLRun
class DOM::HTMLFormElementImpl
class khtml::RenderPartObject
class KJS::Window
class KJS::ScheduledAction
class KJS::JSNodeFilter
class KJS::WindowFunc
class KJS::ExternalFunc
class KJS::JSEventListener
class KJS::DOMDocument
class KJS::SourceFile
class KJSProxy
class KHTMLPartBrowserExtension
class DOM::DocumentImpl
class DOM::HTMLDocumentImpl
class KHTMLPartBrowserHostExtension
class khtml::HTMLTokenizer
class khtml::XMLTokenizer
class khtml::RenderWidget
class khtml::CSSStyleSelector
class KHTMLPartIface
class KHTMLPartFunction
class KHTMLPartPrivate

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)
Version:
Id:
khtml_part.h,v 1.248.2.4 2004/03/23 00:50:48 mueller Exp

Definition at line 183 of file khtml_part.h.


Member Enumeration Documentation

enum KHTMLPart::CaretDisplayPolicy
 

Enumeration for displaying the caret.

Parameters:
Visible  caret is displayed
Invisible  caret is not displayed
Blink  caret toggles between visible and invisible
Since:
3.2

Definition at line 472 of file khtml_part.h.

Referenced by caretDisplayPolicyNonFocused().


Constructor & Destructor Documentation

KHTMLPart::KHTMLPart QWidget   parentWidget = 0,
const char *    widgetname = 0,
QObject   parent = 0,
const char *    name = 0,
GUIProfile    prof = DefaultGUI
 

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 parent argument is 0L, then parentWidget is used as parent for both objects, the part and the view.

Definition at line 160 of file khtml_part.cpp.

References parentPart(), and KParts::PartBase::setInstance().

KHTMLPart::~KHTMLPart   [virtual]
 

Destructor.

Definition at line 394 of file khtml_part.cpp.

References closeURL(), KGlobal::config(), QObject::disconnect(), and parentPart().


Member Function Documentation

bool KHTMLPart::openURL const KURL   url [virtual]
 

Opens the specified URL url.

Reimplemented from KParts::ReadOnlyPart::openURL .

Reimplemented from KParts::ReadOnlyPart.

Definition at line 485 of file khtml_part.cpp.

References closeURL(), KParts::ReadOnlyPart::completed(), QObject::connect(), KParts::URLArgs::contentType(), KParts::URLArgs::doPost(), KURL::encodedHtmlRef(), KIO::get(), gotoAnchor(), KURL::hasRef(), KURL::hasSubURL(), KURL::host(), htmlError(), KURL::htmlRef(), KIO::http_post(), QMap< QString, QString >::insert(), QString::isEmpty(), KURL::join(), KParts::ReadOnlyPart::m_url, KParts::URLArgs::metaData(), parentPart(), KURL::path(), KParts::URLArgs::postData, KURL::prettyURL(), KURL::protocol(), KURL::queryItem(), KParts::URLArgs::redirectedRequest(), KParts::URLArgs::reload, KURL::setPath(), KURL::split(), KParts::ReadOnlyPart::started(), QString::startsWith(), KIO::stat(), QString::toInt(), toplevelURL(), KParts::ReadOnlyPart::url(), KURL::url(), KHTMLSettings::userStyleSheet(), and KParts::Part::widget().

Referenced by restoreState(), and setEncoding().

bool KHTMLPart::closeURL   [virtual]
 

Stops loading the document and kills all data requests (for images, etc.).

Reimplemented from KParts::ReadOnlyPart.

Definition at line 649 of file khtml_part.cpp.

References KHTMLPageCache::cancelEntry(), KHTMLPageCache::cancelFetch(), end(), KParts::ReadOnlyPart::m_url, nodeActivated(), KURL::prettyURL(), and KHTMLPageCache::self().

Referenced by openURL(), restoreState(), setEncoding(), and ~KHTMLPart().

void KHTMLPart::showError KIO::Job   job [virtual]
 

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. job is the job that signaled the error situation

Definition at line 1446 of file khtml_part.cpp.

References KIO::Job::error(), KIO::Job::errorText(), htmlError(), and KIO::Job::showErrorDialog().

DOM::HTMLDocument KHTMLPart::htmlDocument   const
 

Returns a reference to the DOM HTML document (for non-HTML documents, returns null).

Definition at line 724 of file khtml_part.cpp.

DOM::Document KHTMLPart::document   const
 

Returns a reference to the DOM document.

Definition at line 732 of file khtml_part.cpp.

Referenced by selection().

DOM::Node KHTMLPart::activeNode   const
 

Returns the node that has the keyboard focus.

Definition at line 5877 of file khtml_part.cpp.

KParts::BrowserExtension * KHTMLPart::browserExtension   const
 

Returns a pointer to the KParts::BrowserExtension.

Definition at line 738 of file khtml_part.cpp.

KHTMLView * KHTMLPart::view   const
 

Returns a pointer to the HTML document's view.

Definition at line 743 of file khtml_part.cpp.

Referenced by caretDisplayPolicyNonFocused(), khtmlMouseMoveEvent(), setCaretDisplayPolicyNonFocused(), setCaretMode(), setCaretPosition(), setCaretVisible(), and setEditable().

void KHTMLPart::setJScriptEnabled bool    enable
 

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 767 of file khtml_part.cpp.

References jScriptEnabled().

bool KHTMLPart::jScriptEnabled   const
 

Returns true if Javascript support is enabled or false otherwise.

Definition at line 776 of file khtml_part.cpp.

References onlyLocalReferences().

Referenced by setJScriptEnabled().

KJS::Interpreter * KHTMLPart::jScriptInterpreter  
 

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 753 of file khtml_part.cpp.

void KHTMLPart::setStatusMessagesEnabled bool    enable
 

Enable/disable statusbar messages.

Definition at line 748 of file khtml_part.cpp.

bool KHTMLPart::statusMessagesEnabled   const
 

Returns true if status messages are enabled.

Definition at line 762 of file khtml_part.cpp.

void KHTMLPart::setMetaRefreshEnabled bool    enable
 

Enable/disable automatic forwarding by <meta http-equiv="refresh" ....>.

Definition at line 785 of file khtml_part.cpp.

bool KHTMLPart::metaRefreshEnabled   const
 

Returns true if automatic forwarding is enabled.

Definition at line 790 of file khtml_part.cpp.

QVariant KHTMLPart::executeScript const DOM::Node   n,
const QString   script
 

Same as executeScript( const QString & ) except with the Node parameter specifying the 'this' value.

Definition at line 990 of file khtml_part.cpp.

References DOM::Node::isNull(), QObject::name(), DOM::Node::nodeName(), and DOM::Node::nodeType().

Referenced by executeScript().

void KHTMLPart::setDNDEnabled bool    b
 

Enables or disables Drag'n'Drop support.

A drag operation is started if the users drags a link.

Definition at line 5064 of file khtml_part.cpp.

bool KHTMLPart::dndEnabled   const
 

Returns whether Dragn'n'Drop support is enabled or not.

Definition at line 5069 of file khtml_part.cpp.

void KHTMLPart::setJavaEnabled bool    enable
 

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 1048 of file khtml_part.cpp.

bool KHTMLPart::javaEnabled   const
 

Return true if Java applet support is enabled, false if disabled.

Definition at line 1054 of file khtml_part.cpp.

References onlyLocalReferences().

KJavaAppletContext * KHTMLPart::javaContext  
 

Returns the java context of the applets.

If no applet exists, 0 is returned.

Definition at line 1067 of file khtml_part.cpp.

KJavaAppletContext * KHTMLPart::createJavaContext  
 

Returns the java context of the applets.

If no context exists yet, a new one is created.

Definition at line 1072 of file khtml_part.cpp.

void KHTMLPart::setPluginsEnabled bool    enable
 

Enables or disables plugins, default is enabled.

Definition at line 1077 of file khtml_part.cpp.

bool KHTMLPart::pluginsEnabled   const
 

Returns true if plugins are enabled/disabled.

Definition at line 1083 of file khtml_part.cpp.

References onlyLocalReferences().

void KHTMLPart::setAutoloadImages bool    enable
 

Specifies whether images contained in the document should be loaded automatically or not.

Note:
Request will be ignored if called before begin().

Definition at line 1123 of file khtml_part.cpp.

References KXMLGUIClient::actionCollection(), QPtrList::append(), KXMLGUIClient::plugActionList(), and KXMLGUIClient::unplugActionList().

Referenced by begin().

bool KHTMLPart::autoloadImages   const
 

Returns whether images contained in the document are loaded automatically or not.

Note:
that the returned information is unrelieable as long as no begin() was called.

Definition at line 1147 of file khtml_part.cpp.

void KHTMLPart::setOnlyLocalReferences bool    enable
 

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 2298 of file khtml_part.cpp.

bool KHTMLPart::onlyLocalReferences   const
 

Returns whether only file:/ or data:/ references are allowed to be loaded ( default false ).

See also:
setOnlyLocalReferences.

Definition at line 2293 of file khtml_part.cpp.

Referenced by javaEnabled(), jScriptEnabled(), and pluginsEnabled().

bool KHTMLPart::isCaretMode   const
 

Returns whether caret mode is on/off.

Since:
3.2

Definition at line 2343 of file khtml_part.cpp.

Referenced by khtml::EditableLineIterator::isEditable(), khtml::EditableInlineBoxIterator::isEditable(), KHTMLView::layout(), setCaretMode(), setCaretVisible(), and setEditable().

bool KHTMLPart::isEditable   const
 

Returns true if the document is editable, false otherwise.

Since:
3.2

Definition at line 2364 of file khtml_part.cpp.

Referenced by khtml::EditableLineIterator::isEditable(), khtml::EditableInlineBoxIterator::isEditable(), khtmlMouseMoveEvent(), khtmlMousePressEvent(), KHTMLView::layout(), setCaretMode(), setCaretVisible(), and setEditable().

void KHTMLPart::setCaretPosition DOM::Node    node,
long    offset,
bool    extendSelection = false
 

Sets the caret to the given position.

If the given location is invalid, it will snap to the nearest valid location. Immediately afterwards a caretPositionChanged signal containing the effective position is emitted

Parameters:
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.
Since:
3.2

Definition at line 2369 of file khtml_part.cpp.

References KHTMLView::ensureCaretVisible(), DOM::Node::handle(), KHTMLView::moveCaretTo(), DOM::Node::nodeName(), and view().

KHTMLPart::CaretDisplayPolicy KHTMLPart::caretDisplayPolicyNonFocused   const
 

Returns the current caret policy when the view is not focused.

Since:
3.2

Definition at line 2383 of file khtml_part.cpp.

References CaretDisplayPolicy, KHTMLView::caretDisplayPolicyNonFocused(), and view().

void KHTMLPart::setCaretDisplayPolicyNonFocused CaretDisplayPolicy    policy
 

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.

Parameters:
policy  new display policy
Since:
3.2

Definition at line 2392 of file khtml_part.cpp.

References KHTMLView::setCaretDisplayPolicyNonFocused(), and view().

KURL KHTMLPart::backgroundURL   const
 

Returns the URL for the background Image (used by save background).

Definition at line 3457 of file khtml_part.cpp.

References KParts::ReadOnlyPart::m_url.

void KHTMLPart::scheduleRedirection int    delay,
const QString   url,
bool    lockHistory = true
 

Schedules a redirection after delay seconds.

Definition at line 2098 of file khtml_part.cpp.

void KHTMLPart::begin const KURL   url = KURL(),
int    xOffset = 0,
int    yOffset = 0
[virtual]
 

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:

 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.

Definition at line 1614 of file khtml_part.cpp.

References QObject::connect(), KParts::URLArgs::docState, QString::isEmpty(), KURL::isEmpty(), KURL::isValid(), KParts::ReadOnlyPart::m_url, parentPart(), KURL::prettyURL(), KURL::protocol(), KParts::URLArgs::serviceType, setAutoloadImages(), KURL::setQuery(), KURL::setRef(), setUserStyleSheet(), KParts::Part::setWindowCaption(), QString::startsWith(), KURL::url(), KParts::URLArgs::xOffset, and KParts::URLArgs::yOffset.

Referenced by doOpenStream(), and htmlError().

void KHTMLPart::write const char *    str,
int    len = -1
[virtual]
 

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 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.

Definition at line 1699 of file khtml_part.cpp.

References QString::isEmpty().

Referenced by doWriteStream(), end(), and htmlError().

void KHTMLPart::write const QString   str [virtual]
 

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 1731 of file khtml_part.cpp.

References QString::isNull().

void KHTMLPart::end   [virtual]
 

Call this after your last call to write().

Definition at line 1746 of file khtml_part.cpp.

References write().

Referenced by closeURL(), doCloseStream(), htmlError(), selectedText(), and stopAnimations().

void KHTMLPart::paint QPainter  ,
const QRect  ,
int    = 0,
bool *    = 0
 

Paints the HTML page to a QPainter.

See KHTMLView::paint for details

Definition at line 1778 of file khtml_part.cpp.

bool KHTMLPart::setEncoding const QString   name,
bool    override = false
 

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 2174 of file khtml_part.cpp.

References closeURL(), KURL::isEmpty(), KParts::ReadOnlyPart::m_url, and openURL().

QString KHTMLPart::encoding   const
 

Returns the encoding the page currently uses.

Note that the encoding might be different from the charset.

Definition at line 2192 of file khtml_part.cpp.

References KHTMLSettings::encoding().

Referenced by restoreState().

void KHTMLPart::setUserStyleSheet const KURL   url
 

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.

Definition at line 2203 of file khtml_part.cpp.

References KURL::url().

Referenced by begin().

void KHTMLPart::setUserStyleSheet const QString   styleSheet
 

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.

Definition at line 2209 of file khtml_part.cpp.

void KHTMLPart::setStandardFont const QString   name
 

Sets the standard font style.

Parameters:
name  The font name to use for standard text.

Definition at line 2273 of file khtml_part.cpp.

void KHTMLPart::setFixedFont const QString   name
 

Sets the fixed font style.

Parameters:
name  The font name to use for fixed text, e.g. the <pre> tag.

Definition at line 2278 of file khtml_part.cpp.

bool KHTMLPart::gotoAnchor const QString   name
 

Finds the anchor named name.

If the anchor is found, the widget scrolls to the closest position. Returns if the anchor has been found.

Definition at line 2215 of file khtml_part.cpp.

Referenced by openURL().

bool KHTMLPart::nextAnchor  
 

Go to the next anchor.

This is useful to navigate from outside the navigator

Since:
3.2

Definition at line 2255 of file khtml_part.cpp.

bool KHTMLPart::prevAnchor  
 

Go to previous anchor

Since:
3.2.

Definition at line 2264 of file khtml_part.cpp.

void KHTMLPart::setURLCursor const QCursor   c
 

Sets the cursor to use when the cursor is on a link.

Definition at line 2283 of file khtml_part.cpp.

QCursor KHTMLPart::urlCursor   const
 

Returns the cursor which is used when the cursor is on a link.

Definition at line 2288 of file khtml_part.cpp.

void KHTMLPart::findTextBegin  
 

Initiates a text search.

Definition at line 2418 of file khtml_part.cpp.

bool KHTMLPart::findTextNext const QString   str,
bool    forward,
bool    caseSensitive,
bool    isRegExp
 

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 2482 of file khtml_part.cpp.

References QString::length(), QRegExp::matchedLength(), QRegExp::search(), QRegExp::setCaseSensitive(), and QConstString::string().

void KHTMLPart::setZoomFactor int    percent
 

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 4862 of file khtml_part.cpp.

References QApplication::restoreOverrideCursor(), and QApplication::setOverrideCursor().

Referenced by restoreState().

int KHTMLPart::zoomFactor   const
 

Returns the current zoom factor.

Definition at line 4822 of file khtml_part.cpp.

Referenced by khtml::CSSStyleSelector::CSSStyleSelector(), KHTMLView::print(), and restoreState().

QString KHTMLPart::selectedText   const [virtual]
 

Returns the text the user has marked.

Definition at line 2920 of file khtml_part.cpp.

References DOM::Node::elementId(), end(), DOM::Node::firstChild(), DOM::Node::handle(), QString::isEmpty(), DOM::Node::isNull(), QString::left(), QString::length(), QString::mid(), DOM::Node::nextSibling(), DOM::Node::nodeType(), DOM::Node::nodeValue(), and DOM::Node::parentNode().

Referenced by khtmlMouseReleaseEvent().

DOM::Range KHTMLPart::selection   const
 

Returns the selected part of the HTML.

Definition at line 3048 of file khtml_part.cpp.

References DOM::Document::createRange(), and document().

void KHTMLPart::selection DOM::Node   startNode,
long &    startOffset,
DOM::Node   endNode,
long &    endOffset
const
 

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.

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.
Since:
3.2

Definition at line 3056 of file khtml_part.cpp.

void KHTMLPart::setSelection const DOM::Range &   
 

Sets the current selection.

Definition at line 3064 of file khtml_part.cpp.

bool KHTMLPart::hasSelection   const
 

Has the user selected anything?

Call selectedText() to retrieve the selected text.

Returns:
true if there is text selected.

Definition at line 3038 of file khtml_part.cpp.

void KHTMLPart::selectAll  
 

Marks all text in the document as selected.

Definition at line 5688 of file khtml_part.cpp.

void KHTMLPart::show  
 

Convenience method to show the document's view.

Equivalent to widget()->show() or view()->show() .

Definition at line 4795 of file khtml_part.cpp.

void KHTMLPart::hide  
 

Convenience method to hide the document's view.

Equivalent to widget()->hide() or view()->hide().

Definition at line 4801 of file khtml_part.cpp.

KParts::PartManager * KHTMLPart::partManager  
 

Returns a reference to the partmanager instance which manages html frame objects.

Definition at line 4006 of file khtml_part.cpp.

References QObject::connect().

Referenced by currentFrame().

void KHTMLPart::saveState QDataStream   stream [virtual]
 

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 4526 of file khtml_part.cpp.

References KParts::ReadOnlyPart::m_url, and KURL::url().

void KHTMLPart::restoreState QDataStream   stream [virtual]
 

Restores the KHTMLPart's previously saved state (including child frame objects) from the provided QDataStream.

See also:
saveState()
This is called from the restoreState() method of the browserExtension() .

Definition at line 4605 of file khtml_part.cpp.

References QValueList::begin(), closeURL(), KParts::URLArgs::docState, encoding(), frameNames(), KHTMLPageCache::isComplete(), KParts::ReadOnlyPart::m_url, openURL(), KHTMLPageCache::self(), setZoomFactor(), KParts::URLArgs::xOffset, KParts::URLArgs::yOffset, and zoomFactor().

DOM::Node KHTMLPart::nodeUnderMouse   const
 

Returns the Node currently under the mouse.

Definition at line 4807 of file khtml_part.cpp.

KHTMLPart * KHTMLPart::parentPart  
 

Returns a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset.

Returns 0L otherwise.

Definition at line 4482 of file khtml_part.cpp.

References QObject::parent().

Referenced by begin(), khtmlMouseMoveEvent(), khtmlMousePressEvent(), khtmlMouseReleaseEvent(), KHTMLPart(), openURL(), toplevelURL(), and ~KHTMLPart().

QStringList KHTMLPart::frameNames   const
 

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 5021 of file khtml_part.cpp.

Referenced by restoreState().

KHTMLPart * KHTMLPart::findFrame const QString   f
 

Finds a frame by name.

Returns 0L if frame can't be found.

Definition at line 4415 of file khtml_part.cpp.

References QObject::className(), and QObject::inherits().

KParts::ReadOnlyPart * KHTMLPart::currentFrame   const
 

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 4455 of file khtml_part.cpp.

References KParts::PartManager::activePart(), QObject::inherits(), and partManager().

bool KHTMLPart::frameExists const QString   frameName
 

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 4470 of file khtml_part.cpp.

void KHTMLPart::setJSStatusBarText const QString   text
 

Called by KJS.

Sets the StatusBarText assigned via window.status

Definition at line 4923 of file khtml_part.cpp.

References KParts::Part::setStatusBarText().

void KHTMLPart::setJSDefaultStatusBarText const QString   text
 

Called by KJS.

Sets the DefaultStatusBarText assigned via window.defaultStatus

Definition at line 4928 of file khtml_part.cpp.

References KParts::Part::setStatusBarText().

QString KHTMLPart::jsStatusBarText   const
 

Called by KJS.

Returns the StatusBarText assigned via window.status

Definition at line 4933 of file khtml_part.cpp.

QString KHTMLPart::jsDefaultStatusBarText   const
 

Called by KJS.

Returns the DefaultStatusBarText assigned via window.defaultStatus

Definition at line 4938 of file khtml_part.cpp.

QString KHTMLPart::referrer   const
 

Referrer used for links in this page.

Definition at line 4943 of file khtml_part.cpp.

QString KHTMLPart::pageReferrer   const
 

Referrer used to obtain this page.

Definition at line 4948 of file khtml_part.cpp.

References KURL::isValid(), KParts::ReadOnlyPart::m_url, KURL::protocol(), KURL::setPass(), KURL::setRef(), KURL::setUser(), and KURL::url().

QString KHTMLPart::lastModified   const
 

Last-modified date (in raw string format), if received in the [HTTP] headers.

Definition at line 4969 of file khtml_part.cpp.

References KURL::isLocalFile(), KParts::ReadOnlyPart::m_url, KURL::path(), and QDateTime::toString().

void KHTMLPart::preloadStyleSheet const QString   url,
const QString   stylesheet
 

Loads a style sheet into the stylesheet cache.

Definition at line 5912 of file khtml_part.cpp.

void KHTMLPart::preloadScript const QString   url,
const QString   script
 

Loads a script into the script cache.

Definition at line 5917 of file khtml_part.cpp.

void KHTMLPart::setFormNotification FormNotification    fn
 

Determine if signal should be emitted before, instead or never when a submitForm() happens.

Since:
3.2 ### KDE4 remove me

Definition at line 6117 of file khtml_part.cpp.

KHTMLPart::FormNotification KHTMLPart::formNotification   const
 

Determine if signal should be emitted before, instead or never when a submitForm() happens.

### KDE4 remove me

Since:
3.2

Definition at line 6121 of file khtml_part.cpp.

KURL KHTMLPart::toplevelURL  
 

Returns the toplevel (origin) URL of this document, even if this part is a frame or an iframe.

Returns:
the actual orginal url.
Since:
3.2

Definition at line 6125 of file khtml_part.cpp.

References parentPart(), and KParts::ReadOnlyPart::url().

Referenced by openURL().

void KHTMLPart::onURL const QString   url [signal]
 

Emitted if the cursor is moved over an URL.

Referenced by khtmlMouseMoveEvent().

void KHTMLPart::popupMenu const QString   url,
const QPoint   point
[signal]
 

Emitted when the user clicks the right mouse button on the document.

Referenced by khtmlMouseMoveEvent(), and khtmlMousePressEvent().

void KHTMLPart::selectionChanged   [signal]
 

This signal is emitted when the selection changes.

Referenced by khtmlMouseReleaseEvent().

void KHTMLPart::nodeActivated const DOM::Node   [signal]
 

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.

Referenced by closeURL().

void KHTMLPart::caretPositionChanged const DOM::Node   node,
long    offset
[signal]
 

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.

Parameters:
node  node which the caret is in. This can be null if the caret has been deactivated.
offset  offset within the node. If the node is null, the offset is meaningless.
Since:
3.2

void KHTMLPart::formSubmitNotification const char *    action,
const QString   url,
const QByteArray   formData,
const QString   target,
const QString   contentType,
const QString   boundary
[signal]
 

If form notification is on, this will be emitted either for a form submit or before the form submit according to the setting.

Since:
3.2 ### KDE4 remove me

KURL KHTMLPart::completeURL const QString   url [protected]
 

returns a KURL object for the given url.

Use when you know what you're doing.

Definition at line 2088 of file khtml_part.cpp.

Referenced by khtmlMouseMoveEvent().

void KHTMLPart::htmlError int    errorCode,
const QString   text,
const KURL   reqUrl
[protected]
 

presents a detailed error message to the user.

errorCode kio error code, eg KIO::ERR_SERVER_TIMEOUT. text kio additional information text. url the url that triggered the error.

Definition at line 1463 of file khtml_part.cpp.

References QString::arg(), begin(), KIO::buildErrorString(), KParts::ReadOnlyPart::completed(), QDateTime::currentDateTime(), KStdAccel::description(), end(), KLocale::formatDateTime(), QString::fromLatin1(), KURL::htmlURL(), QString::isNull(), QStringList::join(), KGlobal::locale(), KParts::ReadOnlyPart::m_url, KURL::prettyURL(), KURL::protocol(), KIO::rawErrorDetail(), QString::replace(), KParts::ReadOnlyPart::started(), and write().

Referenced by openURL(), and showError().

void KHTMLPart::khtmlMousePressEvent khtml::MousePressEvent *    event [protected, virtual]
 

Eventhandler of the khtml::MousePressEvent.

Definition at line 5109 of file khtml_part.cpp.

References QMouseEvent::button(), QMouseEvent::globalPos(), DOM::Node::handle(), isEditable(), DOM::Node::isNull(), parentPart(), popupMenu(), QMouseEvent::pos(), and QMouseEvent::state().

void KHTMLPart::khtmlMouseDoubleClickEvent khtml::MouseDoubleClickEvent *    [protected, virtual]
 

Eventhandler for the khtml::MouseDoubleClickEvent.

Definition at line 5185 of file khtml_part.cpp.

References QMouseEvent::button(), DOM::Node::handle(), and DOM::Node::isNull().

void KHTMLPart::khtmlMouseMoveEvent khtml::MouseMoveEvent *    event [protected, virtual]
 

Eventhandler for the khtml::MouseDoubleMoveEvent.

Definition at line 5367 of file khtml_part.cpp.

References KMultipleDrag::addDragObject(), QString::arg(), completeURL(), QScrollView::contentsToViewport(), KGlobalSettings::dndEventDelay(), QDragObject::drag(), DOM::Node::elementId(), QMouseEvent::globalPos(), DOM::Node::handle(), isEditable(), DOM::Node::isNull(), QPixmap::isNull(), DOM::DOMString::length(), KURLDrag::metaData(), KMimeType::mimeType(), onURL(), parentPart(), KMimeType::pixmapForURL(), popupMenu(), QMouseEvent::pos(), QDragObject::setPixmap(), KParts::Part::setStatusBarText(), KIcon::SizeMedium, QMouseEvent::state(), DOM::DOMString::string(), view(), QPoint::x(), QMouseEvent::x(), QPoint::y(), and QMouseEvent::y().

void KHTMLPart::khtmlMouseReleaseEvent khtml::MouseReleaseEvent *    event [protected, virtual]
 

Eventhandler for the khtml::MouseMoveEvent.

Definition at line 5510 of file khtml_part.cpp.

References QMouseEvent::button(), KParts::BrowserInterface::callMethod(), QObject::connect(), d, QObject::disconnect(), DOM::Node::firstChild(), DOM::Node::isNull(), DOM::Node::nextSibling(), DOM::Node::parentNode(), parentPart(), QString::replace(), selectedText(), selectionChanged(), and KParts::Part::setStatusBarText().

void KHTMLPart::khtmlDrawContentsEvent khtml::DrawContentsEvent *    [protected, virtual]
 

Eventhandler for the khtml::DrawContentsEvent.

Definition at line 5616 of file khtml_part.cpp.

void KHTMLPart::guiActivateEvent KParts::GUIActivateEvent   event [protected, virtual]
 

Internal reimplementation of KParts::Part::guiActivateEvent .

Reimplemented from KParts::ReadOnlyPart.

Definition at line 5620 of file khtml_part.cpp.

References KParts::GUIActivateEvent::activated(), QPtrList::append(), and KXMLGUIClient::plugActionList().

bool KHTMLPart::openFile   [protected, virtual]
 

Internal empty reimplementation of KParts::ReadOnlyPart::openFile .

Implements KParts::ReadOnlyPart.

Definition at line 1253 of file khtml_part.cpp.

KParts::ReadOnlyPart * KHTMLPart::createPart QWidget   parentWidget,
const char *    widgetName,
QObject   parent,
const char *    name,
const QString   mimetype,
QString   serviceName,
QStringList   serviceTypes,
const QStringList   params
[protected, virtual]
 

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 3960 of file khtml_part.cpp.

References QString::append(), QValueList::begin(), QObject::className(), KLibFactory::create(), QFile::encodeName(), QValueList::end(), KLibLoader::factory(), KXMLGUIClient::factory(), QString::fromLatin1(), QObject::inherits(), QString::isEmpty(), QObject::name(), KTrader::OfferList, KService::Ptr, KTrader::query(), KLibLoader::self(), and KTrader::self().

bool KHTMLPart::doOpenStream const QString   mimeType [protected, virtual]
 

Implements the streaming API of KParts::ReadOnlyPart.

Definition at line 1755 of file khtml_part.cpp.

References begin(), and KParts::ReadOnlyPart::url().

bool KHTMLPart::doWriteStream const QByteArray   data [protected, virtual]
 

Implements the streaming API of KParts::ReadOnlyPart.

Definition at line 1765 of file khtml_part.cpp.

References write().

bool KHTMLPart::doCloseStream   [protected, virtual]
 

Implements the streaming API of KParts::ReadOnlyPart.

Definition at line 1771 of file khtml_part.cpp.

References end().

void KHTMLPart::setActiveNode const DOM::Node   node [slot]
 

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

Parameters:
node  The node to focus

Definition at line 5863 of file khtml_part.cpp.

References QRect::bottom(), DOM::Node::handle(), QRect::left(), QRect::right(), and QRect::top().

void KHTMLPart::stopAnimations   [slot]
 

Stops all animated images on the current and child pages.

Definition at line 1784 of file khtml_part.cpp.

References end().

QVariant KHTMLPart::executeScript const QString   script [slot]
 

Execute the specified snippet of JavaScript code.

Returns true if JavaScript was enabled, no error occurred and the code returned true itself or false otherwise. @deprecated, use executeString( DOM::Node(), script)

Definition at line 985 of file khtml_part.cpp.

References executeScript().

void KHTMLPart::setCaretMode bool    enable [slot]
 

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.

Parameters:
enable  true to enable, false to disable caret mode.
Since:
3.2

Definition at line 2326 of file khtml_part.cpp.

References KHTMLView::caretOff(), KHTMLView::ensureCaretVisible(), KHTMLView::initCaret(), isCaretMode(), isEditable(), and view().

void KHTMLPart::setEditable bool    enable [slot]
 

do not use.

Definition at line 2348 of file khtml_part.cpp.

References KHTMLView::caretOff(), KHTMLView::ensureCaretVisible(), KHTMLView::initCaret(), isCaretMode(), isEditable(), and view().

void KHTMLPart::setCaretVisible bool    show [slot]
 

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:

  • the document is editable
  • the document is in caret mode
  • the document's currently focused element is editable
Parameters:
show  true to make visible, false to hide.
Since:
3.2

Definition at line 2399 of file khtml_part.cpp.

References KHTMLView::caretOff(), KHTMLView::caretOn(), isCaretMode(), isEditable(), and view().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun May 16 22:06:35 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003