ui/views/fullscreenview/src/glxfullscreenview.cpp
changeset 33 1ee2af37811f
parent 29 2c833fc9e98f
child 36 6481344a6d67
equal deleted inserted replaced
29:2c833fc9e98f 33:1ee2af37811f
    27 #include <shareuidialog.h>
    27 #include <shareuidialog.h>
    28 #include <hbdocumentloader.h>
    28 #include <hbdocumentloader.h>
    29 #include <QAbstractItemModel>
    29 #include <QAbstractItemModel>
    30 #include <hbabstractviewitem.h>
    30 #include <hbabstractviewitem.h>
    31 #include <hbiconitem.h>
    31 #include <hbiconitem.h>
       
    32 #include <QCoreApplication>
    32 
    33 
    33 //User Includes
    34 //User Includes
    34 #include "glxlog.h"
    35 #include "glxlog.h"
    35 #include "glxtracer.h"
    36 #include "glxtracer.h"
    36 #include "glxviewids.h"  //contains the view ids of all the views in photos app.
    37 #include "glxviewids.h"  //contains the view ids of all the views in photos app.
    40 #include "glxdocloaderdefs.h" //contains the definations of path, widget names and view names in docml
    41 #include "glxdocloaderdefs.h" //contains the definations of path, widget names and view names in docml
    41 #include "glxloggerenabler.h"
    42 #include "glxloggerenabler.h"
    42 #include "glxtvoutwrapper.h"
    43 #include "glxtvoutwrapper.h"
    43 #include "glxfullscreenview.h" 
    44 #include "glxfullscreenview.h" 
    44 #include "glxcommandhandlers.hrh"
    45 #include "glxcommandhandlers.hrh"
    45 //#include "glxzoomwidget.h"
    46 #include "glxzoomwidget.h"
    46 
    47 
    47 #include "OstTraceDefinitions.h"
    48 #include "OstTraceDefinitions.h"
    48 #ifdef OST_TRACE_COMPILER_IN_USE
    49 #ifdef OST_TRACE_COMPILER_IN_USE
    49 #include "glxfullscreenviewTraces.h"
    50 #include "glxfullscreenviewTraces.h"
    50 #endif
    51 #endif
    63     mTvOutWrapper(NULL),
    64     mTvOutWrapper(NULL),
    64     mFullScreenToolBar(NULL),
    65     mFullScreenToolBar(NULL),
    65 	mFlipAction(NULL),
    66 	mFlipAction(NULL),
    66 	mSendAction(NULL),
    67 	mSendAction(NULL),
    67 	mDeleteAction(NULL),
    68 	mDeleteAction(NULL),
       
    69 	mZoomWidget(NULL),
    68 	mUseImageAction(NULL)
    70 	mUseImageAction(NULL)
    69 {
    71 {
    70     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
    72     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
    71     
    73     
    72     mDocLoader = DocLoader;
    74     mDocLoader = DocLoader;
    93 
    95 
    94     //Initialize the coverflow and partially creates the coverflow with one image
    96     //Initialize the coverflow and partially creates the coverflow with one image
    95     // to make the widget light weight in order to make
    97     // to make the widget light weight in order to make
    96     // transition smooth 
    98     // transition smooth 
    97     mCoverFlow->partiallyCreate( model, screenSize());
    99     mCoverFlow->partiallyCreate( model, screenSize());
    98     setItemVisible(Hb::AllItems, FALSE) ;
   100 	
       
   101     setStatusBarVisible(FALSE);
       
   102     setTitleBarVisible(FALSE);
    99     
   103     
   100     OstTraceFunctionExit0( GLXFULLSCREENVIEW_INITIALIZEVIEW_EXIT );
   104     OstTraceFunctionExit0( GLXFULLSCREENVIEW_INITIALIZEVIEW_EXIT );
   101 }
   105 }
   102 
   106 
   103 void GlxFullScreenView::loadWidgets()
   107 void GlxFullScreenView::loadWidgets()
   105     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_LOADWIDGETS_ENTRY );
   109     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_LOADWIDGETS_ENTRY );
   106     
   110     
   107     //Load the Coverflow and image strip widget    
   111     //Load the Coverflow and image strip widget    
   108     mCoverFlow = qobject_cast<GlxCoverFlow*> (mDocLoader->findWidget(GLXFULLSCREEN_COVERFLOW));
   112     mCoverFlow = qobject_cast<GlxCoverFlow*> (mDocLoader->findWidget(GLXFULLSCREEN_COVERFLOW));
   109 
   113 
       
   114 	 mZoomWidget  =  qobject_cast<GlxZoomWidget*> (mDocLoader->findWidget(GLXFULLSCREENZOOMWIDGET));
       
   115 	 mCoverFlow->setMultitouchFilter(mZoomWidget);
   110     //initialise the cover flow for basic connections and the rest
   116     //initialise the cover flow for basic connections and the rest
   111     mCoverFlow->setCoverFlow();
   117     mCoverFlow->setCoverFlow();
   112 
   118 
   113    //Load the IMAGE STRIP & FULLSCREEN TOOLBAR[PUSH BUTTON]
   119    //Load the IMAGE STRIP & FULLSCREEN TOOLBAR[PUSH BUTTON]
   114     mImageStrip              =   qobject_cast<HbGridView*> (mDocLoader->findWidget(GLXFULLSCREEN_FILMSTRIP));
   120     mImageStrip              =   qobject_cast<HbGridView*> (mDocLoader->findWidget(GLXFULLSCREEN_FILMSTRIP));
   172 
   178 
   173 void GlxFullScreenView::activate()
   179 void GlxFullScreenView::activate()
   174 {
   180 {
   175     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ACTIVATE_ENTRY );    
   181     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ACTIVATE_ENTRY );    
   176 
   182 
   177     setItemVisible(Hb::AllItems, FALSE) ;
   183     setStatusBarVisible(FALSE);
       
   184     setTitleBarVisible(FALSE);
       
   185 	
   178 
   186 
   179 //for zoom might not be required after wk15 release
   187 //for zoom might not be required after wk15 release
   180 	mWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents,true); 
   188 	mWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents,true); 
   181 	mWindow->viewport()->grabGesture(Qt::PinchGesture);
   189 	mWindow->viewport()->grabGesture(Qt::PinchGesture);
   182 	
   190 	
       
   191 	QCoreApplication::instance()->installEventFilter(this);
       
   192 
   183     if(!mCoverFlow){
   193     if(!mCoverFlow){
   184         loadWidgets();  //retrives the widgets
   194         loadWidgets();  //retrives the widgets
   185     }
   195     }
   186 
   196 
   187     //Loads the widgets corresponding to the orientation.
   197     //Loads the widgets corresponding to the orientation.
   234 { 
   244 { 
   235     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_DEACTIVATE_ENTRY );    
   245     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_DEACTIVATE_ENTRY );    
   236     
   246     
   237 	//Clean up the rest of the resources allocated
   247 	//Clean up the rest of the resources allocated
   238     cleanUp();
   248     cleanUp();
   239 
   249     QCoreApplication::instance()->removeEventFilter(this);
   240     //deletes the iconitems in the coverflow   
   250     //deletes the iconitems in the coverflow   
   241     mCoverFlow->ClearCoverFlow();
   251     mCoverFlow->ClearCoverFlow();
   242 
   252 
   243     //the coverflow is not deleted as it is loaded by document loader
   253     //the coverflow is not deleted as it is loaded by document loader
   244     //the coverflow is initialised to null 
   254     //the coverflow is initialised to null 
   268     
   278     
   269     if (mTvOutWrapper) {
   279     if (mTvOutWrapper) {
   270         delete mTvOutWrapper;
   280         delete mTvOutWrapper;
   271         mTvOutWrapper = NULL;
   281         mTvOutWrapper = NULL;
   272     }
   282     }
       
   283     if(mZoomWidget)
       
   284     {
       
   285         mZoomWidget->cleanUp();
       
   286 
       
   287     }
   273     OstTraceFunctionExit0( GLXFULLSCREENVIEW_CLEANUP_EXIT );
   288     OstTraceFunctionExit0( GLXFULLSCREENVIEW_CLEANUP_EXIT );
   274 }
   289 }
   275 
   290 
   276 QGraphicsItem * GlxFullScreenView::getAnimationItem(GlxEffect transitionEffect)
   291 QGraphicsItem * GlxFullScreenView::getAnimationItem(GlxEffect transitionEffect)
   277 {
   292 {
   290     OstTraceExt2( TRACE_NORMAL, GLXFULLSCREENVIEW_SETMODEL, "GlxFullScreenView::setModel; model=%x; mModel=%u", ( TUint )( model ), ( TUint ) mModel );
   305     OstTraceExt2( TRACE_NORMAL, GLXFULLSCREENVIEW_SETMODEL, "GlxFullScreenView::setModel; model=%x; mModel=%u", ( TUint )( model ), ( TUint ) mModel );
   291     
   306     
   292     mModel = model;     
   307     mModel = model;     
   293 	setModelContext();  
   308 	setModelContext();  
   294     setHdmiModel(mModel);
   309     setHdmiModel(mModel);
   295 
   310 	mZoomWidget->setModel(mModel);  
   296     mCoverFlow->setModel(mModel);
   311     mCoverFlow->setModel(mModel);
   297     setImageStripModel();
   312     setImageStripModel();
   298     if(getSubState() == IMAGEVIEWER_S)
   313     if(getSubState() == IMAGEVIEWER_S)
   299         {
   314         {
   300         setTitle("Image Viewer");
   315         setTitle("Image Viewer");
   301         }
   316         }
   302 	else if(getSubState() == FETCHER_S){
   317 	else if(getSubState() == FETCHER_S){
   303 		setItemVisible(Hb::AllItems, TRUE) ;
   318 		setStatusBarVisible(TRUE);
       
   319         setTitleBarVisible(TRUE);
   304 	}
   320 	}
   305     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETMODEL_EXIT );
   321     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETMODEL_EXIT );
   306 }
   322 }
   307 
   323 
   308 void GlxFullScreenView::setHdmiModel(QAbstractItemModel* model)
   324 void GlxFullScreenView::setHdmiModel(QAbstractItemModel* model)
   363             mImageStrip->setCurrentIndex ( mModel->index( variant.value<int>(), 0) );    
   379             mImageStrip->setCurrentIndex ( mModel->index( variant.value<int>(), 0) );    
   364             mImageStrip->scrollTo( mModel->index( variant.value<int>(), 0), HbGridView::PositionAtTop ); 
   380             mImageStrip->scrollTo( mModel->index( variant.value<int>(), 0), HbGridView::PositionAtTop ); 
   365         }
   381         }
   366         
   382         
   367         mFullScreenToolBar->show();
   383         mFullScreenToolBar->show();
   368         setItemVisible(Hb::AllItems, TRUE) ;
   384 		setStatusBarVisible(TRUE);
       
   385         setTitleBarVisible(TRUE);
       
   386        
   369 
   387 
   370         if ( mImageStrip && getSubState() != IMAGEVIEWER_S) {
   388         if ( mImageStrip && getSubState() != IMAGEVIEWER_S) {
   371             mImageStrip->show(); 
   389             mImageStrip->show(); 
   372             HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapShow"), this, "effectFinished" );
   390             HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapShow"), this, "effectFinished" );
   373         }
   391         }
   393         return ;
   411         return ;
   394     }
   412     }
   395     
   413     
   396     mUiOff = TRUE;
   414     mUiOff = TRUE;
   397 	if ( getSubState() != FETCHER_S ) {
   415 	if ( getSubState() != FETCHER_S ) {
   398 		setItemVisible(Hb::AllItems, FALSE) ;
   416 		setStatusBarVisible(FALSE);
       
   417         setTitleBarVisible(FALSE);
   399 	}
   418 	}
   400     if ( mImageStrip && ( getSubState() != IMAGEVIEWER_S && getSubState() != FETCHER_S )) {
   419     if ( mImageStrip && ( getSubState() != IMAGEVIEWER_S && getSubState() != FETCHER_S )) {
   401         HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapHide"), this, "effectFinished" );
   420         HbEffect::start(mImageStrip, QString("HbGridView"), QString("TapHide"), this, "effectFinished" );
   402     }
   421     }
   403 
   422 
   419        // for the image changed on deletion
   438        // for the image changed on deletion
   420        mTvOutWrapper->setImagetoHDMI();
   439        mTvOutWrapper->setImagetoHDMI();
   421        }
   440        }
   422        return;
   441        return;
   423     }         
   442     }         
   424     mModel->setData( index, index.row(), GlxFocusIndexRole );    
   443     mModel->setData( index, index.row(), GlxFocusIndexRole );  
       
   444 	mZoomWidget->indexChanged(index.row());  
   425     if (mTvOutWrapper){
   445     if (mTvOutWrapper){
   426     // for the image changed on swipe
   446     // for the image changed on swipe
   427     mTvOutWrapper->setImagetoHDMI();
   447     mTvOutWrapper->setImagetoHDMI();
   428     }
   448     }
   429     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
   449     OstTraceFunctionExit0( DUP1_GLXFULLSCREENVIEW_CHANGESELECTEDINDEX_EXIT );
   437     if ( variant.isValid() &&  variant.canConvert<int> () && ( index.row() == variant.value<int>() ) ) {
   457     if ( variant.isValid() &&  variant.canConvert<int> () && ( index.row() == variant.value<int>() ) ) {
   438        OstTraceFunctionExit0( GLXFULLSCREENVIEW_INDEXCHANGED_EXIT );
   458        OstTraceFunctionExit0( GLXFULLSCREENVIEW_INDEXCHANGED_EXIT );
   439        return;
   459        return;
   440     }         
   460     }         
   441     mModel->setData( index, index.row(), GlxFocusIndexRole );
   461     mModel->setData( index, index.row(), GlxFocusIndexRole );
       
   462 	mZoomWidget->indexChanged(index.row());
   442     mCoverFlow->indexChanged(index.row());
   463     mCoverFlow->indexChanged(index.row());
   443     mImageStrip->scrollTo(index, HbGridView::EnsureVisible );
   464     mImageStrip->scrollTo(index, HbGridView::EnsureVisible );
   444     if (mTvOutWrapper){
   465     if (mTvOutWrapper){
   445     // for the indexchnaged through filmstrip
   466     // for the indexchnaged through filmstrip
   446     mTvOutWrapper->setImagetoHDMI();
   467     mTvOutWrapper->setImagetoHDMI();
   585     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETLAYOUT_ENTRY );
   606     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_SETLAYOUT_ENTRY );
   586     
   607     
   587     QSize sz = screenSize();
   608     QSize sz = screenSize();
   588 
   609 
   589     mCoverFlow->setItemSize(sz);
   610     mCoverFlow->setItemSize(sz);
   590  	OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETLAYOUT_EXIT );
   611  	mZoomWidget->setWindowSize(sz);
       
   612 
       
   613     OstTraceFunctionExit0( GLXFULLSCREENVIEW_SETLAYOUT_EXIT );
   591 }
   614 }
   592 
   615 
   593 void GlxFullScreenView::addConnection()
   616 void GlxFullScreenView::addConnection()
   594 {
   617 {
   595     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ADDCONNECTION_ENTRY );
   618     OstTraceFunctionEntry0( GLXFULLSCREENVIEW_ADDCONNECTION_ENTRY );
   609 
   632 
   610     if ( mUiOffTimer ) {
   633     if ( mUiOffTimer ) {
   611         connect(mUiOffTimer, SIGNAL(timeout()), this, SLOT(hideUi()));
   634         connect(mUiOffTimer, SIGNAL(timeout()), this, SLOT(hideUi()));
   612     }
   635     }
   613     
   636     
       
   637     if(mCoverFlow && mZoomWidget) {
       
   638 		connect(mZoomWidget,SIGNAL( pinchGestureReceived(int) ), mCoverFlow, SLOT( zoomStarted(int) ) );
       
   639 		connect(mZoomWidget,SIGNAL( zoomWidgetMovedBackground(int) ), mCoverFlow, SLOT( zoomFinished(int) ) );
       
   640 	}
       
   641 
   614     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   642     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   615 
   643 
   616     OstTraceFunctionExit0( GLXFULLSCREENVIEW_ADDCONNECTION_EXIT );
   644     OstTraceFunctionExit0( GLXFULLSCREENVIEW_ADDCONNECTION_EXIT );
   617 }
   645 }
   618 
   646 
   655     }
   683     }
   656 
   684 
   657     if(mUseImageAction) {
   685     if(mUseImageAction) {
   658         disconnect(mUseImageAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );  
   686         disconnect(mUseImageAction, SIGNAL(triggered( )), this, SLOT(handleToolBarAction( )) );  
   659     }
   687     }
       
   688 	if(mCoverFlow && mZoomWidget) {
       
   689 		disconnect(mZoomWidget,SIGNAL( pinchGestureReceived(int) ), mCoverFlow, SLOT( zoomStarted(int) ) );
       
   690 		disconnect(mZoomWidget,SIGNAL( zoomWidgetMovedBackground(int) ), mCoverFlow, SLOT( zoomFinished(int) ) );
       
   691 	}
   660     
   692     
   661 	disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   693 	disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
   662 
   694 
   663     OstTraceFunctionExit0( GLXFULLSCREENVIEW_REMOVECONNECTION_EXIT );
   695     OstTraceFunctionExit0( GLXFULLSCREENVIEW_REMOVECONNECTION_EXIT );
   664 }
   696 }
   681     OstTraceFunctionEntry0( DUP1_GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
   713     OstTraceFunctionEntry0( DUP1_GLXFULLSCREENVIEW_GLXFULLSCREENVIEW_ENTRY );
   682     
   714     
   683 	cleanUp();
   715 	cleanUp();
   684 	
   716 	
   685 	delete mIconItem ;
   717 	delete mIconItem ;
   686 	mIconItem = NULL;
   718     delete mImageStrip;
   687     
   719     delete mFullScreenToolBar;
   688 	if(mImageStrip) {
   720     delete mCoverFlow;
   689         delete mImageStrip;
   721     delete mZoomWidget;
   690         mImageStrip = NULL;
       
   691     }
       
   692 
       
   693     if(mFullScreenToolBar) {
       
   694         delete mFullScreenToolBar;
       
   695         mFullScreenToolBar = NULL;
       
   696     }
       
   697 
       
   698     if(mCoverFlow) {
       
   699         delete mCoverFlow;
       
   700         mCoverFlow = NULL;
       
   701     }
       
   702 
   722 
   703     if(mDocLoader != NULL) {
   723     if(mDocLoader != NULL) {
   704         mDocLoader->reset();
   724         mDocLoader->reset();
   705         delete mDocLoader;    
   725         delete mDocLoader;    
   706     }
   726     }
   758 		substate = variant.value<int>();
   778 		substate = variant.value<int>();
   759 	}
   779 	}
   760 	return substate;
   780 	return substate;
   761 }
   781 }
   762 
   782 
   763 bool GlxFullScreenView::event(QEvent *event)
   783 bool GlxFullScreenView::eventFilter(QObject *obj, QEvent *ev)
   764 {
   784 {
   765     GLX_LOG_INFO1("GlxFullScreenView::event() %d event type", event->type());
   785     GLX_LOG_INFO1("GlxFullScreenView::event() %d event type", ev->type());
   766     if ( event->type() ==  QEvent::WindowActivate && mCoverFlow) {
   786     if ( ev->type() ==  QEvent::ApplicationActivate && mTvOutWrapper) {
   767         if (mTvOutWrapper){
   787         GLX_LOG_INFO("GlxFullScreenView::event() shift to native - CGlxHdmi");
   768         mTvOutWrapper->setToNativeMode();    
   788         mTvOutWrapper->setToNativeMode();    
   769         }
   789     }
   770     }
   790     if ( ev->type() ==  QEvent::ApplicationDeactivate && mTvOutWrapper) {
   771     if ( event->type() ==  QEvent::WindowDeactivate && mCoverFlow) {
   791         GLX_LOG_INFO("GlxFullScreenView::event() shift to Clone - CGlxHdmi");
   772         if (mTvOutWrapper){
       
   773         mTvOutWrapper->setToCloningMode();    
   792         mTvOutWrapper->setToCloningMode();    
   774         }
   793     }
   775     }
   794     return HbView::eventFilter(obj,ev);
   776     return HbView::event(event);
   795 }
   777 }
   796 
   778