MenuManager
#include <bb/system/MenuManager>
To link against this class, add the following line to your .pro file: LIBS += -lbbsystem
An interface for populating a menu of invokable items.
The menu service provides common context-aware logic for building menus. It can construct menus based on a specified type of data. The menu service uses the data, its type, and the context in which the data is being acted on to build a menu and populate it with information to be displayed and with the actions to be performed when an item in the menu is selected.
To build a menu of invokable items, create an instance of the MenuManager class, populate the required parameters using the setter methods, and call populateMenu() to send the request.
Specify the URI to the data. The type of the data will be inferred by the menu service.
Specify the URI to the data and the MIME type of the data to which the URI refers.
Specify the data and its MIME type.
If all three properties are specified, then the MIME type shall be assumed to be the MIME type of the data referenced by the URI.
Connect to the finished() signal to receive a notification that the menu service has completed the request. Call error() to check that the request was successful; if so, retrieve the populated menu using menu().
Here's an example of how to send a request, receive the response, and read the menu data.
// Populate the query parameters.
bb::system::MenuManager *_menuManager = new MenuManager;
_menuManager->setUri(QUrl("file://path/to/file"));
_menuManager->setTargetTypes(InvokeTarget::Application);
// Connect to the finished() signal.
connect(_menuManager, SIGNAL(finished()), this, SLOT(onFinished()));
// Send the request to have the menu populated.
if (_menuManager->populateMenu() != true) {
// Handle the error.
}
// Define a slot to receive the finished() signal.
Q_SLOT void onFinished()
{
// Check for errors.
if (_menuManager->error() != MenuManagerError::None) {
// Handle the error.
} else {
// The menu was populated. Retrieve the data.
bb::system::Menu = _menuManager->menu();
}
}
BlackBerry 10.0.0
Public Functions Index
| MenuManager (QObject *parent=0) | |
| virtual | ~MenuManager () |
| void | setAction (const QString &action) |
| void | setMimeType (const QString &mimeType) |
| void | setUri (QUrl uri) |
| void | setFileTransferMode (bb::system::FileTransferMode::Type fileTransferMode) |
| void | setData (const QByteArray &data) |
| void | setMetadata (const QVariantMap &metadata) |
| void | setTargetTypes (InvokeTarget::Types types) |
| void | setPerimeter (SecurityPerimeter::Type perimeter) |
| QString | action () const |
| QString | mimeType () const |
| QUrl | uri () const |
| bb::system::FileTransferMode::Type | fileTransferMode () const |
| QByteArray | data () const |
| QVariantMap | metadata () const |
| InvokeTarget::Types | targetTypes () const |
| SecurityPerimeter::Type | perimeter () const |
| bool | populateMenu () |
| Menu | menu () const |
| MenuManagerError::Type | error () const |
| bool | isFinished () const |
Signals Index
| void | finished () |
Public Functions
void
Sets the action to be used to filter the invoke target results.
If no action is provided, all actions will be considered.
Required: NO
| Parameters | |
|---|---|
| action |
The action to set. |
BlackBerry 10.0.0
void
Sets the MIME type of the data to be acted on.
If a URI is specified, the MIME type is not required and the menu service will infer the type of data being acted upon. If a URI is not specified, then the MIME type is required.
Required: YES, if the URI is not set; NO, if a URI is set.
| Parameters | |
|---|---|
| mimeType |
The MIME type of the data to be acted on. |
BlackBerry 10.0.0
void
Sets the URI of the data for which the menu applies.
For URIs to local files, consider using QUrl::fromLocalFile() to construct a QUrl instance.
| Parameters | |
|---|---|
| uri |
The URI of the data. |
BlackBerry 10.0.0
void
Sets the file transfer mode of the data for which the menu applies.
The file transfer mode will be applied if the scheme of the URI is "file://" and the path references a file that is not in the shared area.
| Parameters | |
|---|---|
| fileTransferMode |
The file transfer mode of the data. See bb::system::FileTransferMode for the list of possible transfer modes. |
BlackBerry 10.0.0
void
Sets the data to be acted upon.
| Parameters | |
|---|---|
| data |
The data to be acted upon. |
BlackBerry 10.0.0
void
Sets the metadata associated with the invocation.
Metadata is optional and can be included to pass additional information to the target. It will be encoded as a JSON object and sent to the target.
| Parameters | |
|---|---|
| metadata |
The metadata to be associated with the invocation. |
BlackBerry 10.0.0
void
Sets the target types, which indicate the types of targets to consider when building the menu.
Required: NO
| Parameters | |
|---|---|
| types |
The target types. See bb::system::InvokeTarget::Type for the list of individual target types. |
The menu service does not construct menus that contain viewer targets. Therefore, bb::system::InvokeTarget::Viewer is not a valid value. The menu service will reject queries that contain bb::system::InvokeTarget::Viewer as a target type.
BlackBerry 10.0.0
void
Sets the perimeter in which the selected action is to be invoked.
Required: NO
| Parameters | |
|---|---|
| perimeter |
The perimeter in which the selected action is to be invoked. See bb::system::SecurityPerimeter for the list of perimeters. |
BlackBerry 10.0.0
QString
Returns the MIME type of the data to be acted upon.
The MIME type of the data.
BlackBerry 10.0.0
QUrl
Returns the URI of the data for which the menu applies.
The URI of the data.
BlackBerry 10.0.0
bb::system::FileTransferMode::Type
Returns the file transfer mode of the data for which the menu applies.
The file transfer mode will be applied if the scheme of the URI is "file://" and the path references a file that is not in the shared area.
The file transfer mode of the data. See bb::system::FileTransferMode for the list of file transfer modes.
BlackBerry 10.0.0
QByteArray
Returns the data that is to be acted on.
The data to be acted on.
BlackBerry 10.0.0
QVariantMap
Returns the metadata associated with the invocation.
Metadata is optional and can be included to pass additional information to the target. It will be encoded as a JSON object and sent to the target.
The metadata.
BlackBerry 10.0.0
InvokeTarget::Types
Returns the target types.
The target types. See bb::system::InvokeTarget::Type for the list of individual target types.
BlackBerry 10.0.0
SecurityPerimeter::Type
Returns the perimeter in which the selected action is to be invoked.
The perimeter in which the action will be invoked.
BlackBerry 10.0.0
MenuManagerError::Type
Returns the error code from the menu service.
The error code is not valid until the finished() signal has been emitted.
The error code from the menu service. See bb::system::MenuManagerError for the list of possible errors.
BlackBerry 10.0.0
bool
Checks whether a reply from the menu service has been received.
If this method returns false, the values returned by the menu() and error() methods are not valid. If this method returns true, the value returned by error() gives the status of the last request. If the request was successful, menu() will return a valid, populated menu obtained from the menu service.
true if a reply from the menu service has been received and this object is valid, false otherwise.
BlackBerry 10.0.0