void Navigator::on_addressSearchFinished() { if (addressReply->places().size() <= 0) { addressReply->deleteLater(); return; } QGeoPlace place = addressReply->places().at(0); QList<QGeoCoordinate> waypoints = request.waypoints(); waypoints.append(place.coordinate()); request.setWaypoints(waypoints); routeReply = routingManager->calculateRoute(request); if (routeReply->isFinished()) { on_routingFinished(); } else { connect(routeReply, SIGNAL(error(QGeoRouteReply::Error,QString)), this, SIGNAL(routingError(QGeoRouteReply::Error,QString))); connect(routeReply, SIGNAL(finished()), this, SLOT(on_routingFinished())); } endMarker = new Marker(Marker::EndMarker); endMarker->setCoordinate(place.coordinate()); endMarker->setAddress(place.address()); endMarker->setName("Destination"); mapsWidget->map()->addMapObject(endMarker); addressReply->deleteLater(); }
QDeclarativeGeoPlace::QDeclarativeGeoPlace(const QGeoPlace& place, QObject* parent) : QObject(parent), m_declarativeBox(place.viewport(), this), m_declarativeCoordinate(place.coordinate(), this), m_declarativeAddress(place.address(), this) { }
QVariant QDeclarativeGeocodeModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (index.row() > places().count()) return QVariant(); QGeoPlace place = places().at(index.row()); if (role == Qt::DisplayRole) return place.coordinate().toString(); return QDeclarativeGeoSearchModel::data(index, role); }
void QDeclarativeGeoPlace::setPlace(const QGeoPlace& place) { m_declarativeBox.setBox(place.viewport()); m_declarativeCoordinate.setCoordinate(place.coordinate()); m_declarativeAddress.setAddress(place.address()); }