\section{KParts::Read\-Write\-Part Class Reference}
\label{classKParts_1_1ReadWritePart}\index{KParts::ReadWritePart@{KParts::ReadWritePart}}
Base class for an \char`\"{}editor\char`\"{} part.  


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

Inheritance diagram for KParts::Read\-Write\-Part:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=99pt]{classKParts_1_1ReadWritePart__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KParts::Read\-Write\-Part:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=239pt]{classKParts_1_1ReadWritePart__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Slots}
\begin{CompactItemize}
\item 
virtual void {\bf set\-Modified} ()
\begin{CompactList}\small\item\em Call {\bf set\-Modified}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a9})}() whenever the contents get modified. \item\end{CompactList}\item 
virtual bool {\bf save} ()
\begin{CompactList}\small\item\em Save the file in the location from which it was opened. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Read\-Write\-Part} ({\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0)
\begin{CompactList}\small\item\em Constructor See parent constructor for instructions. \item\end{CompactList}\item 
virtual {\bf $\sim$Read\-Write\-Part} ()
\begin{CompactList}\small\item\em Destructor Applications using a {\bf Read\-Write\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart})} should make sure, before destroying it, to call {\bf close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}(). \item\end{CompactList}\item 
bool {\bf is\-Read\-Write} () const 
\item 
virtual void {\bf set\-Read\-Write} (bool readwrite=true)
\begin{CompactList}\small\item\em Changes the behaviour of this part to readonly or readwrite. \item\end{CompactList}\item 
bool {\bf is\-Modified} () const 
\item 
bool {\bf query\-Close} ()
\begin{CompactList}\small\item\em If the document has been modified, ask the user to save changes. \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 close\-URL} (bool prompt\-To\-Save)
\begin{CompactList}\small\item\em Call this method instead of the above if you need control if the save prompt is shown. \item\end{CompactList}\item 
virtual bool {\bf save\-As} (const  {\bf KURL} \&url)
\begin{CompactList}\small\item\em Save the file to a new location. \item\end{CompactList}\item 
virtual void {\bf set\-Modified} (bool modified)
\begin{CompactList}\small\item\em Sets the modified flag of the part. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Slots}
\begin{CompactItemize}
\item 
void {\bf slot\-Upload\-Finished} ({\bf KIO::Job} $\ast$job)\label{classKParts_1_1ReadWritePart_j0}

\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf save\-File} ()=0
\begin{CompactList}\small\item\em Save to a local file. \item\end{CompactList}\item 
virtual bool {\bf save\-To\-URL} ()
\begin{CompactList}\small\item\em Save the file. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Base class for an \char`\"{}editor\char`\"{} part. 

This class handles network transparency for you. Anything that can open a URL, allow modifications, and save (to the same URL or a different one).

A read-write part can be set to read-only mode, using {\bf set\-Read\-Write}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a3})}().

{\bf Part}{\rm (p.\,\pageref{classKParts_1_1Part})} writers : Any part inheriting {\bf Read\-Write\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart})} should check {\bf is\-Read\-Write}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a2})} before allowing any action that modifies the part. The part probably wants to reimplement {\bf set\-Read\-Write}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a3})}, disable those actions. Don't forget to call the parent {\bf set\-Read\-Write}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a3})}. 



Definition at line 498 of file part.h.

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


Constructor See parent constructor for instructions. 



Definition at line 431 of file part.cpp.

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


Destructor Applications using a {\bf Read\-Write\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart})} should make sure, before destroying it, to call {\bf close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}(). 

In {\bf KMain\-Window::query\-Close}(), for instance, they should allow closing only if the return value of {\bf close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}() was true. This allows to cancel. 

Definition at line 437 of file part.cpp.

\subsection{Member Function Documentation}
\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!isReadWrite@{isReadWrite}}
\index{isReadWrite@{isReadWrite}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KParts::Read\-Write\-Part::is\-Read\-Write () const\hspace{0.3cm}{\tt  [inline]}}\label{classKParts_1_1ReadWritePart_a2}


\begin{Desc}
\item[Returns:]true if the part is in read-write mode \end{Desc}


Definition at line 520 of file part.h.

Referenced by close\-URL(), and query\-Close().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!setReadWrite@{setReadWrite}}
\index{setReadWrite@{setReadWrite}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Read\-Write\-Part::set\-Read\-Write (bool {\em readwrite} = true)\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadWritePart_a3}


Changes the behaviour of this part to readonly or readwrite. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em readwrite}]set to true to enable readwrite mode \end{description}
\end{Desc}


Definition at line 445 of file part.cpp.\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!isModified@{isModified}}
\index{isModified@{isModified}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KParts::Read\-Write\-Part::is\-Modified () const\hspace{0.3cm}{\tt  [inline]}}\label{classKParts_1_1ReadWritePart_a4}


\begin{Desc}
\item[Returns:]true if the document has been modified. \end{Desc}


Definition at line 531 of file part.h.

Referenced by close\-URL(), and query\-Close().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!queryClose@{queryClose}}
\index{queryClose@{queryClose}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::query\-Close ()}\label{classKParts_1_1ReadWritePart_a5}


If the document has been modified, ask the user to save changes. 

