radioapp/radiouiengine/src/radioscannerengine_p.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 32 189d20c34778
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    57         return;
    57         return;
    58     }
    58     }
    59 
    59 
    60     Q_Q( RadioScannerEngine );
    60     Q_Q( RadioScannerEngine );
    61     if ( reason == TuneReason::StationScanInitialization ) {
    61     if ( reason == TuneReason::StationScanInitialization ) {
    62         mUiEngine.wrapper().startSeeking( Seeking::Up, TuneReason::StationScan );
    62         mUiEngine.wrapper().startSeeking( Seek::Up, TuneReason::StationScan );
    63     } else if ( reason == TuneReason::StationScan ) {
    63     } else if ( reason == TuneReason::StationScan ) {
    64         if ( frequency > mLastFoundFrequency ) {
    64         if ( frequency == mLastFoundFrequency ) {
       
    65             // Stop scanning
       
    66             q->emitStationFound( RadioStation() );
       
    67         } else if ( frequency > mLastFoundFrequency ) {
    65             // Station has been found normally
    68             // Station has been found normally
    66             mLastFoundFrequency = frequency;
    69             mLastFoundFrequency = frequency;
    67             addFrequencyAndReport( frequency );
    70             addFrequencyAndReport( frequency );
    68         } else if ( frequency == mUiEngine.api().minFrequency() ) {
    71         } else if ( frequency == mUiEngine.api().minFrequency() ) {
    69             // Special case. A station has been found in the mininmum frequency
    72             // Special case. A station has been found in the mininmum frequency
    70             addFrequencyAndReport( frequency );
    73             addFrequencyAndReport( frequency );
    71         } else {
    74         } else {
    72             // Seeking looped around the frequency band. Send invalid station as indicator that the scanning should stop
    75             // Seeking looped around the frequency band. Send invalid station as indicator that the scanning should stop
    73             q->emitStationFound( RadioStation() );
    76             q->emitStationFound( RadioStation() );
    74         }
    77         }
       
    78     } else {
       
    79         q->emitStationFound( RadioStation() );
    75     }
    80     }
    76 }
    81 }
    77 
    82 
    78 /*!
    83 /*!
    79  *
    84  *
    80  */
    85  */
    81 void RadioScannerEnginePrivate::addFrequencyAndReport( const uint frequency )
    86 void RadioScannerEnginePrivate::addFrequencyAndReport( const uint frequency )
    82 {
    87 {
    83     RadioStationModel& stationModel = mUiEngine.api().stationModel();
    88     RadioStationModel& stationModel = mUiEngine.api().stationModel();
    84     stationModel.stationHandlerIf().addScannedFrequency( frequency );
    89     stationModel.stationHandlerIf().addScannedFrequency( frequency );
       
    90 
       
    91     // Return value of findFrequency() is intentionally ignored. The station was just added
       
    92     // to the model in the previous line so it should be found and if it isn't then an
       
    93     // empty station is sent with the signal and scanner will stop the scanning process.
    85     RadioStation station;
    94     RadioStation station;
    86     stationModel.findFrequency( frequency, station );
    95     stationModel.findFrequency( frequency, station );
       
    96 
    87     Q_Q( RadioScannerEngine );
    97     Q_Q( RadioScannerEngine );
    88     q->emitStationFound( station );
    98     q->emitStationFound( station );
    89 }
    99 }
    90 
   100