--- a/radioapp/radioenginewrapper/src/radioenginewrapper_win32_p.cpp Fri Mar 19 09:29:04 2010 +0200
+++ b/radioapp/radioenginewrapper/src/radioenginewrapper_win32_p.cpp Fri Apr 16 14:58:55 2010 +0300
@@ -16,8 +16,8 @@
*/
// System includes
-#include <qtimer>
-#include <qsettings>
+#include <QTimer>
+#include <QSettings>
// User includes
#include "radioenginewrapper_win32_p.h"
@@ -34,6 +34,23 @@
const QString KKeyFrequency = "CurrentFreq";
const QString KKeyOffline = "Offline";
+const uint KScanFrequencies[] = {
+ 87600000,
+ 88000000,
+ 89400000,
+ 96000000,
+ 97600000,
+ 100600000,
+ 101300000,
+ 102600000,
+ 103500000,
+ 104100000,
+ 105500000,
+ 107500000
+};
+
+const int KScanFrequencyCount = sizeof( KScanFrequencies ) / sizeof( KScanFrequencies[0] );
+
/*!
*
*/
@@ -49,6 +66,7 @@
mIsSeeking( false ),
mAntennaAttached( true ),
mFrequency( 0 ),
+ mNextFrequency( 0 ),
mVolume( 5 ),
mMaxVolume( 10000 ),
mFrequencyStepSize( 50000 ),
@@ -156,6 +174,33 @@
void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction )
{
mObserver.seekingStarted( direction );
+
+ // Find the previous and next favorite from current frequency
+ uint previous = 0;
+ uint next = 0;
+ for( int i = 0; i < KScanFrequencyCount; ++i ) {
+ int testFreq = KScanFrequencies[i];
+ if ( testFreq > mFrequency ) {
+ next = testFreq;
+ break;
+ }
+ previous = testFreq;
+ }
+
+
+ if ( direction == Seeking::Up ) {
+ if ( next == 0 ) {
+ next = KScanFrequencies[0];
+ }
+ mNextFrequency = next;
+ } else {
+ if ( previous == 0 ) {
+ previous = KScanFrequencies[KScanFrequencyCount - 1];
+ }
+ mNextFrequency = previous;
+ }
+
+ mTuneTimer->start( 1000 );
}
/*!
@@ -190,11 +235,13 @@
void RadioEngineWrapperPrivate::addSong( const QString& artist, const QString& title )
{
QString radioText = QString( "Now Playing: %1 - %2" ).arg( artist ).arg( title );
+ mArtist = artist;
+ mTitle = title;
const uint frequency = mStationHandler.currentFrequency();
mStationHandler.setCurrentRadioText( frequency, radioText );
- mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Artist, artist );
- mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Title, title );
+
+ QTimer::singleShot( 500, this, SLOT(addSongTags()) );
}
/*!
@@ -226,12 +273,29 @@
*/
void RadioEngineWrapperPrivate::frequencyEvent()
{
+ if ( mNextFrequency ) { // Seeking
+ mFrequency = mNextFrequency;
+ mStationHandler.addScannedFrequency( mFrequency );
+ }
+
mStationHandler.setCurrentStation( mFrequency );
mObserver.tunedToFrequency( mFrequency, mCommandSender );
mStationHandler.startDynamicPsCheck();
}
/*!
+ * Private slot
+ */
+void RadioEngineWrapperPrivate::addSongTags()
+{
+ const uint frequency = mStationHandler.currentFrequency();
+ mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Artist, mArtist );
+ mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Title, mTitle );
+ mArtist = "";
+ mTitle = "";
+}
+
+/*!
*
*/
void RadioEngineWrapperPrivate::frequencyScannerFinished()