• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KParts

KParts::ReadWritePart

KParts::ReadWritePart Class Reference

#include <part.h>

Inheritance diagram for KParts::ReadWritePart:

Inheritance graph
[legend]

List of all members.


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 734 of file part.h.


Public Slots

virtual bool save ()
void setModified ()
bool waitSaveComplete ()

Signals

void sigQueryClose (bool *handled, bool *abortClosing)

Public Member Functions

virtual bool closeUrl (bool promptToSave)
virtual bool closeUrl ()
bool isModified () const
bool isReadWrite () const
virtual bool queryClose ()
 ReadWritePart (QObject *parent=0)
virtual bool saveAs (const KUrl &url)
virtual void setModified (bool modified)
virtual void setReadWrite (bool readwrite=true)
virtual ~ReadWritePart ()

Protected Member Functions

virtual bool saveFile ()=0
virtual bool saveToUrl ()

Constructor & Destructor Documentation

ReadWritePart::ReadWritePart ( QObject *  parent = 0  )  [explicit]

Constructor See parent constructor for instructions.

Definition at line 711 of file part.cpp.

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.

Definition at line 716 of file part.cpp.


Member Function Documentation

bool ReadWritePart::closeUrl ( bool  promptToSave  )  [virtual]

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 809 of file part.cpp.

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.

Definition at line 797 of file part.cpp.

bool ReadWritePart::isModified (  )  const

Returns:
true if the document has been modified.

Definition at line 968 of file part.cpp.

bool ReadWritePart::isReadWrite (  )  const

Returns:
true if the part is in read-write mode

Definition at line 961 of file part.cpp.

bool ReadWritePart::queryClose (  )  [virtual]

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.

Definition at line 750 of file part.cpp.

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.

Definition at line 814 of file part.cpp.

bool ReadWritePart::saveAs ( const KUrl &  url  )  [virtual]

Save the file to a new location.

Calls save(), no need to reimplement

Definition at line 828 of file part.cpp.

virtual bool KParts::ReadWritePart::saveFile (  )  [protected, pure virtual]

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 ReadWritePart::saveToUrl (  )  [protected, virtual]

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.

Definition at line 884 of file part.cpp.

void ReadWritePart::setModified (  )  [slot]

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().

Definition at line 745 of file part.cpp.

void ReadWritePart::setModified ( bool  modified  )  [virtual]

Sets the modified flag of the part.

Definition at line 732 of file part.cpp.

void ReadWritePart::setReadWrite ( bool  readwrite = true  )  [virtual]

Changes the behavior of this part to readonly or readwrite.

Parameters:
readwrite set to true to enable readwrite mode

Definition at line 724 of file part.cpp.

void KParts::ReadWritePart::sigQueryClose ( bool *  handled,
bool *  abortClosing 
) [signal]

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

bool ReadWritePart::waitSaveComplete (  )  [slot]

Waits for any pending upload job to finish and returns whether the last save() action was successful.

Definition at line 975 of file part.cpp.


The documentation for this class was generated from the following files:
  • part.h
  • part.cpp

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal