\section{KParts::Read\-Only\-Part Class Reference}
\label{classKParts_1_1ReadOnlyPart}\index{KParts::ReadOnlyPart@{KParts::ReadOnlyPart}}
Base class for any \char`\"{}viewer\char`\"{} part.  


{\tt \#include $<$part.h$>$}

Inheritance diagram for KParts::Read\-Only\-Part:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=99pt]{classKParts_1_1ReadOnlyPart__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KParts::Read\-Only\-Part:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=239pt]{classKParts_1_1ReadOnlyPart__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
virtual bool {\bf open\-URL} (const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Only reimplement open\-URL if you don't want synchronous network transparency Otherwise, reimplement {\bf open\-File}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_b0})}() only . \item\end{CompactList}\end{CompactItemize}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf started} ({\bf KIO::Job} $\ast$)
\begin{CompactList}\small\item\em The part emits this when starting data. \item\end{CompactList}\item 
void {\bf completed} ()
\begin{CompactList}\small\item\em Emit this when you have completed loading data. \item\end{CompactList}\item 
void {\bf completed} (bool pending\-Action)
\begin{CompactList}\small\item\em 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). \item\end{CompactList}\item 
void {\bf canceled} (const  {\bf QString} \&err\-Msg)
\begin{CompactList}\small\item\em Emit this if loading is canceled by the user or by an error. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Read\-Only\-Part} ({\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0)
\begin{CompactList}\small\item\em Constructor See also {\bf Part}{\rm (p.\,\pageref{classKParts_1_1Part})} for the set\-XXX methods to call. \item\end{CompactList}\item 
virtual {\bf $\sim$Read\-Only\-Part} ()
\begin{CompactList}\small\item\em Destructor. \item\end{CompactList}\item 
void {\bf set\-Progress\-Info\-Enabled} (bool show)
\begin{CompactList}\small\item\em Call this to turn off the progress info dialog used by the internal {\bf KIO} job. \item\end{CompactList}\item 
bool {\bf is\-Progress\-Info\-Enabled} () const 
\begin{CompactList}\small\item\em Returns whether the part shows the progress info dialog used by internal {\bf KIO} job. \item\end{CompactList}\item 
void {\bf show\-Progress\-Info} (bool show)\label{classKParts_1_1ReadOnlyPart_a4}

\item 
{\bf KURL} {\bf url} () const 
\begin{CompactList}\small\item\em Returns the currently in part used URL. \item\end{CompactList}\item 
virtual bool {\bf close\-URL} ()
\begin{CompactList}\small\item\em Called when closing the current url (e.g. \item\end{CompactList}\item 
bool {\bf open\-Stream} (const  {\bf QString} \&mime\-Type, const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Initiate sending data to this part. \item\end{CompactList}\item 
bool {\bf write\-Stream} (const  {\bf QByte\-Array} \&data)
\begin{CompactList}\small\item\em Send some data to the part. \item\end{CompactList}\item 
bool {\bf close\-Stream} ()
\begin{CompactList}\small\item\em Terminate the sending of data to the part. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Slots}
\begin{CompactItemize}
\item 
void {\bf slot\-Job\-Finished} ({\bf KIO::Job} $\ast$job)\label{classKParts_1_1ReadOnlyPart_j0}

\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf open\-File} ()=0
\begin{CompactList}\small\item\em If the part uses the standard implementation of {\bf open\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}(), it must reimplement this, to open {\tt m\_\-file}. \item\end{CompactList}\item 
void {\bf abort\-Load} ()\label{classKParts_1_1ReadOnlyPart_b1}

\item 
virtual void {\bf gui\-Activate\-Event} ({\bf GUIActivate\-Event} $\ast${\bf event})
\begin{CompactList}\small\item\em Reimplemented from {\bf Part}{\rm (p.\,\pageref{classKParts_1_1Part})}, 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() ! \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
{\bf KURL} {\bf m\_\-url}
\begin{CompactList}\small\item\em Remote (or local) url - the one displayed to the user. \item\end{CompactList}\item 
{\bf QString} {\bf m\_\-file}
\begin{CompactList}\small\item\em Local file - the only one the part implementation should deal with. \item\end{CompactList}\item 
bool {\bf m\_\-b\-Temp}
\begin{CompactList}\small\item\em If {\tt true}, {\tt m\_\-file} is a temporary file that needs to be deleted later. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Base class for any \char`\"{}viewer\char`\"{} 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 {\bf open\-File}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_b0})}(), not {\bf open\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}(). To prevent network transparency, or to implement it another way (e.g. asynchronously), override {\bf open\-URL()}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}.

KParts Application can use the signals to show feedback while the URL is being loaded.

{\bf Read\-Only\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart})} handles the window caption by setting it to the current URL (set in {\bf open\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}(), and each time the part is activated). If you want another caption, set it in {\bf open\-File}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_b0})}() and (if the part might ever be used with a part manager) in {\bf gui\-Activate\-Event}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_b2})}() 



Definition at line 290 of file part.h.

\subsection{Constructor \& Destructor Documentation}
\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!ReadOnlyPart@{ReadOnlyPart}}
\index{ReadOnlyPart@{ReadOnlyPart}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Read\-Only\-Part::Read\-Only\-Part ({\bf QObject} $\ast$ {\em parent} = 0, const char $\ast$ {\em name} = 0)}\label{classKParts_1_1ReadOnlyPart_a0}


Constructor See also {\bf Part}{\rm (p.\,\pageref{classKParts_1_1Part})} for the set\-XXX methods to call. 



Definition at line 292 of file part.cpp.

References KStd\-Accel::name().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!~ReadOnlyPart@{$\sim$ReadOnlyPart}}
\index{~ReadOnlyPart@{$\sim$ReadOnlyPart}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Read\-Only\-Part::$\sim${\bf Read\-Only\-Part} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadOnlyPart_a1}


Destructor. 



Definition at line 298 of file part.cpp.

\subsection{Member Function Documentation}
\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!setProgressInfoEnabled@{setProgressInfoEnabled}}
\index{setProgressInfoEnabled@{setProgressInfoEnabled}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Read\-Only\-Part::set\-Progress\-Info\-Enabled (bool {\em show})}\label{classKParts_1_1ReadOnlyPart_a2}


Call this to turn off the progress info dialog used by the internal {\bf 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 {\bf started}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_l0})}. 

Definition at line 304 of file part.cpp.\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!isProgressInfoEnabled@{isProgressInfoEnabled}}
\index{isProgressInfoEnabled@{isProgressInfoEnabled}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::is\-Progress\-Info\-Enabled () const}\label{classKParts_1_1ReadOnlyPart_a3}


Returns whether the part shows the progress info dialog used by internal {\bf KIO} job. 



Definition at line 309 of file part.cpp.\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!openURL@{openURL}}
\index{openURL@{openURL}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::open\-URL (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKParts_1_1ReadOnlyPart_i0}


Only reimplement open\-URL if you don't want synchronous network transparency Otherwise, reimplement {\bf open\-File}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_b0})}() only . 

If you reimplement it, don't forget to set the caption, usually with emit set\-Window\-Caption( url.pretty\-URL() ); 

Definition at line 321 of file part.cpp.

References close\-URL(), completed(), QObject::connect(), QFile\-Info::extension(), KIO::file\_\-copy(), QString::is\-Empty(), KURL::is\-Local\-File(), KURL::is\-Malformed(), m\_\-b\-Temp, m\_\-file, m\_\-url, KTemp\-File::name(), open\-File(), KURL::path(), KURL::pretty\-URL(), KURL::set\-Path(), KParts::Part::set\-Window\-Caption(), and started().

Referenced by KParts::Browser\-Extension::restore\-State().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!url@{url}}
\index{url@{url}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} KParts::Read\-Only\-Part::url () const\hspace{0.3cm}{\tt  [inline]}}\label{classKParts_1_1ReadOnlyPart_a5}


Returns the currently in part used URL. 

\begin{Desc}
\item[Returns:]The current used URL. \end{Desc}


Definition at line 340 of file part.h.

References m\_\-url.

Referenced by KParts::Read\-Write\-Part::query\-Close(), and KParts::Browser\-Extension::save\-State().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!closeURL@{closeURL}}
\index{closeURL@{closeURL}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::close\-URL ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadOnlyPart_a6}


Called when closing the current url (e.g. 

document), for instance when switching to another url (note that {\bf open\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}() 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. \begin{Desc}
\item[Returns:]always true, but the return value exists for reimplementations \end{Desc}


Reimplemented in {\bf KParts::Read\-Write\-Part} {\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}.

Definition at line 370 of file part.cpp.

References QFile::encode\-Name(), m\_\-b\-Temp, and m\_\-file.

Referenced by open\-Stream(), and open\-URL().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!openStream@{openStream}}
\index{openStream@{openStream}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::open\-Stream (const {\bf QString} \& {\em mime\-Type}, const {\bf KURL} \& {\em url})}\label{classKParts_1_1ReadOnlyPart_a7}


Initiate sending data to this part. 

This is an alternative to open\-URL, which allows the user of the part to load the data itself, and send it progressively to the part.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em url}]the URL representing this data. Although not directly used, every {\bf Read\-Only\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart})} has a URL (see {\bf url}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a5})}()), so this simply sets it. \item[{\em mime\-Type}]the type of data that is going to be sent to this part. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the part supports progressive loading and accepts data, false otherwise. \end{Desc}


Definition at line 411 of file part.cpp.

References close\-URL(), and m\_\-url.\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!writeStream@{writeStream}}
\index{writeStream@{writeStream}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::write\-Stream (const {\bf QByte\-Array} \& {\em data})}\label{classKParts_1_1ReadOnlyPart_a8}


Send some data to the part. 

{\bf open\-Stream}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a7})} must have been called previously, and must have returned true. \begin{Desc}
\item[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 {\bf close\-Stream}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a9})}. \end{Desc}


Definition at line 419 of file part.cpp.\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!closeStream@{closeStream}}
\index{closeStream@{closeStream}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Only\-Part::close\-Stream ()}\label{classKParts_1_1ReadOnlyPart_a9}


