KFileItemActionPluginV2 Class
KAbstractFileItemActionPlugin with a QObject-based actions() replacement. More...
| Header: | #include <kabstractfileitemactionplugin.h> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS KIO)target_link_libraries(mytarget PRIVATE KF6::KIOWidgets) |
| Since: | 6.32 |
| Inherits: | KAbstractFileItemActionPlugin |
Public Functions
| virtual QList<QAction *> | actionsForParent(const KFileItemListProperties &fileItemInfos, QObject *parent, const QUrl ¤tWorkingDirectory) = 0 |
Detailed Description
actions() requires a QWidget to parent the returned QActions to, but some callers (e.g. Plasma's desktop containment) have no widget to offer, which leaves those actions without an owner. Plugins that need a guaranteed owner for their actions can inherit from this class instead of KAbstractFileItemActionPlugin directly, and implement actionsForParent() instead of actions(); KFileItemActions calls it with a QObject that is never null, even when no QWidget is available (see KFileItemActions::setParentObject()). actions() itself is implemented here to forward to actionsForParent(), so plugins only need to implement the latter.
Member Function Documentation
[pure virtual] QList<QAction *> KFileItemActionPluginV2::actionsForParent(const KFileItemListProperties &fileItemInfos, QObject *parent, const QUrl ¤tWorkingDirectory)
Like KAbstractFileItemActionPlugin::actions(), but takes a QObject instead of a QWidget, so the returned actions can always be given a valid owner.
fileItemInfos Information about the selected file items.
parent Never null. To be used as parent for the returned QActions. May or may not be a QWidget; use qobject_cast<QWidget *> to check.
currentWorkingDirectory The folder the actions are being requested for (e.g. the folder currently shown in the view). Lets a plugin tell whether fileItemInfos refers to this folder itself or to item(s) within it, and present different actions accordingly. May be empty if the caller has no such notion, or if invoked through the actions() fallback above.
Returns a list of actions to be added to a contextual menu for the file items.