This method is meant to be called from {\bf KMain\-Window::query\-Close}(). It will also be called from {\bf close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}().

\begin{Desc}
\item[Returns:]true if {\bf close\-URL()}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})} can be called without the user losing important data, false if the user chooses to cancel.\end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 467 of file part.cpp.

References KFile\-Dialog::get\-Save\-URL(), KURL::is\-Empty(), is\-Modified(), is\-Read\-Write(), KParts::Read\-Only\-Part::m\_\-url, save(), save\-As(), KParts::Read\-Only\-Part::url(), KMessage\-Box::warning\-Yes\-No\-Cancel(), and KParts::Part::widget().

Referenced by close\-URL().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!closeURL@{closeURL}}
\index{closeURL@{closeURL}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::close\-URL ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadWritePart_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.

If {\bf is\-Modified}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a4})}(), {\bf query\-Close}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a5})}() will be called.

\begin{Desc}
\item[Returns:]false on cancel \end{Desc}


Reimplemented from {\bf KParts::Read\-Only\-Part} {\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a6})}.

Definition at line 495 of file part.cpp.

References is\-Modified(), is\-Read\-Write(), and query\-Close().

Referenced by close\-URL().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!closeURL@{closeURL}}
\index{closeURL@{closeURL}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::close\-URL (bool {\em prompt\-To\-Save})}\label{classKParts_1_1ReadWritePart_a7}


Call this method instead of the above if you need control if the save prompt is shown. 

For example, if you call {\bf query\-Close}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a5})}() from {\bf KMain\-Window::query\-Close}(), you would not want to prompt again when closing the url.

Equivalent to prompt\-To\-Save ? {\bf close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a6})}() : {\bf Read\-Only\-Part::close\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_a6})}()

\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 507 of file part.cpp.

References close\-URL().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!saveAs@{saveAs}}
\index{saveAs@{saveAs}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::save\-As (const {\bf KURL} \& {\em url})\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadWritePart_a8}


Save the file to a new location. 

Calls {\bf save}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_i1})}(), no need to reimplement 

Definition at line 519 of file part.cpp.

References QFile::encode\-Name(), QString::is\-Empty(), KURL::is\-Local\-File(), KURL::is\-Malformed(), KParts::Read\-Only\-Part::m\_\-b\-Temp, KParts::Read\-Only\-Part::m\_\-file, KParts::Read\-Only\-Part::m\_\-url, KTemp\-File::name(), KURL::path(), KURL::pretty\-URL(), save(), KParts::Part::set\-Window\-Caption(), and KURL::url().

Referenced by query\-Close().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!setModified@{setModified}}
\index{setModified@{setModified}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Read\-Write\-Part::set\-Modified (bool {\em modified})\hspace{0.3cm}{\tt  [virtual]}}\label{classKParts_1_1ReadWritePart_a9}


Sets the modified flag of the part. 



Definition at line 451 of file part.cpp.\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!setModified@{setModified}}
\index{setModified@{setModified}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Read\-Write\-Part::set\-Modified ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKParts_1_1ReadWritePart_i0}


Call {\bf set\-Modified}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_a9})}() whenever the contents get modified. 

This is a slot for convenience, so that you can connect it to a signal, like text\-Changed(). 

Definition at line 462 of file part.cpp.

Referenced by save\-To\-URL().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!save@{save}}
\index{save@{save}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::save ()\hspace{0.3cm}{\tt  [virtual, slot]}}\label{classKParts_1_1ReadWritePart_i1}


Save the file in the location from which it was opened. 

You can connect this to the \char`\"{}save\char`\"{} action. Calls {\bf save\-File}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_b0})}() and {\bf save\-To\-URL}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart_b1})}(), no need to reimplement. 

Definition at line 512 of file part.cpp.

References save\-File(), and save\-To\-URL().

Referenced by query\-Close(), and save\-As().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!saveFile@{saveFile}}
\index{saveFile@{saveFile}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KParts::Read\-Write\-Part::save\-File ()\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKParts_1_1ReadWritePart_b0}


Save to a local file. 

You need to implement it, to save to {\tt m\_\-file}. The framework takes care of re-uploading afterwards. 

Referenced by save().\index{KParts::ReadWritePart@{KParts::Read\-Write\-Part}!saveToURL@{saveToURL}}
\index{saveToURL@{saveToURL}!KParts::ReadWritePart@{KParts::Read\-Write\-Part}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Read\-Write\-Part::save\-To\-URL ()\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKParts_1_1ReadWritePart_b1}


Save the file. 

Uploads the file, if {\tt m\_\-url} is remote. This will emit {\bf started}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_l0})}(), and either {\bf completed}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_l1})}() or {\bf canceled}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart_l3})}(), in case you want to provide feedback. 

Definition at line 552 of file part.cpp.

References KParts::Read\-Only\-Part::completed(), QObject::connect(), QFile::encode\-Name(), KIO::file\_\-move(), KURL::is\-Local\-File(), KParts::Read\-Only\-Part::m\_\-b\-Temp, KParts::Read\-Only\-Part::m\_\-file, KParts::Read\-Only\-Part::m\_\-url, KTemp\-File::name(), set\-Modified(), and KTemp\-File::unlink().

Referenced by save().

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