QGeoRouteReply* QGeoRoutingManagerEngineNokia::calculateRoute(const QGeoRouteRequest& request) { QString reqString = calculateRouteRequestString(request); if (reqString.isEmpty()) { QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString))); QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(request, networkReply, this); connect(reply, SIGNAL(finished()), this, SLOT(routeFinished())); connect(reply, SIGNAL(error(QGeoRouteReply::Error, QString)), this, SLOT(routeError(QGeoRouteReply::Error, QString))); return reply; }
QGeoRouteReply* QGeoRoutingManagerEngineNokia::updateRoute(const QGeoRoute &route, const QGeoCoordinate &position) { QString reqString = updateRouteRequestString(route, position); if (reqString.isEmpty()) { QGeoRouteReply *reply = new QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError, "The given route request options are not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QNetworkReply *networkReply = m_networkManager->get(QNetworkRequest(QUrl(reqString))); QGeoRouteRequest updateRequest(route.request()); updateRequest.setTravelModes(route.travelMode()); QGeoRouteReplyNokia *reply = new QGeoRouteReplyNokia(updateRequest, networkReply, this); connect(reply, SIGNAL(finished()), this, SLOT(routeFinished())); connect(reply, SIGNAL(error(QGeoRouteReply::Error, QString)), this, SLOT(routeError(QGeoRouteReply::Error, QString))); return reply; }
void MapBox::addRoute(const QList<QGeoCoordinate> & waypoints) { QGeoRoutingManager * routingManager = m_serviceProvider->routingManager(); QGeoRouteRequest req(waypoints); QGeoRouteReply * reply = routingManager->calculateRoute(req); connect(reply, SIGNAL(finished()), this, SLOT(routeFinished())); }
// Update vehicle position etc. void Car::update() { if (!isFinished()) { // Updating direction of the sprite updateSpriteDirection(); // Update if not blocked if (!mBlocked) { updatePosition(); } // Route is finished if (mDirection == Tile::NO_DIRECTION) { routeFinished(); } mBlocked = false; } }