--- a/radioapp/radiouiengine/src/radiouiengine_p.cpp Fri Jun 11 16:24:13 2010 +0100
+++ b/radioapp/radiouiengine/src/radiouiengine_p.cpp Thu Jul 22 16:33:45 2010 +0100
@@ -32,18 +32,13 @@
#include "radiostationmodel.h"
#include "radiostationmodel_p.h"
#include "radiohistorymodel.h"
-#include "radiocarouselmodel.h"
#include "radiopresetstorage.h"
#include "radiosettings.h"
#include "radiostation.h"
#include "radioscannerengine.h"
#include "radiostationhandlerif.h"
-#ifndef BUILD_WIN32
-# include "radiocontrolservice.h"
-# include "radiomonitorservice.h"
-#else
-# include "radiomonitorservice_win32.h"
-#endif
+#include "radiocontrolservice.h"
+#include "radiomonitorservice.h"
#include "radioservicedef.h"
#include "radiologger.h"
@@ -51,7 +46,8 @@
*
*/
RadioUiEnginePrivate::RadioUiEnginePrivate( RadioUiEngine* engine ) :
- q_ptr( engine )
+ q_ptr( engine ),
+ mPowerOffTimer( NULL )
{
}
@@ -65,7 +61,7 @@
XQPublishAndSubscribeUtils utils( settingsManager );
XQPublishAndSubscribeSettingsKey radioStartupKey( KRadioPSUid, KRadioStartupKey );
bool deleted = utils.deleteProperty( radioStartupKey );
- LOG_ASSERT( deleted, LOG( "RadioUiEnginePrivate::~RadioUiEnginePrivate(). Failed to delete P&S key" ) );
+ LOG_ASSERT( deleted, LOG( "RadioUiEnginePrivate::~RadioUiEnginePrivate(). Failed to remove P&S key" ) );
#endif
}
@@ -83,13 +79,16 @@
*/
bool RadioUiEnginePrivate::init()
{
-#ifndef BUILD_WIN32
mControlService.reset( new RadioControlService( *q_ptr ) );
-#endif
mMonitorService.reset( new RadioMonitorService( *this ) );
mStationModel.reset( new RadioStationModel( *this ) );
+
mEngineWrapper.reset( new RadioEngineWrapper( mStationModel->stationHandlerIf() ) );
+ if ( !mEngineWrapper->init() ) {
+ return false;
+ }
mEngineWrapper->addObserver( this );
+
mPresetStorage.reset( new RadioPresetStorage() );
mStationModel->initialize( mPresetStorage.data(), mEngineWrapper.data() );
mHistoryModel.reset( new RadioHistoryModel( *q_ptr ) );
@@ -107,7 +106,7 @@
mMonitorService->init();
- return mEngineWrapper->isEngineConstructed();
+ return true;
}
/*!
@@ -142,33 +141,6 @@
{
Q_Q( RadioUiEngine );
q->emitRadioStatusChanged( radioIsOn );
-
- if ( radioIsOn ) {
- Q_Q( RadioUiEngine );
- QStringList args; // = qApp->arguments();
- if ( args.count() == 2 )
- {
- if ( args.at( 0 ) == "-f" ) // Frequency
- {
- uint frequency = args.at( 1 ).toUInt();
-
- if ( frequency >= mEngineWrapper->minFrequency() && frequency <= mEngineWrapper->maxFrequency() )
- {
- LOG_FORMAT( "RadioApplication::handleArguments, Tuning to frequency: %d", frequency );
- q->tuneFrequency( frequency, 0 );
- }
- }
- else if ( args.at( 0 ) == "-i" ) // Preset index
- {
- int preset = args.at( 1 ).toInt();
- if ( preset > 0 && preset < mStationModel->rowCount() )
- {
- LOG_FORMAT( "RadioApplication::handleArguments, Tuning to preset %d", preset );
- q->tunePreset( preset );
- }
- }
- }
- }
}
/*!
@@ -183,6 +155,32 @@
/*!
*
*/
+void RadioUiEnginePrivate::increaseVolume()
+{
+ Q_Q( RadioUiEngine );
+ if( q->isScanning() ){
+ // volume not changed while scanning
+ } else {
+ mEngineWrapper->increaseVolume();
+ }
+}
+
+/*!
+ *
+ */
+void RadioUiEnginePrivate::decreaseVolume()
+{
+ Q_Q( RadioUiEngine );
+ if( q->isScanning() ) {
+ // volume not changed while scanning
+ } else {
+ mEngineWrapper->decreaseVolume();
+ }
+}
+
+/*!
+ *
+ */
void RadioUiEnginePrivate::volumeChanged( int volume )
{
Q_Q( RadioUiEngine );
@@ -221,7 +219,7 @@
*/
void RadioUiEnginePrivate::skipPrevious()
{
- skip( StationSkip::PreviousFavorite );
+ skip( StationSkip::PreviousFavorite, 0, TuneReason::SkipFromEngine );
}
/*!
@@ -229,23 +227,36 @@
*/
void RadioUiEnginePrivate::skipNext()
{
- skip( StationSkip::NextFavorite );
+ skip( StationSkip::NextFavorite, 0, TuneReason::SkipFromEngine );
}
/*!
* Tunes to next or previous station
*/
-uint RadioUiEnginePrivate::skip( StationSkip::Mode mode, uint startFrequency )
+uint RadioUiEnginePrivate::skip( StationSkip::Mode mode, uint startFrequency, const int reason )
{
LOG_FORMAT( "RadioUiEnginePrivate::skip: mode: %d", mode );
if ( startFrequency == 0 ) {
startFrequency = mEngineWrapper->currentFrequency();
}
- const uint newFrequency = mStationModel->findClosest( startFrequency, mode ).frequency();
+ const int favoriteCount = mStationModel->favoriteCount();
+ if ( favoriteCount < 2 ) {
+ if ( mode == StationSkip::NextFavorite ) {
+ mode = StationSkip::Next;
+ } else if ( mode == StationSkip::PreviousFavorite ) {
+ mode = StationSkip::Previous;
+ }
+ }
- LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", startFrequency, newFrequency );
- mEngineWrapper->tuneFrequency( newFrequency, TuneReason::Skip );
- return newFrequency;
+ const RadioStation station = mStationModel->findClosest( startFrequency, mode );
+ if ( station.isValid() ) {
+ const uint newFrequency = station.frequency();
+
+ LOG_FORMAT( "RadioUiEnginePrivate::skip. CurrentFreq: %u, tuning to: %u", startFrequency, newFrequency );
+ mEngineWrapper->setFrequency( newFrequency, reason );
+ return newFrequency;
+ }
+ return startFrequency;
}