KParts
KParts::ReadWritePart Class Reference
Base class for an "editor" part. More...
#include <part.h>
Public Slots | |
virtual bool | save () |
virtual void | setModified () |
bool | waitSaveComplete () |
Signals | |
void | sigQueryClose (bool *handled, bool *abortClosing) |
Public Member Functions | |
bool | closeURL (bool promptToSave) |
virtual bool | closeURL () |
bool | isModified () const |
bool | isReadWrite () const |
bool | queryClose () |
ReadWritePart (QObject *parent=0, const char *name=0) | |
virtual bool | saveAs (const KURL &url) |
virtual void | setModified (bool modified) |
virtual void | setReadWrite (bool readwrite=true) |
virtual | ~ReadWritePart () |
Protected Slots | |
void | slotUploadFinished (KIO::Job *job) |
Protected Member Functions | |
virtual bool | saveFile ()=0 |
virtual bool | saveToURL () |
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 544 of file part.h.
Constructor & Destructor Documentation
ReadWritePart::ReadWritePart | ( | QObject * | parent = 0 , |
|
const char * | name = 0 | |||
) |
ReadWritePart::~ReadWritePart | ( | ) | [virtual] |
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
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()
- Since:
- 3.2
bool ReadWritePart::closeURL | ( | ) | [virtual] |
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.
- Returns:
- false on cancel
Reimplemented from KParts::ReadOnlyPart.
bool KParts::ReadWritePart::isModified | ( | ) | const [inline] |
bool KParts::ReadWritePart::isReadWrite | ( | ) | const [inline] |
bool ReadWritePart::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().
- Returns:
- true if closeURL() can be called without the user losing important data, false if the user chooses to cancel.
- Since:
- 3.2
bool ReadWritePart::save | ( | ) | [virtual, slot] |
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.
virtual bool KParts::ReadWritePart::saveFile | ( | ) | [protected, pure virtual] |
Save to a local file.
You need to implement it, to save to m_file
. The framework takes care of re-uploading afterwards.
- Returns:
- true on success, false on failure. On failure the function should inform the user about the problem with an appropriate message box. Standard error messages can be constructed using KIO::buildErrorString() in combination with the error codes defined in kio/global.h
bool ReadWritePart::saveToURL | ( | ) | [protected, virtual] |
Save the file.
Uploads the file, if m_url
is remote. This will emit started(), and either completed() or canceled(), in case you want to provide feedback.
- Returns:
- true on success, false on failure.
void ReadWritePart::setModified | ( | ) | [virtual, slot] |
Call setModified() whenever the contents get modified.
This is a slot for convenience, so that you can connect it to a signal, like textChanged().
void ReadWritePart::setModified | ( | bool | modified | ) | [virtual] |
void ReadWritePart::setReadWrite | ( | bool | readwrite = true |
) | [virtual] |
- Since:
- 3.2, remove in KDE 4, when queryClose is made virtual
void ReadWritePart::slotUploadFinished | ( | KIO::Job * | job | ) | [protected, slot] |
bool ReadWritePart::waitSaveComplete | ( | ) | [slot] |
The documentation for this class was generated from the following files: