ContentAction::Action represents an action for the given resources. More...
Public Member Functions | |
bool | isValid () const |
Returns true if the Action object represents an action which can be triggered. | |
QString | name () const |
Returns the name of the action (the basename of the .desktop file describing the action). | |
QString | localizedName () const |
Returns the localized name of the action. | |
QString | icon () const |
Returns the icon name for the action. | |
Action (const Action &other) | |
Action & | operator= (const Action &other) |
void | trigger () const |
Triggers the action represented by this object, using the URIs contained by the Action object. | |
void | triggerAndWait () const |
Triggers the action represented by this object, using the URIs contained by the Action object. | |
Static Public Member Functions | |
static Action | defaultAction (const QString &uri) |
Returns the default action for the given uri representing an object stored in Tracker. | |
static Action | defaultAction (const QStringList &uris) |
Returns the default action for a given list of uris representing Tracker resources. | |
static Action | defaultActionForFile (const QUrl &fileUri) |
Returns the default action for a given fileUri, based on its content type. | |
static Action | defaultActionForFile (const QUrl &fileUri, const QString &mimeType) |
Returns the default action for a given fileUri, assuming its mime type is mimeType. | |
static Action | defaultActionForFile (const QList< QUrl > &fileUris, const QString &mimeType) |
Returns the default action for the given files, assuming all their mime types are mimeType. | |
static Action | defaultActionForScheme (const QString &uri) |
Returns the default action for handling the scheme of the passed uri. | |
static Action | defaultActionForString (const QString ¶m) |
Returns the default action for handling the passed param. | |
static QList< Action > | actions (const QString &uri) |
Returns the set of applicable actions for an object stored in Tracker represented by the given uri. | |
static QList< Action > | actions (const QStringList &uris) |
Returns the set of actions applicable to all uris (which represent Tracker resources). | |
static QList< Action > | actionsForFile (const QUrl &fileUri) |
Returns the set of applicable actions for a given fileUri, based on its content type. | |
static QList< Action > | actionsForFile (const QUrl &fileUri, const QString &mimeType) |
Returns the set of applicable actions for a given fileUri, assuming its content type is mimeType. | |
static QList< Action > | actionsForFile (const QList< QUrl > &fileUri, const QString &mimeType) |
Returns the set of applicable actions for a given mimeType, using the given uris as the parameters when the actions are triggered. | |
static QList< Action > | actionsForScheme (const QString &uri) |
Returns all actions handling the scheme of the given uri. | |
static QList< Action > | actionsForString (const QString ¶m) |
Returns all actions handling the given string param. | |
static Action | launcherAction (const QString &app, const QStringList ¶ms) |
Creates an action that will launch the given application (specified by .desktop file name) with the params the way the application specifies in their .desktop file. | |
static Action | launcherAction (QSharedPointer< MDesktopEntry >, const QStringList ¶ms) |
Creates an action that will launch the given application (specified by MDesktopEntry) with the params the way the application specifies in their .desktop file. | |
static QList< Match > | highlight (const QString &text) |
Highlights fragments of text which have applicable actions. | |
static QList< QPair< int, int > > | findHighlights (const QString &text) |
Finds fragments of text which have applicable actions. | |
static QPair< int, int > | findNextHighlight (const QString &text, int start=0) |
Finds the next fragment of text, starting from start, which has applicable actions. | |
Friends | |
Action | createAction (const QString &desktopFilePath, const QStringList ¶ms) |
Creates an Action object which will launch the application defined by desktopFilePath with the given params when triggered. | |
Action | createAction (QSharedPointer< MDesktopEntry > desktopEntry, const QStringList ¶ms) |
Creates an Action object which will launch the application defined by desktopEntry with the given params when triggered. |
ContentAction::Action represents an action for the given resources.
The Action object binds together the method of invocation (e.g. which D-Bus method to call, what binary to execute) and the resources (URIs, Tracker objects, text snippets, etc.) used for its creation.
There are multiple ways to construct an Action:
"mailto:"
use Action::actionsForScheme() or Action::defaultActionForScheme()Functions returning multiple actions try to return them in the order of relevance. The action can be triggered by calling the trigger() method.
Some functions accept multiple inputs (a list), they will return the intersection of applicable actions for all inputs. If the actions for the inputs would conflict, these methods return an empty result set (emtpy list or an invalid Action).
QList< Action > ContentAction::Action::actions | ( | const QString & | uri | ) | [static] |
Returns the set of applicable actions for an object stored in Tracker represented by the given uri.
The applicability is determined by the pre-defined Tracker conditions. If a condition cond
applies to uri, then we consider that x-maemo-nepomuk/cond
is one of the mime types of the uri, and construct the Action:s accordingly. Additionally we check whether the uri has both nie:url
and nie:mimeType
properties, in which case we append extra Actions for the corresponding mime types. Note that these actions are passed the nie:url
as argument.
QList< Action > ContentAction::Action::actions | ( | const QStringList & | uris | ) | [static] |
Returns the set of actions applicable to all uris (which represent Tracker resources).
The set is constructed by first figuring out the "pseudo-mimetypes" for all uris. The resulting actions are the common ones handling all uris. The order of the actions is the order in which they appear in the action list of the first uri. Additional actions for nie:mimeType
properties of the uris are appended similarly to the single-uri version of this function.
QList< Action > ContentAction::Action::actionsForFile | ( | const QList< QUrl > & | uris, | |
const QString & | mimeType | |||
) | [static] |
Returns the set of applicable actions for a given mimeType, using the given uris as the parameters when the actions are triggered.
QList< Action > ContentAction::Action::actionsForFile | ( | const QUrl & | fileUri | ) | [static] |
Returns the set of applicable actions for a given fileUri, based on its content type.
QList< Action > ContentAction::Action::actionsForFile | ( | const QUrl & | fileUri, | |
const QString & | mimeType_arg | |||
) | [static] |
Returns the set of applicable actions for a given fileUri, assuming its content type is mimeType.
This function can be used even when fileUri doesn't exist but will be created before trigger() is called, or if you already know the mime type. Note: if the file is a .desktop file, it must exist when this function is called.
QList< Action > ContentAction::Action::actionsForScheme | ( | const QString & | uri | ) | [static] |
Returns all actions handling the scheme of the given uri.
The uri scheme is mapped to mime types by prefixing it with "x-maemo-urischeme/"
. For example an email client may declare to handle the "x-maemo-urischeme/mailto"
mimetype and a browser then just triggers the returned Action to activate a mailto:
link.
QList< Action > ContentAction::Action::actionsForString | ( | const QString & | param | ) | [static] |
Returns all actions handling the given string param.
Dispatching is done based on exact matching against the regexpx of highlighter configuration.
Action ContentAction::Action::defaultAction | ( | const QString & | uri | ) | [static] |
Returns the default action for the given uri representing an object stored in Tracker.
A default action is determined by checking the conditions that apply to the uri, and taking the first one having a default action. If no default action is found in this way, it checks whether uri represents a resource with nie:url
and nie:mimeType
properties. If there is a default action for the given mimetype, it is returned (note that triggering this action will pass the nie:url
as argument). If neither methods succeeded, it falls back to the most relevant action, i.e. the first action returned by actions(). If there are no applicable actions, an invalid Action object is returned.
Action ContentAction::Action::defaultAction | ( | const QStringList & | uris | ) | [static] |
Returns the default action for a given list of uris representing Tracker resources.
If the URIs represent objects of different types (e.g. one is an image, other is an audio file), a default action cannot be constructed in this manner. In that case the nie:mimeType
properties of all uris are checked and we attempt to construct a default action based on them (passing nie:url
as argument) (
Action ContentAction::Action::defaultActionForFile | ( | const QUrl & | fileUri, | |
const QString & | mimeType_arg | |||
) | [static] |
Returns the default action for a given fileUri, assuming its mime type is mimeType.
This function can be used even when fileUri doesn't exist yet but will be created before trigger() is called, or if you already know the mime type. Note: if the file is a .desktop file, it must exist when this function is called.
Action ContentAction::Action::defaultActionForFile | ( | const QList< QUrl > & | uris, | |
const QString & | mimeType | |||
) | [static] |
Returns the default action for the given files, assuming all their mime types are mimeType.
This function can be used even when the files doesn't exist yet but will be created before trigger() is called, or if you already know the mime type.
Action ContentAction::Action::defaultActionForFile | ( | const QUrl & | fileUri | ) | [static] |
Returns the default action for a given fileUri, based on its content type.
Action ContentAction::Action::defaultActionForScheme | ( | const QString & | uri | ) | [static] |
Returns the default action for handling the scheme of the passed uri.
Action ContentAction::Action::defaultActionForString | ( | const QString & | param | ) | [static] |
Returns the default action for handling the passed param.
QList< QPair< int, int > > ContentAction::Action::findHighlights | ( | const QString & | text | ) | [static] |
Finds fragments of text which have applicable actions.
Returns a list of (start, length) pairs which identify the locations of the fragments. The fragments can be passed to ContentAction::Action::actionsForString() and ContentAction::Action::defaultActionForString() for finding out the applicable actions and the default action.
QPair< int, int > ContentAction::Action::findNextHighlight | ( | const QString & | text, | |
int | start = 0 | |||
) | [static] |
Finds the next fragment of text, starting from start, which has applicable actions.
Returns a (start, length) pair which identifies the location of the fragment. Returns (-1, -1) if no such fragment can be found. The fragment can be passed to ContentAction::Action::actionsForString() and ContentAction::Action::defaultActionForString() for finding out the applicable actions and the default action.
QList< Match > ContentAction::Action::highlight | ( | const QString & | text | ) | [static] |
Highlights fragments of text which have applicable actions.
Returns a list of Match objects.
bool ContentAction::Action::isValid | ( | ) | const |
Returns true if the Action object represents an action which can be triggered.
Action ContentAction::Action::launcherAction | ( | QSharedPointer< MDesktopEntry > | mDesktop, | |
const QStringList & | params | |||
) | [static] |
Creates an action that will launch the given application (specified by MDesktopEntry) with the params the way the application specifies in their .desktop file.
Action ContentAction::Action::launcherAction | ( | const QString & | app, | |
const QStringList & | params | |||
) | [static] |
Creates an action that will launch the given application (specified by .desktop file name) with the params the way the application specifies in their .desktop file.
app is the name of the .desktop file (with the .desktop extension). It is looked for in the standard locations.
QString ContentAction::Action::localizedName | ( | ) | const |
Returns the localized name of the action.
Note that if the locale changes, actions must be recreated.
QString ContentAction::Action::name | ( | ) | const |
Returns the name of the action (the basename of the .desktop file describing the action).
void ContentAction::Action::trigger | ( | ) | const |
Triggers the action represented by this object, using the URIs contained by the Action object.
void ContentAction::Action::triggerAndWait | ( | ) | const |
Action createAction | ( | const QString & | desktopFilePath, | |
const QStringList & | params | |||
) | [friend] |
Creates an Action object which will launch the application defined by desktopFilePath with the given params when triggered.
This function supports both desktop entries of type "Application" and "Link". A "Link" is launched via Action::defaultActionForScheme.
Action createAction | ( | QSharedPointer< MDesktopEntry > | desktopEntry, | |
const QStringList & | params | |||
) | [friend] |
Creates an Action object which will launch the application defined by desktopEntry with the given params when triggered.
This function supports both desktop entries of type "Application" and "Link". A "Link" is launched via Action::defaultActionForScheme.