radioapp/radiouiengine/src/radiostationmodel_p.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 32 189d20c34778
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    32 
    32 
    33 // Constants
    33 // Constants
    34 /**
    34 /**
    35  * Timeout period for checking if station is sending dynamic PS in milliseconds
    35  * Timeout period for checking if station is sending dynamic PS in milliseconds
    36  */
    36  */
    37 const int KDynamicPsCheckTimeout = 10 * 1000;
    37 const int DYNAMIC_PS_CHECK_TIMEOUT = 10 * 1000;
    38 
    38 
    39 /*!
    39 /*!
    40  *
    40  *
    41  */
    41  */
    42 RadioStationModelPrivate::RadioStationModelPrivate( RadioStationModel* model,
    42 RadioStationModelPrivate::RadioStationModelPrivate( RadioStationModel* model,
    44     q_ptr( model ),
    44     q_ptr( model ),
    45     mUiEngine( uiEngine ),
    45     mUiEngine( uiEngine ),
    46     mCurrentStation( &mManualStation ),
    46     mCurrentStation( &mManualStation ),
    47     mDynamicPsTimer( new QTimer() )
    47     mDynamicPsTimer( new QTimer() )
    48 {
    48 {
    49     connectAndTest( mDynamicPsTimer.data(), SIGNAL(timeout()),
    49     mManualStation.setType( RadioStation::ManualStation );
       
    50     Radio::connect( mDynamicPsTimer.data(), SIGNAL(timeout()),
    50                     q_ptr,                  SLOT(dynamicPsCheckEnded()) );
    51                     q_ptr,                  SLOT(dynamicPsCheckEnded()) );
    51     mDynamicPsTimer->setInterval( KDynamicPsCheckTimeout );
    52     mDynamicPsTimer->setInterval( DYNAMIC_PS_CHECK_TIMEOUT );
    52     mDynamicPsTimer->setSingleShot( true );
    53     mDynamicPsTimer->setSingleShot( true );
    53 }
    54 }
    54 
    55 
    55 /*!
    56 /*!
    56  *
    57  *
    87         // We have to be careful to check that key exists before using operator[]
    88         // We have to be careful to check that key exists before using operator[]
    88         // with QMap since it will insert a default-constructed value if it doesn't exist yet.
    89         // with QMap since it will insert a default-constructed value if it doesn't exist yet.
    89         mCurrentStation = &mStations[ frequency ];
    90         mCurrentStation = &mStations[ frequency ];
    90     } else {
    91     } else {
    91         mManualStation.reset();
    92         mManualStation.reset();
       
    93         mManualStation.setType( RadioStation::ManualStation );
    92         mManualStation.setFrequency( frequency );
    94         mManualStation.setFrequency( frequency );
    93         mCurrentStation = &mManualStation;
    95         mCurrentStation = &mManualStation;
    94     }
    96     }
    95 
    97 
    96     Q_Q( RadioStationModel );
    98     Q_Q( RadioStationModel );
    97     if ( oldStation && oldStation->isValid() ) {
    99     if ( oldStation && oldStation->isValid() ) {
    98         q->emitDataChanged( *oldStation );
   100         q->emitDataChanged( *oldStation );
       
   101         q->emitDataChanged( *mCurrentStation );
    99     }
   102     }
   100 }
   103 }
   101 
   104 
   102 /*!
   105 /*!
   103  * \reimp
   106  * \reimp
   104  * Sets the genre to the currently tuned station
   107  * Sets the genre to the currently tuned station
   105  */
   108  */
   106 void RadioStationModelPrivate::setCurrentGenre( uint frequency, int genre )
   109 void RadioStationModelPrivate::setCurrentGenre( uint frequency, int genre )
   107 {
   110 {
   108     Q_Q( RadioStationModel );
   111     Q_Q( RadioStationModel );
   109     RadioStation station = q->findCurrentStation( frequency );
   112     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   110     if ( !station.isValid() ) {
   113     if ( !station.isValid() ) {
   111         LOG( "Unable to find current station. Ignoring RDS" );
   114         LOG( "Unable to find current station. Ignoring RDS" );
   112         return;
   115         return;
   113     }
   116     }
   114     station.setGenre( genre );
   117     station.setGenre( genre );
   188  */
   191  */
   189 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   192 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   190 {
   193 {
   191     Q_Q( RadioStationModel );
   194     Q_Q( RadioStationModel );
   192     LOG_FORMAT( "void RadioStationModelPrivate::setCurrentPsName: %s", GETSTRING( name ) );
   195     LOG_FORMAT( "void RadioStationModelPrivate::setCurrentPsName: %s", GETSTRING( name ) );
   193     RadioStation station = q->findCurrentStation( frequency );
   196     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   194     if ( !station.isValid() ) {
   197     if ( !station.isValid() ) {
   195         LOG( "Unable to find current station. Ignoring RDS" );
   198         LOG( "Unable to find current station. Ignoring RDS" );
   196         return;
   199         return;
   197     }
   200     }
   198 
   201 
   249  * Sets the radio text to the currently tuned station
   252  * Sets the radio text to the currently tuned station
   250  */
   253  */
   251 void RadioStationModelPrivate::setCurrentRadioText( uint frequency, const QString& radioText )
   254 void RadioStationModelPrivate::setCurrentRadioText( uint frequency, const QString& radioText )
   252 {
   255 {
   253     Q_Q( RadioStationModel );
   256     Q_Q( RadioStationModel );
   254     RadioStation station = q->findCurrentStation( frequency );
   257     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   255     if ( !station.isValid() ) {
   258     if ( !station.isValid() ) {
   256         LOG( "Unable to find current station. Ignoring RDS" );
   259         LOG( "Unable to find current station. Ignoring RDS" );
   257         return;
   260         return;
   258     }
   261     }
   259     station.setRadioText( radioText );
   262     station.setRadioText( radioText );
   266  * Sets the radio text plus to the currently tuned station
   269  * Sets the radio text plus to the currently tuned station
   267  */
   270  */
   268 void RadioStationModelPrivate::setCurrentRadioTextPlus( uint frequency, int rtClass, const QString& rtItem )
   271 void RadioStationModelPrivate::setCurrentRadioTextPlus( uint frequency, int rtClass, const QString& rtItem )
   269 {
   272 {
   270     Q_Q( RadioStationModel );
   273     Q_Q( RadioStationModel );
   271     RadioStation station = q->findCurrentStation( frequency );
   274     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   272     if ( !station.isValid() ) {
   275     if ( !station.isValid() ) {
   273         LOG( "Unable to find current station. Ignoring RDS" );
   276         LOG( "Unable to find current station. Ignoring RDS" );
   274         return;
   277         return;
   275     }
   278     }
   276     station.setRadioTextPlus( rtClass, rtItem );
   279     station.setRadioTextPlus( rtClass, rtItem );
   283  * Sets the PI code to the currently tuned station
   286  * Sets the PI code to the currently tuned station
   284  */
   287  */
   285 void RadioStationModelPrivate::setCurrentPiCode( uint frequency, int piCode )
   288 void RadioStationModelPrivate::setCurrentPiCode( uint frequency, int piCode )
   286 {
   289 {
   287     Q_Q( RadioStationModel );
   290     Q_Q( RadioStationModel );
   288     RadioStation station = q->findCurrentStation( frequency );
   291     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   289     if ( !station.isValid() ) {
   292     if ( !station.isValid() ) {
   290         LOG( "Unable to find current station. Ignoring RDS" );
   293         LOG( "Unable to find current station. Ignoring RDS" );
   291         return;
   294         return;
   292     }
   295     }
   293 #ifdef SHOW_CALLSIGN_IN_ANY_REGION
   296 #ifdef SHOW_CALLSIGN_IN_ANY_REGION
   308     mStations.insert( station.frequency(), station );
   311     mStations.insert( station.frequency(), station );
   309 
   312 
   310     if ( persistentSave ) {
   313     if ( persistentSave ) {
   311         const bool success = mPresetStorage->savePreset( *station.data_ptr() );
   314         const bool success = mPresetStorage->savePreset( *station.data_ptr() );
   312         RADIO_ASSERT( success, "RadioStationModelPrivate::saveStation", "Failed to add station" );
   315         RADIO_ASSERT( success, "RadioStationModelPrivate::saveStation", "Failed to add station" );
       
   316         Q_UNUSED( success );
   313     }
   317     }
   314 }
   318 }
   315 
   319 
   316 /*!
   320 /*!
   317  *
   321  *