KParts::ReadOnlyPart

Search for usage in LXR

#include <KParts/ReadOnlyPart>

Inheritance diagram for KParts::ReadOnlyPart:

Properties

QUrl url
 
- Properties inherited from QObject
 objectName
 

Signals

void canceled (const QString &errMsg)
 
void completed ()
 
void completed (bool pendingAction)
 
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 openUrl (const QUrl &url)
 

Public Member Functions

 ReadOnlyPart (QObject *parent=nullptr)
 
 ~ReadOnlyPart () override
 
OpenUrlArguments arguments () const
 
BrowserExtensionbrowserExtension () const
 
bool closeStream ()
 
virtual bool closeUrl ()
 
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
 
KPluginMetaData metaData () 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 QRegExp &regExp, 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
 
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 (const QObject *object)
 
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 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 ()
 
 ~PartBase () override
 
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

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
 
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
KPARTS_NO_EXPORT Part (PartPrivate &dd, QObject *parent)
 
void customEvent (QEvent *event) override
 
QWidgethostContainer (const QString &containerName)
 
void loadPlugins ()
 
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const KAboutData &aboutData)
 
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const QString &parentInstanceName)
 
virtual void partActivateEvent (PartActivateEvent *event)
 
virtual void partSelectEvent (PartSelectEvent *event)
 
void setMetaData (const KPluginMetaData &metaData)
 
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
KPARTS_NO_EXPORT PartBase (PartBasePrivate &dd)
 
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const KAboutData &aboutData)
 
void loadPlugins (QObject *parent, KXMLGUIClient *parentGUIClient, const QString &parentInstanceName)
 
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

- 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)
 
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
const std::unique_ptr< PartBasePrivate > d_ptr
 

Detailed Description

Base class for any "viewer" part.

This class takes care of network transparency for you, in the simplest way (downloading to a temporary file, then letting the part load from the temporary file). To use the built-in network transparency, you only need to implement openFile(), not openUrl().

To implement network transparency differently (e.g. for progressive loading, like a web browser does for instance), or to prevent network transparency (but why would you do that?), you can override openUrl().

An application using KParts can use the signals to show feedback while the URL is being loaded.

ReadOnlyPart handles the window caption by setting it to the current URL (set in openUrl(), and each time the part is activated). If you want another caption, set it in openFile() and, if the part might ever be used with a part manager, in guiActivateEvent().

Definition at line 51 of file readonlypart.h.

Constructor & Destructor Documentation

◆ ReadOnlyPart()

ReadOnlyPart::ReadOnlyPart ( QObject parent = nullptr)
explicit

Constructor.

See also Part for the setXXX methods to call.

Definition at line 29 of file readonlypart.cpp.

◆ ~ReadOnlyPart()

ReadOnlyPart::~ReadOnlyPart ( )
override

Destructor.

Definition at line 39 of file readonlypart.cpp.

Member Function Documentation

◆ abortLoad()

void ReadOnlyPart::abortLoad ( )
protected

Definition at line 227 of file readonlypart.cpp.

◆ arguments()

OpenUrlArguments KParts::ReadOnlyPart::arguments ( ) const
Returns
the arguments that were used to open this URL.

Definition at line 362 of file readonlypart.cpp.

◆ browserExtension()

BrowserExtension * ReadOnlyPart::browserExtension ( ) const

This convenience method returns the BrowserExtension for this part, or nullptr if there isn't one.

Definition at line 350 of file readonlypart.cpp.

◆ canceled

void KParts::ReadOnlyPart::canceled ( const QString errMsg)
signal

Emit this if loading is canceled by the user or by an error.

Parameters
errMsgthe error message, empty if the user canceled the loading voluntarily.

◆ closeStream()

bool ReadOnlyPart::closeStream ( )

Terminate the sending of data to the part.

With some data types (text, html...) closeStream might never actually be called, in the case of continuous streams, for instance plain text or HTML data.

Definition at line 345 of file readonlypart.cpp.

◆ closeUrl()

