KWebPage

Search for usage in LXR

#include <kwebpage.h>

Inherits QWebPage.

Public Types

typedef QFlags< IntegrationFlagsIntegration
 
enum  IntegrationFlags { NoIntegration = 0x01, KIOIntegration = 0x02, KPartsIntegration = 0x04, KWalletIntegration = 0x08 }
 

Public Slots

virtual void downloadRequest (const QNetworkRequest &request)
 
void downloadResponse (QNetworkReply *reply)
 
virtual void downloadUrl (const QUrl &url)
 

Public Member Functions

 KWebPage (QObject *parent=nullptr, Integration flags=Integration())
 
 ~KWebPage ()
 
bool isExternalContentAllowed () const
 
void setAllowExternalContent (bool allow)
 
void setWallet (KWebWallet *wallet)
 
KWebWalletwallet () const
 

Protected Member Functions

bool acceptNavigationRequest (QWebFrame *frame, const QNetworkRequest &request, NavigationType type) override
 
bool handleReply (QNetworkReply *reply, QString *contentType=nullptr, KIO::MetaData *metaData=nullptr)
 
void removeRequestMetaData (const QString &key)
 
void removeSessionMetaData (const QString &key)
 
QString requestMetaData (const QString &key) const
 
QString sessionMetaData (const QString &key) const
 
void setRequestMetaData (const QString &key, const QString &value)
 
void setSessionMetaData (const QString &key, const QString &value)
 
QString userAgentForUrl (const QUrl &url) const override
 

Detailed Description

An enhanced QWebPage that provides integration with KDE Frameworks.

This is a convenience class that provides full integration with KDE frameworks technologies such as KIO for network request handling, KCookiejar for cookie handling, KParts for embedding non-html content and KWallet for storing form data. It also sets standard icons for many of the actions provided by QWebPage.

Most of this integration happens behind the scenes. If you want KWallet integration, however, you will have to provide a mechanism for deciding whether to allow form data to be stored. To do this, you will need to connect to the KWebWallet::saveFormDataRequested signal and call either KWebWallet::acceptSaveFormDataRequest or KWebWallet::rejectSaveFormDataRequest, typically after asking the user whether they want to save the form data. If you do not do this, no form data will be saved.

KWebPage will also not automatically load form data for you. You should connect to QWebPage::loadFinished and, if the page was loaded successfully, call

page->wallet()->fillFormData(page->mainFrame());
See also
KIO::Integration
KWebWallet
Author
Urs Wolfer <uwolfer @ kde.org>
Dawit Alemayehu <adawit @ kde.org>
Since
4.4

Definition at line 75 of file kwebpage.h.

Member Enumeration Documentation

Flags for setting the desired level of integration.

Enumerator
NoIntegration 

Provide only very basic integration such as using KDE icons for the actions provided by QWebPage.

KIOIntegration 

Use KIO to handle network requests.

See also
KIO::Integration::AccessManager
KPartsIntegration 

Use KPart componenets, if available, to display content in <embed> and <object> tags.

KWalletIntegration 

Use KWallet to store login credentials and other form data from web sites.

See also
wallet() and setWallet()

Definition at line 83 of file kwebpage.h.

Constructor & Destructor Documentation

KWebPage::KWebPage ( QObject parent = nullptr,
Integration  flags = Integration() 
)
explicit

Constructs a KWebPage with parent parent.

Note that if no integration flags are set (the default), all integration options are activated. If you inherit from this class you can use the flags in IntegrationFlags to control how much integration should be used.

See also
KIO::Integration::CookieJar
KIO::Integration::AccessManager
wallet() and setWallet()

Definition at line 235 of file kwebpage.cpp.

KWebPage::~KWebPage ( )

Destroys the KWebPage.

Definition at line 299 of file kwebpage.cpp.

Member Function Documentation

bool KWebPage::acceptNavigationRequest ( QWebFrame *  frame,
const QNetworkRequest request,
NavigationType  type 
)
overrideprotected
Reimplemented from superclass.

This performs various integration-related actions when navigation is requested. If you override this method, make sure you call the parent's implementation unless you want to block the request outright.

If you do override acceptNavigationRequest and call this method, however, be aware of the effect of the page's linkDelegationPolicy on how * QWebPage::acceptNavigationRequest behaves.

See also
QWebPage::acceptNavigationRequest

Definition at line 465 of file kwebpage.cpp.

void KWebPage::downloadRequest ( const QNetworkRequest request)
virtualslot

Download request using KIO.

This slot first prompts the user where to save the requested resource and then downloads it using KIO.

Definition at line 340 of file kwebpage.cpp.

void KWebPage::downloadResponse ( QNetworkReply reply)
slot

Download the resource specified by reply using KIO.

This slot first prompts the user where to save the requested resource and then downloads it using KIO.

If reply contains a QObject property called "DownloadManagerExe", then an attempt will be made to the command specified by that property to download the specified resource.

If the "DownloadManagerExe" property is not defined or the command specified by it could not be successfully executed, then the user will be prompted for the action to take.

Since
4.5
See also
handleReply

Definition at line 357 of file kwebpage.cpp.

void KWebPage::downloadUrl ( const QUrl url)
virtualslot

Download url using KIO.

This slot first prompts the user where to save the requested resource and then downloads it using KIO.

Definition at line 352 of file kwebpage.cpp.

bool KWebPage::handleReply ( QNetworkReply reply,
QString contentType = nullptr,
KIO::MetaData metaData = nullptr 
)
protected

Attempts to handle reply and returns true on success, false otherwise.

If reply contains a QObject property called "DownloadManagerExe", then an attempt will be made to let the command specified by that property to download the requested resource.

If the "DownloadManagerExe" property is not defined or the command specified by it could not be successfully executed, then the user will be prompted for the action to take.

Parameters
replythe QNetworkReply object to be handled.
contentTypeif not null, it will be set to the content-type specified in reply, if any.
metaDataif not null, it will be set to the KIO meta-data specified in reply, if any.
Since
4.6.3

Definition at line 499 of file kwebpage.cpp.

bool KWebPage::isExternalContentAllowed ( ) const

Whether access to remote content is permitted.

If this is false, only resources on the local system can be accessed through this web page. By default access to remote content is allowed.

If KIO integration is disabled, this will always return true.

See also
setAllowExternalContent()
KIO::Integration::AccessManager::isExternalContentAllowed()
Returns
true if access to remote content is permitted, false otherwise

Definition at line 304 of file kwebpage.cpp.

void KWebPage::removeRequestMetaData ( const QString key)
protected

Remove an item of request metadata.

Removes the temporary (per-request) metadata associated with key.

See also
KIO::Integration::AccessManager::requestMetaData
setRequestMetaData
Parameters
keythe key for the metadata to remove

Definition at line 434 of file kwebpage.cpp.

void KWebPage::removeSessionMetaData ( const QString key)
protected

Remove an item of session metadata.

Removes the permanent (per-session) metadata associated with key.

See also
KIO::Integration::AccessManager::sessionMetaData
setSessionMetaData
Parameters
keythe key for the metadata to remove

Definition at line 426 of file kwebpage.cpp.

QString KWebPage::requestMetaData ( const QString key) const
protected

Get an item of request metadata.

Retrieves the value of the temporary (per-request) metadata for key.

If KIO integration is disabled, this will always return an empty string.

See also
KIO::Integration::AccessManager::requestMetaData
setRequestMetaData
Parameters
keythe key of the metadata to retrieve
Returns
the value of the metadata associated with key, or an empty string if there is no such metadata

Definition at line 398 of file kwebpage.cpp.

QString KWebPage::sessionMetaData ( const QString key) const
protected

Get an item of session metadata.

Retrieves the value of the permanent (per-session) metadata for key.

If KIO integration is disabled, this will always return an empty string.

See also
KIO::Integration::AccessManager::sessionMetaData
setSessionMetaData
Parameters
keythe key of the metadata to retrieve
Returns
the value of the metadata associated with key, or an empty string if there is no such metadata

Definition at line 386 of file kwebpage.cpp.

void KWebPage::setAllowExternalContent ( bool  allow)

Set whether to allow remote content.

If KIO integration is not enabled, this method will have no effect.

See also
isExternalContentAllowed()
KIO::Integration::AccessManager::setAllowExternalContent(bool)
Parameters
allowtrue if access to remote content should be allowed, false if only local content should be accessible

Definition at line 318 of file kwebpage.cpp.

void KWebPage::setRequestMetaData ( const QString key,
const QString value 
)
protected

Set an item of metadata to be sent to the KIO slave with the next request.

If KIO integration is disabled, this method will have no effect.

Metadata set using this method will be deleted after it has been sent once.

See also
KIO::Integration::AccessManager::requestMetaData
Parameters
keythe key for the metadata; any existing metadata associated with this key will be overwritten
valuethe value to associate with key

Definition at line 418 of file kwebpage.cpp.

void KWebPage::setSessionMetaData ( const QString key,
const QString value 
)
protected

Set an item of metadata to be sent to the KIO slave with every request.

If KIO integration is disabled, this method will have no effect.

Metadata set using this method will be sent with every request.

See also
KIO::Integration::AccessManager::sessionMetaData
Parameters
keythe key for the metadata; any existing metadata associated with this key will be overwritten
valuethe value to associate with key

Definition at line 410 of file kwebpage.cpp.

void KWebPage::setWallet ( KWebWallet wallet)

Set the KWebWallet that is used to store form data.

This KWebPage will take ownership of wallet, so that the wallet is deleted when the KWebPage is deleted. If you do not want that to happen, you should call setParent() on wallet after calling this function.

See also
KWebWallet
Parameters
walletthe KWebWallet to be used for storing form data, or 0 to disable KWallet integration

Definition at line 326 of file kwebpage.cpp.

QString KWebPage::userAgentForUrl ( const QUrl url) const
overrideprotected
Reimplemented from superclass.

This function is re-implemented to provide KIO user-agent management integration with KProtocolManager.

If a special user-agent has been configured for the host indicated by url, that user-agent will be returned. Otherwise, QWebPage's default user agent is returned.

See also
KProtocolManager::userAgentForHost.
QWebPage::userAgentForUrl.

Definition at line 442 of file kwebpage.cpp.

KWebWallet * KWebPage::wallet ( ) const

The wallet integration manager.

If you wish to use KWallet integration, you will have to connect to signals emitted by this object and react accordingly. See KWebWallet for more information.

Returns
the wallet integration manager, or 0 if KWallet integration is disabled

Definition at line 313 of file kwebpage.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 02:09:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.