src/sensors/qtapsensor.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qtapsensor.h"
       
    43 #include "qtapsensor_p.h"
       
    44 
       
    45 QTM_BEGIN_NAMESPACE
       
    46 
       
    47 IMPLEMENT_READING(QTapReading)
       
    48 
       
    49 /*!
       
    50     \class QTapReading
       
    51     \ingroup sensors_reading
       
    52 
       
    53     \brief The QTapReading class represents one reading from the
       
    54            tap sensor.
       
    55 
       
    56     \section2 QTapReading Units
       
    57     The tap sensor registers tap events in one of the six directions.
       
    58     There are 3 axes that originate from the phone. They are arranged as follows.
       
    59 
       
    60     \image sensors-coordinates2.jpg
       
    61 
       
    62     By default it returns only double tap events. The QTapSensor::returnDoubleTapEvents property
       
    63     must be set to false to return individual tap events.
       
    64 */
       
    65 
       
    66 /*!
       
    67     \enum QTapReading::TapDirection
       
    68 
       
    69     The tap direction is reported as one of the six directions (X, Y, Z, positive and negative).
       
    70     There are 3 flags that you can use if you only care about the axis in use.
       
    71 
       
    72     \value Undefined This value means that the direction is unknown.
       
    73     \value X     This flag is set if the tap was along the X axis.
       
    74     \value Y     This flag is set if the tap was along the Y axis.
       
    75     \value Z     This flag is set if the tap was along the Z axis.
       
    76     \value X_Pos This value is returned if the tap was towards the positive X direction.
       
    77     \value Y_Pos This value is returned if the tap was towards the positive Y direction.
       
    78     \value Z_Pos This value is returned if the tap was towards the positive Z direction.
       
    79     \value X_Neg This value is returned if the tap was towards the negative X direction.
       
    80     \value Y_Neg This value is returned if the tap was towards the negative Y direction.
       
    81     \value Z_Neg This value is returned if the tap was towards the negative Z direction.
       
    82 */
       
    83 
       
    84 /*!
       
    85     \property QTapReading::tapDirection
       
    86     \brief the direction of the tap.
       
    87 
       
    88     \sa {QTapReading Units}
       
    89 */
       
    90 
       
    91 QTapReading::TapDirection QTapReading::tapDirection() const
       
    92 {
       
    93     return static_cast<QTapReading::TapDirection>(d->tapDirection);
       
    94 }
       
    95 
       
    96 /*!
       
    97     Sets the tap direction to \a tapDirection.
       
    98 */
       
    99 void QTapReading::setTapDirection(QTapReading::TapDirection tapDirection)
       
   100 {
       
   101     d->tapDirection = tapDirection;
       
   102 }
       
   103 
       
   104 /*!
       
   105     \property QTapReading::doubleTap
       
   106     \brief a value indicating if there was a single or double tap.
       
   107 
       
   108     \list
       
   109     \o true - double tap
       
   110     \o false - single tap
       
   111     \endlist
       
   112     \sa {QTapReading Units}
       
   113 */
       
   114 
       
   115 bool QTapReading::isDoubleTap() const
       
   116 {
       
   117     return d->doubleTap;
       
   118 }
       
   119 
       
   120 /*!
       
   121     Sets the double tap status of the reading to \a doubleTap.
       
   122 */
       
   123 void QTapReading::setDoubleTap(bool doubleTap)
       
   124 {
       
   125     d->doubleTap = doubleTap;
       
   126 }
       
   127 
       
   128 // =====================================================================
       
   129 
       
   130 /*!
       
   131     \class QTapFilter
       
   132     \ingroup sensors_filter
       
   133 
       
   134     \brief The QTapFilter class is a convenience wrapper around QSensorFilter.
       
   135 
       
   136     The only difference is that the filter() method features a pointer to QTapReading
       
   137     instead of QSensorReading.
       
   138 */
       
   139 
       
   140 /*!
       
   141     \fn QTapFilter::filter(QTapReading *reading)
       
   142 
       
   143     Called when \a reading changes. Returns false to prevent the reading from propagating.
       
   144 
       
   145     \sa QSensorFilter::filter()
       
   146 */
       
   147 
       
   148 char const * const QTapSensor::type("QTapSensor");
       
   149 
       
   150 /*!
       
   151     \class QTapSensor
       
   152     \ingroup sensors_type
       
   153 
       
   154     \brief The QTapSensor class is a convenience wrapper around QSensor.
       
   155 
       
   156     The only behavioural difference is that this class sets the type properly.
       
   157 
       
   158     This class also features a reading() function that returns a QTapReading instead of a QSensorReading.
       
   159 
       
   160     For details about how the sensor works, see \l QTapReading.
       
   161 
       
   162     \sa QTapReading
       
   163 */
       
   164 
       
   165 /*!
       
   166     \fn QTapSensor::QTapSensor(QObject *parent)
       
   167 
       
   168     Construct the sensor as a child of \a parent.
       
   169 */
       
   170 
       
   171 /*!
       
   172     \fn QTapSensor::~QTapSensor()
       
   173 
       
   174     Destroy the sensor. Stops the sensor if it has not already been stopped.
       
   175 */
       
   176 
       
   177 /*!
       
   178     \fn QTapSensor::reading() const
       
   179 
       
   180     Returns the reading class for this sensor.
       
   181 
       
   182     \sa QSensor::reading()
       
   183 */
       
   184 
       
   185 /*!
       
   186     \property QTapSensor::returnDoubleTapEvents
       
   187     \brief a value indicating if double tap events should be reported.
       
   188 
       
   189     Set to true (the default) to have the sensor report only on double tap events.
       
   190     Set to false to have the sensor report only on individual tap events.
       
   191 
       
   192     It is not possible to have the sensor report both single and double tap events.
       
   193     If both are needed the app should create 2 sensor objects.
       
   194 
       
   195     Note that you must access this property via QObject::property() and QObject::setProperty().
       
   196     The property must be set before calling start().
       
   197 */
       
   198 
       
   199 #include "moc_qtapsensor.cpp"
       
   200 QTM_END_NAMESPACE
       
   201