ui/viewmanagement/viewmanager/src/glxviewmanager.cpp
changeset 45 863223ea6961
parent 44 aa2fa096cbfb
child 50 a0f57508af73
child 55 fb37077c270f
--- a/ui/viewmanagement/viewmanager/src/glxviewmanager.cpp	Fri Jun 11 17:53:15 2010 +0530
+++ b/ui/viewmanagement/viewmanager/src/glxviewmanager.cpp	Fri Jun 25 15:41:33 2010 +0530
@@ -38,6 +38,8 @@
 #include <hbprogressdialog.h>
 #include <QItemSelectionModel>
 #include <glxmainwindoweventfilter.h>
+#include <xqsettingsmanager.h>
+#include <xqsettingskey.h>
 
 
 GlxViewManager::GlxViewManager() 
@@ -46,7 +48,6 @@
       mEffectEngine( NULL ), 
       mViewToolBar( NULL ), 
       mMarkingToolBar( NULL ), 
-      mMenu( NULL ),
       mSelectionModel ( NULL ),
       mProgressDialog( NULL )
 {
@@ -56,6 +57,7 @@
         mMainWindow = GlxExternalUtility::instance()->getMainWindow();
         if(mMainWindow == NULL)	{
             mMainWindow = new HbMainWindow();
+            connect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() ));
         }
 		//Without this Zoom Does not work
 
@@ -66,6 +68,12 @@
     }
     HbStyleLoader::registerFilePath(":/data/photos.css");
 }
+void GlxViewManager::handleReadyView()
+{
+    emit actionTriggered( EGlxCmdSetupItem );
+    emit applicationReady();
+    disconnect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() ));
+}
 
 void GlxViewManager::setupItems( )
 {
@@ -123,7 +131,8 @@
     //create the back soft key action and set the data
     mBackAction = new HbAction(Hb::BackNaviAction, this);
     mBackAction->setData(EGlxCmdBack);
-    mView->setNavigationAction(mBackAction);
+    mBackAction->setObjectName( "App Back" );
+    mView->setNavigationAction( mBackAction );
 }
 
 Qt::Orientation GlxViewManager::orientation() const
@@ -206,7 +215,10 @@
 void GlxViewManager::launchProgressDialog( int maxValue )
 {
     if ( maxValue <= 0 ) {
-        return;
+        // TNM return the some error code ( negative value ) until it populated the count
+		// To show progress dialog 10 is chossen
+	     maxValue = 10;
+		          
     }
     if ( mProgressDialog == NULL ) {
         mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog );
@@ -226,7 +238,7 @@
     mMainWindow->lower();
 }
 
-void GlxViewManager::updateProgressDialog( int currentValue)
+void GlxViewManager::updateProgressDialog( int currentValue )
 {
     static int i = 0;
     HbIcon icon;
@@ -273,10 +285,18 @@
             mProgressDialog->setMaximum( currentValue );
             max = currentValue ;
         }
-        int value = max - currentValue;
-        mProgressDialog->setProgressValue( value );
+        
         mProgressDialog->setIcon(icon);
-        mProgressDialog->setText( QString( " %1 / %2").arg( value ).arg( max ) );
+        
+        if ( currentValue < 0 ) {
+            mProgressDialog->setText( QString( "Refreshing" ) ); //To:Do string will change later
+            mProgressDialog->setProgressValue( 0 );
+        }
+        else {
+            int value = max - currentValue;
+            mProgressDialog->setProgressValue( value );
+            mProgressDialog->setText( QString( " %1 " ).arg( currentValue ) );
+        }
     }
 }
 
@@ -334,21 +354,12 @@
     GlxView *view = findView ( viewId );
     qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId);
     
-    //In the case of first time create the marking mode menu( Mark All, Un Mark All )
-    if( mMenu == NULL ) {
-        mMenu = new HbMenu();
-        mMenuManager->createMarkingModeMenu(mMenu);
-    }
-    
     if ( mMarkingToolBar == NULL) {
         createMarkingModeToolBar(); //Marking mode tool bar is different from normal mode tool bar
     }
     
     if ( view ) { 
         view->enableMarking();
-        HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu
-        view->setMenu(mMenu); //Set the marking mode menu
-        mMenu = menu;
         view->takeToolBar();
         view->addToolBar(mMarkingToolBar);
         mSelectionModel = view->getSelectionModel();
@@ -367,9 +378,6 @@
     qDebug("GlxViewManager::exitMarkingMode view ID %d", viewId);
     if ( view ) { 
         view->disableMarking(); 
-        HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu
-        view->setMenu(mMenu); //Set the view menu option
-        mMenu = menu;
         view->takeToolBar();
         view->addToolBar(mViewToolBar);
         if(mSelectionModel)
@@ -426,7 +434,9 @@
         if ( mMenuManager ) {
             mMenuManager->addMenu( id, view->menu());
         }
-        view->setNavigationAction(mBackAction);
+        if ( mBackAction ) {
+            view->setNavigationAction( mBackAction );
+        }
     }
     return view;
 }
@@ -501,30 +511,63 @@
     mActionList.clear();  
     
     //create the All tool bar button action
-    HbAction* allAction = new HbAction(this);
-    allAction->setData(EGlxCmdAllGridOpen);
-    mActionList.append(allAction);    
-    allAction->setIcon(HbIcon(GLXICON_ALL)) ;
+    HbAction* allAction = new HbAction( this );
+    allAction->setData( EGlxCmdAllGridOpen );
+    mActionList.append( allAction );    
+    allAction->setIcon( HbIcon( GLXICON_ALL ) ) ;
+    allAction->setObjectName( "All Action" );
        
     //create the Album tool bar button action
-    HbAction* albumAction = new HbAction(this);
-    albumAction->setData(EGlxCmdAlbumListOpen);
-    mActionList.append(albumAction);
-    albumAction->setIcon(HbIcon(GLXICON_ALBUMS)) ;
+    HbAction* albumAction = new HbAction( this );
+    albumAction->setData( EGlxCmdAlbumListOpen );
+    mActionList.append( albumAction );
+    albumAction->setIcon( HbIcon( GLXICON_ALBUMS ) ) ;
+    albumAction->setObjectName( "Album Action" );
    
     //create the album tool bar button action
-    HbAction* cameraAction = new HbAction(this);
-    cameraAction->setData(EGlxCmdCameraOpen);
-    mActionList.append(cameraAction);  
-    cameraAction->setIcon(HbIcon(GLXICON_CAMERA)) ;
+    HbAction* cameraAction = new HbAction( this );
+    cameraAction->setData( EGlxCmdCameraOpen );
+    mActionList.append( cameraAction );  
+    cameraAction->setIcon( HbIcon( GLXICON_CAMERA ) ) ;
+    cameraAction->setObjectName( "Camera Action" );
+    
+    //Configure the 4 th Action in the tool bar
+    XQSettingsManager *ciSettingsManager = NULL;
+    ciSettingsManager = new XQSettingsManager(this);
+    
+    
+    XQSettingsKey* operatorLinkCenrepKey = NULL;
+    operatorLinkCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, 
+                                            KGlxCi_UidGallery, KGlxOperatorLink);
+    QVariant value = ciSettingsManager->readItemValue(*operatorLinkCenrepKey);
     
     
-    //create the ovi tool bar button action
-    HbAction* oviAction = new HbAction(this);
-    oviAction->setData(EGlxCmdOviOpen);
-    mActionList.append(oviAction);
-    oviAction->setIcon(HbIcon(GLXICON_OVI)) ;
+    switch(value.toInt()) {
+        case KGlxOvi:
+            {
+                XQSettingsKey* oviCenrepKey = NULL;
+                oviCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, 
+                                                        KGlxCi_UidGallery, KGlxOvi);
+                QVariant Ovivalue = ciSettingsManager->readItemValue(*oviCenrepKey, XQSettingsManager::TypeString);
+                HbAction* configurableAction = new HbAction(this);
+                configurableAction->setData(EGlxCmdOviOpen);
+                mActionList.append(configurableAction);
+            
+                if ( Ovivalue.isValid() && Ovivalue.canConvert<QString>() ) {
+                    configurableAction->setIcon( HbIcon( Ovivalue.toString() ) );
+                }
 
+                delete oviCenrepKey;
+            }
+            break;
+            
+        default:
+            qDebug("GlxViewManager::Configurable Action is empty " );
+            break;
+    }
+    
+    delete operatorLinkCenrepKey;
+    delete ciSettingsManager;
 }
 
 void GlxViewManager::createMarkingModeActions()
@@ -534,6 +577,7 @@
     //create the ok tool bar button action
     HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this);
     selectAction->setData(EGlxCmdSelect);
+    selectAction->setObjectName( "Select Action" );
     mMarkingActionList.append(selectAction);
     connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection );
     mMarkingToolBar->addAction( selectAction );
@@ -541,6 +585,7 @@
     //create the cancel tool bar button action
     HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this);
     cancelAction->setData(EGlxCmdCancel);
+    cancelAction->setObjectName( "Cancel Action" );
     mMarkingActionList.append(cancelAction); 
     connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); 
     mMarkingToolBar->addAction( cancelAction );
@@ -639,20 +684,21 @@
     HbStyleLoader::unregisterFilePath(":/data/photos.css");
 	
     removeConnection();
+	
     delete mMenuManager;
-    qDebug("GlxViewManager::~GlxViewManager deleted menu manager");
+    qDebug("GlxViewManager::~GlxViewManager deleted menu manager");    
+    delete mViewToolBar;
+    delete mMarkingToolBar;
+    qDebug("GlxViewManager::~GlxViewManager deleted toolbar");
     
     while( mViewList.isEmpty( ) == FALSE){
         delete mViewList.takeLast() ;
     }
-    qDebug("GlxViewManager::~GlxViewManager view deleted");
-    
+    qDebug("GlxViewManager::~GlxViewManager view deleted");    
         
     delete mBackAction;
-    delete mViewToolBar;
-    delete mMarkingToolBar;
-    delete mMenu;
     delete mProgressDialog;
+    
     if ( mEffectEngine ) {
         mEffectEngine->deregistertransitionEffect();
         delete mEffectEngine;