Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 50facae208d4a6f280e44a513b104320 > files > 1440

qt-mobility-doc-1.2.0-13.mga5.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qml-serviceframework.qdoc -->
  <title>Qt Mobility 1.2: Service Framework QML Plugin</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="content"> 
    <a href="index.html" class="qtref"><span>QtMobility Reference Documentation</span></a>
  </div>
  <div class="breadcrumb toolblock">
    <ul>
      <li class="first"><a href="index.html">Home</a></li>
      <!--  Breadcrumbs go here -->
<li>Service Framework QML Plugin</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#overview">Overview</a></li>
<li class="level1"><a href="#elements">Elements</a></li>
<li class="level2"><a href="#service">Service</a></li>
<li class="level2"><a href="#servicelist">ServiceList</a></li>
<li class="level1"><a href="#examples">Examples</a></li>
<li class="level1"><a href="#qml-elements">QML Elements</a></li>
</ul>
</div>
<h1 class="title">Service Framework QML Plugin</h1>
<span class="subtitle"></span>
<!-- $$$qml-serviceframework.html-description -->
<div class="descr"> <a name="details"></a>
<a name="overview"></a>
<h2>Overview</h2>
<p>The Service Framework API in the QtMobility Project gives developers a mechanism for discovering and instantiating arbitrary services. The QML Service Framework Plugin enables accessing services in a very easy and simple manner by allowing users to declare a service or find a list of services using QML.</p>
<a name="elements"></a>
<h2>Elements</h2>
<p>The service framework QML plugin provides two elements that allow access to registered services via QML script. In general, the QML plugin can only discover and load pre-registered services and does not support any run-time registration or unregistration of services. The servicefw tool can be used to register services to the service framework system prior to running any QML script utilising this plugin. The two available elements are in the subsequent sections.</p>
<a name="service"></a>
<h3>Service</h3>
<p>The <a href="qml-service.html">Service</a> element provides QML with functionality reflecting the <a href="qserviceinterfacedescriptor.html">QServiceInterfaceDescriptor</a> class which represents the details of a single service registered on the service framework system. This element also allows the service to be loaded so that it will return a <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> reference of the instantiated service object. If this element is used on its own and not in conjunction to the <a href="qml-servicelist.html">ServiceList</a> element below, it will represent the default interface at the specified interface name, which is the most convenient use-case of the QML plugin. The code snippet below demonstrates a typical way to load an interface in QML.</p>
<pre class="qml"> import Qt 4.7
 import QtMobility.serviceframework 1.1
 // ...
 property variant myObject: 0

 Service {
     id: myService
     interfaceName: &quot;com.nokia.qt.examples.ExampleService&quot;

     Component.onCompleted: {
         myObject = myService.serviceObject;
     }
 }</pre>
<p>In the above code we use a variant to store the <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> reference provided by the <a href="qml-service.html#serviceObject-prop">Service::serviceObject</a>. In this case it will be an instance of the default service found at the interface address &quot;com.nokia.qt.examples.ExampleService&quot;. The code inside the QML component element is recommended so that the variable <i>myObject</i> holds a valid object instance which can be used throughout the entire QML script.</p>
<p>This element also provides several readable properties about the service interface. A useful one is the <a href="qml-service.html#valid-prop">Service::valid</a> property which will help debug if the system has found a valid default interface descriptor at the specified interface name. The plugin also allows connecting to signals provided by the service. Here is a typical example of receiving service signals within QML for the above code.</p>
<pre class="qml"> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qml-connections.html">Connections</a></span> {
     <span class="name">target</span>: <span class="name">myObject</span>
     <span class="name">ignoreUnknownSignals</span>: <span class="number">true</span>

     <span class="name">onMySignal</span>: {
         <span class="comment">// do something</span>
     }
 }</pre>
