radioapp/radiouiengine/src/radiostationmodel.cpp
changeset 14 63aabac4416d
parent 13 46974bebc798
child 16 f54ebcfc1b80
equal deleted inserted replaced
13:46974bebc798 14:63aabac4416d
    14 * Description:
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <qstringlist>
    19 #include <QStringList>
    20 
    20 
    21 #include "radiostationmodel.h"
    21 #include "radiostationmodel.h"
    22 #include "radiostationmodel_p.h"
    22 #include "radiostationmodel_p.h"
    23 #include "radiopresetstorage.h"
    23 #include "radiopresetstorage.h"
    24 #include "radioenginewrapper.h"
    24 #include "radioenginewrapper.h"
    25 #include "radiouiengine.h"
    25 #include "radiouiengine.h"
    26 #include "radiostation.h"
    26 #include "radiostation.h"
    27 #include "radiostation_p.h"
    27 #include "radiostation_p.h"
       
    28 #ifndef BUILD_WIN32
       
    29 #   include "radiomonitorservice.h"
       
    30 #else
       
    31 #   include "radiomonitorservice_win32.h"
       
    32 #endif
    28 #include "radiologger.h"
    33 #include "radiologger.h"
    29 
    34 
    30 /*!
    35 /*!
    31  *
    36  *
    32  */
    37  */
   329 
   334 
   330         endRemoveRows();
   335         endRemoveRows();
   331 
   336 
   332         d->setCurrentStation( d->mEngine->currentFrequency() );
   337         d->setCurrentStation( d->mEngine->currentFrequency() );
   333 
   338 
   334         if ( tempStation.isFavorite() ) {
   339         emit stationRemoved( tempStation );
   335             tempStation.setFavorite( false );
   340 
   336             emit favoriteChanged( tempStation );
       
   337         }
       
   338     }
   341     }
   339 }
   342 }
   340 
   343 
   341 /*!
   344 /*!
   342  * Adds a new station to the list
   345  * Adds a new station to the list
   559     Q_D( RadioStationModel );
   562     Q_D( RadioStationModel );
   560 	
   563 	
   561     if ( d->mStations.count() == 0 ) {
   564     if ( d->mStations.count() == 0 ) {
   562         return;
   565         return;
   563     }
   566     }
   564 	
   567 
   565     QList<RadioStation> favorites;
   568     QList<RadioStation> tempStations = d->mStations.values();
   566     foreach( const RadioStation& station, d->mStations ) {
   569 
   567         if ( station.isFavorite() ) {
       
   568             favorites.append( station );
       
   569         }
       
   570     }
       
   571 
   570 
   572     beginRemoveRows( QModelIndex(), 0, rowCount() - 1 );
   571     beginRemoveRows( QModelIndex(), 0, rowCount() - 1 );
   573 
   572 
   574     // Preset utility deletes all presets with index -1
   573     // Preset utility deletes all presets with index -1
   575 #ifdef COMPILE_WITH_NEW_PRESET_UTILITY
       
   576     bool success = d->mPresetStorage->deletePreset( -1 );
   574     bool success = d->mPresetStorage->deletePreset( -1 );
   577 #else
       
   578     bool success = d->mPresetStorage->deletePreset( 0 );
       
   579 #endif // COMPILE_WITH_NEW_PRESET_UTILITY
       
   580     RADIO_ASSERT( success, "FMRadio", "Failed to remove station" );
   575     RADIO_ASSERT( success, "FMRadio", "Failed to remove station" );
   581 
   576 
   582     d->mStations.clear();
   577     d->mStations.clear();
   583     d->setCurrentStation( d->mEngine->currentFrequency() );
   578     d->setCurrentStation( d->mEngine->currentFrequency() );
   584 
   579 
   585     endRemoveRows();
   580     endRemoveRows();
   586 
   581 
   587     foreach( RadioStation station, favorites ) {
   582     foreach( RadioStation station, tempStations ) {
   588         station.setFavorite( false );
   583         emit stationRemoved( station );
   589         emit favoriteChanged( station );
       
   590     }
   584     }
   591 }
   585 }
   592 
   586 
   593 /*!
   587 /*!
   594  * Private slot
   588  * Private slot
   602     {
   596     {
   603         d->mCurrentStation->setPsType( RadioStation::Static );
   597         d->mCurrentStation->setPsType( RadioStation::Static );
   604         d->mCurrentStation->setName( d->mCurrentStation->dynamicPsText() );
   598         d->mCurrentStation->setName( d->mCurrentStation->dynamicPsText() );
   605         d->mCurrentStation->setDynamicPsText( "" );
   599         d->mCurrentStation->setDynamicPsText( "" );
   606         saveStation( *d->mCurrentStation );
   600         saveStation( *d->mCurrentStation );
       
   601         d->mUiEngine.monitor().notifyName( d->mCurrentStation->name() );
   607     }
   602     }
   608 }
   603 }
   609 
   604 
   610 /*!
   605 /*!
   611  * Checks the given station and emits signals based on what member variables had been changed
   606  * Checks the given station and emits signals based on what member variables had been changed