Commit 4b122d2a authored by Dennis Nienhüser's avatar Dennis Nienhüser
Browse files

Remove MarbleWidget (superseded by MarbleQuickItem). Use namespace.

parent b1a77d2e
......@@ -53,7 +53,7 @@ void MarbleDeclarativePlugin::registerTypes( const char *uri )
qmlRegisterType<Bookmarks>( uri, 0, 20, "Bookmarks" );
qmlRegisterType<Tracking>( uri, 0, 20, "Tracking" );
qmlRegisterType<Marble::Routing>( uri, 0, 20, "Routing" );
qmlRegisterType<Navigation>( uri, 0, 20, "Navigation" );
qmlRegisterType<Marble::Navigation>( uri, 0, 20, "Navigation" );
qmlRegisterType<Search>( uri, 0, 20, "Find" );
qmlRegisterType<CloudSync>( uri, 0, 20, "CloudSync" );
qmlRegisterType<Marble::MergeItem>( uri, 0, 20, "MergeItem" );
......
......@@ -22,22 +22,22 @@
#include "routing/VoiceNavigationModel.h"
#include "ViewportParams.h"
namespace Marble {
class NavigationPrivate
{
public:
NavigationPrivate();
MarbleWidget* m_marbleWidget;
Marble::MarbleQuickItem * m_marbleQuickItem;
MarbleQuickItem * m_marbleQuickItem;
bool m_muted;
Marble::RouteSegment m_currentSegment;
RouteSegment m_currentSegment;
Marble::AutoNavigation* m_autoNavigation;
AutoNavigation* m_autoNavigation;
Marble::VoiceNavigationModel m_voiceNavigation;
VoiceNavigationModel m_voiceNavigation;
qreal m_nextInstructionDistance;
......@@ -46,28 +46,28 @@ public:
double m_screenAccuracy;
QPointF m_screenPosition;
Marble::RouteSegment nextRouteSegment();
RouteSegment nextRouteSegment();
void updateNextInstructionDistance( const Marble::Route &route );
void updateNextInstructionDistance( const Route &route );
Marble::MarbleModel * model() const;
MarbleModel * model() const;
QPointF positionOnRoute() const;
QPointF currentPosition() const;
};
NavigationPrivate::NavigationPrivate() :
m_marbleWidget( nullptr ), m_marbleQuickItem( nullptr ), m_muted( false ), m_autoNavigation( 0 ), m_nextInstructionDistance( 0.0 ),
m_marbleQuickItem( nullptr ), m_muted( false ), m_autoNavigation( 0 ), m_nextInstructionDistance( 0.0 ),
m_destinationDistance( 0.0 ), m_screenAccuracy(0)
{
// nothing to do
}
void NavigationPrivate::updateNextInstructionDistance( const Marble::Route &route )
void NavigationPrivate::updateNextInstructionDistance( const Route &route )
{
const Marble::GeoDataCoordinates position = route.position();
const Marble::GeoDataCoordinates interpolated = route.positionOnRoute();
const Marble::GeoDataCoordinates onRoute = route.currentWaypoint();
const GeoDataCoordinates position = route.position();
const GeoDataCoordinates interpolated = route.positionOnRoute();
const GeoDataCoordinates onRoute = route.currentWaypoint();
qreal planetRadius = 0;
if (model()){
......@@ -75,7 +75,7 @@ void NavigationPrivate::updateNextInstructionDistance( const Marble::Route &rout
}
qreal distance = planetRadius * ( distanceSphere( position, interpolated ) + distanceSphere( interpolated, onRoute ) );
qreal remaining = 0.0;
const Marble::RouteSegment &segment = route.currentSegment();
const RouteSegment &segment = route.currentSegment();
for ( int i=0; i<segment.path().size(); ++i ) {
if ( segment.path()[i] == onRoute ) {
distance += segment.path().length( planetRadius, i );
......@@ -85,7 +85,7 @@ void NavigationPrivate::updateNextInstructionDistance( const Marble::Route &rout
bool upcoming = false;
for ( int i=0; i<route.size(); ++i ) {
const Marble::RouteSegment &segment = route.at( i );
const RouteSegment &segment = route.at( i );
if ( upcoming ) {
remaining += segment.path().length( planetRadius );
......@@ -100,26 +100,15 @@ void NavigationPrivate::updateNextInstructionDistance( const Marble::Route &rout
m_destinationDistance = distance + remaining;
}
Marble::MarbleModel * NavigationPrivate::model() const
MarbleModel * NavigationPrivate::model() const
{
if (m_marbleQuickItem != nullptr) {
return m_marbleQuickItem->model();
}
else if (m_marbleWidget != nullptr)
{
return m_marbleWidget->model();
}
return nullptr;
return m_marbleQuickItem ? m_marbleQuickItem->model() : nullptr;
}
Marble::RouteSegment NavigationPrivate::nextRouteSegment()
RouteSegment NavigationPrivate::nextRouteSegment()
{
if ( m_marbleWidget || m_marbleQuickItem) {
// Not using m_currentSegment on purpose
return model()->routingManager()->routingModel()->route().currentSegment().nextRouteSegment();
}
return Marble::RouteSegment();
// Not using m_currentSegment on purpose
return m_marbleQuickItem ? model()->routingManager()->routingModel()->route().currentSegment().nextRouteSegment() : RouteSegment();
}
Navigation::Navigation( QObject* parent) :
......@@ -133,51 +122,18 @@ Navigation::~Navigation()
delete d;
}
MarbleWidget *Navigation::map()
{
return d->m_marbleWidget;
}
void Navigation::setMap( MarbleWidget* widget )
{
d->m_marbleWidget = widget;
if ( d->m_marbleWidget ) {
// Avoid the QWidget based warning
d->m_marbleWidget->model()->routingManager()->setShowGuidanceModeStartupWarning( false );
connect( d->m_marbleWidget->model()->routingManager()->routingModel(),
SIGNAL(positionChanged()), this, SLOT(update()) );
delete d->m_autoNavigation;
d->m_autoNavigation = new Marble::AutoNavigation( d->m_marbleWidget->model(), d->m_marbleWidget->viewport(), this );
connect( d->m_autoNavigation, SIGNAL(zoomIn(FlyToMode)),
d->m_marbleWidget, SLOT(zoomIn()) );
connect( d->m_autoNavigation, SIGNAL(zoomOut(FlyToMode)),
d->m_marbleWidget, SLOT(zoomOut()) );
connect( d->m_autoNavigation, SIGNAL(centerOn(GeoDataCoordinates,bool)),
d->m_marbleWidget, SLOT(centerOn(GeoDataCoordinates)) );
connect( d->m_marbleWidget, SIGNAL(visibleLatLonAltBoxChanged()),
d->m_autoNavigation, SLOT(inhibitAutoAdjustments()) );
connect( d->m_marbleWidget->model()->positionTracking(), SIGNAL(statusChanged(PositionProviderStatus)),
&d->m_voiceNavigation, SLOT(handleTrackingStatusChange(PositionProviderStatus)) );
}
emit mapChanged();
}
bool Navigation::guidanceModeEnabled() const
{
if (d->m_marbleWidget || d->m_marbleQuickItem) {
return d->model()->routingManager()->guidanceModeEnabled();
}
return false;
return d->m_marbleQuickItem ? d->model()->routingManager()->guidanceModeEnabled() : false;
}
void Navigation::setGuidanceModeEnabled( bool enabled )
{
if ( d->m_marbleWidget || d->m_marbleQuickItem ) {
if ( d->m_marbleQuickItem ) {
d->model()->routingManager()->setGuidanceModeEnabled( enabled );
d->m_autoNavigation->setAutoZoom( enabled );
d->m_autoNavigation->setRecenter( enabled ? Marble::AutoNavigation::RecenterOnBorder : Marble::AutoNavigation::DontRecenter );
d->m_autoNavigation->setRecenter( enabled ? AutoNavigation::RecenterOnBorder : AutoNavigation::DontRecenter );
if ( enabled && !d->m_muted ) {
//d->m_audio.announceStart();
......@@ -208,23 +164,23 @@ QString Navigation::nextRoad() const
QString Navigation::nextInstructionImage() const
{
switch ( d->nextRouteSegment().maneuver().direction() ) {
case Marble::Maneuver::Unknown: return "";
case Marble::Maneuver::Continue: return "qrc:/marble/turn-continue.svg";
case Marble::Maneuver::Merge: return "qrc:/marble/turn-merge.svg";
case Marble::Maneuver::Straight: return "qrc:/marble/turn-continue.svg";
case Marble::Maneuver::SlightRight: return "qrc:/marble/turn-slight-right.svg";
case Marble::Maneuver::Right: return "qrc:/marble/turn-right.svg";
case Marble::Maneuver::SharpRight: return "qrc:/marble/turn-sharp-right.svg";
case Marble::Maneuver::TurnAround: return "qrc:/marble/turn-around.svg";
case Marble::Maneuver::SharpLeft: return "qrc:/marble/turn-sharp-left.svg";
case Marble::Maneuver::Left: return "qrc:/marble/turn-left.svg";
case Marble::Maneuver::SlightLeft: return "qrc:/marble/turn-slight-left.svg";
case Marble::Maneuver::RoundaboutFirstExit: return "qrc:/marble/turn-roundabout-first.svg";
case Marble::Maneuver::RoundaboutSecondExit: return "qrc:/marble/turn-roundabout-second.svg";
case Marble::Maneuver::RoundaboutThirdExit: return "qrc:/marble/turn-roundabout-third.svg";
case Marble::Maneuver::RoundaboutExit: return "qrc:/marble/turn-roundabout-far.svg";
case Marble::Maneuver::ExitLeft: return "qrc:/marble/turn-exit-left.svg";
case Marble::Maneuver::ExitRight: return "qrc:/marble/turn-exit-right.svg";
case Maneuver::Unknown: return "";
case Maneuver::Continue: return "qrc:/marble/turn-continue.svg";
case Maneuver::Merge: return "qrc:/marble/turn-merge.svg";
case Maneuver::Straight: return "qrc:/marble/turn-continue.svg";
case Maneuver::SlightRight: return "qrc:/marble/turn-slight-right.svg";
case Maneuver::Right: return "qrc:/marble/turn-right.svg";
case Maneuver::SharpRight: return "qrc:/marble/turn-sharp-right.svg";
case Maneuver::TurnAround: return "qrc:/marble/turn-around.svg";
case Maneuver::SharpLeft: return "qrc:/marble/turn-sharp-left.svg";
case Maneuver::Left: return "qrc:/marble/turn-left.svg";
case Maneuver::SlightLeft: return "qrc:/marble/turn-slight-left.svg";
case Maneuver::RoundaboutFirstExit: return "qrc:/marble/turn-roundabout-first.svg";
case Maneuver::RoundaboutSecondExit: return "qrc:/marble/turn-roundabout-second.svg";
case Maneuver::RoundaboutThirdExit: return "qrc:/marble/turn-roundabout-third.svg";
case Maneuver::RoundaboutExit: return "qrc:/marble/turn-roundabout-far.svg";
case Maneuver::ExitLeft: return "qrc:/marble/turn-exit-left.svg";
case Maneuver::ExitRight: return "qrc:/marble/turn-exit-right.svg";
}
return "";
......@@ -267,22 +223,22 @@ void Navigation::setSoundEnabled( bool soundEnabled )
bool Navigation::deviated() const
{
if ( d->m_marbleWidget || d->m_marbleQuickItem ) {
Marble::RoutingModel const * routingModel = d->model()->routingManager()->routingModel();
if ( d->m_marbleQuickItem ) {
RoutingModel const * routingModel = d->model()->routingManager()->routingModel();
return routingModel->deviatedFromRoute();
}
return true;
}
Marble::MarbleQuickItem *Navigation::marbleQuickItem() const
MarbleQuickItem *Navigation::marbleQuickItem() const
{
return d->m_marbleQuickItem;
}
QPointF NavigationPrivate::positionOnRoute() const
{
Marble::RoutingModel const * routingModel = model()->routingManager()->routingModel();
RoutingModel const * routingModel = model()->routingManager()->routingModel();
GeoDataCoordinates coordinates = routingModel->route().positionOnRoute();
qreal x = 0;
qreal y = 0;
......@@ -309,7 +265,7 @@ double Navigation::screenAccuracy() const
return d->m_screenAccuracy;
}
void Navigation::setMarbleQuickItem(Marble::MarbleQuickItem *marbleQuickItem)
void Navigation::setMarbleQuickItem(MarbleQuickItem *marbleQuickItem)
{
if ( d->m_marbleQuickItem == marbleQuickItem) {
return;
......@@ -340,7 +296,7 @@ void Navigation::setMarbleQuickItem(Marble::MarbleQuickItem *marbleQuickItem)
SIGNAL(deviatedFromRoute(bool)), this, SIGNAL(deviationChanged()) );
delete d->m_autoNavigation;
d->m_autoNavigation = new Marble::AutoNavigation( d->model(), d->m_marbleQuickItem->map()->viewport(), this );
d->m_autoNavigation = new AutoNavigation( d->model(), d->m_marbleQuickItem->map()->viewport(), this );
connect( d->m_autoNavigation, SIGNAL(zoomIn(FlyToMode)),
d->m_marbleQuickItem, SLOT(zoomIn()) );
connect( d->m_autoNavigation, SIGNAL(zoomOut(FlyToMode)),
......@@ -370,11 +326,11 @@ void Navigation::update()
return;
}
Marble::RoutingModel const * routingModel = d->model()->routingManager()->routingModel();
RoutingModel const * routingModel = d->model()->routingManager()->routingModel();
d->updateNextInstructionDistance( routingModel->route() );
emit nextInstructionDistanceChanged();
emit destinationDistanceChanged();
Marble::RouteSegment segment = routingModel->route().currentSegment();
RouteSegment segment = routingModel->route().currentSegment();
if ( !d->m_muted ) {
d->m_voiceNavigation.update( routingModel->route(), d->m_nextInstructionDistance, d->m_destinationDistance, routingModel->deviatedFromRoute() );
}
......@@ -400,5 +356,6 @@ void Navigation::updateScreenPosition()
}
}
}
#include "moc_Navigation.cpp"
......@@ -16,19 +16,15 @@
class QAbstractItemModel;
class MarbleWidget;
namespace Marble {
class MarbleQuickItem;
class MarbleModel;
}
class NavigationPrivate;
class Navigation : public QObject
{
Q_OBJECT
Q_PROPERTY(MarbleWidget* map READ map WRITE setMap NOTIFY mapChanged)
Q_PROPERTY(Marble::MarbleQuickItem * marbleQuickItem READ marbleQuickItem WRITE setMarbleQuickItem NOTIFY marbleQuickItemChanged)
Q_PROPERTY(bool guidanceModeEnabled READ guidanceModeEnabled WRITE setGuidanceModeEnabled NOTIFY guidanceModeEnabledChanged)
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
......@@ -49,10 +45,6 @@ public:
~Navigation();
MarbleWidget* map();
void setMap( MarbleWidget* widget );
bool guidanceModeEnabled() const;
void setGuidanceModeEnabled( bool enabled );
......@@ -131,4 +123,6 @@ private:
NavigationPrivate* const d;
};
}
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment