radioapp/radiowidgets/src/radioviewbase.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 19 afea38384506
parent 33 11b6825f0862
--- a/radioapp/radiowidgets/src/radioviewbase.cpp	Fri Jun 11 16:24:13 2010 +0100
+++ b/radioapp/radiowidgets/src/radioviewbase.cpp	Thu Jul 22 16:33:45 2010 +0100
@@ -35,7 +35,6 @@
     HbView( 0 ),
     mMainWindow( 0 ),
     mUiLoader( 0 ),
-    mInitialized( false ),
     mTransientView( transient ),
     mUseLoudspeakerAction( 0 ),
     mOrientation( Qt::Vertical )
@@ -55,10 +54,27 @@
 /*!
  *
  */
-void RadioViewBase::setMembers( RadioUiLoader* uiLoader, RadioWindow* mainWindow )
+void RadioViewBase::setMembers( RadioWindow* mainWindow, RadioUiLoader* uiLoader )
+{
+    mMainWindow = mainWindow;
+    mUiLoader.reset( uiLoader );
+}
+
+/*!
+ *
+ */
+void RadioViewBase::preLazyLoadInit()
 {
-    mUiLoader.reset( uiLoader );
-    mMainWindow = mainWindow;
+    // Default implementation does nothing
+}
+
+/*!
+ *
+ */
+void RadioViewBase::initialize( QSharedPointer<RadioUiEngine> uiEngine )
+{
+    mUiEngine = uiEngine;
+    init();
 }
 
 /*!
@@ -66,7 +82,7 @@
  */
 bool RadioViewBase::isInitialized() const
 {
-    return mInitialized;
+    return mUiEngine;
 }
 
 /*!
@@ -89,6 +105,14 @@
 }
 
 /*!
+ *
+ */
+void RadioViewBase::bringToForeground()
+{
+    mMainWindow->raise();
+}
+
+/*!
  * Protected slot
  *
  */
@@ -120,7 +144,6 @@
 
 /*!
  * Private slot
- * TODO: Refactor this awkwardness once Orbit figures out a better way
  */
 void RadioViewBase::handleUserAnswer( HbAction* answer )
 {
@@ -137,9 +160,9 @@
 {
     // The default back button activates the tuning view
     HbAction* backAction = new HbAction( Hb::BackNaviAction, this );
-    connectAndTest( backAction,     SIGNAL(triggered()),
+    Radio::connect( backAction,     SIGNAL(triggered()),
                     mMainWindow,    SLOT(activateMainView()) );
-    setNavigationAction( backAction );    
+    setNavigationAction( backAction );
 }
 
 /*!
@@ -147,14 +170,19 @@
  */
 void RadioViewBase::connectCommonMenuItem( int menuItem )
 {
-    RadioUiEngine* engine = &mMainWindow->uiEngine();
     switch ( menuItem ) {
         case MenuItem::UseLoudspeaker:
             mUseLoudspeakerAction = mUiLoader->findObject<HbAction>( DOCML::NAME_LOUDSPEAKER_ACTION );
             if ( mUseLoudspeakerAction ) {
-                connectAndTest( mUseLoudspeakerAction, SIGNAL(triggered()), engine, SLOT(toggleAudioRoute()) );
-                updateAudioRouting( engine->isUsingLoudspeaker() );
-                connectAndTest( engine, SIGNAL(audioRouteChanged(bool)), this, SLOT(updateAudioRouting(bool)) );
+                Radio::connect( mUseLoudspeakerAction, SIGNAL(triggered()), mUiEngine.data(), SLOT(toggleAudioRoute()) );
+                updateAudioRouting( mUiEngine->isUsingLoudspeaker() );
+                Radio::connect( mUiEngine.data(), SIGNAL(audioRouteChanged(bool)), this, SLOT(updateAudioRouting(bool)) );
+            }
+            break;
+
+        case MenuItem::Exit:
+            if ( HbAction* exitAction = mUiLoader->findObject<HbAction>( DOCML::NAME_EXIT_ACTION ) ) {
+                Radio::connect( exitAction, SIGNAL(triggered()), this, SLOT(quit()) );
             }
             break;
 
@@ -166,10 +194,10 @@
 /*!
  *
  */
-void RadioViewBase::connectXmlElement( const char* name, const char* signal, QObject* receiver, const char* slot )
+void RadioViewBase::connectXmlElement( const QString& name, const char* signal, QObject* receiver, const char* slot )
 {
     if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) {
-        connectAndTest( action, signal, receiver, slot );
+        Radio::connect( action, signal, receiver, slot );
     }
 }
 
@@ -179,7 +207,7 @@
 void RadioViewBase::connectViewChangeMenuItem( QString name, const char* slot )
 {
     if ( QObject* action = mUiLoader->findObject<QObject>( name ) ) {
-        connectAndTest( action, SIGNAL(triggered()), mMainWindow, slot );
+        Radio::connect( action, SIGNAL(triggered()), mMainWindow, slot );
     }
 }
 
@@ -189,7 +217,7 @@
 void RadioViewBase::loadSection( const QString& docml, const QString& section )
 {
     LOG_FORMAT( "RadioViewBase::loadSection: Docml: %s, section: %s", GETSTRING( docml ), GETSTRING( section ) );
-    bool ok = false;    
+    bool ok = false;
     mUiLoader->load( docml, section, &ok );
     LOG_ASSERT( ok, LOG_FORMAT( "Loading of section %s failed!", GETSTRING( section ) ) );
 }