KParts
KParts::ReadOnlyPart Class Reference
Base class for any "viewer" part. More...
#include <part.h>
Public Slots | |
virtual bool | openURL (const KURL &url) |
Signals | |
void | canceled (const QString &errMsg) |
void | completed (bool pendingAction) |
void | completed () |
void | started (KIO::Job *) |
Public Member Functions | |
bool | closeStream () |
virtual bool | closeURL () |
bool | isProgressInfoEnabled () const |
bool | openStream (const QString &mimeType, const KURL &url) |
ReadOnlyPart (QObject *parent=0, const char *name=0) | |
void | setProgressInfoEnabled (bool show) |
void | showProgressInfo (bool show) |
KURL | url () const |
bool | writeStream (const QByteArray &data) |
virtual | ~ReadOnlyPart () |
Protected Slots | |
void | slotJobFinished (KIO::Job *job) |
Protected Member Functions | |
void | abortLoad () |
virtual void | guiActivateEvent (GUIActivateEvent *event) |
virtual bool | openFile ()=0 |
Protected Attributes | |
bool | m_bTemp |
QString | m_file |
KURL | m_url |
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()
Definition at line 338 of file part.h.
Constructor & Destructor Documentation
ReadOnlyPart::ReadOnlyPart | ( | QObject * | parent = 0 , |
|
const char * | name = 0 | |||
) |
Member Function Documentation
void ReadOnlyPart::abortLoad | ( | ) | [protected] |
void KParts::ReadOnlyPart::canceled | ( | const QString & | errMsg | ) | [signal] |
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.
bool ReadOnlyPart::closeStream | ( | ) |
bool ReadOnlyPart::closeURL | ( | ) | [virtual] |
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
Reimplemented in KParts::ReadWritePart.
void KParts::ReadOnlyPart::completed | ( | bool | pendingAction | ) | [signal] |
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.
- Parameters:
-
pendingAction true if a pending action exists, false otherwise.
void KParts::ReadOnlyPart::completed | ( | ) | [signal] |
Emit this when you have completed loading data.
Hosting apps will want to know when the process of loading the data is finished, so that they can access the data when everything is loaded.
void ReadOnlyPart::guiActivateEvent | ( | GUIActivateEvent * | event | ) | [protected, virtual] |
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)
Reimplemented from KParts::Part.
bool ReadOnlyPart::isProgressInfoEnabled | ( | ) | const |
virtual bool KParts::ReadOnlyPart::openFile | ( | ) | [protected, pure virtual] |
If the part uses the standard implementation of openURL(), it must reimplement this, to open m_file
.
Otherwise simply define it to { return false; }
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.
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() );
void ReadOnlyPart::setProgressInfoEnabled | ( | bool | show | ) |
void ReadOnlyPart::slotJobFinished | ( | KIO::Job * | job | ) | [protected, slot] |
void KParts::ReadOnlyPart::started | ( | KIO::Job * | ) | [signal] |
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.
KURL KParts::ReadOnlyPart::url | ( | ) | const [inline] |
bool ReadOnlyPart::writeStream | ( | const QByteArray & | data | ) |
Member Data Documentation
bool KParts::ReadOnlyPart::m_bTemp [protected] |
QString KParts::ReadOnlyPart::m_file [protected] |
KURL KParts::ReadOnlyPart::m_url [protected] |
The documentation for this class was generated from the following files: