ReadOnlyPart Class Reference
from PyKDE4.kparts import *
Inherits: KParts.Part → QObject
Namespace: KParts
Detailed Description
Base class for any "viewer" part.
This class takes care of network transparency for you, in the simplest way (downloading to a temporary file, then letting the part load from the temporary file). To use the built-in network transparency, you only need to implement openFile(), not openUrl().
To implement network transparency differently (e.g. for progressive loading, like a web browser does for instance), or to prevent network transparency (but why would you do that?), you can override openUrl().
KParts Application can use the signals to show feedback while the URL is being loaded.
ReadOnlyPart handles the window caption by setting it to the current URL (set in openUrl(), and each time the part is activated). If you want another caption, set it in openFile() and (if the part might ever be used with a part manager) in guiActivateEvent()
Signals | |
canceled (QString errMsg) | |
completed () | |
completed (bool pendingAction) | |
started (KIO.Job a0) | |
Methods | |
__init__ (self, QObject parent=0) | |
__init__ (self, KParts.ReadOnlyPart a0) | |
abortLoad (self) | |
KParts.OpenUrlArguments | arguments (self) |
KParts.BrowserExtension | browserExtension (self) |
bool | closeStream (self) |
bool | closeUrl (self) |
guiActivateEvent (self, KParts.GUIActivateEvent event) | |
bool | isLocalFileTemporary (self) |
bool | isProgressInfoEnabled (self) |
QString | localFilePath (self) |
bool | openFile (self) |
bool | openStream (self, QString mimeType, KUrl url) |
bool | openUrl (self, KUrl url) |
setArguments (self, KParts.OpenUrlArguments arguments) | |
setLocalFilePath (self, QString localFilePath) | |
setLocalFileTemporary (self, bool temp) | |
setProgressInfoEnabled (self, bool show) | |
setUrl (self, KUrl url) | |
showProgressInfo (self, bool show) | |
KUrl | url (self) |
bool | writeStream (self, QByteArray data) |
Signal Documentation
canceled | ( | QString | errMsg | |
) |
Emit this if loading is canceled by the user or by an error.
- Parameters:
-
errMsg the error message, empty if the user canceled the loading voluntarily.
- Signal syntax:
QObject.connect(source, SIGNAL("canceled(const QString&)"), target_slot)
completed | ( | ) |
Same as the above signal except it indicates whether there is a pending action to be executed on a delay timer. An example of this is the meta-refresh tags on web pages used to reload/redirect after a certain period of time. This signal is useful if you want to give the user the ability to cancel such pending actions.
pendingAction true if a pending action exists, false otherwise.
- Signal syntax:
QObject.connect(source, SIGNAL("completed()"), target_slot)
completed | ( | bool | pendingAction | |
) |
Same as the above signal except it indicates whether there is a pending action to be executed on a delay timer. An example of this is the meta-refresh tags on web pages used to reload/redirect after a certain period of time. This signal is useful if you want to give the user the ability to cancel such pending actions.
pendingAction true if a pending action exists, false otherwise.
- Signal syntax:
QObject.connect(source, SIGNAL("completed(bool)"), target_slot)
started | ( | KIO.Job | a0 | |
) |
The part emits this when starting data. If using a KIO.Job, it sets the job in the signal, so that progress information can be shown. Otherwise, job is 0.
- Signal syntax:
QObject.connect(source, SIGNAL("started(KIO::Job*)"), target_slot)
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
Constructor See also Part for the setXXX methods to call.
__init__ | ( | self, | ||
KParts.ReadOnlyPart | a0 | |||
) |
abortLoad | ( | self ) |
- Internal:
KParts.OpenUrlArguments arguments | ( | self ) |
- Returns:
- the arguments that were used to open this URL.
KParts.BrowserExtension browserExtension | ( | self ) |
This convenience method returns the browserExtension for this part, or 0 if there isn't any.
bool closeStream | ( | self ) |
Terminate the sending of data to the part. With some data types (text, html...) closeStream might never actually be called, in the case of continuous streams, for instance plain text or HTML data.
bool closeUrl | ( | self ) |
Called when closing the current url (e.g. document), for instance when switching to another url (note that openUrl() calls it automatically in this case). If the current URL is not fully loaded yet, aborts loading. Deletes the temporary file used when the url is remote.
- Returns:
- always true, but the return value exists for reimplementations
guiActivateEvent | ( | self, | ||
KParts.GUIActivateEvent | event | |||
) |
Reimplemented from Part, so that the window caption is set to the current url (decoded) when the part is activated This is the usual behavior in 99% of the apps Reimplement if you don't like it - test for event->activated() !
Technical note : this is done with GUIActivateEvent and not with PartActivateEvent because it's handled by the mainwindow (which gets the even after the PartActivateEvent events have been sent)
bool isLocalFileTemporary | ( | self ) |
- Internal:
bool isProgressInfoEnabled | ( | self ) |
Returns whether the part shows the progress info dialog used by internal KIO job.
QString localFilePath | ( | self ) |
Returns the local file path associated with this part.
bool openFile | ( | self ) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
If the part uses the standard implementation of openUrl(), it must reimplement this, to open the local file. The default implementation is simply { return false; }
bool openStream | ( | self, | ||
QString | mimeType, | |||
KUrl | url | |||
) |
Initiate sending data to this part. This is an alternative to openUrl, which allows the user of the part to load the data itself, and send it progressively to the part.
- Parameters:
-
mimeType the type of data that is going to be sent to this part. url the URL representing this data. Although not directly used, every ReadOnlyPart has a URL (see url()), so this simply sets it.
- Returns:
- true if the part supports progressive loading and accepts data, false otherwise.
bool openUrl | ( | self, | ||
KUrl | url | |||
) |
Only reimplement openUrl if you don't want the network transparency support to download from the url into a temporary file (when the url isn't local). Otherwise, reimplement openFile() only .
If you reimplement it, don't forget to set the caption, usually with emit setWindowCaption( url.prettyUrl() );
setArguments | ( | self, | ||
KParts.OpenUrlArguments | arguments | |||
) |
Sets the arguments to use for the next openUrl call.
setLocalFilePath | ( | self, | ||
QString | localFilePath | |||
) |
Sets the local file path associated with this part.
setLocalFileTemporary | ( | self, | ||
bool | temp | |||
) |
- Internal:
setProgressInfoEnabled | ( | self, | ||
bool | show | |||
) |
Call this to turn off the progress info dialog used by the internal KIO job. Use this if you provide another way of displaying progress info (e.g. a statusbar), using the signals emitted by this class, and/or those emitted by the Job given by started.
setUrl | ( | self, | ||
KUrl | url | |||
) |
Sets the url associated with this part.
showProgressInfo | ( | self, | ||
bool | show | |||
) |
KUrl url | ( | self ) |
Returns the URL currently opened in this part.
- Returns:
- The current URL.
bool writeStream | ( | self, | ||
QByteArray | data | |||
) |
Send some data to the part. openStream must have been called previously, and must have returned true.
- Returns:
- true if the data was accepted by the part. If false is returned, the application should stop sending data, and doesn't have to call closeStream.