KParts::ReadWritePart

KParts::ReadWritePart Class Referenceabstract

#include <KParts/ReadWritePart>

Inheritance diagram for KParts::ReadWritePart:

Signals

void sigQueryClose (bool *handled, bool *abortClosing)
 
- Signals inherited from KParts::ReadOnlyPart
void canceled (const QString &errMsg)
 
void completed ()
 
void completed (bool pendingAction)
 
void started (KIO::Job *job)
 
void urlChanged (const QUrl &url)
 
- Signals inherited from KParts::Part
void setStatusBarText (const QString &text)
 
void setWindowCaption (const QString &caption)
 

Public Slots

virtual bool save ()
 
void setModified ()
 
bool waitSaveComplete ()
 
- Public Slots inherited from KParts::ReadOnlyPart
virtual bool openUrl (const QUrl &url)
 

Public Member Functions

 ReadWritePart (QObject *parent=nullptr)
 
 ~ReadWritePart () override
 
bool closeUrl () override
 
virtual bool closeUrl (bool promptToSave)
 
bool isModified () const
 
bool isReadWrite () const
 
virtual bool queryClose ()
 
virtual bool saveAs (const QUrl &url)
 
virtual void setModified (bool modified)
 
virtual void setReadWrite (bool readwrite=true)
 
- Public Member Functions inherited from KParts::ReadOnlyPart
 ReadOnlyPart (QObject *parent=nullptr)
 
 ~ReadOnlyPart () override
 
OpenUrlArguments arguments () const
 
BrowserExtensionbrowserExtension () const
 
bool closeStream ()
 
bool isProgressInfoEnabled () const
 
bool openStream (const QString &mimeType, const QUrl &url)
 
void setArguments (const OpenUrlArguments &arguments)
 
void setProgressInfoEnabled (bool show)
 
void showProgressInfo (bool show)
 
QUrl url () const
 
bool writeStream (const QByteArray &data)
 
- Public Member Functions inherited from KParts::Part
 Part (QObject *parent=nullptr)
 
 ~Part () override
 
virtual void embed (QWidget *parentWidget)
 
virtual ParthitTest (QWidget *widget, const QPoint &globalPos)
 
KIconLoadericonLoader ()
 
bool isSelectable () const
 
PartManagermanager () const
 
void setAutoDeletePart (bool autoDeletePart)
 
void setAutoDeleteWidget (bool autoDeleteWidget)
 
virtual void setManager (PartManager *manager)
 
virtual void setSelectable (bool selectable)
 
virtual QWidgetwidget ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from KParts::PartBase
 PartBase ()
 
virtual ~PartBase ()
 
KAboutData componentData () const
 
QObjectpartObject () const
 
void setPartObject (QObject *object)
 
- Public Member Functions inherited from KXMLGUIClient
 KXMLGUIClient (KXMLGUIClient *parent)
 
QActionaction (const char *name) const
 
virtual QActionaction (const QDomElement &element) const
 
virtual KActionCollectionactionCollection () const
 
QList< KXMLGUIClient * > childClients ()
 
KXMLGUIBuilderclientBuilder () const
 
virtual QString componentName () const
 
virtual QDomDocument domDocument () const
 
KXMLGUIFactoryfactory () const
 
void insertChildClient (KXMLGUIClient *child)
 
KXMLGUIClientparentClient () const
 
void plugActionList (const QString &name, const QList< QAction * > &actionList)
 
void reloadXML ()
 
void removeChildClient (KXMLGUIClient *child)
 
void replaceXMLFile (const QString &xmlfile, const QString &localxmlfile, bool merge=false)
 
void setClientBuilder (KXMLGUIBuilder *builder)
 
void setFactory (KXMLGUIFactory *factory)
 
void setXMLGUIBuildDocument (const QDomDocument &doc)
 
void unplugActionList (const QString &name)
 
virtual QString xmlFile () const
 
QDomDocument xmlguiBuildDocument () const
 

Protected Member Functions

virtual bool saveFile ()=0
 
virtual bool saveToUrl ()
 
- Protected Member Functions inherited from KParts::ReadOnlyPart
 ReadOnlyPart (ReadOnlyPartPrivate &dd, QObject *parent)
 
void abortLoad ()
 
virtual bool doCloseStream ()
 
virtual bool doOpenStream (const QString &mimeType)
 
virtual bool doWriteStream (const QByteArray &data)
 
void guiActivateEvent (GUIActivateEvent *event) override
 
bool isLocalFileTemporary () const
 
QString localFilePath () const
 
virtual bool openFile ()
 
void setLocalFilePath (const QString &localFilePath)
 
void setLocalFileTemporary (bool temp)
 
void setUrl (const QUrl &url)
 
- Protected Member Functions inherited from KParts::Part
 Part (PartPrivate &dd, QObject *parent)
 
void customEvent (QEvent *event) override
 
QWidgethostContainer (const QString &containerName)
 
void loadPlugins ()
 
virtual void partActivateEvent (PartActivateEvent *event)
 
virtual void partSelectEvent (PartSelectEvent *event)
 
virtual void setWidget (QWidget *widget)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from KParts::PartBase
 PartBase (PartBasePrivate &dd)
 
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const KAboutData &aboutData)
 
virtual void setComponentData (const KAboutData &componentData)
 
virtual void setComponentData (const KAboutData &pluginData, bool loadPlugins)
 
void setPluginInterfaceVersion (int version)
 
void setPluginLoadingMode (PluginLoadingMode loadingMode)
 
- Protected Member Functions inherited from KXMLGUIClient
void loadStandardsXmlFile ()
 
virtual void setComponentName (const QString &componentName, const QString &componentDisplayName)
 
virtual void setDOMDocument (const QDomDocument &document, bool merge=false)
 
virtual void setLocalXMLFile (const QString &file)
 
virtual void setXML (const QString &document, bool merge=false)
 
virtual void setXMLFile (const QString &file, bool merge=false, bool setXMLDoc=true)
 
virtual void stateChanged (const QString &newstate, ReverseStateChange reverse=StateNoReverse)
 

Additional Inherited Members

- Properties inherited from KParts::ReadOnlyPart
QUrl url
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Public Member Functions inherited from KXMLGUIClient
static QString findVersionNumber (const QString &xml)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Types inherited from KParts::PartBase
enum  PluginLoadingMode { DoNotLoadPlugins = 0, LoadPlugins = 1, LoadPluginsIfEnabled = 2 }
 
- Protected Slots inherited from KParts::Part
void slotWidgetDestroyed ()
 
- Static Protected Member Functions inherited from KXMLGUIClient
static QString standardsXmlFileLocation ()
 
- Protected Attributes inherited from KParts::PartBase
PartBasePrivate * d_ptr
 

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 37 of file readwritepart.h.

Constructor & Destructor Documentation

ReadWritePart::ReadWritePart ( QObject parent = nullptr)
explicit

Constructor See parent constructor for instructions.

Definition at line 33 of file readwritepart.cpp.

ReadWritePart::~ReadWritePart ( )
override

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 38 of file readwritepart.cpp.

Member Function Documentation

bool ReadWritePart::closeUrl ( )
overridevirtual

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 122 of file readwritepart.cpp.

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 134 of file readwritepart.cpp.

bool ReadWritePart::isModified ( ) const
Returns
true if the document has been modified.

Definition at line 293 of file readwritepart.cpp.

bool ReadWritePart::isReadWrite ( ) const
Returns
true if the part is in read-write mode

Definition at line 286 of file readwritepart.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 71 of file readwritepart.cpp.

bool ReadWritePart::save ( )
virtualslot

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 139 of file readwritepart.cpp.

bool ReadWritePart::saveAs ( const QUrl url)
virtual

Save the file to a new location.

Calls save(), no need to reimplement

Definition at line 155 of file readwritepart.cpp.

virtual bool KParts::ReadWritePart::saveFile ( )
protectedpure 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 ( )
protectedvirtual

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 220 of file readwritepart.cpp.

void ReadWritePart::setModified ( bool  modified)
virtual

Sets the modified flag of the part.

Definition at line 54 of file readwritepart.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 66 of file readwritepart.cpp.

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

Changes the behavior of this part to readonly or readwrite.

Parameters
readwriteset to true to enable readwrite mode

Definition at line 46 of file readwritepart.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 300 of file readwritepart.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:54:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.