KParts::ReadWritePart Class Reference
Base class for an "editor" part. More...
#include <part.h>
Inheritance diagram for KParts::ReadWritePart:

Public Slots | |
virtual void | setModified () |
Call setModified() whenever the contents get modified. | |
virtual bool | save () |
Save the file in the location from which it was opened. | |
Public Member Functions | |
ReadWritePart (QObject *parent=0, const char *name=0) | |
Constructor See parent constructor for instructions. | |
virtual | ~ReadWritePart () |
Destructor Applications using a ReadWritePart should make sure, before destroying it, to call closeURL(). | |
bool | isReadWrite () const |
virtual void | setReadWrite (bool readwrite=true) |
Changes the behaviour of this part to readonly or readwrite. | |
bool | isModified () const |
bool | queryClose () |
If the document has been modified, ask the user to save changes. | |
virtual bool | closeURL () |
Called when closing the current url (e.g. | |
bool | closeURL (bool promptToSave) |
Call this method instead of the above if you need control if the save prompt is shown. | |
virtual bool | saveAs (const KURL &url) |
Save the file to a new location. | |
virtual void | setModified (bool modified) |
Sets the modified flag of the part. | |
Protected Slots | |
void | slotUploadFinished (KIO::Job *job) |
Protected Member Functions | |
virtual bool | saveFile ()=0 |
Save to a local file. | |
virtual bool | saveToURL () |
Save the file. |
Detailed Description
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).
A read-write part can be set to read-only mode, using setReadWrite().
Part writers : Any part inheriting ReadWritePart should check isReadWrite before allowing any action that modifies the part. The part probably wants to reimplement setReadWrite, disable those actions. Don't forget to call the parent setReadWrite.
Definition at line 498 of file part.h.
Constructor & Destructor Documentation
|
Constructor See parent constructor for instructions.
Definition at line 431 of file part.cpp. References KStdAccel::name(). |
|
Destructor Applications using a ReadWritePart should make sure, before destroying it, to call closeURL(). In KMainWindow::queryClose(), for instance, they should allow closing only if the return value of closeURL() was true. This allows to cancel. |
Member Function Documentation
|
Definition at line 520 of file part.h. Referenced by closeURL(), and queryClose(). |
|
Changes the behaviour of this part to readonly or readwrite.
|
|
Definition at line 531 of file part.h. Referenced by closeURL(), and queryClose(). |
|
If the document has been modified, ask the user to save changes. This method is meant to be called from KMainWindow::queryClose(). It will also be called from closeURL().
Definition at line 467 of file part.cpp. References KFileDialog::getSaveURL(), KURL::isEmpty(), isModified(), isReadWrite(), KParts::ReadOnlyPart::m_url, save(), saveAs(), KParts::ReadOnlyPart::url(), KMessageBox::warningYesNoCancel(), and KParts::Part::widget(). Referenced by closeURL(). |
|
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. If isModified(), queryClose() will be called.
Reimplemented from KParts::ReadOnlyPart. Definition at line 495 of file part.cpp. References isModified(), isReadWrite(), and queryClose(). Referenced by closeURL(). |
|
Call this method instead of the above if you need control if the save prompt is shown. For example, if you call queryClose() from KMainWindow::queryClose(), you would not want to prompt again when closing the url. Equivalent to promptToSave ? closeURL() : ReadOnlyPart::closeURL()
Definition at line 507 of file part.cpp. References closeURL(). |
|
Save the file to a new location. Calls save(), no need to reimplement Definition at line 519 of file part.cpp. 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(). Referenced by queryClose(). |
|
Sets the modified flag of the part.
|
|
Call setModified() 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. Referenced by saveToURL(). |
|
Save the file in the location from which it was opened. You can connect this to the "save" action. Calls saveFile() and saveToURL(), no need to reimplement. Definition at line 512 of file part.cpp. References saveFile(), and saveToURL(). Referenced by queryClose(), and saveAs(). |
|
Save to a local file.
You need to implement it, to save to Referenced by save(). |
|
Save the file.
Uploads the file, if Definition at line 552 of file part.cpp. 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(). Referenced by save(). |
The documentation for this class was generated from the following files: