radioapp/radiouiengine/src/radiostationmodel_p.cpp
changeset 32 189d20c34778
parent 28 075425b8d9a4
child 37 451b2e1545b2
child 47 74b7c6e79031
equal deleted inserted replaced
28:075425b8d9a4 32:189d20c34778
    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     mManualStation.setType( RadioStation::ManualStation );
    49     Radio::connect( mDynamicPsTimer.data(), SIGNAL(timeout()),
    50     Radio::connect( mDynamicPsTimer.data(), SIGNAL(timeout()),
    50                     q_ptr,                  SLOT(dynamicPsCheckEnded()) );
    51                     q_ptr,                  SLOT(dynamicPsCheckEnded()) );
    51     mDynamicPsTimer->setInterval( DYNAMIC_PS_CHECK_TIMEOUT );
    52     mDynamicPsTimer->setInterval( DYNAMIC_PS_CHECK_TIMEOUT );
    52     mDynamicPsTimer->setSingleShot( true );
    53     mDynamicPsTimer->setSingleShot( true );
    53 }
    54 }
    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 );
   105  * Sets the genre to the currently tuned station
   107  * Sets the genre to the currently tuned station
   106  */
   108  */
   107 void RadioStationModelPrivate::setCurrentGenre( uint frequency, int genre )
   109 void RadioStationModelPrivate::setCurrentGenre( uint frequency, int genre )
   108 {
   110 {
   109     Q_Q( RadioStationModel );
   111     Q_Q( RadioStationModel );
   110     RadioStation station = q->findCurrentStation( frequency );
   112     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   111     if ( !station.isValid() ) {
   113     if ( !station.isValid() ) {
   112         LOG( "Unable to find current station. Ignoring RDS" );
   114         LOG( "Unable to find current station. Ignoring RDS" );
   113         return;
   115         return;
   114     }
   116     }
   115     station.setGenre( genre );
   117     station.setGenre( genre );
   189  */
   191  */
   190 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   192 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   191 {
   193 {
   192     Q_Q( RadioStationModel );
   194     Q_Q( RadioStationModel );
   193     LOG_FORMAT( "void RadioStationModelPrivate::setCurrentPsName: %s", GETSTRING( name ) );
   195     LOG_FORMAT( "void RadioStationModelPrivate::setCurrentPsName: %s", GETSTRING( name ) );
   194     RadioStation station = q->findCurrentStation( frequency );
   196     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   195     if ( !station.isValid() ) {
   197     if ( !station.isValid() ) {
   196         LOG( "Unable to find current station. Ignoring RDS" );
   198         LOG( "Unable to find current station. Ignoring RDS" );
   197         return;
   199         return;
   198     }
   200     }
   199 
   201 
   250  * Sets the radio text to the currently tuned station
   252  * Sets the radio text to the currently tuned station
   251  */
   253  */
   252 void RadioStationModelPrivate::setCurrentRadioText( uint frequency, const QString& radioText )
   254 void RadioStationModelPrivate::setCurrentRadioText( uint frequency, const QString& radioText )
   253 {
   255 {
   254     Q_Q( RadioStationModel );
   256     Q_Q( RadioStationModel );
   255     RadioStation station = q->findCurrentStation( frequency );
   257     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   256     if ( !station.isValid() ) {
   258     if ( !station.isValid() ) {
   257         LOG( "Unable to find current station. Ignoring RDS" );
   259         LOG( "Unable to find current station. Ignoring RDS" );
   258         return;
   260         return;
   259     }
   261     }
   260     station.setRadioText( radioText );
   262     station.setRadioText( radioText );
   267  * Sets the radio text plus to the currently tuned station
   269  * Sets the radio text plus to the currently tuned station
   268  */
   270  */
   269 void RadioStationModelPrivate::setCurrentRadioTextPlus( uint frequency, int rtClass, const QString& rtItem )
   271 void RadioStationModelPrivate::setCurrentRadioTextPlus( uint frequency, int rtClass, const QString& rtItem )
   270 {
   272 {
   271     Q_Q( RadioStationModel );
   273     Q_Q( RadioStationModel );
   272     RadioStation station = q->findCurrentStation( frequency );
   274     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   273     if ( !station.isValid() ) {
   275     if ( !station.isValid() ) {
   274         LOG( "Unable to find current station. Ignoring RDS" );
   276         LOG( "Unable to find current station. Ignoring RDS" );
   275         return;
   277         return;
   276     }
   278     }
   277     station.setRadioTextPlus( rtClass, rtItem );
   279     station.setRadioTextPlus( rtClass, rtItem );
   284  * Sets the PI code to the currently tuned station
   286  * Sets the PI code to the currently tuned station
   285  */
   287  */
   286 void RadioStationModelPrivate::setCurrentPiCode( uint frequency, int piCode )
   288 void RadioStationModelPrivate::setCurrentPiCode( uint frequency, int piCode )
   287 {
   289 {
   288     Q_Q( RadioStationModel );
   290     Q_Q( RadioStationModel );
   289     RadioStation station = q->findCurrentStation( frequency );
   291     RadioStation station = q->findStation( frequency, FindCriteria::IncludeManualStation );
   290     if ( !station.isValid() ) {
   292     if ( !station.isValid() ) {
   291         LOG( "Unable to find current station. Ignoring RDS" );
   293         LOG( "Unable to find current station. Ignoring RDS" );
   292         return;
   294         return;
   293     }
   295     }
   294 #ifdef SHOW_CALLSIGN_IN_ANY_REGION
   296 #ifdef SHOW_CALLSIGN_IN_ANY_REGION