Terminate the sending of data to the part. 

With some data types (text, html...) {\bf close\-Stream}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a9})} 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.\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!started@{started}}
\index{started@{started}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KParts::Read\-Only\-Part::started ({\bf KIO::Job} $\ast$)\hspace{0.3cm}{\tt  [signal]}}\label{classKParts_1_1ReadOnlyPart_l0}


The part emits this when starting data. 

If using a {\bf KIO::Job}, it sets the job in the signal, so that progress information can be shown. Otherwise, job is 0. 

Referenced by open\-URL().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!completed@{completed}}
\index{completed@{completed}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KParts::Read\-Only\-Part::completed ()\hspace{0.3cm}{\tt  [signal]}}\label{classKParts_1_1ReadOnlyPart_l1}


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 open\-URL(), and KParts::Read\-Write\-Part::save\-To\-URL().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!completed@{completed}}
\index{completed@{completed}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KParts::Read\-Only\-Part::completed (bool {\em pending\-Action})\hspace{0.3cm}{\tt  [signal]}}\label{classKParts_1_1ReadOnlyPart_l2}


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.

{\tt pending\-Action} if true, a pending action exists (ex: a scheduled refresh) \index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!canceled@{canceled}}
\index{canceled@{canceled}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KParts::Read\-Only\-Part::canceled (const {\bf QString} \& {\em err\-Msg})\hspace{0.3cm}{\tt  [signal]}}\label{classKParts_1_1ReadOnlyPart_l3}


Emit this if loading is canceled by the user or by an error. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em err\-Msg}]the error message, empty if the user canceled the loading voluntarily. \end{description}
\end{Desc}
\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!openFile@{openFile}}
\index{openFile@{openFile}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KParts::Read\-Only\-Part::open\-File ()\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKParts_1_1ReadOnlyPart_b0}


If the part uses the standard implementation of {\bf open\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_i0})}(), it must reimplement this, to open {\tt m\_\-file}. 

Otherwise simply define it to \{ return false; \} 

Referenced by open\-URL().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!guiActivateEvent@{guiActivateEvent}}
\index{guiActivateEvent@{guiActivateEvent}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Read\-Only\-Part::gui\-Activate\-Event ({\bf GUIActivate\-Event} $\ast$ {\em event})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKParts_1_1ReadOnlyPart_b2}


Reimplemented from {\bf Part}{\rm (p.\,\pageref{classKParts_1_1Part})}, 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 {\bf GUIActivate\-Event}{\rm (p.\,\pageref{classKParts_1_1GUIActivateEvent})} and not with {\bf Part\-Activate\-Event}{\rm (p.\,\pageref{classKParts_1_1PartActivateEvent})} because it's handled by the mainwindow (which gets the even after the {\bf Part\-Activate\-Event}{\rm (p.\,\pageref{classKParts_1_1PartActivateEvent})} events have been sent) 

Reimplemented from {\bf KParts::Part} {\rm (p.\,\pageref{classKParts_1_1Part_b4})}.

Definition at line 399 of file part.cpp.

References KNotify\-Client::event(), KURL::is\-Empty(), m\_\-url, KURL::pretty\-URL(), and KParts::Part::set\-Window\-Caption().

\subsection{Member Data Documentation}
\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!m_url@{m\_\-url}}
\index{m_url@{m\_\-url}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KURL} {\bf KParts::Read\-Only\-Part::m\_\-url}\hspace{0.3cm}{\tt  [protected]}}\label{classKParts_1_1ReadOnlyPart_p0}


Remote (or local) url - the one displayed to the user. 



Definition at line 469 of file part.h.

Referenced by gui\-Activate\-Event(), open\-Stream(), open\-URL(), KParts::Read\-Write\-Part::query\-Close(), KParts::Read\-Write\-Part::save\-As(), KParts::Read\-Write\-Part::save\-To\-URL(), and url().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!m_file@{m\_\-file}}
\index{m_file@{m\_\-file}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} {\bf KParts::Read\-Only\-Part::m\_\-file}\hspace{0.3cm}{\tt  [protected]}}\label{classKParts_1_1ReadOnlyPart_p1}


Local file - the only one the part implementation should deal with. 



Definition at line 473 of file part.h.

Referenced by close\-URL(), open\-URL(), KParts::Read\-Write\-Part::save\-As(), and KParts::Read\-Write\-Part::save\-To\-URL().\index{KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}!m_bTemp@{m\_\-bTemp}}
\index{m_bTemp@{m\_\-bTemp}!KParts::ReadOnlyPart@{KParts::Read\-Only\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool {\bf KParts::Read\-Only\-Part::m\_\-b\-Temp}\hspace{0.3cm}{\tt  [protected]}}\label{classKParts_1_1ReadOnlyPart_p2}


If {\tt true}, {\tt m\_\-file} is a temporary file that needs to be deleted later. 



Definition at line 477 of file part.h.

Referenced by close\-URL(), open\-URL(), KParts::Read\-Write\-Part::save\-As(), and KParts::Read\-Write\-Part::save\-To\-URL().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
part.h\item 
part.cpp\end{CompactItemize}
