radioapp/radioenginewrapper/src/radioenginewrapper_win32_p.cpp
changeset 28 075425b8d9a4
parent 24 6df133bd92e1
child 37 451b2e1545b2
child 54 a8ba0c289b44
--- a/radioapp/radioenginewrapper/src/radioenginewrapper_win32_p.cpp	Fri Jun 04 10:21:36 2010 +0100
+++ b/radioapp/radioenginewrapper/src/radioenginewrapper_win32_p.cpp	Fri Jun 11 13:38:32 2010 +0300
@@ -69,7 +69,8 @@
     mFrequencyStepSize( 50000 ),
     mRegionId( RadioRegion::Default ),
     mMinFrequency( 87500000 ),
-    mMaxFrequency( 108000000 )
+    mMaxFrequency( 108000000 ),
+    mManualSeekMode( false )
 {
     ::theInstance = this;
     mEngineSettings.reset( new QSettings( "Nokia", "QtFmRadio" ) );
@@ -78,7 +79,7 @@
         mFrequency = mMinFrequency;
     }
 
-    connectAndTest( mTuneTimer, SIGNAL(timeout()), this, SLOT(frequencyEvent()) );
+    Radio::connect( mTuneTimer, SIGNAL(timeout()), this, SLOT(frequencyEvent()) );
     mTuneTimer->setSingleShot( true );    
 }
 
@@ -103,7 +104,7 @@
 /*!
  * Initializes the private implementation
  */
-void RadioEngineWrapperPrivate::init()
+bool RadioEngineWrapperPrivate::init()
 {
     mUseLoudspeaker = false;
     if ( !mUseLoudspeaker ) {
@@ -111,13 +112,6 @@
     }
 
     parseData();
-}
-
-/*!
- * Starts up the radio engine
- */
-bool RadioEngineWrapperPrivate::isEngineConstructed()
-{
     return true;
 }
 
@@ -136,23 +130,17 @@
 /*!
  * Tunes to the given frequency
  */
-void RadioEngineWrapperPrivate::tuneFrequency( uint frequency, const int reason )
+void RadioEngineWrapperPrivate::setFrequency( uint frequency, const int reason )
 {
     mNextFrequency = frequency;
     mTuneReason = reason;
+
     mTuneTimer->stop();
-    mTuneTimer->start( 500 );
-}
-
-/*!
- * Tunes to the given frequency after a delay
- */
-void RadioEngineWrapperPrivate::tuneWithDelay( uint frequency, const int reason )
-{
-    mNextFrequency = frequency;
-    mTuneReason = reason;
-    mTuneTimer->stop();
-    mTuneTimer->start( 1500 );
+    if ( !mManualSeekMode ) {
+        mTuneTimer->start( 500 );
+    } else {
+        frequencyEvent();
+    }
 }
 
 /*!
@@ -166,9 +154,10 @@
 /*!
  *
  */
-void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction, const int reason )
+void RadioEngineWrapperPrivate::startSeeking( Seek::Direction direction, const int reason )
 {
     mTuneReason = reason;
+    mNextFrequency = 0;
 
     // Find the previous and next favorite from current frequency
     uint previous = 0;
@@ -183,7 +172,7 @@
     }
 
 
-    if ( direction == Seeking::Up ) {
+    if ( direction == Seek::Up ) {
         if ( next == 0 ) {
             next = KScanFrequencies[0];
         }
@@ -286,10 +275,14 @@
  */
 void RadioEngineWrapperPrivate::frequencyEvent()
 {
-    mFrequency = mNextFrequency;
-    mEngineSettings->setValue( KKeyFrequency, mFrequency );
+    if ( mNextFrequency > 0 ) {
+        mFrequency = mNextFrequency;
+        mEngineSettings->setValue( KKeyFrequency, mFrequency );
+    }
 
-    RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( mFrequency, mTuneReason ) );
+    if ( !mManualSeekMode ) {
+        RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( mNextFrequency, mTuneReason ) );
+    }
 }
 
 /*!