Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

locationplugin.cpp Example File
whereabouts/sampleplugin/locationplugin/locationplugin.cpp

    /****************************************************************************
    **
    ** This file is part of the Qt Extended Commercial Package.
    **
    ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    **
    ** $QT_EXTENDED_DUAL_LICENSE$
    **
    ****************************************************************************/

    #include "locationplugin.h"

    #include <QWhereabouts>
    #include <QTimer>

    LocationProvider::LocationProvider(QObject *parent)
        : QWhereabouts(QWhereabouts::TerminalBasedUpdate, parent),
          m_timer(new QTimer(this))
    {
        connect(m_timer, SIGNAL(timeout()), SLOT(requestUpdate()));
    }

    void LocationProvider::requestUpdate()
    {
        QWhereaboutsUpdate update;
        update.setCoordinate(QWhereaboutsCoordinate(0.0, 0.0));
        update.setUpdateDateTime(QDateTime::currentDateTime());
        emitUpdated(update);
    }

    void LocationProvider::startUpdates()
    {
        if (updateInterval() > 0)
            m_timer->start(updateInterval());
        else
            m_timer->start(1000);
    }

    void LocationProvider::stopUpdates()
    {
        m_timer->stop();
    }

    //=========================================================

    LocationPlugin::LocationPlugin(QObject *parent)
        : QWhereaboutsPlugin(parent)
    {
    }

    QWhereabouts *LocationPlugin::create(const QString &source)
    {
        Q_UNUSED(source);
        return new LocationProvider;
    }

    QTOPIA_EXPORT_PLUGIN(LocationPlugin)


Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3