KParts::BrowserExtension

#include <KParts/BrowserExtension>

Inheritance diagram for KParts::BrowserExtension:

Public Types

typedef QMap< QString, QList< QAction * > > ActionGroupMap
 
typedef QMap< QByteArray, int > ActionNumberMap
 
typedef QMap< QByteArray, QByteArrayActionSlotMap
 
enum  PopupFlag {
  DefaultPopupItems = 0x0000, ShowNavigationItems = 0x0001, ShowUp = 0x0002, ShowReload = 0x0004,
  ShowBookmark = 0x0008, ShowCreateDirectory = 0x0010, ShowTextSelectionItems = 0x0020, NoDeletion = 0x0040,
  IsLink = 0x0080, ShowUrlOperations = 0x0100, ShowProperties = 0x200
}
 
typedef QFlags< PopupFlagPopupFlags
 

Properties

bool urlDropHandling
 
- Properties inherited from QObject
 objectName
 

Signals

void addWebSideBar (const QUrl &url, const QString &name)
 
void createNewWindow (const QUrl &url, const KParts::OpenUrlArguments &arguments=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments(), const KParts::WindowArgs &windowArgs=KParts::WindowArgs(), KParts::ReadOnlyPart **part=nullptr)
 
void enableAction (const char *name, bool enabled)
 
void infoMessage (const QString &)
 
void itemsRemoved (const KFileItemList &items)
 
void loadingProgress (int percent)
 
void mouseOverInfo (const KFileItem &item)
 
void moveTopLevelWidget (int x, int y)
 
void openUrlNotify ()
 
void openUrlRequest (const QUrl &url, const KParts::OpenUrlArguments &arguments=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments())
 
void openUrlRequestDelayed (const QUrl &url, const KParts::OpenUrlArguments &arguments, const KParts::BrowserArguments &browserArguments)
 
void popupMenu (const QPoint &global, const KFileItemList &items, const KParts::OpenUrlArguments &args=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments(), KParts::BrowserExtension::PopupFlags flags=KParts::BrowserExtension::DefaultPopupItems, const KParts::BrowserExtension::ActionGroupMap &actionGroups=ActionGroupMap())
 
void popupMenu (const QPoint &global, const QUrl &url, mode_t mode=static_cast< mode_t >(-1), const KParts::OpenUrlArguments &args=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments(), KParts::BrowserExtension::PopupFlags flags=KParts::BrowserExtension::DefaultPopupItems, const KParts::BrowserExtension::ActionGroupMap &actionGroups=ActionGroupMap())
 
void requestFocus (KParts::ReadOnlyPart *part)
 
void resizeTopLevelWidget (int w, int h)
 
void selectionInfo (const KFileItemList &items)
 
void selectionInfo (const QString &text)
 
void selectionInfo (const QList< QUrl > &urls)
 
void setActionText (const char *name, const QString &text)
 
void setIconUrl (const QUrl &url)
 
void setLocationBarUrl (const QString &url)
 
void setPageSecurity (int)
 
void speedProgress (int bytesPerSecond)
 

Public Member Functions

 BrowserExtension (KParts::ReadOnlyPart *parent)
 
QString actionText (const char *name) const
 
BrowserArguments browserArguments () const
 
BrowserInterfacebrowserInterface () const
 
bool isActionEnabled (const char *name) const
 
bool isURLDropHandlingEnabled () const
 
void pasteRequest ()
 
virtual void restoreState (QDataStream &stream)
 
virtual void saveState (QDataStream &stream)
 
virtual void setBrowserArguments (const BrowserArguments &args)
 
void setBrowserInterface (BrowserInterface *impl)
 
void setURLDropHandlingEnabled (bool enable)
 
virtual int xOffset ()
 
virtual int yOffset ()
 
- 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
 

Static Public Member Functions

static ActionSlotMap actionSlotMap ()
 
static ActionSlotMapactionSlotMapPtr ()
 
static BrowserExtensionchildObject (QObject *obj)
 
- 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)
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
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)
 

Detailed Description

The Browser Extension is an extension (yes, no kidding) to KParts::ReadOnlyPart, which allows a better integration of parts with browsers (in particular Konqueror).

Remember that ReadOnlyPart only has openUrl(QUrl) and a few arguments() but not much more. For full-fledged browsing, we need much more than that, including enabling/disabling of standard actions (print, copy, paste...), allowing parts to save and restore their data into the back/forward history, allowing parts to control the location bar URL, to requests URLs to be opened by the hosting browser, etc.

The part developer needs to define its own class derived from BrowserExtension, to implement the virtual methods [and the standard-actions slots, see below].

The way to associate the BrowserExtension with the part is to simply create the BrowserExtension as a child of the part (in QObject's terms). The hosting application will look for it automatically.

Another aspect of the browser integration is that a set of standard actions are provided by the browser, but implemented by the part (for the actions it supports).

The following standard actions are defined by the host of the view:

[selection-dependent actions]

  • cut : Copy selected items to clipboard and store 'not cut' in clipboard.
  • copy : Copy selected items to clipboard and store 'cut' in clipboard.
  • paste : Paste clipboard into view URL.
  • pasteTo(const QUrl &) : Paste clipboard into given URL.
  • searchProvider : Lookup selected text at default search provider

[normal actions]

  • None anymore.

The view defines a slot with the name of the action in order to implement the action. The browser will detect the slot automatically and connect its action to it when appropriate (i.e. when the view is active).

The selection-dependent actions are disabled by default and the view should enable them when the selection changes, emitting enableAction().

The normal actions do not depend on the selection.

A special case is the configuration slots, not connected to any action directly.

[configuration slot]

  • reparseConfiguration : Re-read configuration and apply it.
  • disableScrolling: no scrollbars

Definition at line 86 of file browserextension.h.

Member Typedef Documentation

Associates a list of actions with a predefined name known by the host's popupmenu: "editactions" for actions related text editing, "linkactions" for actions related to hyperlinks, "partactions" for any other actions provided by the part.

Definition at line 264 of file browserextension.h.

Stores a combination of PopupFlag values.

Definition at line 125 of file browserextension.h.

Member Enumeration Documentation

Set of flags passed via the popupMenu signal, to ask for some items in the popup menu.

See also
PopupFlags
Enumerator
DefaultPopupItems 

default value, no additional menu item

ShowNavigationItems 
Deprecated:
since 5.27, no effect anymore
ShowUp 
Deprecated:
since 5.27, no effect anymore
ShowReload 
Deprecated:
since 5.27, no effect anymore
ShowBookmark 

show "add to bookmarks" (usually not done on the local filesystem)

ShowCreateDirectory 

show "create directory" (usually only done on the background of the view, or in hierarchical views like directory trees, where the new dir would be visible)

ShowTextSelectionItems 

set when selecting text, for a popup that only contains text-related items.

NoDeletion 

deletion, trashing and renaming not allowed (e.g.

parent dir not writeable). (this is only needed if the protocol itself supports deletion, unlike e.g. HTTP)

IsLink 

show "Bookmark This Link" and other link-related actions (linkactions merging group)

ShowUrlOperations 

show copy, paste, as well as cut if NoDeletion is not set.

ShowProperties 

show "Properties" action (usually done by directory views)

Definition at line 104 of file browserextension.h.

Constructor & Destructor Documentation

BrowserExtension::BrowserExtension ( KParts::ReadOnlyPart parent)
explicit

Constructor.

Parameters
parentThe KParts::ReadOnlyPart that this extension ... "extends" :)

Definition at line 101 of file browserextension.cpp.

Member Function Documentation

BrowserExtension::ActionSlotMap BrowserExtension::actionSlotMap ( )
static

Returns a map containing the action names as keys and corresponding SLOT()'ified method names as data entries.

This is very useful for the host component, when connecting the own signals with the extension's slots. Basically you iterate over the map, check if the extension implements the slot and connect to the slot using the data value of your map iterator. Checking if the extension implements a certain slot can be done like this:

extension->metaObject()->slotNames().contains( actionName + "()" )