bool ReadOnlyPart::closeUrl ( )
virtual

Called when closing the current URL (for example, a 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. Deletes the temporary file used when the URL is remote. Resets the current url() to QUrl().

Returns
always true, but the return value exists for reimplementations

Reimplemented in KParts::ReadWritePart, and KHTMLPart.

Definition at line 243 of file readonlypart.cpp.

◆ completed [1/2]

void KParts::ReadOnlyPart::completed ( )
signal

Emit this when you have completed loading data.

Hosting applications will want to know when the process of loading the data is finished, so that they can access the data when everything is loaded.

◆ completed [2/2]

void KParts::ReadOnlyPart::completed ( bool  pendingAction)
signal

Same as the above signal except it indicates whether there is a pending action to be executed on a delay timer.

An example of this is the meta-refresh tags on web pages used to reload/redirect after a certain period of time. This signal is useful if you want to give the user the ability to cancel such pending actions.

pendingAction true if a pending action exists, false otherwise.

Deprecated:
since 5.80, use the KParts::ReadOnlyPart::completedWithPendingAction() signal

◆ completedWithPendingAction

void KParts::ReadOnlyPart::completedWithPendingAction ( )
signal

This signal is similar to the KParts::ReadOnlyPart::completed() signal except it is only emitted if there is still a pending action to be executed on a delayed timer.

An example of this is the meta-refresh tags on web pages used to reload/redirect after a certain period of time. This signal is useful if you want to give the user the ability to cancel such pending actions.

Since
5.81

◆ doCloseStream()

virtual bool KParts::ReadOnlyPart::doCloseStream ( )
inlineprotectedvirtual

This is called by closeStream(), to indicate that all the data has been sent.

Parts should ensure that all of the data is displayed at this point.

Returns
whether the data could be displayed correctly.

Reimplemented in KHTMLPart.

Definition at line 209 of file readonlypart.h.

◆ doOpenStream()

virtual bool KParts::ReadOnlyPart::doOpenStream ( const QString mimeType)
inlineprotectedvirtual

Called by openStream to initiate sending of data.

Parts which implement progress loading should check the mimeType parameter, and return true if they can accept a data stream of that type.

Reimplemented in KHTMLPart.

Definition at line 188 of file readonlypart.h.

◆ doWriteStream()

virtual bool KParts::ReadOnlyPart::doWriteStream ( const QByteArray data)
inlineprotectedvirtual

Receive some data from the hosting application.

In this method the part should attempt to display the data progressively. With some data types (text, html...) closeStream might never actually be called, in the case of continuous streams. This can't happen with e.g. images.

Reimplemented in KHTMLPart.

Definition at line 199 of file readonlypart.h.

◆ guiActivateEvent()

void ReadOnlyPart::guiActivateEvent ( GUIActivateEvent event)
overrideprotectedvirtual

Reimplemented from Part, so that the window caption is set to the current URL (decoded) when the part is activated.

This is the usual behavior in 99% of applications. Reimplement if you don't like it - test for event->activated()!

Note
This is done with GUIActivateEvent and not with PartActivateEvent because it's handled by the main window (which gets the event after the PartActivateEvent events have been sent).

Reimplemented from KParts::Part.

Definition at line 313 of file readonlypart.cpp.

◆ isLocalFileTemporary()

bool ReadOnlyPart::isLocalFileTemporary ( ) const
protected

Definition at line 80 of file readonlypart.cpp.

◆ isProgressInfoEnabled()

bool ReadOnlyPart::isProgressInfoEnabled ( ) const

Returns whether the part shows the progress info dialog used by the internal KIO job.

Definition at line 104 of file readonlypart.cpp.

◆ localFilePath()

QString ReadOnlyPart::localFilePath ( ) const
protected

Returns the local file path associated with this part.

Note
The result will only be valid if openUrl() or setLocalFilePath() has previously been called.

Definition at line 65 of file readonlypart.cpp.

◆ openFile()

bool ReadOnlyPart::openFile ( )
protectedvirtual

If the part uses the standard implementation of openUrl(), it must reimplement this to open the local file.

The default implementation simply returns false.

If this method returns true the part emits completed(), otherwise it emits canceled().

See also
completed(), canceled()

Reimplemented in KHTMLPart.

Definition at line 161 of file readonlypart.cpp.

◆ openStream()

bool ReadOnlyPart::openStream ( const QString mimeType,
const QUrl url 
)

Initiate sending data to this part.

This is an alternative to openUrl(), which allows the user of the part to load the data itself, and send it progressively to the part.

Parameters
mimeTypethe type of data that is going to be sent to this part.
urlthe URL representing this data. Although not directly used, every ReadOnlyPart has a URL (see url()), so this simply sets it.
Returns
true if the part supports progressive loading and accepts data, false otherwise.

Definition at line 327 of file readonlypart.cpp.

◆ openUrl

bool ReadOnlyPart::openUrl ( const QUrl url)
virtualslot

Only reimplement this if you don't want the network transparency support to download from the URL into a temporary file (when the URL isn't local).

