ui/views/fullscreenview/src/glxfullscreenview.cpp
changeset 26 c499df2dbb33
parent 24 99ad1390cd33
child 29 2c833fc9e98f
equal deleted inserted replaced
24:99ad1390cd33 26:c499df2dbb33
    37 #include "glxicondefs.h" //Contains the icon names/Ids
    37 #include "glxicondefs.h" //Contains the icon names/Ids
    38 #include "glxmodelparm.h"
    38 #include "glxmodelparm.h"
    39 #include "glxcoverflow.h"
    39 #include "glxcoverflow.h"
    40 #include "glxdocloaderdefs.h" //contains the definations of path, widget names and view names in docml
    40 #include "glxdocloaderdefs.h" //contains the definations of path, widget names and view names in docml
    41 #include "glxloggerenabler.h"
    41 #include "glxloggerenabler.h"
    42 #include "glxhdmicontroller.h"
    42 #include "glxtvoutwrapper.h"
    43 #include "glxfullscreenview.h" 
    43 #include "glxfullscreenview.h" 
    44 #include "glxcommandhandlers.hrh"
    44 #include "glxcommandhandlers.hrh"
    45 //#include "glxzoomwidget.h"
    45 //#include "glxzoomwidget.h"
    46 
    46 
    47 #include "OstTraceDefinitions.h"
    47 #include "OstTraceDefinitions.h"
    57     mModel(NULL), 
    57     mModel(NULL), 
    58     mWindow( window), 
    58     mWindow( window), 
    59     mCoverFlow(NULL) , 
    59     mCoverFlow(NULL) , 
    60     mImageStrip (NULL), 
    60     mImageStrip (NULL), 
    61     mUiOffTimer(NULL),
    61     mUiOffTimer(NULL),
    62     iHdmiController(NULL),
    62     mIconItem(NULL),
       
    63     mTvOutWrapper(NULL),
    63     mFullScreenToolBar(NULL),
    64     mFullScreenToolBar(NULL),
    64 	mFlipAction(NULL),
    65 	mFlipAction(NULL),
    65 	mSendAction(NULL),
    66 	mSendAction(NULL),
    66 	mDeleteAction(NULL)
    67 	mDeleteAction(NULL),
       
    68 	mUseImageAction(NULL)
    67 {
    69 {
    68     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
    70     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
    69     
    71     
    70     mDocLoader = DocLoader;
    72     mDocLoader = DocLoader;
    71     setContentFullScreen( true );
    73     setContentFullScreen( true );
    78 
    80 
    79 void GlxFullScreenView::initializeView(QAbstractItemModel *model)
    81 void GlxFullScreenView::initializeView(QAbstractItemModel *model)
    80 {
    82 {
    81     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_INITIALIZEVIEW_ENTRY );
    83     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_INITIALIZEVIEW_ENTRY );
    82     
    84     
       
    85     // if animations is on, then Set the image to HDMI here
       
    86     if (!mTvOutWrapper){
       
    87         mTvOutWrapper = new GlxTvOutWrapper();
       
    88     }
       
    89     setHdmiModel(model);
    83 
    90 
    84     //Load/Retrieve the Widgets
    91     //Load/Retrieve the Widgets
    85     loadWidgets();
    92     loadWidgets();
    86 
    93 
    87     //Initialize the coverflow and partially creates the coverflow with one image
    94     //Initialize the coverflow and partially creates the coverflow with one image
   140     mFullScreenToolBar->addAction( mSendAction);
   147     mFullScreenToolBar->addAction( mSendAction);
   141 
   148 
   142     //create  Delete tool bar button action
   149     //create  Delete tool bar button action
   143     mDeleteAction = new HbAction(this);
   150     mDeleteAction = new HbAction(this);
   144     mDeleteAction->setData(EGlxCmdDelete);        
   151     mDeleteAction->setData(EGlxCmdDelete);        
   145     mDeleteAction->setIcon(HbIcon(GLXICON_DELETE));   
   152     mDeleteAction->setIcon(HbIcon(GLXICON_DELETE)); 
   146     mFullScreenToolBar->addAction( mDeleteAction); 
   153     
       
   154     //create  Use Image tool bar button action
       
   155     mUseImageAction = new HbAction(this);
       
   156     //mUseImageAction->setData(EGlxCmdDelete);        
       
   157     mUseImageAction->setIcon(HbIcon(GLXICON_USEIMAGE)); 
       
   158     if(getSubState() != IMAGEVIEWER_S){
       
   159         mFullScreenToolBar->addAction( mDeleteAction);
       
   160     }else{
       
   161         mFullScreenToolBar->addAction( mUseImageAction);
       
   162     }
       
   163      
   147 
   164 
   148     connect(mFlipAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) ); 
   165     connect(mFlipAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) ); 
   149     connect(mSendAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) ); 
   166     connect(mSendAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) ); 
   150     connect(mDeleteAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );
   167     connect(mDeleteAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );
       
   168     connect(mUseImageAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );
   151     
   169     
   152     OstTraceFunctionExit0( GLXFULLSCREENVIEW_LOADFULLSCREENTOOLBAR_EXIT );
   170     OstTraceFunctionExit0( GLXFULLSCREENVIEW_LOADFULLSCREENTOOLBAR_EXIT );
   153 }
   171 }
   154 
   172 
   155 void GlxFullScreenView::activate()
   173 void GlxFullScreenView::activate()
   171         
   189         
   172     mUiOffTimer = new QTimer();
   190     mUiOffTimer = new QTimer();
   173     mUiOff = true;
   191     mUiOff = true;
   174     mUiOffTimer->stop();        
   192     mUiOffTimer->stop();        
   175     mCoverFlow->setUiOn(FALSE);    
   193     mCoverFlow->setUiOn(FALSE);    
   176 
       
   177     addConnection(); 
   194     addConnection(); 
   178     setLayout();
   195     setLayout();
   179      
   196      
   180     if (!iHdmiController) {
   197     if (!mTvOutWrapper){
   181         OstTrace0( TRACE_NORMAL, GLXFULLSCREENVIEW_ACTIVATE, "GlxFullScreenView::activate - CGlxHdmi" );
   198         mTvOutWrapper = new GlxTvOutWrapper();
   182         iHdmiController = CGlxHdmiController::NewL();
   199         }
   183     }
       
   184     
       
   185     OstTraceFunctionExit0( GLXFULLSCREENVIEW_ACTIVATE_EXIT );
   200     OstTraceFunctionExit0( GLXFULLSCREENVIEW_ACTIVATE_EXIT );
   186 }
   201 }
   187 
   202 
   188 void GlxFullScreenView::loadViewSection()
   203 void GlxFullScreenView::loadViewSection()
   189 {
   204 {
   204 
   219 
   205 void GlxFullScreenView::resetView()
   220 void GlxFullScreenView::resetView()
   206 {
   221 {
   207     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_RESETVIEW_ENTRY );    
   222     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_RESETVIEW_ENTRY );    
   208 
   223 
       
   224     //Clean up the rest of the resources allocated
       
   225     cleanUp(); 
       
   226         
   209     //Clear the 4 icons present in the Coverflow,so that the transition between the views are smooth
   227     //Clear the 4 icons present in the Coverflow,so that the transition between the views are smooth
   210     mCoverFlow->partiallyClean();
   228     mCoverFlow->partiallyClean();
   211 
       
   212     //Clean up the rest of the resources allocated
       
   213     cleanUp(); 
       
   214     
   229     
   215     OstTraceFunctionExit0( GLXFULLSCREENVIEW_RESETVIEW_EXIT );
   230     OstTraceFunctionExit0( GLXFULLSCREENVIEW_RESETVIEW_EXIT );
   216 }
   231 }
   217 
   232 
   218 void GlxFullScreenView::deActivate()
   233 void GlxFullScreenView::deActivate()
   250        mFullScreenToolBar->clearActions();
   265        mFullScreenToolBar->clearActions();
   251        delete mFullScreenToolBar;
   266        delete mFullScreenToolBar;
   252        mFullScreenToolBar = NULL;
   267        mFullScreenToolBar = NULL;
   253     }
   268     }
   254     
   269     
   255     
   270     if (mTvOutWrapper) {
   256     if (iHdmiController) {
   271         delete mTvOutWrapper;
   257         OstTrace0( TRACE_NORMAL, DUP2_GLXFULLSCREENVIEW_CLEANUP, "GlxFullScreenView::cleanUp() delete iHdmiController" );
   272         mTvOutWrapper = NULL;
   258         delete iHdmiController;
   273     }
   259         iHdmiController = NULL;
       
   260     }
       
   261     
       
   262     OstTraceFunctionExit0( GLXFULLSCREENVIEW_CLEANUP_EXIT );
   274     OstTraceFunctionExit0( GLXFULLSCREENVIEW_CLEANUP_EXIT );
   263 }
   275 }
   264 
   276 
   265 QGraphicsItem * GlxFullScreenView::getAnimationItem(GlxEffect transitionEffect)
   277 QGraphicsItem * GlxFullScreenView::getAnimationItem(GlxEffect transitionEffect)
   266 {
   278 {
   277 {
   289 {
   278     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETMODEL_ENTRY );
   290     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETMODEL_ENTRY );
   279     OstTraceExt2( TRACE_NORMAL, GLXFULLSCREENVIEW_SETMODEL, "GlxFullScreenView::setModel; model=%x; mModel=%u", ( TUint )( model ), ( TUint ) mModel );
   291     OstTraceExt2( TRACE_NORMAL, GLXFULLSCREENVIEW_SETMODEL, "GlxFullScreenView::setModel; model=%x; mModel=%u", ( TUint )( model ), ( TUint ) mModel );
   280     
   292     
   281     mModel = model;     
   293     mModel = model;     
   282 	mCoverFlow->setModel(mModel);
   294     setHdmiModel(mModel);
   283    setImageStripModel();
   295 
   284     SetImageToHdmiL(); // for the first image on screen
   296     mCoverFlow->setModel(mModel);
   285     
   297     setImageStripModel();
       
   298     if(getSubState() == IMAGEVIEWER_S)
       
   299         {
       
   300         setTitle("Image Viewer");
       
   301         }
       
   302 	else if(getSubState() == FETCHER_S){
       
   303 		setItemVisible(Hb::AllItems, TRUE) ;
       
   304 	}
   286     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETMODEL_EXIT );
   305     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETMODEL_EXIT );
   287 }
   306 }
       
   307 
       
   308 void GlxFullScreenView::setHdmiModel(QAbstractItemModel* model)
       
   309     {
       
   310     if (mTvOutWrapper)
       
   311         mTvOutWrapper->setModel(model);
       
   312     
       
   313     // for the first image on screen
       
   314     mTvOutWrapper->setImagetoHDMI();
       
   315     }
   288 
   316 
   289 void GlxFullScreenView::setModelContext()
   317 void GlxFullScreenView::setModelContext()
   290 {
   318 {
   291     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETMODELCONTEXT_ENTRY );
   319     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETMODELCONTEXT_ENTRY );
   292     
   320     
   322 
   350 
   323 void GlxFullScreenView::activateUI()
   351 void GlxFullScreenView::activateUI()
   324 {
   352 {
   325     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ACTIVATEUI_ENTRY );
   353     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ACTIVATEUI_ENTRY );
   326     
   354     
   327     if ( mUiOff ){      
   355     if ( mUiOff && getSubState() != FETCHER_S){      
   328         if(!mFullScreenToolBar) {
   356         if(!mFullScreenToolBar) {
   329             loadFullScreenToolBar();
   357             loadFullScreenToolBar();
   330         }
   358         }
   331         mUiOff = FALSE;
   359         mUiOff = FALSE;
   332         
   360         
   334         if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
   362         if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
   335             mImageStrip->setCurrentIndex ( mModel->index( variant.value<int>(), 0) );    
   363             mImageStrip->setCurrentIndex ( mModel->index( variant.value<int>(), 0) );    
   336             mImageStrip->scrollTo( mModel->index( variant.value<int>(), 0), HbGridView::PositionAtTop ); 
   364             mImageStrip->scrollTo( mModel->index( variant.value<int>(), 0), HbGridView::PositionAtTop ); 
   337         }
   365         }
   338         
   366         
   339         mImageStrip->show(); 
       
   340         mFullScreenToolBar->show();
   367         mFullScreenToolBar->show();
   341         setItemVisible(Hb::AllItems, TRUE) ;
   368         setItemVisible(Hb::AllItems, TRUE) ;
   342         HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapShow"), this, "effectFinished" );
   369 
       
   370         if ( mImageStrip && getSubState() != IMAGEVIEWER_S) {
       
   371             mImageStrip->show(); 
       
   372             HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapShow"), this, "effectFinished" );
       
   373         }
       
   374         else if( getSubState() == IMAGEVIEWER_S){
       
   375             setTitle("Image Viewer");
       
   376         }
   343     }
   377     }
   344     else {
   378     else {
   345         hideUi();
   379         hideUi();
   346     }
   380     }
   347     
   381     
   358         OstTraceFunctionExit0( GLXFULLSCREENVIEW_HIDEUI_EXIT );
   392         OstTraceFunctionExit0( GLXFULLSCREENVIEW_HIDEUI_EXIT );
   359         return ;
   393         return ;
   360     }
   394     }
   361     
   395     
   362     mUiOff = TRUE;
   396     mUiOff = TRUE;
   363     setItemVisible(Hb::AllItems, FALSE) ;
   397 	if ( getSubState() != FETCHER_S ) {
   364     if ( mImageStrip ) {
   398 		setItemVisible(Hb::AllItems, FALSE) ;
       
   399 	}
       
   400     if ( mImageStrip && ( getSubState() != IMAGEVIEWER_S && getSubState() != FETCHER_S )) {
   365         HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapHide"), this, "effectFinished" );
   401         HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapHide"), this, "effectFinished" );
   366     }
   402     }
   367 
   403 
   368     if(mFullScreenToolBar) {
   404     if(mFullScreenToolBar) {
   369        mFullScreenToolBar->hide();
   405        mFullScreenToolBar->hide();
   377     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_ENTRY );
   413     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_ENTRY );
   378     
   414     
   379     QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole );    
   415     QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole );    
   380     if ( variant.isValid() &&  variant.canConvert<int> () && ( index.row() == variant.value<int>() ) ) {
   416     if ( variant.isValid() &&  variant.canConvert<int> () && ( index.row() == variant.value<int>() ) ) {
   381        OstTraceFunctionExit0( GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
   417        OstTraceFunctionExit0( GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
       
   418        if (mTvOutWrapper){
       
   419        // for the image changed on deletion
       
   420        mTvOutWrapper->setImagetoHDMI();
       
   421        }
   382        return;
   422        return;
   383     }         
   423     }         
   384     mModel->setData( index, index.row(), GlxFocusIndexRole );    
   424     mModel->setData( index, index.row(), GlxFocusIndexRole );    
   385 	SetImageToHdmiL(); // for the image changed on swipe
   425     if (mTvOutWrapper){
   386     
   426     // for the image changed on swipe
       
   427     mTvOutWrapper->setImagetoHDMI();
       
   428     }
   387     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
   429     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
   388 }
   430 }
   389 
   431 
   390 void GlxFullScreenView::indexChanged(const QModelIndex &index)
   432 void GlxFullScreenView::indexChanged(const QModelIndex &index)
   391 {
   433 {
   397        return;
   439        return;
   398     }         
   440     }         
   399     mModel->setData( index, index.row(), GlxFocusIndexRole );
   441     mModel->setData( index, index.row(), GlxFocusIndexRole );
   400     mCoverFlow->indexChanged(index.row());
   442     mCoverFlow->indexChanged(index.row());
   401     mImageStrip->scrollTo(index, HbGridView::EnsureVisible );
   443     mImageStrip->scrollTo(index, HbGridView::EnsureVisible );
   402     SetImageToHdmiL();  // for the indexchnaged through filmstrip  
   444     if (mTvOutWrapper){
   403         //disable the animation for the time being
   445     // for the indexchnaged through filmstrip
       
   446     mTvOutWrapper->setImagetoHDMI();
       
   447     }
       
   448     //disable the animation for the time being
   404     //imageSelectionAnimation( index );
   449     //imageSelectionAnimation( index );
   405     
   450     
   406     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_INDEXCHANGED_EXIT );
   451     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_INDEXCHANGED_EXIT );
   407 }
   452 }
   408 
   453 
   501 
   546 
   502 void GlxFullScreenView::effectFinished( const HbEffect::EffectStatus  )
   547 void GlxFullScreenView::effectFinished( const HbEffect::EffectStatus  )
   503 {
   548 {
   504     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_EFFECTFINISHED_ENTRY );
   549     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_EFFECTFINISHED_ENTRY );
   505     
   550     
       
   551     if ( mUiOffTimer == NULL ){ //view is already deactivate so no need to do any thing
       
   552        return ;
       
   553     }
       
   554     
   506     if ( mUiOff ) {
   555     if ( mUiOff ) {
   507         mUiOffTimer->stop();        
   556         mUiOffTimer->stop();        
   508         mCoverFlow->setUiOn(FALSE);
   557         mCoverFlow->setUiOn(FALSE);
   509         mImageStrip->hide();
   558         mImageStrip->hide();
   510     }
   559     }
   603 
   652 
   604     if(mDeleteAction) {
   653     if(mDeleteAction) {
   605         disconnect(mDeleteAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );  
   654         disconnect(mDeleteAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );  
   606     }
   655     }
   607 
   656 
       
   657     if(mUseImageAction) {
       
   658         disconnect(mUseImageAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );  
       
   659     }
       
   660     
   608 	disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   661 	disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   609 
   662 
   610     OstTraceFunctionExit0( GLXFULLSCREENVIEW_REMOVECONNECTION_EXIT );
   663     OstTraceFunctionExit0( GLXFULLSCREENVIEW_REMOVECONNECTION_EXIT );
   611 }
   664 }
   612 
   665 
   676     }
   729     }
   677 
   730 
   678     OstTraceFunctionExit0( GLXFULLSCREENVIEW_HANDLEUSERACTION_EXIT );
   731     OstTraceFunctionExit0( GLXFULLSCREENVIEW_HANDLEUSERACTION_EXIT );
   679 }
   732 }
   680 
   733 
   681 void GlxFullScreenView::SetImageToHdmiL()
       
   682 {
       
   683     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETIMAGETOHDMIL_ENTRY );
       
   684     
       
   685     if (iHdmiController) {
       
   686         OstTrace0( TRACE_NORMAL, GLXFULLSCREENVIEW_SETIMAGETOHDMIL, "GlxFullScreenView::SetImageToHdmiL() - CGlxHdmi 2" );
       
   687         
       
   688         // Get the image uri
       
   689         QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>();
       
   690         if(imagePath.isNull()) {
       
   691             OstTrace0( TRACE_NORMAL, DUP1_GLXFULLSCREENVIEW_SETIMAGETOHDMIL, "GlxFullScreenView::SetImageToHdmiL() path is null" );
       
   692         }
       
   693        
       
   694         TPtrC aPtr = reinterpret_cast<const TUint16*>(imagePath.utf16());
       
   695 
       
   696         iHdmiController->SetImageL(aPtr);
       
   697     }
       
   698 
       
   699     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETIMAGETOHDMIL_EXIT );
       
   700 }
       
   701 
       
   702 void GlxFullScreenView::imageSelectionAnimation(const QModelIndex &index)
   734 void GlxFullScreenView::imageSelectionAnimation(const QModelIndex &index)
   703 {
   735 {
   704     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_IMAGESELECTIONANIMATION_ENTRY );
   736     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_IMAGESELECTIONANIMATION_ENTRY );
   705 
   737 
   706     if ( mIconItem == NULL ) {
   738     if ( mIconItem == NULL ) {
   734     qint32 commandId = action->data().toInt();
   766     qint32 commandId = action->data().toInt();
   735     emit actionTriggered( commandId );
   767     emit actionTriggered( commandId );
   736     
   768     
   737     OstTraceFunctionExit0( GLXFULLSCREENVIEW_HANDLETOOLBARACTION_EXIT );
   769     OstTraceFunctionExit0( GLXFULLSCREENVIEW_HANDLETOOLBARACTION_EXIT );
   738 }
   770 }
       
   771 
       
   772 int GlxFullScreenView::getSubState()
       
   773 {
       
   774 	int substate = NO_FULLSCREEN_S;
       
   775 	QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );    
       
   776 	if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
       
   777 		substate = variant.value<int>();
       
   778 	}
       
   779 	return substate;
       
   780 }