ui/viewmanagement/viewmanager/src/glxviewmanager.cpp
changeset 49 f291796e213d
parent 48 d0b4e67b3a60
child 50 a0f57508af73
child 55 fb37077c270f
equal deleted inserted replaced
48:d0b4e67b3a60 49:f291796e213d
    36 #include <QDebug>
    36 #include <QDebug>
    37 #include <hbstyleloader.h>
    37 #include <hbstyleloader.h>
    38 #include <hbprogressdialog.h>
    38 #include <hbprogressdialog.h>
    39 #include <QItemSelectionModel>
    39 #include <QItemSelectionModel>
    40 #include <glxmainwindoweventfilter.h>
    40 #include <glxmainwindoweventfilter.h>
       
    41 #include <xqsettingsmanager.h>
       
    42 #include <xqsettingskey.h>
    41 
    43 
    42 
    44 
    43 GlxViewManager::GlxViewManager() 
    45 GlxViewManager::GlxViewManager() 
    44     : mBackAction( NULL ), 
    46     : mBackAction( NULL ), 
    45       mMenuManager( NULL ), 
    47       mMenuManager( NULL ), 
    46       mEffectEngine( NULL ), 
    48       mEffectEngine( NULL ), 
    47       mViewToolBar( NULL ), 
    49       mViewToolBar( NULL ), 
    48       mMarkingToolBar( NULL ), 
    50       mMarkingToolBar( NULL ), 
    49       mMenu( NULL ),
       
    50       mSelectionModel ( NULL ),
    51       mSelectionModel ( NULL ),
    51       mProgressDialog( NULL )
    52       mProgressDialog( NULL )
    52 {
    53 {
    53     qDebug("GlxViewManager::GlxViewManager() ");
    54     qDebug("GlxViewManager::GlxViewManager() ");
    54     PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) {
    55     PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) {
    55         //check the case when application launch through some other application (view plugin)
    56         //check the case when application launch through some other application (view plugin)
    56         mMainWindow = GlxExternalUtility::instance()->getMainWindow();
    57         mMainWindow = GlxExternalUtility::instance()->getMainWindow();
    57         if(mMainWindow == NULL)	{
    58         if(mMainWindow == NULL)	{
    58             mMainWindow = new HbMainWindow();
    59             mMainWindow = new HbMainWindow();
       
    60             connect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() ));
    59         }
    61         }
    60 		//Without this Zoom Does not work
    62 		//Without this Zoom Does not work
    61 
    63 
    62 		mWindowEventFilter = new GlxMainWindowEventFilter;
    64 		mWindowEventFilter = new GlxMainWindowEventFilter;
    63 		mMainWindow->scene()->installEventFilter(mWindowEventFilter);
    65 		mMainWindow->scene()->installEventFilter(mWindowEventFilter);
    64 		mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    66 		mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    65 		mMainWindow->viewport()->grabGesture(Qt::PinchGesture);
    67 		mMainWindow->viewport()->grabGesture(Qt::PinchGesture);
    66     }
    68     }
    67     HbStyleLoader::registerFilePath(":/data/photos.css");
    69     HbStyleLoader::registerFilePath(":/data/photos.css");
       
    70 }
       
    71 void GlxViewManager::handleReadyView()
       
    72 {
       
    73     emit actionTriggered( EGlxCmdSetupItem );
       
    74     emit applicationReady();
       
    75     disconnect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() ));
    68 }
    76 }
    69 
    77 
    70 void GlxViewManager::setupItems( )
    78 void GlxViewManager::setupItems( )
    71 {
    79 {
    72     mMenuManager = new GlxMenuManager(mMainWindow);
    80     mMenuManager = new GlxMenuManager(mMainWindow);
   121 {
   129 {
   122     qDebug("GlxViewManager::addBackSoftKeyAction ");
   130     qDebug("GlxViewManager::addBackSoftKeyAction ");
   123     //create the back soft key action and set the data
   131     //create the back soft key action and set the data
   124     mBackAction = new HbAction(Hb::BackNaviAction, this);
   132     mBackAction = new HbAction(Hb::BackNaviAction, this);
   125     mBackAction->setData(EGlxCmdBack);
   133     mBackAction->setData(EGlxCmdBack);
   126     mView->setNavigationAction(mBackAction);
   134     mBackAction->setObjectName( "App Back" );
       
   135     mView->setNavigationAction( mBackAction );
   127 }
   136 }
   128 
   137 
   129 Qt::Orientation GlxViewManager::orientation() const
   138 Qt::Orientation GlxViewManager::orientation() const
   130 {
   139 {
   131     return mMainWindow->orientation();
   140     return mMainWindow->orientation();
   204 }
   213 }
   205 
   214 
   206 void GlxViewManager::launchProgressDialog( int maxValue )
   215 void GlxViewManager::launchProgressDialog( int maxValue )
   207 {
   216 {
   208     if ( maxValue <= 0 ) {
   217     if ( maxValue <= 0 ) {
   209         return;
   218         // TNM return the some error code ( negative value ) until it populated the count
       
   219 		// To show progress dialog 10 is chossen
       
   220 	     maxValue = 10;
       
   221 		          
   210     }
   222     }
   211     if ( mProgressDialog == NULL ) {
   223     if ( mProgressDialog == NULL ) {
   212         mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog );
   224         mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog );
   213         mProgressDialog->actions().at(0)->disconnect( SIGNAL( triggered() ) );
   225         mProgressDialog->actions().at(0)->disconnect( SIGNAL( triggered() ) );
   214         connect ( mProgressDialog->actions().at(0), SIGNAL( triggered() ), this, SLOT( hideProgressDialog() ) );
   226         connect ( mProgressDialog->actions().at(0), SIGNAL( triggered() ), this, SLOT( hideProgressDialog() ) );
   224 void GlxViewManager::hideProgressDialog( )
   236 void GlxViewManager::hideProgressDialog( )
   225 {
   237 {
   226     mMainWindow->lower();
   238     mMainWindow->lower();
   227 }
   239 }
   228 
   240 
   229 void GlxViewManager::updateProgressDialog( int currentValue)
   241 void GlxViewManager::updateProgressDialog( int currentValue )
   230 {
   242 {
   231     static int i = 0;
   243     static int i = 0;
   232     HbIcon icon;
   244     HbIcon icon;
   233     User::ResetInactivityTime();  
   245     User::ResetInactivityTime();  
   234 
   246 
   271         int max = mProgressDialog->maximum() ;
   283         int max = mProgressDialog->maximum() ;
   272         if ( currentValue > max ) {
   284         if ( currentValue > max ) {
   273             mProgressDialog->setMaximum( currentValue );
   285             mProgressDialog->setMaximum( currentValue );
   274             max = currentValue ;
   286             max = currentValue ;
   275         }
   287         }
   276         int value = max - currentValue;
   288         
   277         mProgressDialog->setProgressValue( value );
       
   278         mProgressDialog->setIcon(icon);
   289         mProgressDialog->setIcon(icon);
   279         mProgressDialog->setText( QString( " %1 / %2").arg( value ).arg( max ) );
   290         
       
   291         if ( currentValue < 0 ) {
       
   292             mProgressDialog->setText( QString( "Refreshing" ) ); //To:Do string will change later
       
   293             mProgressDialog->setProgressValue( 0 );
       
   294         }
       
   295         else {
       
   296             int value = max - currentValue;
       
   297             mProgressDialog->setProgressValue( value );
       
   298             mProgressDialog->setText( QString( " %1 " ).arg( currentValue ) );
       
   299         }
   280     }
   300     }
   281 }
   301 }
   282 
   302 
   283 //to be called only when the photos plugin was activated by external means
   303 //to be called only when the photos plugin was activated by external means
   284 void GlxViewManager::deactivateCurrentView()
   304 void GlxViewManager::deactivateCurrentView()
   332 void GlxViewManager::enterMarkingMode(qint32 viewId)
   352 void GlxViewManager::enterMarkingMode(qint32 viewId)
   333 {
   353 {
   334     GlxView *view = findView ( viewId );
   354     GlxView *view = findView ( viewId );
   335     qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId);
   355     qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId);
   336     
   356     
   337     //In the case of first time create the marking mode menu( Mark All, Un Mark All )
       
   338     if( mMenu == NULL ) {
       
   339         mMenu = new HbMenu();
       
   340         mMenuManager->createMarkingModeMenu(mMenu);
       
   341     }
       
   342     
       
   343     if ( mMarkingToolBar == NULL) {
   357     if ( mMarkingToolBar == NULL) {
   344         createMarkingModeToolBar(); //Marking mode tool bar is different from normal mode tool bar
   358         createMarkingModeToolBar(); //Marking mode tool bar is different from normal mode tool bar
   345     }
   359     }
   346     
   360     
   347     if ( view ) { 
   361     if ( view ) { 
   348         view->enableMarking();
   362         view->enableMarking();
   349         HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu
       
   350         view->setMenu(mMenu); //Set the marking mode menu
       
   351         mMenu = menu;
       
   352         view->takeToolBar();
   363         view->takeToolBar();
   353         view->addToolBar(mMarkingToolBar);
   364         view->addToolBar(mMarkingToolBar);
   354         mSelectionModel = view->getSelectionModel();
   365         mSelectionModel = view->getSelectionModel();
   355         if(mSelectionModel) 
   366         if(mSelectionModel) 
   356         {
   367         {
   365 {
   376 {
   366     GlxView *view = findView ( viewId );
   377     GlxView *view = findView ( viewId );
   367     qDebug("GlxViewManager::exitMarkingMode view ID %d", viewId);
   378     qDebug("GlxViewManager::exitMarkingMode view ID %d", viewId);
   368     if ( view ) { 
   379     if ( view ) { 
   369         view->disableMarking(); 
   380         view->disableMarking(); 
   370         HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu
       
   371         view->setMenu(mMenu); //Set the view menu option
       
   372         mMenu = menu;
       
   373         view->takeToolBar();
   381         view->takeToolBar();
   374         view->addToolBar(mViewToolBar);
   382         view->addToolBar(mViewToolBar);
   375         if(mSelectionModel)
   383         if(mSelectionModel)
   376         {
   384         {
   377             disconnect(mSelectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT(checkMarked()));
   385             disconnect(mSelectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT(checkMarked()));
   424         mViewList.append(view);
   432         mViewList.append(view);
   425         mMainWindow->addView(view);
   433         mMainWindow->addView(view);
   426         if ( mMenuManager ) {
   434         if ( mMenuManager ) {
   427             mMenuManager->addMenu( id, view->menu());
   435             mMenuManager->addMenu( id, view->menu());
   428         }
   436         }
   429         view->setNavigationAction(mBackAction);
   437         if ( mBackAction ) {
       
   438             view->setNavigationAction( mBackAction );
       
   439         }
   430     }
   440     }
   431     return view;
   441     return view;
   432 }
   442 }
   433 
   443 
   434 void GlxViewManager::itemSpecificMenuTriggered(qint32 viewId,QPointF pos)
   444 void GlxViewManager::itemSpecificMenuTriggered(qint32 viewId,QPointF pos)
   499 {
   509 {
   500     qDebug("GlxViewManager::createActions() " );
   510     qDebug("GlxViewManager::createActions() " );
   501     mActionList.clear();  
   511     mActionList.clear();  
   502     
   512     
   503     //create the All tool bar button action
   513     //create the All tool bar button action
   504     HbAction* allAction = new HbAction(this);
   514     HbAction* allAction = new HbAction( this );
   505     allAction->setData(EGlxCmdAllGridOpen);
   515     allAction->setData( EGlxCmdAllGridOpen );
   506     mActionList.append(allAction);    
   516     mActionList.append( allAction );    
   507     allAction->setIcon(HbIcon(GLXICON_ALL)) ;
   517     allAction->setIcon( HbIcon( GLXICON_ALL ) ) ;
       
   518     allAction->setObjectName( "All Action" );
   508        
   519        
   509     //create the Album tool bar button action
   520     //create the Album tool bar button action
   510     HbAction* albumAction = new HbAction(this);
   521     HbAction* albumAction = new HbAction( this );
   511     albumAction->setData(EGlxCmdAlbumListOpen);
   522     albumAction->setData( EGlxCmdAlbumListOpen );
   512     mActionList.append(albumAction);
   523     mActionList.append( albumAction );
   513     albumAction->setIcon(HbIcon(GLXICON_ALBUMS)) ;
   524     albumAction->setIcon( HbIcon( GLXICON_ALBUMS ) ) ;
       
   525     albumAction->setObjectName( "Album Action" );
   514    
   526    
   515     //create the album tool bar button action
   527     //create the album tool bar button action
   516     HbAction* cameraAction = new HbAction(this);
   528     HbAction* cameraAction = new HbAction( this );
   517     cameraAction->setData(EGlxCmdCameraOpen);
   529     cameraAction->setData( EGlxCmdCameraOpen );
   518     mActionList.append(cameraAction);  
   530     mActionList.append( cameraAction );  
   519     cameraAction->setIcon(HbIcon(GLXICON_CAMERA)) ;
   531     cameraAction->setIcon( HbIcon( GLXICON_CAMERA ) ) ;
   520     
   532     cameraAction->setObjectName( "Camera Action" );
   521     
   533     
   522     //create the ovi tool bar button action
   534     //Configure the 4 th Action in the tool bar
   523     HbAction* oviAction = new HbAction(this);
   535     XQSettingsManager *ciSettingsManager = NULL;
   524     oviAction->setData(EGlxCmdOviOpen);
   536     ciSettingsManager = new XQSettingsManager(this);
   525     mActionList.append(oviAction);
   537     
   526     oviAction->setIcon(HbIcon(GLXICON_OVI)) ;
   538     
   527 
   539     XQSettingsKey* operatorLinkCenrepKey = NULL;
       
   540     operatorLinkCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, 
       
   541                                             KGlxCi_UidGallery, KGlxOperatorLink);
       
   542     QVariant value = ciSettingsManager->readItemValue(*operatorLinkCenrepKey);
       
   543     
       
   544     
       
   545     switch(value.toInt()) {
       
   546         case KGlxOvi:
       
   547             {
       
   548                 XQSettingsKey* oviCenrepKey = NULL;
       
   549                 oviCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, 
       
   550                                                         KGlxCi_UidGallery, KGlxOvi);
       
   551                 QVariant Ovivalue = ciSettingsManager->readItemValue(*oviCenrepKey, XQSettingsManager::TypeString);
       
   552                 HbAction* configurableAction = new HbAction(this);
       
   553                 configurableAction->setData(EGlxCmdOviOpen);
       
   554                 mActionList.append(configurableAction);
       
   555             
       
   556                 if ( Ovivalue.isValid() && Ovivalue.canConvert<QString>() ) {
       
   557                     configurableAction->setIcon( HbIcon( Ovivalue.toString() ) );
       
   558                 }
       
   559 
       
   560                 delete oviCenrepKey;
       
   561             }
       
   562             break;
       
   563             
       
   564         default:
       
   565             qDebug("GlxViewManager::Configurable Action is empty " );
       
   566             break;
       
   567     }
       
   568     
       
   569     delete operatorLinkCenrepKey;
       
   570     delete ciSettingsManager;
   528 }
   571 }
   529 
   572 
   530 void GlxViewManager::createMarkingModeActions()
   573 void GlxViewManager::createMarkingModeActions()
   531 {
   574 {
   532     mMarkingActionList.clear();
   575     mMarkingActionList.clear();
   533     
   576     
   534     //create the ok tool bar button action
   577     //create the ok tool bar button action
   535     HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this);
   578     HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this);
   536     selectAction->setData(EGlxCmdSelect);
   579     selectAction->setData(EGlxCmdSelect);
       
   580     selectAction->setObjectName( "Select Action" );
   537     mMarkingActionList.append(selectAction);
   581     mMarkingActionList.append(selectAction);
   538     connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection );
   582     connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection );
   539     mMarkingToolBar->addAction( selectAction );
   583     mMarkingToolBar->addAction( selectAction );
   540     
   584     
   541     //create the cancel tool bar button action
   585     //create the cancel tool bar button action
   542     HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this);
   586     HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this);
   543     cancelAction->setData(EGlxCmdCancel);
   587     cancelAction->setData(EGlxCmdCancel);
       
   588     cancelAction->setObjectName( "Cancel Action" );
   544     mMarkingActionList.append(cancelAction); 
   589     mMarkingActionList.append(cancelAction); 
   545     connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); 
   590     connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); 
   546     mMarkingToolBar->addAction( cancelAction );
   591     mMarkingToolBar->addAction( cancelAction );
   547 }
   592 }
   548 
   593 
   637 {
   682 {
   638     qDebug("GlxViewManager::~GlxViewManager");
   683     qDebug("GlxViewManager::~GlxViewManager");
   639     HbStyleLoader::unregisterFilePath(":/data/photos.css");
   684     HbStyleLoader::unregisterFilePath(":/data/photos.css");
   640 	
   685 	
   641     removeConnection();
   686     removeConnection();
       
   687 	
   642     delete mMenuManager;
   688     delete mMenuManager;
   643     qDebug("GlxViewManager::~GlxViewManager deleted menu manager");
   689     qDebug("GlxViewManager::~GlxViewManager deleted menu manager");    
       
   690     delete mViewToolBar;
       
   691     delete mMarkingToolBar;
       
   692     qDebug("GlxViewManager::~GlxViewManager deleted toolbar");
   644     
   693     
   645     while( mViewList.isEmpty( ) == FALSE){
   694     while( mViewList.isEmpty( ) == FALSE){
   646         delete mViewList.takeLast() ;
   695         delete mViewList.takeLast() ;
   647     }
   696     }
   648     qDebug("GlxViewManager::~GlxViewManager view deleted");
   697     qDebug("GlxViewManager::~GlxViewManager view deleted");    
   649     
       
   650         
   698         
   651     delete mBackAction;
   699     delete mBackAction;
   652     delete mViewToolBar;
       
   653     delete mMarkingToolBar;
       
   654     delete mMenu;
       
   655     delete mProgressDialog;
   700     delete mProgressDialog;
       
   701     
   656     if ( mEffectEngine ) {
   702     if ( mEffectEngine ) {
   657         mEffectEngine->deregistertransitionEffect();
   703         mEffectEngine->deregistertransitionEffect();
   658         delete mEffectEngine;
   704         delete mEffectEngine;
   659     }
   705     }
   660  
   706