QDeclarativeGeoRoute::QDeclarativeGeoRoute(const QGeoRoute &route, QObject *parent) : QObject(parent), route_(route) { bounds_ = new QDeclarativeGeoBoundingBox(route.bounds(), this); for (int i = 0; i < route_.path().size(); ++i) path_.append(new QDeclarativeCoordinate(route_.path().at(i), this)); QGeoRouteSegment segment = route_.firstRouteSegment(); while (segment.isValid()) { segments_.append(new QDeclarativeGeoRouteSegment(segment, this)); segment = segment.nextRouteSegment(); } }
void RoutePresenter::showRoute(QTreeWidgetItem* top, const QGeoRoute& route) { QTreeWidgetItem* routeItem = new QTreeWidgetItem(top); routeItem->setText(0, "route"); QTreeWidgetItem* idItem = 0; if (!route.routeId().isEmpty()) { idItem = new QTreeWidgetItem(routeItem); idItem->setText(0, "id"); idItem->setText(1, route.routeId()); } QTreeWidgetItem* modeItem = new QTreeWidgetItem(routeItem); modeItem->setText(0, "mode"); showModes(modeItem, route.request(), route.travelMode()); QTreeWidgetItem* distanceItem = new QTreeWidgetItem(routeItem); distanceItem->setText(0, "distance"); distanceItem->setText(1, QString().setNum(route.distance())); showBoundingBox(routeItem, route.bounds()); QTreeWidgetItem* wayPointsItem = new QTreeWidgetItem(routeItem); QString overviewLabel = "overview"; if (route.path().count() > 100) overviewLabel += "(100)"; wayPointsItem->setText(0, overviewLabel); showPoints(wayPointsItem, route.path()); QList<QGeoRouteSegment> segments; QGeoRouteSegment segment = route.firstRouteSegment(); while (segment.isValid()) { segments << segment; segment = segment.nextRouteSegment(); } QTreeWidgetItem* segmentsItem = new QTreeWidgetItem(routeItem); QString segmentsLabel = "segments"; if (segments.length() > 100) segmentsLabel += "(100)"; segmentsItem->setText(0, segmentsLabel); segmentsItem->setText(1, QString().setNum(segments.length())); for (int i = 0; i < segments.length() && i < 100; ++i) { showRouteSegment(segmentsItem, segments[i]); } }