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

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

.in +1c
.ti -1c
.RI "virtual void \fBsetModified\fP ()"
.br
.RI "\fICall \fBsetModified\fP() whenever the contents get modified. \fP"
.ti -1c
.RI "virtual bool \fBsave\fP ()"
.br
.RI "\fISave the file in the location from which it was opened. \fP"
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBReadWritePart\fP (\fBQObject\fP *\fBparent\fP=0, const  char *\fBname\fP=0)"
.br
.RI "\fIConstructor See parent constructor for instructions. \fP"
.ti -1c
.RI "virtual \fB~ReadWritePart\fP ()"
.br
.RI "\fIDestructor Applications using a \fBReadWritePart\fP should make sure, before destroying it, to call \fBcloseURL\fP(). \fP"
.ti -1c
.RI "bool \fBisReadWrite\fP () const "
.br
.ti -1c
.RI "virtual void \fBsetReadWrite\fP (bool readwrite=true)"
.br
.RI "\fIChanges the behaviour of this part to readonly or readwrite. \fP"
.ti -1c
.RI "bool \fBisModified\fP () const "
.br
.ti -1c
.RI "bool \fBqueryClose\fP ()"
.br
.RI "\fIIf the document has been modified, ask the user to save changes. \fP"
.ti -1c
.RI "virtual bool \fBcloseURL\fP ()"
.br
.RI "\fICalled when closing the current url (e.g. \fP"
.ti -1c
.RI "bool \fBcloseURL\fP (bool promptToSave)"
.br
.RI "\fICall this method instead of the above if you need control if the save prompt is shown. \fP"
.ti -1c
.RI "virtual bool \fBsaveAs\fP (const  \fBKURL\fP &url)"
.br
.RI "\fISave the file to a new location. \fP"
.ti -1c
.RI "virtual void \fBsetModified\fP (bool modified)"
.br
.RI "\fISets the modified flag of the part. \fP"
.in -1c
.SS "Protected Slots"

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

