kparts Library API Documentation

KParts::ReadWritePart Class Reference

Base class for an "editor" part. More...

#include <part.h>

Inheritance diagram for KParts::ReadWritePart:

KParts::ReadOnlyPart KParts::Part QObject KParts::PartBase KXMLGUIClient List of all members.

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 Methods

 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
virtual bool closeURL ()
 Called when closing the current url (e.g.

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 Methods

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

ReadWritePart::ReadWritePart QObject   parent = 0,
const char *    name = 0
 

Constructor See parent constructor for instructions.

Definition at line 429 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 435 of file part.cpp.


Member Function Documentation

bool KParts::ReadWritePart::isReadWrite   const [inline]
 

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

Definition at line 520 of file part.h.

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

Changes the behaviour of this part to readonly or readwrite.

Parameters:
readwrite  set to true to enable readwrite mode

Definition at line 443 of file part.cpp.

Referenced by KParts::GenericFactory< T >::createPartObject().

bool KParts::ReadWritePart::isModified   const [inline]
 

Returns:
true if the document has been modified.

Definition at line 531 of file part.h.

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. Reimplemented from ReadOnlyPart, to handle modified parts (and suggest saving in this case, with yes/no/cancel).

Returns:
false on cancel

Reimplemented from KParts::ReadOnlyPart.

Definition at line 465 of file part.cpp.

References KFileDialog::getSaveURL(), KURL::isEmpty(), KParts::ReadOnlyPart::m_url, save(), saveAs(), setModified(), KParts::ReadOnlyPart::url(), KMessageBox::warningYesNoCancel(), and KParts::Part::widget().

bool ReadWritePart::saveAs const KURL   url [virtual]
 

Save the file to a new location.

Calls save(), no need to reimplement

Definition at line 508 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 closeURL().

void ReadWritePart::setModified bool    modified [virtual]
 

Sets the modified flag of the part.

Definition at line 449 of file part.cpp.

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

Definition at line 460 of file part.cpp.

Referenced by closeURL(), and saveToURL().

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

References saveFile(), and saveToURL().

Referenced by closeURL(), and saveAs().

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.

Referenced by save().

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.

Definition at line 542 of file part.cpp.

References KParts::ReadOnlyPart::completed(), QObject::connect(), KIO::file_copy(), KURL::isLocalFile(), KParts::ReadOnlyPart::m_bTemp, KParts::ReadOnlyPart::m_file, KParts::ReadOnlyPart::m_url, and setModified().

Referenced by save().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:46 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001