Ubuntu.OnlineAccounts.AccountServiceModel
A model of the user's Online Accounts More...
Import Statement: | import Ubuntu.OnlineAccounts 0.1 |
Properties
- account : Account
- accountId : quint32
- applicationId : string
- includeDisabled : bool
- provider : string
- service : string
- serviceType : string
Methods
- variant get(int row, string roleName)
Detailed Description
The AccountServiceModel is a model representing the user's Online Accounts services. Please note that an Online Account can offer several different services (chat, e-mail, micro-blogging, etc.); these are the items represented by this model, and not the user accounts as a whole. Since most applications are interested on a small subset of the user's accounts, AccountServiceModel offers some filtering functionalities: it is possible to restrict it to only one account provider, to a specific service type (for instance, an e-mail application will probably be interested in only those accounts which offer an e-mail service), or to a specific service (e.g., picasa; this is often equivalent to filtering by provider and by service-type, because it's rare for a provider to offer two different services of the same type). By default, only enabled accounts are returned. Use the includeDisabled property to list also disabled accounts; keep in mind, though, that an application should never use an account which has been disabled by the user.
The model defines the following roles:
displayName
is the name of the account (usually the user's login)providerName
is the name of the account provider (e.g., "Google")serviceName
is the name of the service (e.g., "Picasa")enabled
accountServiceHandle
is a handle to the underlying Qt object which can be used to instantiate an AccountService from QMLaccountId
is the numeric ID of the accountaccountHandle
is a handle to the underlying Qt object which can be used to instantiate an Account from QML
Examples of use:
1. Model of all enabled microblogging accounts:
Item { AccountServiceModel { id: accounts serviceType: "microblogging" } ListView { model: accounts delegate: Text { text: model.displayName + " by " + model.providerName } } }
2. List all Facebook account services:
Item { AccountServiceModel { id: accounts provider: "facebook" includeDisabled: true } ListView { model: accounts delegate: Text { text: model.serviceName + " on " + model.displayName } } }
3. List all Flickr accounts enabled for uploading:
Item { AccountServiceModel { id: accounts service: "flickr-sharing" } ListView { model: accounts delegate: Rectangle { id: rect Text { text: rect.model.displayName } AccountService { id: accountService objectHandle: rect.model.accountServiceHandle onAuthenticated: { console.log("Access token is " + reply.AccessToken) } onAuthenticationError: { console.log("Authentication failed, code " + error.code) } } MouseArea { anchors.fill: parent onClicked: accountService.authenticate() } } } }
4. List all the online accounts, without their services:
Item { AccountServiceModel { id: accounts service: "global" } ListView { model: accounts delegate: Rectangle { id: rect Text { text: account.displayName } Account { id: account objectHandle: rect.model.accountHandle } } } }
Property Documentation
account : Account |
If set, the model will list only those accounts services available in the given account.
accountId : quint32 |
If set, the model will list only those accounts services available in the given account.
applicationId : string |
If set, the model will only show those account services which are relevant for the given applicationId. This means that an account service will only be shown if it can be used by the application, as described in the application's manifest file.
includeDisabled : bool |
If true, even disabled account services will be listed. Note that an application should never use a disabled account.
By default, this property is false.
provider : string |
If set, the model will list only those accounts services provided by this provider.
service : string |
If set, the model will list only those accounts services for this specific service.
serviceType : string |
If set, the model will list only those accounts services supporting this service type. Each provider-specific service is an instance of a generic service type (such as "e-mail", "IM", etc.) which identifies the main functionality provided by the service.
Method Documentation
variant get(int row, string roleName) |
Returns the data at row for the role roleName.