ReadWritePart Class Reference
from PyKDE4.kparts import *
Inherits: KParts.ReadOnlyPart
Namespace: KParts
Detailed Description
- Abstract class:
- This class can be used as a base class for new classes, but can not be instantiated directly.
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.
Signals | |
sigQueryClose (bool handled, bool abortClosing) | |
Methods | |
__init__ (self, QObject parent=0) | |
__init__ (self, KParts.ReadWritePart a0) | |
bool | closeUrl (self) |
bool | closeUrl (self, bool promptToSave) |
bool | isModified (self) |
bool | isReadWrite (self) |
bool | queryClose (self) |
bool | save (self) |
bool | saveAs (self, KUrl url) |
bool | saveFile (self) |
bool | saveToUrl (self) |
setModified (self, bool modified) | |
setModified (self) | |
setReadWrite (self, bool readwrite=1) | |
sigQueryClose (self, bool handled, bool abortClosing) | |
bool | waitSaveComplete (self) |
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
Constructor See parent constructor for instructions.
__init__ | ( | self, | ||
KParts.ReadWritePart | a0 | |||
) |
bool closeUrl | ( | self ) |
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
bool closeUrl | ( | self, | ||
bool | promptToSave | |||
) |
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()
bool isModified | ( | self ) |
- Returns:
- true if the document has been modified.
bool isReadWrite | ( | self ) |
- Returns:
- true if the part is in read-write mode
bool queryClose | ( | self ) |
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.
bool save | ( | self ) |
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.
bool saveAs | ( | self, | ||
KUrl | url | |||
) |
Save the file to a new location.
Calls save(), no need to reimplement
bool saveFile | ( | self ) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
Save to a local file. You need to implement it, to save to the local 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 saveToUrl | ( | self ) |
Save the file.
Uploads the file, if 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.
setModified | ( | self, | ||
bool | modified | |||
) |
Sets the modified flag of the part.
setModified | ( | self ) |
Call setModified() whenever the contents get modified. This is a slot for convenience, since it simply calls setModified(true), so that you can connect it to a signal, like textChanged().
setReadWrite | ( | self, | ||
bool | readwrite=1 | |||
) |
Changes the behavior of this part to readonly or readwrite.
- Parameters:
-
readwrite set to true to enable readwrite mode
sigQueryClose | ( | self, | ||
bool | handled, | |||
bool | abortClosing | |||
) |
set handled to true, if you don't want the default handling set abortClosing to true, if you handled the request, but for any reason don't want to allow closing the document
- Signal syntax:
QObject.connect(source, SIGNAL("sigQueryClose(bool*, bool*)"), target_slot)
bool waitSaveComplete | ( | self ) |
Waits for any pending upload job to finish and returns whether the last save() action was successful.