m_mapEngine,
SLOT(showMapArea(const GeoCoordinate&, const GeoCoordinate&)));
+ connect(m_ui, SIGNAL(clearRoute()),
+ m_mapEngine, SLOT(clearRoute()));
+
// signals from distence indicator button
connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
this, SLOT(changeAutoCenteringSetting(bool)));
scrollToPosition(SceneCoordinate(coordinate));
}
+void MapEngine::clearRoute()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (m_mapRouteItem) {
+ m_mapScene->removeItem(m_mapRouteItem);
+ delete m_mapRouteItem;
+ m_mapRouteItem = 0;
+ }
+}
+
QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
- m_route = route;
-
- // delete old route track (if exists)
- if (m_mapRouteItem) {
- m_mapScene->removeItem(m_mapRouteItem);
- delete m_mapRouteItem;
- m_mapRouteItem = 0;
- }
+ clearRoute();
- // create new route track
- m_mapRouteItem = new MapRouteItem(&m_route);
+ m_mapRouteItem = new MapRouteItem(&route);
m_mapScene->addItem(m_mapRouteItem);
centerAndZoomTo(m_mapRouteItem->boundingRect().toRect());
private slots:
/**
+ * @brief Slot for clearing the current route
+ */
+ void clearRoute();
+
+ /**
* @brief This slot is called after friend items position have been updated
*
* Does run MapScene::spanItems()
MapScene *m_mapScene; ///< Scene for map tiles
MapScroller *m_scroller; ///< Kinetic scroller
OwnLocationItem *m_ownLocation; ///< Item to show own location
- Route m_route; ///< Current route data
};
#endif // MAPENGINE_H
connect(m_routingPanel, SIGNAL(requestSearchLocation()),
this, SLOT(startLocationSearch()));
+
+ connect(m_routingPanel, SIGNAL(clearRoute()),
+ this, SIGNAL(clearRoute()));
}
void MainWindow::buildUserInfoPanel()
void centerToSceneCoordinates(const SceneCoordinate &coordinate);
/**
+ * @brief Emitted when route is cleared
+ */
+ void clearRoute();
+
+ /**
* @brief Signal when direction and distance from current map center point to current GPS
* location is changed
*
ImageButton *searchLocationButton = new ImageButton(":/res/images/search.png",
":/res/images/search_s.png",
"", this);
-
+ searchLocationButton->setCheckable(true);
m_contextButtonLayout->addWidget(searchLocationButton);
m_routeButton = new ImageButton(":res/images/route_to_location.png",
":res/images/route_to_location_s.png", "", this);
+ m_routeButton->setCheckable(true);
m_routeButton->setDisabled(true);
m_locationListHeaderWidget = new QWidget();
connect(m_routeWaypointListView, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
this, SIGNAL(routeWaypointItemClicked(GeoCoordinate)));
- connect(m_routeButton, SIGNAL(clicked()),
- this, SLOT(routeToSelectedLocation()));
+ connect(m_routeButton, SIGNAL(toggled(bool)),
+ this, SLOT(routeButtonToggled(bool)));
- connect(searchLocationButton, SIGNAL(clicked()),
- this, SIGNAL(requestSearchLocation()));
+ connect(searchLocationButton, SIGNAL(toggled(bool)),
+ this, SLOT(searchLocationButtonToggled(bool)));
// CONTEXT BUTTONS
m_contextButtonLayout->addWidget(m_routeButton);
m_locationListView->scrollToTop();
}
+void RoutingPanel::routeButtonToggled(bool checked)
+{
+ if (checked) {
+ routeToSelectedLocation();
+ } else {
+ emit clearRoute();
+ /// @todo clear route panel
+ }
+}
+
void RoutingPanel::routeToSelectedLocation()
{
qDebug() << __PRETTY_FUNCTION__;
emit routeToLocation(item->coordinates());
}
+void RoutingPanel::searchLocationButtonToggled(bool checked)
+{
+ if (checked) {
+ emit requestSearchLocation();
+ } else {
+ m_locationListHeaderWidget->hide();
+ m_locationListView->hide();
+ }
+}
+
void RoutingPanel::setRoute(Route &route)
{
qDebug() << __PRETTY_FUNCTION__;
*/
void populateLocationListView(const QList<Location> &locations);
+ void routeButtonToggled(bool checked);
+
/**
* @brief Routes to selected location.
*
*/
void routeToSelectedLocation();
+ void searchLocationButtonToggled(bool checked);
+
/**
* @brief Sets route to the panel.
*
******************************************************************************/
signals:
/**
+ * @brief Emitted when route is cleared
+ */
+ void clearRoute();
+
+ /**
* @brief Signal for location item clicked.
*
* @param swBound south-west bound GeoCoordinate