radioapp/radiouiengine/src/radiostationmodel_p.cpp
changeset 19 afea38384506
parent 16 f54ebcfc1b80
child 37 451b2e1545b2
equal deleted inserted replaced
16:f54ebcfc1b80 19:afea38384506
    27 #include "radiouiengine.h"
    27 #include "radiouiengine.h"
    28 #include "radiouiengine_p.h"
    28 #include "radiouiengine_p.h"
    29 #include "radiostation.h"
    29 #include "radiostation.h"
    30 #include "radiostation_p.h"
    30 #include "radiostation_p.h"
    31 #include "radiohistorymodel.h"
    31 #include "radiohistorymodel.h"
    32 #ifndef BUILD_WIN32
       
    33 #   include "radiomonitorservice.h"
       
    34 #else
       
    35 #   include "radiomonitorservice_win32.h"
       
    36 #endif
       
    37 
    32 
    38 // Constants
    33 // Constants
    39 /**
    34 /**
    40  * 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
    41  */
    36  */
   100 
    95 
   101     Q_Q( RadioStationModel );
    96     Q_Q( RadioStationModel );
   102     if ( oldStation && oldStation->isValid() ) {
    97     if ( oldStation && oldStation->isValid() ) {
   103         q->emitDataChanged( *oldStation );
    98         q->emitDataChanged( *oldStation );
   104     }
    99     }
   105 
       
   106     mUiEngine.api().monitor().notifyName( mCurrentStation->name().isEmpty() ? mCurrentStation->frequencyMhz()
       
   107                                                                             : mCurrentStation->name() );
       
   108 }
   100 }
   109 
   101 
   110 /*!
   102 /*!
   111  * \reimp
   103  * \reimp
   112  * Sets the genre to the currently tuned station
   104  * Sets the genre to the currently tuned station
   119         LOG( "Unable to find current station. Ignoring RDS" );
   111         LOG( "Unable to find current station. Ignoring RDS" );
   120         return;
   112         return;
   121     }
   113     }
   122     station.setGenre( genre );
   114     station.setGenre( genre );
   123     q->saveStation( station );
   115     q->saveStation( station );
   124     mUiEngine.api().monitor().notifyGenre( mUiEngine.api().genreToString( genre, GenreTarget::HomeScreen ) );
       
   125 }
   116 }
   126 
   117 
   127 /*!
   118 /*!
   128  * \reimp
   119  * \reimp
   129  *
   120  *
   191     }
   182     }
   192 }
   183 }
   193 
   184 
   194 /*!
   185 /*!
   195  * \reimp
   186  * \reimp
   196  * Removes all local stations that are not favorites
       
   197  */
       
   198 void RadioStationModelPrivate::removeLocalStations()
       
   199 {
       
   200     Q_Q( RadioStationModel );
       
   201     foreach( const RadioStation& station, mStations ) {
       
   202         if ( station.isType( RadioStation::LocalStation ) && !station.isFavorite() ) {
       
   203             q->removeStation( station );
       
   204         }
       
   205     }
       
   206     q->reset();
       
   207 }
       
   208 
       
   209 /*!
       
   210  * \reimp
       
   211  * Sets the PS name to the currently tuned station
   187  * Sets the PS name to the currently tuned station
   212  */
   188  */
   213 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   189 void RadioStationModelPrivate::setCurrentPsName( uint frequency, const QString& name )
   214 {
   190 {
   215     Q_Q( RadioStationModel );
   191     Q_Q( RadioStationModel );
   223     if ( station.psType() == RadioStation::Static ) {
   199     if ( station.psType() == RadioStation::Static ) {
   224 
   200 
   225         if ( name.compare( station.name() ) != 0 && !station.isRenamed() ) {
   201         if ( name.compare( station.name() ) != 0 && !station.isRenamed() ) {
   226             station.setName( name );
   202             station.setName( name );
   227             q->saveStation( station );
   203             q->saveStation( station );
   228             mUiEngine.api().monitor().notifyName( name );
       
   229         }
   204         }
   230 
   205 
   231     } else {
   206     } else {
   232 
   207 
   233         if ( mDynamicPsTimer->isActive() ) {    // Dynamic PS check is ongoing
   208         if ( mDynamicPsTimer->isActive() ) {    // Dynamic PS check is ongoing
   282         return;
   257         return;
   283     }
   258     }
   284     station.setRadioText( radioText );
   259     station.setRadioText( radioText );
   285     q->saveStation( station );
   260     q->saveStation( station );
   286     mUiEngine.api().historyModel().clearRadioTextPlus();
   261     mUiEngine.api().historyModel().clearRadioTextPlus();
   287     mUiEngine.api().monitor().notifyRadioText( radioText );
       
   288 }
   262 }
   289 
   263 
   290 /*!
   264 /*!
   291  * \reimp
   265  * \reimp
   292  * Sets the radio text plus to the currently tuned station
   266  * Sets the radio text plus to the currently tuned station
   336     if ( persistentSave ) {
   310     if ( persistentSave ) {
   337         const bool success = mPresetStorage->savePreset( *station.data_ptr() );
   311         const bool success = mPresetStorage->savePreset( *station.data_ptr() );
   338         RADIO_ASSERT( success, "RadioStationModelPrivate::saveStation", "Failed to add station" );
   312         RADIO_ASSERT( success, "RadioStationModelPrivate::saveStation", "Failed to add station" );
   339     }
   313     }
   340 }
   314 }
       
   315 
       
   316 /*!
       
   317  *
       
   318  */
       
   319 QList<RadioStation> RadioStationModelPrivate::favorites() const
       
   320 {
       
   321     QList<RadioStation> favoriteList;
       
   322     foreach( const RadioStation& tempStation, mStations ) {
       
   323         if ( tempStation.isFavorite() ) {
       
   324             favoriteList.append( tempStation );
       
   325         }
       
   326     }
       
   327     return favoriteList;
       
   328 }