(note that actionName is the iterator's key value if already iterating over the action slot map, returned by this method)

Connecting to the slot can be done like this:

connect( yourObject, SIGNAL( yourSignal() ),
extension, mapIterator.data() )

(where "mapIterator" is your ActionSlotMap iterator)

Definition at line 305 of file browserextension.cpp.

BrowserExtension::ActionSlotMap * BrowserExtension::actionSlotMapPtr ( )
static
Returns
a pointer to the static action-slot map. Preferred method to get it. The map is created if it doesn't exist yet

Definition at line 310 of file browserextension.cpp.

QString BrowserExtension::actionText ( const char *  name) const
Returns
the text of an action, if it was set explicitly by the part. When the setActionText signal is emitted, the browserextension stores the text of the action internally, so that it's possible to query later for the text of the action, using this method.

Definition at line 294 of file browserextension.cpp.

void KParts::BrowserExtension::addWebSideBar ( const QUrl url,
const QString name 
)
signal

Ask the hosting application to add a new HTML (aka Mozilla/Netscape) SideBar entry.

BrowserArguments BrowserExtension::browserArguments ( ) const

Retrieve the set of parameters to use for opening the URL (this must be called from openUrl() in the part).

See also
BrowserArguments

Definition at line 144 of file browserextension.cpp.

BrowserExtension * BrowserExtension::childObject ( QObject obj)
static

Queries obj for a child object which inherits from this BrowserExtension class.

Convenience method.

Definition at line 318 of file browserextension.cpp.

void KParts::BrowserExtension::createNewWindow ( const QUrl url,
const KParts::OpenUrlArguments arguments = KParts::OpenUrlArguments(),
const KParts::BrowserArguments browserArguments = KParts::BrowserArguments(),
const KParts::WindowArgs windowArgs = KParts::WindowArgs(),
KParts::ReadOnlyPart **  part = nullptr 
)
signal

Asks the hosting browser to open a new window for the given url and return a reference to the content part.

arguments is optional additional information about how to open the url,

See also
KParts::OpenUrlArguments

browserArguments is optional additional information for web browsers,

See also
KParts::BrowserArguments

The request for a pointer to the part is only fulfilled/processed if the mimeType is set in the browserArguments. (otherwise the request cannot be processed synchronously).

void KParts::BrowserExtension::enableAction ( const char *  name,
bool  enabled 
)
signal

Enables or disable a standard action held by the browser.

See class documentation for the list of standard actions.

bool BrowserExtension::isActionEnabled ( const char *  name) const
Returns
the status (enabled/disabled) of an action. When the enableAction signal is emitted, the browserextension stores the status of the action internally, so that it's possible to query later for the status of the action, using this method.

Definition at line 277 of file browserextension.cpp.

bool BrowserExtension::isURLDropHandlingEnabled ( ) const

Returns whether url drop handling is enabled.

See setURLDropHandlingEnabled for more information about this property.

Definition at line 179 of file browserextension.cpp.

void KParts::BrowserExtension::itemsRemoved ( const KFileItemList items)
signal

Inform the host about items that have been removed.

void KParts::BrowserExtension::loadingProgress ( int  percent)
signal

Since the part emits the jobid in the started() signal, progress information is automatically displayed.

However, if you don't use a KIO::Job in the part, you can use loadingProgress() and speedProgress() to display progress information.

void KParts::BrowserExtension::mouseOverInfo ( const KFileItem item)
signal

Inform the hosting application that the user moved the mouse over an item.

Used when the mouse is on an URL.

void KParts::BrowserExtension::moveTopLevelWidget ( int  x,
int  y 
)
signal

Ask the hosting application to move the top level widget.

void KParts::BrowserExtension::openUrlNotify ( )
signal

Tells the hosting browser that the part opened a new URL (which can be queried via KParts::Part::url().

This helps the browser to update/create an entry in the history. The part may not emit this signal together with openUrlRequest(). Emit openUrlRequest() if you want the browser to handle a URL the user asked to open (from within your part/document). This signal however is useful if you want to handle URLs all yourself internally, while still telling the hosting browser about new opened URLs, in order to provide a proper history functionality to the user. An example of usage is a html rendering component which wants to emit this signal when a child frame document changed its URL. Conclusion: you probably want to use openUrlRequest() instead.

void KParts::BrowserExtension::openUrlRequest ( const QUrl url,
const KParts::OpenUrlArguments arguments = KParts::OpenUrlArguments(),
const KParts::BrowserArguments browserArguments = KParts::BrowserArguments() 
)
signal

Asks the host (browser) to open url.

To set a reload, the x and y offsets, the service type etc., fill in the appropriate fields in the args structure. Hosts should not connect to this signal but to openUrlRequestDelayed().

void KParts::BrowserExtension::openUrlRequestDelayed ( const QUrl url,
const KParts::OpenUrlArguments arguments,
const KParts::BrowserArguments browserArguments 
)
signal

This signal is emitted when openUrlRequest() is called, after a 0-seconds timer.

This allows the caller to terminate what it's doing first, before (usually) being destroyed. Parts should never use this signal, hosts should only connect to this signal.

void BrowserExtension::pasteRequest ( )

Asks the hosting browser to perform a paste (using openUrlRequestDelayed())

Definition at line 195 of file browserextension.cpp.

void KParts::BrowserExtension::popupMenu ( const QPoint global,
const KFileItemList items,
const KParts::OpenUrlArguments args = KParts::OpenUrlArguments(),
const KParts::BrowserArguments browserArguments = KParts::BrowserArguments(),
KParts::BrowserExtension::PopupFlags  flags = KParts::BrowserExtension::DefaultPopupItems,
const KParts::BrowserExtension::ActionGroupMap actionGroups = ActionGroupMap() 
)
signal

Emit this to make the browser show a standard popup menu for the files items.

Parameters
globalglobal coordinates where the popup should be shown
itemslist of file items which the popup applies to
argsOpenUrlArguments, mostly for metadata here
browserArgumentsBrowserArguments, mostly for referrer
flagsenables/disables certain builtin actions in the popupmenu
actionGroupsnamed groups of actions which should be inserted into the popup, see ActionGroupMap
void KParts::BrowserExtension::popupMenu ( const QPoint global,
const QUrl url,
mode_t  mode = static_cast< mode_t >(-1),
const KParts::OpenUrlArguments args = KParts::OpenUrlArguments(),
const KParts::BrowserArguments browserArguments = KParts::BrowserArguments(),
KParts::BrowserExtension::PopupFlags  flags = KParts::BrowserExtension::DefaultPopupItems,
const KParts::BrowserExtension::ActionGroupMap actionGroups = ActionGroupMap() 
)
signal

Emit this to make the browser show a standard popup menu for the given url.

Give as much information about this URL as possible, like args.mimeType and the file type mode

Parameters
globalglobal coordinates where the popup should be shown
urlthe URL this popup applies to
modethe file type of the url (S_IFREG, S_IFDIR...)
argsOpenUrlArguments, set the mimetype of the URL using setMimeType()
browserArgumentsBrowserArguments, mostly for referrer
flagsenables/disables certain builtin actions in the popupmenu
actionGroupsnamed groups of actions which should be inserted into the popup, see ActionGroupMap
void KParts::BrowserExtension::requestFocus ( KParts::ReadOnlyPart part)
signal

Ask the hosting application to focus part.

void KParts::BrowserExtension::resizeTopLevelWidget ( int  w,
int  h 
)
signal

Ask the hosting application to resize the top level widget.

void BrowserExtension::restoreState ( QDataStream stream)
virtual

Used by the browser to restore the view in the state it was when we left it.

If you saved additional properties, reimplement it but don't forget to call the parent method (probably first).

Definition at line 165 of file browserextension.cpp.

void BrowserExtension::saveState ( QDataStream stream)
virtual

Used by the browser to save the current state of the view (in order to restore it if going back in navigation).

If you want to save additional properties, reimplement it but don't forget to call the parent method (probably first).

Definition at line 159 of file browserextension.cpp.

void KParts::BrowserExtension::selectionInfo ( const KFileItemList items)
signal

Inform the hosting application about the current selection.

Used when a set of files/URLs is selected (with full information about those URLs, including size, permissions etc.)

void KParts::BrowserExtension::selectionInfo ( const QString text)
signal

Inform the hosting application about the current selection.

Used when some text is selected.

void KParts::BrowserExtension::selectionInfo ( const QList< QUrl > &  urls)
signal

Inform the hosting application about the current selection.

Used when a set of URLs is selected.

void KParts::BrowserExtension::setActionText ( const char *  name,
const QString text 
)
signal

Change the text of a standard action held by the browser.

This can be used to change "Paste" into "Paste Image" for instance.

See class documentation for the list of standard actions.

void BrowserExtension::setBrowserArguments ( const BrowserArguments args)
virtual

Set the parameters to use for opening the next URL.

This is called by the "hosting" application, to pass parameters to the part.

See also
BrowserArguments

Definition at line 139 of file browserextension.cpp.

void KParts::BrowserExtension::setIconUrl ( const QUrl url)
signal

Sets the URL of an icon for the currently displayed page.

void KParts::BrowserExtension::setLocationBarUrl ( const QString url)
signal

Updates the URL shown in the browser's location bar to url.

void KParts::BrowserExtension::setPageSecurity ( int  )
signal

Tell the host (browser) about security state of current page enum PageSecurity { NotCrypted, Encrypted, Mixed };.

void BrowserExtension::setURLDropHandlingEnabled ( bool  enable)

Enables or disables url drop handling.

URL drop handling is a property describing whether the hosting shell component is allowed to install an event filter on the part's widget, to listen for URI drop events. Set it to true if you are exporting a BrowserExtension implementation and do not provide any special URI drop handling. If set to false you can be sure to receive all those URI drop events unfiltered. Also note that the implementation as of Konqueror installs the event filter only on the part's widget itself, not on child widgets.

Definition at line 184 of file browserextension.cpp.

void KParts::BrowserExtension::speedProgress ( int  bytesPerSecond)
signal
See also
loadingProgress
int BrowserExtension::xOffset ( )
virtual

Returns the current x offset.

For a scrollview, implement this using contentsX().

Definition at line 149 of file browserextension.cpp.

int BrowserExtension::yOffset ( )
virtual

Returns the current y offset.

For a scrollview, implement this using contentsY().

Definition at line 154 of file browserextension.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 Sun Oct 25 2020 22:58:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.