.in +1c
.ti -1c
.RI "virtual bool \fBsaveFile\fP ()=0"
.br
.RI "\fISave to a local file. \fP"
.ti -1c
.RI "virtual bool \fBsaveToURL\fP ()"
.br
.RI "\fISave the file. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Base class for an 'editor' 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).
.PP
A read-write part can be set to read-only mode, using \fBsetReadWrite\fP().
.PP
\fBPart\fP writers : Any part inheriting \fBReadWritePart\fP should check \fBisReadWrite\fP before allowing any action that modifies the part. The part probably wants to reimplement \fBsetReadWrite\fP, disable those actions. Don't forget to call the parent \fBsetReadWrite\fP. 
.PP
Definition at line 498 of file part.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "ReadWritePart::ReadWritePart (\fBQObject\fP * parent = 0, const char * name = 0)"
.PP
Constructor See parent constructor for instructions. Definition at line 431 of file part.cpp.
.PP
References KStdAccel::name().
.SS "ReadWritePart::~\fBReadWritePart\fP ()\fC [virtual]\fP"
.PP
Destructor Applications using a \fBReadWritePart\fP should make sure, before destroying it, to call \fBcloseURL\fP(). In \fBKMainWindow::queryClose\fP(), for instance, they should allow closing only if the return value of \fBcloseURL\fP() was true. This allows to cancel. Definition at line 437 of file part.cpp.
.SH "Member Function Documentation"
.PP 
.SS "bool KParts::ReadWritePart::isReadWrite () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
true if the part is in read-write mode 
.RE
.PP
Definition at line 520 of file part.h.
.PP
Referenced by closeURL(), and queryClose().
.SS "void ReadWritePart::setReadWrite (bool readwrite = true)\fC [virtual]\fP"
.PP
Changes the behaviour of this part to readonly or readwrite. \fBParameters:\fP
.RS 4
\fIreadwrite\fP set to true to enable readwrite mode 
.RE
.PP
Definition at line 445 of file part.cpp.
.SS "bool KParts::ReadWritePart::isModified () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
true if the document has been modified. 
.RE
.PP
Definition at line 531 of file part.h.
.PP
Referenced by closeURL(), and queryClose().
.SS "bool ReadWritePart::queryClose ()"
.PP
If the document has been modified, ask the user to save changes. This method is meant to be called from \fBKMainWindow::queryClose\fP(). It will also be called from \fBcloseURL\fP().
.PP
\fBReturns:\fP
.RS 4
true if \fBcloseURL()\fP can be called without the user losing important data, false if the user chooses to cancel.
.RE
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP
Definition at line 467 of file part.cpp.
.PP
References KFileDialog::getSaveURL(), KURL::isEmpty(), isModified(), isReadWrite(), KParts::ReadOnlyPart::m_url, save(), saveAs(), KParts::ReadOnlyPart::url(), KMessageBox::warningYesNoCancel(), and KParts::Part::widget().
.PP
Referenced by closeURL().
.SS "bool ReadWritePart::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).
.PP
If the current URL is not fully loaded yet, aborts loading.
.PP
If \fBisModified\fP(), \fBqueryClose\fP() will be called.
.PP
\fBReturns:\fP
.RS 4
false on cancel 
.RE
.PP
Reimplemented from \fBKParts::ReadOnlyPart\fP.
.PP
Definition at line 495 of file part.cpp.
.PP
References isModified(), isReadWrite(), and queryClose().
.PP
Referenced by closeURL().
.SS "bool ReadWritePart::closeURL (bool promptToSave)"
.PP
Call this method instead of the above if you need control if the save prompt is shown. For example, if you call \fBqueryClose\fP() from \fBKMainWindow::queryClose\fP(), you would not want to prompt again when closing the url.
.PP
Equivalent to promptToSave ? \fBcloseURL\fP() : \fBReadOnlyPart::closeURL\fP()
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP
Definition at line 507 of file part.cpp.
.PP
References closeURL().
.SS "bool ReadWritePart::saveAs (const \fBKURL\fP & url)\fC [virtual]\fP"
.PP
Save the file to a new location. Calls \fBsave\fP(), no need to reimplement Definition at line 519 of file part.cpp.
.PP
References QFile::encodeName(), QString::isEmpty(), KURL::isLocalFile(), KURL::isMalformed(), KParts::ReadOnlyPart::m_bTemp, KParts::ReadOnlyPart::m_file, KParts::ReadOnlyPart::m_url, KTempFile::name(), KURL::path(), KURL::prettyURL(), save(), KParts::Part::setWindowCaption(), and KURL::url().
.PP
Referenced by queryClose().
.SS "void ReadWritePart::setModified (bool modified)\fC [virtual]\fP"
.PP
Sets the modified flag of the part. Definition at line 451 of file part.cpp.
.SS "void ReadWritePart::setModified ()\fC [virtual, slot]\fP"
.PP
Call \fBsetModified\fP() whenever the contents get modified. This is a slot for convenience, so that you can connect it to a signal, like textChanged(). Definition at line 462 of file part.cpp.
.PP
Referenced by saveToURL().
.SS "bool ReadWritePart::save ()\fC [virtual, slot]\fP"
.PP
Save the file in the location from which it was opened. You can connect this to the 'save' action. Calls \fBsaveFile\fP() and \fBsaveToURL\fP(), no need to reimplement. Definition at line 512 of file part.cpp.
.PP
References saveFile(), and saveToURL().
.PP
Referenced by queryClose(), and saveAs().
.SS "virtual bool KParts::ReadWritePart::saveFile ()\fC [protected, pure virtual]\fP"
.PP
Save to a local file. You need to implement it, to save to \fCm_file\fP. The framework takes care of re-uploading afterwards. Referenced by save().
.SS "bool ReadWritePart::saveToURL ()\fC [protected, virtual]\fP"
.PP
Save the file. Uploads the file, if \fCm_url\fP is remote. This will emit \fBstarted\fP(), and either \fBcompleted\fP() or \fBcanceled\fP(), in case you want to provide feedback. Definition at line 552 of file part.cpp.
.PP
References KParts::ReadOnlyPart::completed(), QObject::connect(), QFile::encodeName(), KIO::file_move(), KURL::isLocalFile(), KParts::ReadOnlyPart::m_bTemp, KParts::ReadOnlyPart::m_file, KParts::ReadOnlyPart::m_url, KTempFile::name(), setModified(), and KTempFile::unlink().
.PP
Referenced by save().

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