.TH "KParts::ReadOnlyPart" 3 "28 Jan 2004" "kparts Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KParts::ReadOnlyPart \- Base class for any 'viewer' part.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <part.h>\fP
.PP
Inherits \fBKParts::Part\fP.
.PP
Inherited by \fBKParts::ReadWritePart\fP.
.PP
.SS "Public Slots"

.in +1c
.ti -1c
.RI "virtual bool \fBopenURL\fP (const  \fBKURL\fP &url)"
.br
.RI "\fIOnly reimplement openURL if you don't want synchronous network transparency Otherwise, reimplement \fBopenFile\fP() only . \fP"
.in -1c
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBstarted\fP (\fBKIO::Job\fP *)"
.br
.RI "\fIThe part emits this when starting data. \fP"
.ti -1c
.RI "void \fBcompleted\fP ()"
.br
.RI "\fIEmit this when you have completed loading data. \fP"
.ti -1c
.RI "void \fBcompleted\fP (bool pendingAction)"
.br
.RI "\fISame as the above signal except besides indicating that the data has been completely loaded it also informs the host, by setting the flag, that a pending action has been generated as a result of completing the requested task (loading the data). \fP"
.ti -1c
.RI "void \fBcanceled\fP (const  \fBQString\fP &errMsg)"
.br
.RI "\fIEmit this if loading is canceled by the user or by an error. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBReadOnlyPart\fP (\fBQObject\fP *\fBparent\fP=0, const  char *\fBname\fP=0)"
.br
.RI "\fIConstructor See also \fBPart\fP for the setXXX methods to call. \fP"
.ti -1c
.RI "virtual \fB~ReadOnlyPart\fP ()"
.br
.RI "\fIDestructor. \fP"
.ti -1c
.RI "void \fBsetProgressInfoEnabled\fP (bool show)"
.br
.RI "\fICall this to turn off the progress info dialog used by the internal \fBKIO\fP job. \fP"
.ti -1c
.RI "bool \fBisProgressInfoEnabled\fP () const "
.br
.RI "\fIReturns whether the part shows the progress info dialog used by internal \fBKIO\fP job. \fP"
.ti -1c
.RI "void \fBshowProgressInfo\fP (bool show)"
.br
.ti -1c
.RI "\fBKURL\fP \fBurl\fP () const "
.br
.RI "\fIReturns the currently in part used URL. \fP"
.ti -1c
.RI "virtual bool \fBcloseURL\fP ()"
.br
.RI "\fICalled when closing the current url (e.g. \fP"
.ti -1c
.RI "bool \fBopenStream\fP (const  \fBQString\fP &mimeType, const  \fBKURL\fP &url)"
.br
.RI "\fIInitiate sending data to this part. \fP"
.ti -1c
.RI "bool \fBwriteStream\fP (const  \fBQByteArray\fP &data)"
.br
.RI "\fISend some data to the part. \fP"
.ti -1c
.RI "bool \fBcloseStream\fP ()"
.br
.RI "\fITerminate the sending of data to the part. \fP"
.in -1c
.SS "Protected Slots"

.in +1c
.ti -1c
.RI "void \fBslotJobFinished\fP (\fBKIO::Job\fP *job)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBopenFile\fP ()=0"
.br
.RI "\fIIf the part uses the standard implementation of \fBopenURL\fP(), it must reimplement this, to open \fCm_file\fP. \fP"
.ti -1c
.RI "void \fBabortLoad\fP ()"
.br
.ti -1c
.RI "virtual void \fBguiActivateEvent\fP (\fBGUIActivateEvent\fP *\fBevent\fP)"
.br
.RI "\fIReimplemented from \fBPart\fP, so that the window caption is set to the current url (decoded) when the part is activated This is the usual behaviour in 99% of the apps Reimplement if you don't like it - test for event->activated() ! \fP"
.in -1c
.SS "Protected Attributes"

.in +1c
.ti -1c
.RI "\fBKURL\fP \fBm_url\fP"
.br
.RI "\fIRemote (or local) url - the one displayed to the user. \fP"
.ti -1c
.RI "\fBQString\fP \fBm_file\fP"
.br
.RI "\fILocal file - the only one the part implementation should deal with. \fP"
.ti -1c
.RI "bool \fBm_bTemp\fP"
.br
.RI "\fIIf \fCtrue\fP, \fCm_file\fP is a temporary file that needs to be deleted later. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Base class for any 'viewer' part. 