Otherwise, reimplement openFile() only.

If you reimplement it, don't forget to set the caption, usually with

and also, if the URL refers to a local file, resolve it to a local path and call setLocalFilePath().

Reimplemented in KHTMLPart.

Definition at line 120 of file readonlypart.cpp.

◆ setArguments()

void KParts::ReadOnlyPart::setArguments ( const OpenUrlArguments arguments)

Sets the arguments to use for the next openUrl() call.

Definition at line 355 of file readonlypart.cpp.

◆ setLocalFilePath()

void ReadOnlyPart::setLocalFilePath ( const QString localFilePath)
protected

Sets the local file path associated with this part.

Definition at line 72 of file readonlypart.cpp.

◆ setLocalFileTemporary()

void ReadOnlyPart::setLocalFileTemporary ( bool  temp)
protected

Definition at line 89 of file readonlypart.cpp.

◆ setProgressInfoEnabled()

void ReadOnlyPart::setProgressInfoEnabled ( bool  show)

Call this to turn off the progress info dialog used by the internal KIO job.

Use this if you provide another way of displaying progress info (e.g. a statusbar), using the signals emitted by this class, and/or those emitted by the job given by started().

Definition at line 97 of file readonlypart.cpp.

◆ setUrl()

void ReadOnlyPart::setUrl ( const QUrl url)
protected

Sets the URL associated with this part.

Definition at line 53 of file readonlypart.cpp.

◆ showProgressInfo()

void ReadOnlyPart::showProgressInfo ( bool  show)
Deprecated:
Since 3.0, use setProgressInfoEnabled(bool)

Definition at line 112 of file readonlypart.cpp.

◆ started

void KParts::ReadOnlyPart::started ( KIO::Job job)
signal

The part emits this when starting to load data.

If using a KIO::Job, it provides the job so that progress information can be shown. Otherwise, job is nullptr.

◆ url()

QUrl KParts::ReadOnlyPart::url ( ) const

Returns the URL currently opened in (or being opened by) this part.

Note
The URL is not cleared if openUrl() fails to load the URL. Call closeUrl() if you need to explicitly reset it.
Returns
The current URL.

◆ urlChanged

void KParts::ReadOnlyPart::urlChanged ( const QUrl url)
signal

Emitted by the part when url() changes.

Since
4.10

◆ writeStream()

bool ReadOnlyPart::writeStream ( const QByteArray data)

Send some data to the part.

openStream must have been called previously, and must have returned true.

Returns
true if the data was accepted by the part. If false is returned, the application should stop sending data, and doesn't have to call closeStream.

Definition at line 340 of file readonlypart.cpp.


The documentation for this class was generated from the following files:
Q_EMITQ_EMIT
QString toDisplayString(QUrl::FormattingOptions options) const const
void setWindowCaption(const QString &caption)
Emitted by the part, to set the caption of the window(s) hosting this part.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 03:53:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.