KParts::ReadWritePart
#include <KParts/ReadWritePart>
Signals | |
void | sigQueryClose (bool *handled, bool *abortClosing) |
Signals inherited from KParts::ReadOnlyPart | |
void | canceled (const QString &errMsg) |
void | completed () |
void | completedWithPendingAction () |
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, const KPluginMetaData &data={}) | |
~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, const KPluginMetaData &data={}) | |
~ReadOnlyPart () override | |
OpenUrlArguments | arguments () const |
bool | closeStream () |
bool | isProgressInfoEnabled () const |
NavigationExtension * | navigationExtension () const |
bool | openStream (const QString &mimeType, const QUrl &url) |
void | setArguments (const OpenUrlArguments &arguments) |
void | setProgressInfoEnabled (bool show) |
QUrl | url () const |
bool | writeStream (const QByteArray &data) |
Public Member Functions inherited from KParts::Part | |
Part (QObject *parent=nullptr, const KPluginMetaData &data={}) | |
~Part () override | |
virtual Part * | hitTest (QWidget *widget, const QPoint &globalPos) |
PartManager * | manager () const |
KPluginMetaData | metaData () const |
void | setAutoDeletePart (bool autoDeletePart) |
void | setAutoDeleteWidget (bool autoDeleteWidget) |
virtual void | setManager (PartManager *manager) |
virtual QWidget * | widget () |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () 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 () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
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 | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Public Member Functions inherited from KParts::PartBase | |
PartBase () | |
~PartBase () override | |
QObject * | partObject () const |
void | setPartObject (QObject *object) |
Public Member Functions inherited from KXMLGUIClient | |
KXMLGUIClient (KXMLGUIClient *parent) | |
virtual QAction * | action (const QDomElement &element) const |
QAction * | action (const QString &name) const |
virtual KActionCollection * | actionCollection () const |
QList< KXMLGUIClient * > | childClients () |
KXMLGUIBuilder * | clientBuilder () const |
virtual QString | componentName () const |
virtual QDomDocument | domDocument () const |
KXMLGUIFactory * | factory () const |
void | insertChildClient (KXMLGUIClient *child) |
KXMLGUIClient * | parentClient () 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 | |
KPARTS_NO_EXPORT | 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 |
QString | localFilePath () const |
virtual bool | openFile () |
void | setLocalFilePath (const QString &localFilePath) |
void | setUrl (const QUrl &url) |
Protected Member Functions inherited from KParts::Part | |
KPARTS_NO_EXPORT | Part (PartPrivate &dd, QObject *parent) |
void | customEvent (QEvent *event) override |
QWidget * | hostContainer (const QString &containerName) |
virtual void | partActivateEvent (PartActivateEvent *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 |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Member Functions inherited from KParts::PartBase | |
KPARTS_NO_EXPORT | PartBase (PartBasePrivate &dd) |
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 | |
Public Types inherited from QObject | |
typedef | QObjectList |
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 *context, Functor functor, 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) |
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, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Static Public Member Functions inherited from KXMLGUIClient | |
static QString | findVersionNumber (const QString &xml) |
Protected Slots inherited from KParts::Part | |
void | slotWidgetDestroyed () |
Static Protected Member Functions inherited from KXMLGUIClient | |
static QString | standardsXmlFileLocation () |
Protected Attributes inherited from KParts::PartBase | |
std::unique_ptr< PartBasePrivate > const | 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 35 of file readwritepart.h.
Constructor & Destructor Documentation
◆ ReadWritePart()
|
explicit |
Constructor See parent constructor for instructions.
Definition at line 36 of file readwritepart.cpp.
◆ ~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 41 of file readwritepart.cpp.
Member Function Documentation
◆ closeUrl() [1/2]
|
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 128 of file readwritepart.cpp.
◆ closeUrl() [2/2]
|
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 140 of file readwritepart.cpp.
◆ isModified()
bool ReadWritePart::isModified | ( | ) | const |
- Returns
- true if the document has been modified.
Definition at line 305 of file readwritepart.cpp.
◆ isReadWrite()
bool ReadWritePart::isReadWrite | ( | ) | const |
- Returns
- true if the part is in read-write mode
Definition at line 298 of file readwritepart.cpp.
◆ 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 74 of file readwritepart.cpp.
◆ 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 145 of file readwritepart.cpp.
◆ saveAs()
|
virtual |
Save the file to a new location.
Calls save(), no need to reimplement
Definition at line 161 of file readwritepart.cpp.
◆ 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
Implemented in KTextEditor::DocumentPrivate.
◆ 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 226 of file readwritepart.cpp.
◆ setModified [1/2]
|
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 69 of file readwritepart.cpp.
◆ setModified() [2/2]
|
virtual |
Sets the modified flag of the part.
Definition at line 57 of file readwritepart.cpp.
◆ setReadWrite()
|
virtual |
Changes the behavior of this part to readonly or readwrite.
- Parameters
-
readwrite set to true to enable readwrite mode
Definition at line 49 of file readwritepart.cpp.
◆ sigQueryClose
|
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
◆ waitSaveComplete
|
slot |
Waits for any pending upload job to finish and returns whether the last save() action was successful.
Definition at line 312 of file readwritepart.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.