void TestQGeoPositionInfoSource::setUpdateInterval_data() { QTest::addColumn<int>("interval"); QTest::addColumn<int>("expectedInterval"); #ifdef TST_GEOCLUEMOCK_ENABLED initGeoclueMock(); #endif QGeoPositionInfoSource *source = createTestSource(); int minUpdateInterval = source ? source->minimumUpdateInterval() : -1; if (source) delete source; #if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QTest::newRow("0") << 0 << minUpdateInterval; #else QTest::newRow("0") << 0 << 0; #endif if (minUpdateInterval > -1) { QTest::newRow("INT_MIN") << INT_MIN << minUpdateInterval; QTest::newRow("-1") << -1 << minUpdateInterval; } if (minUpdateInterval > 0) { QTest::newRow("more than minInterval") << minUpdateInterval + 1 << minUpdateInterval + 1; QTest::newRow("equal to minInterval") << minUpdateInterval << minUpdateInterval; } if (minUpdateInterval > 1) { QTest::newRow("less then minInterval") << minUpdateInterval - 1 << minUpdateInterval; QTest::newRow("in btw zero and minInterval") << 1 << minUpdateInterval; } // Fails on S60, should investigate //QTest::newRow("INT_MAX") << INT_MAX << INT_MAX; }
void TestQGeoPositionInfoSource::setUpdateInterval_data() { QTest::addColumn<int>("interval"); QTest::addColumn<int>("expectedInterval"); QGeoPositionInfoSource *source = createTestSource(); int minUpdateInterval = source ? source->minimumUpdateInterval() : -1; if (source) delete source; QTest::newRow("0") << 0 << 0; if (minUpdateInterval > -1) { QTest::newRow("INT_MIN") << INT_MIN << minUpdateInterval; QTest::newRow("-1") << -1 << minUpdateInterval; } if (minUpdateInterval > 0) { QTest::newRow("more than minInterval") << minUpdateInterval + 1 << minUpdateInterval + 1; QTest::newRow("equal to minInterval") << minUpdateInterval << minUpdateInterval; } if (minUpdateInterval > 1) { QTest::newRow("less then minInterval") << minUpdateInterval - 1 << minUpdateInterval; QTest::newRow("in btw zero and minInterval") << 1 << minUpdateInterval; } // Fails on S60, should investigate //QTest::newRow("INT_MAX") << INT_MAX << INT_MAX; }
ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app) { // create scene document from main.qml asset // set parent to created document to ensure it exists for the whole application lifetime QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); // Expose this class to QML such that our Q_INVOKABLE methods defined in applicationui.hpp // can be called from our QML classes. qml->setContextProperty("cpp", this); // create root object for the UI AbstractPane *root = qml->createRootObject<AbstractPane>(); // set created root object as a scene app->setScene(root); // The code from here down to "void ApplicationUI::logEvent" is used to determine the device // location and log the result to the Flurry server. Any errors in the process will also be // logged QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this); if (source) { bool positionUpdatedConnected = connect(source, SIGNAL(positionUpdated (const QGeoPositionInfo &)), this, SLOT(positionUpdated (const QGeoPositionInfo &))); if (positionUpdatedConnected) { source->requestUpdate(); } else { qDebug() << "positionUpdated connection failed"; Flurry::Analytics::LogError("positionUpdated connection failed"); } } else {
void tst_PositionPlugin::create() { QGeoPositionInfoSource *src = 0; src = QGeoPositionInfoSource::createSource("test.source", 0); QVERIFY(src != 0); QVERIFY(src->minimumUpdateInterval() == 1000); }
void tst_PositionPlugin::getUpdates() { QGeoPositionInfoSource *src = QGeoPositionInfoSource::createSource("test.source", 0); src->setUpdateInterval(1000); QSignalSpy spy(src, SIGNAL(positionUpdated(QGeoPositionInfo))); src->startUpdates(); QTest::qWait(1500); QCOMPARE(spy.count(), 1); QCOMPARE(spy[0].size(), 1); QGeoPositionInfo info = qvariant_cast<QGeoPositionInfo>(spy[0][0]); QCOMPARE(info.coordinate().latitude(), 0.1); QCOMPARE(info.coordinate().longitude(), 0.1); }
void tst_PositionPlugin::create() { QGeoPositionInfoSource *src = 0; src = QGeoPositionInfoSource::createSource("test.source", 0); QVERIFY(src != 0); QVERIFY(src->minimumUpdateInterval() == 1000); src = QGeoPositionInfoSource::createSource("invalid source that will never exist", 0); QVERIFY(src == 0); QGeoSatelliteInfoSource *ssrc = 0; ssrc = QGeoSatelliteInfoSource::createSource("test.source", 0); QVERIFY(ssrc == 0); }
void GpsLocation::serviceEnable(bool toggle) { QGeoPositionInfoSource *gpsSource = getGpsSource(); if (haveSource != HAVEGPS) { if (toggle) status("Can't start location service, no location source available"); return; } if (toggle) { gpsSource->startUpdates(); status(QString("Starting Subsurface GPS service with update interval %1").arg(gpsSource->updateInterval())); } else { gpsSource->stopUpdates(); status("Stopping Subsurface GPS service"); } }
Client::Client(QWidget *parent) : QMainWindow(parent), networkSession(0) { sysInfo = new QSystemDeviceInfo(this); QGeoPositionInfo::QGeoPositionInfo(info); QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this); if(source){ connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positonUpdated(QGeoPositionInfo))); source->requestUpdate(); } hostLabel = new QLabel(tr("&Server name:")); QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); //#############KOSTIL'################## ipAddress = "91.221.60.166"; break; } } if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); hostLineEdit = new QLineEdit(ipAddress); hostLabel->setBuddy(hostLineEdit); statusLabel = new QLabel(tr("")); alarmTypeUnus = new QPushButton(tr("Fire")); alarmTypeDuo = new QPushButton(tr("Pain")); alarmTypeTres = new QPushButton(tr("Breakin")); quitButton = new QPushButton(tr("Quit")); sendButton = new QPushButton(tr("Send datastring")); buttonBox = new QDialogButtonBox; buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); tcpSocket = new QTcpSocket(this); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); connect(alarmTypeUnus, SIGNAL(clicked()), this, SLOT(pressedUnus())); connect(alarmTypeDuo, SIGNAL(clicked()), this, SLOT(pressedDuo())); connect(alarmTypeTres, SIGNAL(clicked()), this, SLOT(pressedTres())); connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError))); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(hostLabel, 0, 0); mainLayout->addWidget(hostLineEdit, 0, 1); mainLayout->addWidget(alarmTypeUnus, 3, 0); mainLayout->addWidget(alarmTypeDuo, 3, 1); mainLayout->addWidget(alarmTypeTres, 3, 2); mainLayout->addWidget(buttonBox, 4, 0); setLayout(mainLayout); setWindowTitle(tr("Alarm Client")); QNetworkConfigurationManager manager; if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("QtNetwork")); const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); settings.endGroup(); QNetworkConfiguration config = manager.configurationFromIdentifier(id); if ((config.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { config = manager.defaultConfiguration(); } networkSession = new QNetworkSession(config, this); connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); statusLabel->setText(tr("Opening network session.")); networkSession->open(); } }