2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "DeviceOrientationProviderQt.h"
23 #include "DeviceOrientationClientMockQt.h"
27 DeviceOrientationProviderQt::DeviceOrientationProviderQt()
29 m_rotation.addFilter(this);
30 m_orientation = DeviceOrientation::create();
32 if (DeviceOrientationClientMockQt::mockIsActive)
36 DeviceOrientationProviderQt::~DeviceOrientationProviderQt()
41 void DeviceOrientationProviderQt::start()
46 void DeviceOrientationProviderQt::stop()
51 bool DeviceOrientationProviderQt::filter(QRotationReading* reading)
53 // Provide device orientation data according W3C spec:
54 // http://dev.w3.org/geo/api/spec-source-orientation.html
55 // Qt mobility provide these data via QRotationSensor using the
56 // QRotationReading class:
57 // - the rotation around z axis (alpha) is given as z in QRotationReading;
58 // - the rotation around x axis (beta) is given as x in QRotationReading;
59 // - the rotation around y axis (gamma) is given as y in QRotationReading;
60 // See: http://doc.qt.nokia.com/qtmobility-1.0/qrotationreading.html
61 // The Z (alpha) rotation angle is checked via hasAlpha() private method,
62 // depending if the device is able do detect the alpha rotation. X (beta) and
63 // Y (gamma) axis are availble in this context.
64 m_orientation = DeviceOrientation::create(hasAlpha(), reading->z(),
65 /* x available */ true, reading->x(),
66 /* y available */ true, reading->y());
67 emit deviceOrientationChanged(m_orientation.get());
72 void DeviceOrientationProviderQt::changeDeviceOrientation(DeviceOrientation* orientation)
74 m_orientation = orientation;
77 void DeviceOrientationProviderQt::activeClientMock()
79 connect(DeviceOrientationClientMockQt::client(), SIGNAL(mockOrientationChanged(DeviceOrientation*)), SLOT(changeDeviceOrientation(DeviceOrientation*)));
84 #include "moc_DeviceOrientationProviderQt.cpp"