This class takes care of network transparency for you, in the simplest way (synchronously). To use the built-in network transparency, you only need to implement \fBopenFile\fP(), not \fBopenURL\fP(). To prevent network transparency, or to implement it another way (e.g. asynchronously), override \fBopenURL()\fP.
.PP
KParts Application can use the signals to show feedback while the URL is being loaded.
.PP
\fBReadOnlyPart\fP handles the window caption by setting it to the current URL (set in \fBopenURL\fP(), and each time the part is activated). If you want another caption, set it in \fBopenFile\fP() and (if the part might ever be used with a part manager) in \fBguiActivateEvent\fP() 
.PP
Definition at line 290 of file part.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "ReadOnlyPart::ReadOnlyPart (\fBQObject\fP * parent = 0, const char * name = 0)"
.PP
Constructor See also \fBPart\fP for the setXXX methods to call. Definition at line 292 of file part.cpp.
.PP
References KStdAccel::name().
.SS "ReadOnlyPart::~\fBReadOnlyPart\fP ()\fC [virtual]\fP"
.PP
Destructor. Definition at line 298 of file part.cpp.
.SH "Member Function Documentation"
.PP 
.SS "void ReadOnlyPart::setProgressInfoEnabled (bool show)"
.PP
Call this to turn off the progress info dialog used by the internal \fBKIO\fP 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 \fBstarted\fP. Definition at line 304 of file part.cpp.
.SS "bool ReadOnlyPart::isProgressInfoEnabled () const"
.PP
Returns whether the part shows the progress info dialog used by internal \fBKIO\fP job. Definition at line 309 of file part.cpp.
.SS "bool ReadOnlyPart::openURL (const \fBKURL\fP & url)\fC [virtual, slot]\fP"
.PP
Only reimplement openURL if you don't want synchronous network transparency Otherwise, reimplement \fBopenFile\fP() only . If you reimplement it, don't forget to set the caption, usually with emit setWindowCaption( url.prettyURL() ); Definition at line 321 of file part.cpp.
.PP
References closeURL(), completed(), QObject::connect(), QFileInfo::extension(), KIO::file_copy(), QString::isEmpty(), KURL::isLocalFile(), KURL::isMalformed(), m_bTemp, m_file, m_url, KTempFile::name(), openFile(), KURL::path(), KURL::prettyURL(), KURL::setPath(), KParts::Part::setWindowCaption(), and started().
.PP
Referenced by KParts::BrowserExtension::restoreState().
.SS "\fBKURL\fP KParts::ReadOnlyPart::url () const\fC [inline]\fP"
.PP
Returns the currently in part used URL. \fBReturns:\fP
.RS 4
The current used URL. 
.RE
.PP
Definition at line 340 of file part.h.
.PP
References m_url.
.PP
Referenced by KParts::ReadWritePart::queryClose(), and KParts::BrowserExtension::saveState().
.SS "bool ReadOnlyPart::closeURL ()\fC [virtual]\fP"
.PP
Called when closing the current url (e.g. document), for instance when switching to another url (note that \fBopenURL\fP() 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. 
.PP
\fBReturns:\fP
.RS 4
always true, but the return value exists for reimplementations 
.RE
.PP
Reimplemented in \fBKParts::ReadWritePart\fP.
.PP
Definition at line 370 of file part.cpp.
.PP
References QFile::encodeName(), m_bTemp, and m_file.
.PP
Referenced by openStream(), and openURL().
.SS "bool ReadOnlyPart::openStream (const \fBQString\fP & mimeType, const \fBKURL\fP & url)"
.PP
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.
.PP
\fBParameters:\fP
.RS 4
\fIurl\fP the URL representing this data. Although not directly used, every \fBReadOnlyPart\fP has a URL (see \fBurl\fP()), so this simply sets it. 
.br
\fImimeType\fP the type of data that is going to be sent to this part. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if the part supports progressive loading and accepts data, false otherwise. 
.RE
.PP
Definition at line 411 of file part.cpp.
.PP
References closeURL(), and m_url.
.SS "bool ReadOnlyPart::writeStream (const \fBQByteArray\fP & data)"
.PP
Send some data to the part. \fBopenStream\fP must have been called previously, and must have returned true. 
.PP
\fBReturns:\fP
.RS 4
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 \fBcloseStream\fP. 
.RE
.PP
Definition at line 419 of file part.cpp.
.SS "bool ReadOnlyPart::closeStream ()"
.PP
Terminate the sending of data to the part. With some data types (text, html...) \fBcloseStream\fP might never actually be called, in the case of continous streams, for instance plain text or HTML data. Definition at line 424 of file part.cpp.
.SS "void KParts::ReadOnlyPart::started (\fBKIO::Job\fP *)\fC [signal]\fP"
.PP
The part emits this when starting data. If using a \fBKIO::Job\fP, it sets the job in the signal, so that progress information can be shown. Otherwise, job is 0. Referenced by openURL().
.SS "void KParts::ReadOnlyPart::completed ()\fC [signal]\fP"
.PP
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. Referenced by openURL(), and KParts::ReadWritePart::saveToURL().
.SS "void KParts::ReadOnlyPart::completed (bool pendingAction)\fC [signal]\fP"
.PP
Same as the above signal except besides indicating that the data has been completely loaded it also informs the host, by setting the flag, that a pending action has been generated as a result of completing the requested task (loading the data). An example of this is meta-refresh tags on HTML pages which result in the page either being refreshed or the viewer being redirected to another page. By emitting this signal after appropriately setting the flag, the part can tell the host of the pending scheduled action inorder to give it a chance to accept or cancel that action.
.PP
\fCpendingAction\fP if true, a pending action exists (ex: a scheduled refresh) 
.SS "void KParts::ReadOnlyPart::canceled (const \fBQString\fP & errMsg)\fC [signal]\fP"
.PP
Emit this if loading is canceled by the user or by an error. \fBParameters:\fP
.RS 4
\fIerrMsg\fP the error message, empty if the user canceled the loading voluntarily. 
.RE
.PP

.SS "virtual bool KParts::ReadOnlyPart::openFile ()\fC [protected, pure virtual]\fP"
.PP
If the part uses the standard implementation of \fBopenURL\fP(), it must reimplement this, to open \fCm_file\fP. Otherwise simply define it to { return false; } Referenced by openURL().
.SS "void ReadOnlyPart::guiActivateEvent (\fBGUIActivateEvent\fP * event)\fC [protected, virtual]\fP"
.PP
Reimplemented from \fBPart\fP, so that the window caption is set to the current url (decoded) when the part is activated This is the usual behaviour in 99% of the apps Reimplement if you don't like it - test for event->activated() ! Technical note : this is done with \fBGUIActivateEvent\fP and not with \fBPartActivateEvent\fP because it's handled by the mainwindow (which gets the even after the \fBPartActivateEvent\fP events have been sent) Reimplemented from \fBKParts::Part\fP.
.PP
Definition at line 399 of file part.cpp.
.PP
References KNotifyClient::event(), KURL::isEmpty(), m_url, KURL::prettyURL(), and KParts::Part::setWindowCaption().
.SH "Member Data Documentation"
.PP 
.SS "\fBKURL\fP \fBKParts::ReadOnlyPart::m_url\fP\fC [protected]\fP"
.PP
Remote (or local) url - the one displayed to the user. Definition at line 469 of file part.h.
.PP
Referenced by guiActivateEvent(), openStream(), openURL(), KParts::ReadWritePart::queryClose(), KParts::ReadWritePart::saveAs(), KParts::ReadWritePart::saveToURL(), and url().
.SS "\fBQString\fP \fBKParts::ReadOnlyPart::m_file\fP\fC [protected]\fP"
.PP
Local file - the only one the part implementation should deal with. Definition at line 473 of file part.h.
.PP
Referenced by closeURL(), openURL(), KParts::ReadWritePart::saveAs(), and KParts::ReadWritePart::saveToURL().
.SS "bool \fBKParts::ReadOnlyPart::m_bTemp\fP\fC [protected]\fP"
.PP
If \fCtrue\fP, \fCm_file\fP is a temporary file that needs to be deleted later. Definition at line 477 of file part.h.
.PP
Referenced by closeURL(), openURL(), KParts::ReadWritePart::saveAs(), and KParts::ReadWritePart::saveToURL().

.SH "Author"
.PP 
Generated automatically by Doxygen for kparts Library from the source code.
