<commit_before>//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011      <NAME> <<EMAIL>>
//

#include "Navigation.h"

#include "MarbleDeclarativeWidget.h"
#include "MarbleModel.h"
#include "routing/RoutingManager.h"
#include "routing/RoutingModel.h"
#include "PositionTracking.h"
#include "MarbleMath.h"

namespace Marble
{
namespace Declarative
{

class NavigationPrivate
{
public:
    NavigationPrivate();

    Marble::Declarative::MarbleWidget* m_marbleWidget;

    bool m_muted;

    RouteSegment m_currentSegment;

    RouteSegment nextRouteSegment();
};

NavigationPrivate::NavigationPrivate() :
    m_marbleWidget( 0 ), m_muted( false )
{
    // nothing to do
}

RouteSegment NavigationPrivate::nextRouteSegment()
{
    if ( m_marbleWidget ) {
        // Not using m_currentSegment on purpose
        return m_marbleWidget->model()->routingManager()->routingModel()->route().currentSegment().nextRouteSegment();
    }

    return RouteSegment();
}

Navigation::Navigation( QObject* parent) :
    QObject( parent ), d( new NavigationPrivate )
{
    // nothing to do
}

Navigation::~Navigation()
{
    delete d;
}

void Navigation::setMarbleWidget( Marble::Declarative::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() ) );
    }
}

bool Navigation::guidanceModeEnabled() const
{
    return d->m_marbleWidget ? d->m_marbleWidget->model()->routingManager()->guidanceModeEnabled() : false;
}

void Navigation::setGuidanceModeEnabled( bool enabled )
{
    if ( d->m_marbleWidget ) {
        d->m_marbleWidget->model()->routingManager()->setGuidanceModeEnabled( enabled );

        if ( enabled && !d->m_muted ) {
            //d->m_audio.announceStart();
        }
    }
}

bool Navigation::muted() const
{
    return d->m_muted;
}<commit_msg>Auto navigation in navigation activity (cherry picked from commit <PASSWORD>)<commit_after>//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2011      <NAME> <<EMAIL>>
//

#include "Navigation.h"

#include "MarbleDeclarativeWidget.h"
#include "MarbleModel.h"
#include "routing/RoutingManager.h"
#include "routing/RoutingModel.h"
#include "PositionTracking.h"
#include "MarbleMath.h"
#include "routing/AdjustNavigation.h"

namespace Marble
{
namespace Declarative
{

class NavigationPrivate
{
public:
    NavigationPrivate();

    Marble::Declarative::MarbleWidget* m_marbleWidget;

    bool m_muted;

    RouteSegment m_currentSegment;

    AdjustNavigation* m_autoNavigation;

    RouteSegment nextRouteSegment();
};

NavigationPrivate::NavigationPrivate() :
    m_marbleWidget( 0 ), m_muted( false ), m_autoNavigation( 0 )
{
    // nothing to do
}

RouteSegment NavigationPrivate::nextRouteSegment()
{
    if ( m_marbleWidget ) {
        // Not using m_currentSegment on purpose
        return m_marbleWidget->model()->routingManager()->routingModel()->route().currentSegment().nextRouteSegment();
    }

    return RouteSegment();
}

Navigation::Navigation( QObject* parent) :
    QObject( parent ), d( new NavigationPrivate )
{
    // nothing to do
}

Navigation::~Navigation()
{
    delete d;
}

void Navigation::setMarbleWidget( Marble::Declarative::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() ) );

        d->m_autoNavigation = new AdjustNavigation( 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( const GeoDataCoordinates &, bool ) ),
                 d->m_marbleWidget, SLOT( centerOn( const GeoDataCoordinates & ) ) );

        connect( d->m_marbleWidget, SIGNAL( visibleLatLonAltBoxChanged() ),
                 d->m_autoNavigation, SLOT( inhibitAutoAdjustments() ) );

        d->m_marbleWidget->model()->routingManager()->setAdjustNavigation( d->m_autoNavigation );
    }
}

bool Navigation::guidanceModeEnabled() const
{
    return d->m_marbleWidget ? d->m_marbleWidget->model()->routingManager()->guidanceModeEnabled() : false;
}

void Navigation::setGuidanceModeEnabled( bool enabled )
{
    if ( d->m_marbleWidget ) {
        d->m_marbleWidget->model()->routingManager()->setGuidanceModeEnabled( enabled );

        if ( enabled && !d->m_muted ) {
            //d->m_audio.announceStart();
        }
    }
}

bool Navigation::muted() const
{
    return d->m_muted;
}
{'fraction_non_alphanumeric': 0.13253012048192772, 'fraction_numerical': 0.002008032128514056, 'mean_word_length': 3.600335852225021, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7543263', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1650, 'n_words': 364}