<p>Note the usage of the ignoreUnkownSignals attribute which is useful for ignoring uknown signals, especially in the case where <a href="qml-service.html#serviceObject-prop">Service::serviceObject</a> has not been called yet or provides an invalid interface.</p>
<p>Once a valid service instance has been obtained its methods and properties can be called and accessed as if it were normal <a href="http://qt.nokia.com/doc/4.7/qobject.html">QObject</a> in QML. The service framework example <a href="declarative-sfw-notes.html">Declarative Notes Manager</a> demonstrates the use of the QML plugin.</p>
<a name="servicelist"></a>
<h3>ServiceList</h3>
<p>The <a href="qml-servicelist.html">ServiceList</a> element provides QML with functionality reflecting the <a href="qservicefilter.html">QServiceFilter</a> class which provides a list of <a href="qml-service.html">Service</a> elements. A very specific service list element can be defined by using the following code.</p>
<pre class="qml"> <span class="type"><a href="qml-servicelist.html">ServiceList</a></span> {
     <span class="name">id</span>: <span class="name">myServiceList</span>
     <span class="name">serviceName</span>: <span class="string">&quot;MyExampleService&quot;</span>
     <span class="name">interfaceName</span>: <span class="string">&quot;com.nokia.qt.examples.ExampleService&quot;</span>
     <span class="name">versionMatch</span>: <span class="name">ServiceList</span>.<span class="name">Exact</span>
     <span class="name">majorVersion</span>: <span class="number">1</span>
     <span class="name">minorVersion</span>: <span class="number">3</span>
 }</pre>
<p>If the <a href="qml-servicelist.html#serviceName-prop">ServiceList::serviceName</a> is not supplied the filter will search with a default empty string as the service name, meaning all interfaces will be returned regardless of the service name. Similarly if no <a href="qml-servicelist.html#versionMatch-prop">ServiceList::versionMatch</a> is provided the filter will search with a minimum version match rule.</p>
<p>The actual <a href="http://qt.nokia.com/doc/4.7/qdeclarativelistproperty.html">QDeclarativeListProperty</a> of <a href="qml-service.html">Service</a> elements can be obtained by reading the <a href="qml-servicelist.html#services-prop">ServiceList::services</a> property which searches based on the filter values. This list model can then be used in a list view element.</p>
<pre class="qml"> <span class="type"><a href="http://qt.nokia.com/doc/4.7/qml-listview.html">ListView</a></span> {
     <span class="name">id</span>: <span class="name">myListView</span>
     <span class="name">model</span>: <span class="name">myServiceList</span>.<span class="name">services</span>
     <span class="name">delegate</span>: <span class="name">myDelegate</span>
     <span class="comment">// ...</span>
 }</pre>
<p>The service framework example <a href="declarative-sfw-dialer.html">Declarative Dialer</a> better demonstrates the use of <a href="qml-servicelist.html">ServiceList</a> coupled with the <a href="qml-service.html">Service</a> element to search and select a service instance to implement the QML dialer application.</p>
<a name="examples"></a>
<h2>Examples</h2>
<ul>
<li><a href="declarative-sfw-notes.html">Declarative Notes Manager</a></li>
<li><a href="declarative-sfw-dialer.html">Declarative Serviceframework Dialer</a></li>
</ul>
<a name="qml-elements"></a>
<h2>QML Elements</h2>
<table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qml-service.html">QML Service Element</a></p></td><td class="tblDescr"><p>The Service element holds an instance of a service object.</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qml-servicelist.html">QML ServiceList Element</a></p></td><td class="tblDescr"><p>The ServiceList element holds a list of Service elements.</p></td></tr>
</table>
</div>
<!-- @@@qml-serviceframework.html -->
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
  <p>
     <acronym title="Copyright">&copy;</acronym> 2008-2011 Nokia Corporation and/or its
     subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation 
     in Finland and/or other countries worldwide.</p>
  <p>
     All other trademarks are property of their respective owners. <a title="Privacy Policy"
     href="http://qt.nokia.com/about/privacy-policy">Privacy Policy</a></p>
  <br />
  <p>
    Licensees holding valid Qt Commercial licenses may use this document in accordance with the    Qt Commercial License Agreement provided with the Software or, alternatively, in accordance    with the terms contained in a written agreement between you and Nokia.</p>
  <p>
    Alternatively, this document may be used under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU
    Free Documentation License version 1.3</a>
    as published by the Free Software Foundation.</p>
</div>
</body>
</html>