ui/viewmanagement/viewmanager/src/glxviewmanager.cpp
changeset 42 5e1df1b52eb3
parent 26 c499df2dbb33
child 36 6481344a6d67
equal deleted inserted replaced
41:ae07d189b490 42:5e1df1b52eb3
    33 #include <hbaction.h>
    33 #include <hbaction.h>
    34 #include <hbtoolbar.h>
    34 #include <hbtoolbar.h>
    35 #include <hbmenu.h>
    35 #include <hbmenu.h>
    36 #include <QDebug>
    36 #include <QDebug>
    37 #include <hbstyleloader.h>
    37 #include <hbstyleloader.h>
       
    38 #include <hbprogressdialog.h>
       
    39 #include <QItemSelectionModel>
       
    40 #include <glxmainwindoweventfilter.h>
    38 
    41 
    39 
    42 
    40 GlxViewManager::GlxViewManager() 
    43 GlxViewManager::GlxViewManager() 
    41     : mBackAction( NULL ), 
    44     : mBackAction( NULL ), 
    42       mMenuManager( NULL ), 
    45       mMenuManager( NULL ), 
    43       mEffectEngine( NULL ), 
    46       mEffectEngine( NULL ), 
    44       mViewToolBar( NULL ), 
    47       mViewToolBar( NULL ), 
    45       mMarkingToolBar( NULL ),      
    48       mMarkingToolBar( NULL ), 
    46       mMenu( NULL ),
    49       mMenu( NULL ),
    47       mSelectionModel ( NULL )
    50       mSelectionModel ( NULL ),
       
    51       mProgressDialog( NULL )
    48 {
    52 {
    49     qDebug("GlxViewManager::GlxViewManager() ");
    53     qDebug("GlxViewManager::GlxViewManager() ");
    50     PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) {
    54     PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) {
    51         //check the case when application launch through some other application (view plugin)
    55         //check the case when application launch through some other application (view plugin)
    52         mMainWindow = GlxExternalUtility::instance()->getMainWindow();
    56         mMainWindow = GlxExternalUtility::instance()->getMainWindow();
    53         if(mMainWindow == NULL)	{
    57         if(mMainWindow == NULL)	{
    54             mMainWindow = new HbMainWindow();
    58             mMainWindow = new HbMainWindow();
    55         }
    59         }
    56 		//Without this Zoom Does not work
    60 		//Without this Zoom Does not work
       
    61 
       
    62 		mWindowEventFilter = new GlxMainWindowEventFilter;
       
    63 		mMainWindow->scene()->installEventFilter(mWindowEventFilter);
       
    64 		mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    57 		mMainWindow->viewport()->grabGesture(Qt::PinchGesture);
    65 		mMainWindow->viewport()->grabGesture(Qt::PinchGesture);
    58     }
    66     }
    59     HbStyleLoader::registerFilePath(":/data/photos.css");
    67     HbStyleLoader::registerFilePath(":/data/photos.css");
    60 }
    68 }
    61 
    69 
    62 void GlxViewManager::setupItems(int subState)
    70 void GlxViewManager::setupItems( )
    63 {
    71 {
    64     mMenuManager = new GlxMenuManager(mMainWindow);
    72     mMenuManager = new GlxMenuManager(mMainWindow);
    65     addBackSoftKeyAction(); 
    73     addBackSoftKeyAction(); 
    66     createToolBar();
    74     createToolBar();
    67     addConnection();
    75     addConnection();
   181     }
   189     }
   182     else {
   190     else {
   183         deActivateView();
   191         deActivateView();
   184         activateView();       
   192         activateView();       
   185     }    
   193     }    
       
   194 }
       
   195 
       
   196 void GlxViewManager::launchProgressDialog( int maxValue )
       
   197 {
       
   198     if ( maxValue <= 0 ) {
       
   199         return;
       
   200     }
       
   201     if ( mProgressDialog == NULL ) {
       
   202         mProgressDialog = new HbProgressDialog( HbProgressDialog::ProgressDialog );
       
   203         mProgressDialog->actions().at(0)->disconnect( SIGNAL( triggered() ) );
       
   204         connect ( mProgressDialog->actions().at(0), SIGNAL( triggered() ), this, SLOT( hideProgressDialog() ) );
       
   205         mProgressDialog->setMinimum( 0 );
       
   206     }
       
   207     mProgressDialog->setMaximum( maxValue );
       
   208     mProgressDialog->setProgressValue( 0 );
       
   209     mProgressDialog->setModal( true );
       
   210     mProgressDialog->actions().at(0)->setText( GLX_BUTTON_HIDE );
       
   211     mProgressDialog->open();
       
   212 }
       
   213 
       
   214 void GlxViewManager::hideProgressDialog( )
       
   215 {
       
   216     mMainWindow->lower();
       
   217 }
       
   218 
       
   219 void GlxViewManager::updateProgressDialog( int currentValue)
       
   220 {
       
   221     static int i = 0;
       
   222     HbIcon icon;
       
   223     User::ResetInactivityTime();  
       
   224 
       
   225     //To:Do temp code remove later
       
   226     if ( mProgressDialog ) {
       
   227         i = ++i % 10;
       
   228         switch ( i ) {
       
   229         case 0 :
       
   230             icon = HbIcon( QString(":/data/Image1.jpg") );
       
   231             break;
       
   232         case 1 :
       
   233             icon = HbIcon( QString(":/data/Image2.jpg") );
       
   234             break;
       
   235         case 2 :
       
   236             icon = HbIcon( QString(":/data/Image3.jpg") );
       
   237             break;
       
   238         case 3 :
       
   239             icon = HbIcon( QString(":/data/Image4.jpg") );
       
   240             break;
       
   241         case 4 :
       
   242             icon = HbIcon( QString(":/data/Image5.jpg") );
       
   243             break;
       
   244         case 5 :
       
   245             icon = HbIcon( QString(":/data/Image6.jpg") );
       
   246             break;
       
   247         case 6 :
       
   248             icon = HbIcon( QString(":/data/Image7.jpg") );
       
   249             break;
       
   250         case 7 :
       
   251             icon = HbIcon( QString(":/data/Image8.jpg") );
       
   252             break;
       
   253         case 8 :
       
   254             icon = HbIcon( QString(":/data/Image9.jpg") );
       
   255             break;
       
   256         case 9 :
       
   257             icon = HbIcon( QString(":/data/Image10.jpg") );
       
   258             break;            
       
   259         }
       
   260         
       
   261         int max = mProgressDialog->maximum() ;
       
   262         if ( currentValue > max ) {
       
   263             mProgressDialog->setMaximum( currentValue );
       
   264             max = currentValue ;
       
   265         }
       
   266         int value = max - currentValue;
       
   267         mProgressDialog->setProgressValue( value );
       
   268         mProgressDialog->setIcon(icon);
       
   269         mProgressDialog->setText( QString( " %1 / %2").arg( value ).arg( max ) );
       
   270     }
   186 }
   271 }
   187 
   272 
   188 //to be called only when the photos plugin was activated by external means
   273 //to be called only when the photos plugin was activated by external means
   189 void GlxViewManager::deactivateCurrentView()
   274 void GlxViewManager::deactivateCurrentView()
   190 {
   275 {
   224 {
   309 {
   225     qDebug("GlxViewManager::checkMarked");
   310     qDebug("GlxViewManager::checkMarked");
   226     QModelIndexList selectedModelIndex = mSelectionModel->selectedIndexes();
   311     QModelIndexList selectedModelIndex = mSelectionModel->selectedIndexes();
   227     for ( int i = 0 ; i <  mMarkingActionList.count(); i++) {
   312     for ( int i = 0 ; i <  mMarkingActionList.count(); i++) {
   228         if( mMarkingActionList.at(i)->data()==EGlxCmdSelect) {
   313         if( mMarkingActionList.at(i)->data()==EGlxCmdSelect) {
   229        		bool noSelection=selectedModelIndex.empty();
   314        	    bool noSelection=selectedModelIndex.empty();
   230           mMarkingActionList.at(i)->setDisabled(noSelection);
   315             mMarkingActionList.at(i)->setDisabled(noSelection);
   231           mMenuManager->disableAction(mView->menu(),noSelection);
   316             mMenuManager->disableAction(mView->menu(),noSelection);
   232         	break;
   317             break;
   233         }
   318         }
   234     }
   319     }
   235 }
   320 }
       
   321 
   236 void GlxViewManager::enterMarkingMode(qint32 viewId)
   322 void GlxViewManager::enterMarkingMode(qint32 viewId)
   237 {
   323 {
   238     GlxView *view = findView ( viewId );
   324     GlxView *view = findView ( viewId );
   239     qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId);
   325     qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId);
   240     
   326     
   298     GlxView *view = findView ( viewId );
   384     GlxView *view = findView ( viewId );
   299     if ( view ) { 
   385     if ( view ) { 
   300         return view->getSelectionModel();
   386         return view->getSelectionModel();
   301     }
   387     }
   302     return NULL;
   388     return NULL;
       
   389 }
       
   390 
       
   391 void GlxViewManager::setModel( QAbstractItemModel *model )
       
   392 {
       
   393     if ( mView ) {
       
   394         mView->setModel( model ) ;
       
   395     }
       
   396     
       
   397     if ( mMenuManager ) {
       
   398         mMenuManager->setModel( model );
       
   399     }    
   303 }
   400 }
   304 
   401 
   305 GlxView * GlxViewManager::resolveView(qint32 id)
   402 GlxView * GlxViewManager::resolveView(qint32 id)
   306 {
   403 {
   307     qDebug("GlxViewManager::resolveView %d", id);
   404     qDebug("GlxViewManager::resolveView %d", id);
   543         
   640         
   544     delete mBackAction;
   641     delete mBackAction;
   545     delete mViewToolBar;
   642     delete mViewToolBar;
   546     delete mMarkingToolBar;
   643     delete mMarkingToolBar;
   547     delete mMenu;
   644     delete mMenu;
   548              
   645     delete mProgressDialog;
   549     if ( mEffectEngine ) {
   646     if ( mEffectEngine ) {
   550         mEffectEngine->deregistertransitionEffect();
   647         mEffectEngine->deregistertransitionEffect();
   551         delete mEffectEngine;
   648         delete mEffectEngine;
   552     }
   649     }
   553  
   650  
   554     if( mMainWindow != GlxExternalUtility::instance()->getMainWindow() ){
   651     if( mMainWindow != GlxExternalUtility::instance()->getMainWindow() ){
   555         qDebug("GlxViewManager::~GlxViewManager remove view");
   652         qDebug("GlxViewManager::~GlxViewManager remove view");
   556         delete mMainWindow;
   653         delete mMainWindow;
   557     }
   654     }
       
   655     delete mWindowEventFilter;
   558     
   656     
   559     qDebug("GlxViewManager::~GlxViewManager Exit");
   657     qDebug("GlxViewManager::~GlxViewManager Exit");
   560 }
   658 }
   561 
   659