• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KIO

Public Slots | Public Member Functions | Static Public Member Functions

KFileItemActions Class Reference

This class creates and handles the actions for a url (or urls) in a popupmenu. More...

#include <kfileitemactions.h>

Inheritance diagram for KFileItemActions:
Inheritance graph
[legend]

List of all members.

Public Slots

void runPreferredApplications (const KFileItemList &fileOpenList, const QString &traderConstraint)

Public Member Functions

 KFileItemActions (QObject *parent=0)
 ~KFileItemActions ()
void addOpenWithActionsTo (QMenu *menu, const QString &traderConstraint=QString())
int addServiceActionsTo (QMenu *menu)
KAction * preferredOpenWithAction (const QString &traderConstraint)
void setItemListProperties (const KFileItemListProperties &itemList)
void setParentWidget (QWidget *widget)

Static Public Member Functions

static KService::List associatedApplications (const QStringList &mimeTypeList, const QString &traderConstraint)

Detailed Description

This class creates and handles the actions for a url (or urls) in a popupmenu.

This includes:

  • "open with <application>" actions, but also
  • builtin services like mount/unmount for old-style device desktop files
  • user-defined actions for a .desktop file, defined in the file itself (see the desktop entry standard)
  • servicemenus actions, defined in .desktop files and selected based on the mimetype of the url
Since:
4.3

Definition at line 44 of file kfileitemactions.h.


Constructor & Destructor Documentation

KFileItemActions::KFileItemActions ( QObject *  parent = 0)

Creates a KFileItemActions instance.

Note that this instance must stay alive for at least as long as the popupmenu; it has the slots for the actions created by addOpenWithActionsTo/addServiceActionsTo.

Definition at line 176 of file kfileitemactions.cpp.

KFileItemActions::~KFileItemActions ( )

Destructor.

Definition at line 182 of file kfileitemactions.cpp.


Member Function Documentation

void KFileItemActions::addOpenWithActionsTo ( QMenu *  menu,
const QString &  traderConstraint = QString() 
)

Generate the "Open With <Application>" actions, and adds them to the menu.

All actions are created as children of the menu.

Parameters:
menuthe QMenu where to add actions
traderConstraintthis constraint allows to exclude the current application from the "open with" list. Example: "DesktopEntryName != 'kfmclient'". (Default value added in kdelibs-4.5, pass QString() explicitely for earlier versions).

Definition at line 494 of file kfileitemactions.cpp.

int KFileItemActions::addServiceActionsTo ( QMenu *  menu)

Generate the user-defined actions and submenus, and adds them to the menu.

User-defined actions include:

  • builtin services like mount/unmount for old-style device desktop files
  • user-defined actions for a .desktop file, defined in the file itself (see the desktop entry standard)
  • servicemenus actions, defined in .desktop files and selected based on the mimetype of the url

When KFileItemListProperties::supportsWriting() is false, actions that modify the files are not shown. This is controlled by Require=Write in the servicemenu desktop files.

All actions are created as children of the menu.

Returns:
the number of actions added

Definition at line 201 of file kfileitemactions.cpp.

KService::List KFileItemActions::associatedApplications ( const QStringList &  mimeTypeList,
const QString &  traderConstraint 
) [static]

Helper method used internally, can also be used for similar GUIs that show the list of associated applications.

Used in KParts::BrowserOpenOrSaveQuestion for example.

This is basically a KMimeTypeTrader::query, but it supports multiple mimetypes, and also cleans up "apparent" duplicates, such as the kde3 and kde4 applications with the same name.

The list is sorted according to the user preferences for the given mimetype(s). In case multiple mimetypes appear in the url list, the logic is: applications that on average appear earlier on the associated applications list for the given mimetypes also appear earlier on the final applications list.

Note that for a single mimetype there is no need to use this, you should use KMimeTypeTrader instead, e.g. query() or preferredService().

Returns the applications associated with all the given mimetypes.

Parameters:
mimeTypeListthe mimetypes
traderConstraintthis optional constraint allows to exclude the current application from the "open with" list. Example: "DesktopEntryName != 'kfmclient'".
Returns:
the sorted list of services.
Since:
4.4

Definition at line 428 of file kfileitemactions.cpp.

KAction * KFileItemActions::preferredOpenWithAction ( const QString &  traderConstraint)

Returns an action for the preferred application only.

Parameters:
traderConstraintthis constraint allows to exclude the current application from the "open with" list. Example: "DesktopEntryName != 'kfmclient'".
Returns:
the action - or 0 if no application was found.

Definition at line 701 of file kfileitemactions.cpp.

void KFileItemActions::runPreferredApplications ( const KFileItemList &  fileOpenList,
const QString &  traderConstraint 
) [slot]

Slot used to execute a list of files in their respective preferred application.

Parameters:
fileOpenListthe list of KFileItems to open.
traderConstraintthis optional constraint allows to exclude the current application
Since:
4.5

Definition at line 624 of file kfileitemactions.cpp.

void KFileItemActions::setItemListProperties ( const KFileItemListProperties &  itemList)

Sets all the data for the next instance of the popupmenu.

See also:
KFileItemListProperties

Definition at line 187 of file kfileitemactions.cpp.

void KFileItemActions::setParentWidget ( QWidget *  widget)

Set the parent widget for any dialogs being shown.

This should normally be your mainwindow, not a popup menu, so that it still exists even after the popup is closed (e.g. error message from KRun) and so that QAction::setStatusTip can find a statusbar, too.

Definition at line 710 of file kfileitemactions.cpp.


The documentation for this class was generated from the following files:
  • kfileitemactions.h
  • kfileitemactions.cpp

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal