locationplugin.cpp Example File
whereabouts/sampleplugin/locationplugin/locationplugin.cpp
#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 Trolltech |
Trademarks |
Qt Extended 4.4.3 |