ui/views/slideshowview/src/glxslideshowview.cpp
changeset 24 99ad1390cd33
parent 23 74c9f037fd5d
child 26 c499df2dbb33
equal deleted inserted replaced
23:74c9f037fd5d 24:99ad1390cd33
    36 #include <glxlog.h>
    36 #include <glxlog.h>
    37 #include <glxtracer.h>
    37 #include <glxtracer.h>
    38 
    38 
    39 GlxSlideShowView::GlxSlideShowView(HbMainWindow *window,HbDocumentLoader *DocLoader) : GlxView(GLX_SLIDESHOWVIEW_ID), mModel(NULL),
    39 GlxSlideShowView::GlxSlideShowView(HbMainWindow *window,HbDocumentLoader *DocLoader) : GlxView(GLX_SLIDESHOWVIEW_ID), mModel(NULL),
    40                   mWindow(window), mSlideShowWidget(NULL),iHdmiController(NULL)
    40                   mWindow(window), mSlideShowWidget(NULL),iHdmiController(NULL)
    41     {
    41 {
    42     TRACER("GlxSlideShowView::GlxSlideShowView()");
    42     TRACER("GlxSlideShowView::GlxSlideShowView()");
    43     mDocLoader = DocLoader;
    43     mDocLoader = DocLoader;
    44     }
    44 }
    45 
    45 
    46 GlxSlideShowView::~GlxSlideShowView()
    46 GlxSlideShowView::~GlxSlideShowView()
    47     {
    47 {
    48     TRACER("GlxSlideShowView::~GlxSlideShowView()");
    48     TRACER("GlxSlideShowView::~GlxSlideShowView()");
    49     if(mSlideShowWidget){
    49     if(mSlideShowWidget){
    50         disconnect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) );
    50         disconnect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) );
    51         delete mSlideShowWidget;
    51         delete mSlideShowWidget;
    52         mSlideShowWidget = NULL;
    52         mSlideShowWidget = NULL;
    53         }
    53     }
    54 
    54 
    55     if(mDocLoader) {
    55     if(mDocLoader) {
    56         mDocLoader->reset();
    56         mDocLoader->reset();
    57         delete mDocLoader;
    57         delete mDocLoader;
    58         mDocLoader = NULL;
    58         mDocLoader = NULL;
    59         }
    59     }
    60     }
    60 }
    61 
    61 
    62 void GlxSlideShowView::activate()
    62 void GlxSlideShowView::activate()
    63     {
    63 {
    64     //To:Do error handling
    64     //To:Do error handling
    65     TRACER("GlxSlideShowView::activate()");
    65     TRACER("GlxSlideShowView::activate()");
       
    66     mWindow->setOrientation(Qt::Horizontal, false);
    66 
    67 
    67     //finds the widgets from the docml
    68     //finds the widgets from the docml
    68     loadObjects();
    69     loadObjects();
    69     mWindow->setItemVisible(Hb::AllItems, false) ;
    70     setItemVisible(Hb::AllItems, false) ;
    70     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
       
    71     connect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) ); 
    71     connect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) ); 
    72     connect( mSlideShowWidget, SIGNAL( indexchanged() ), this, SLOT( indexchanged() ) );
    72     connect( mSlideShowWidget, SIGNAL( indexchanged() ), this, SLOT( indexchanged() ) );
       
    73     
    73     if (!iHdmiController) {
    74     if (!iHdmiController) {
    74         GLX_LOG_INFO("GlxSlideShowView::activate() - CGlxHdmi" );
    75         GLX_LOG_INFO("GlxSlideShowView::activate() - CGlxHdmi" );
    75         iHdmiController = CGlxHdmiController::NewL();
    76         iHdmiController = CGlxHdmiController::NewL();
    76         }   
    77     } 
    77     }
    78 }
    78 
    79 
    79 void GlxSlideShowView::deActivate()
    80 void GlxSlideShowView::deActivate()
    80     {
    81 {
    81     TRACER("GlxSlideShowView::deActivate()");
    82     TRACER("GlxSlideShowView::deActivate()");
    82     mWindow->setItemVisible(Hb::AllItems , TRUE);
    83     mWindow->unsetOrientation(false);
    83     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationChanged(Qt::Orientation)));
    84     setItemVisible(Hb::AllItems , TRUE);
    84     disconnect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) );
    85     disconnect( mSlideShowWidget, SIGNAL( slideShowEvent( GlxSlideShowEvent ) ), this, SLOT( slideShowEventHandler( GlxSlideShowEvent ) ) );
    85     disconnect( mSlideShowWidget, SIGNAL( indexchanged() ), this, SLOT( indexchanged() ) );
    86     disconnect( mSlideShowWidget, SIGNAL( indexchanged() ), this, SLOT( indexchanged() ) );
    86     //Delete the Items in the slide show widget
    87     //Delete the Items in the slide show widget
    87     mSlideShowWidget->cleanUp();
    88     mSlideShowWidget->cleanUp();
    88     mModel = NULL;
    89     mModel = NULL;
    89     if (iHdmiController) {
    90     if (iHdmiController) {
    90         GLX_LOG_INFO("GlxSlideShowView() deActivate delete iHdmiController " );
    91         GLX_LOG_INFO("GlxSlideShowView() deActivate delete iHdmiController " );
    91         delete iHdmiController;
    92         delete iHdmiController;
    92         iHdmiController = NULL;
    93         iHdmiController = NULL;
    93         }
    94     }
    94     }
    95 }
    95 
    96 
    96 void GlxSlideShowView::setModel(QAbstractItemModel *model)
    97 void GlxSlideShowView::setModel(QAbstractItemModel *model)
    97     {
    98 {
    98     TRACER("GlxSlideShowView::setModel()");
    99     TRACER("GlxSlideShowView::setModel()");
    99     GLX_LOG_INFO2("GlxSlideShowView::setModel() model %u mModel %u", model, mModel);
   100     GLX_LOG_INFO2("GlxSlideShowView::setModel() model %u mModel %u", model, mModel);
   100     if ( mModel == model ) {
   101     if ( mModel == model ) {
   101     return ;
   102         return ;
   102     }
   103     }
   103     mModel = model;
   104     mModel = model;
   104     mSlideShowWidget->setModel(mModel);
   105     mSlideShowWidget->setModel(mModel);
   105     SetImageToHdmiL();
   106     SetImageToHdmiL();
   106     }
   107 }
   107 
   108 
   108 void GlxSlideShowView::setModelContext()
   109 void GlxSlideShowView::setModelContext()
   109     {
   110 {
   110     TRACER("GlxSlideShowView::setModelContext()");
   111     TRACER("GlxSlideShowView::setModelContext()");
   111     if ( mModel && mWindow ) {
   112     if ( mModel && mWindow ) {
   112     GLX_LOG_INFO1("GlxSlideShowView::setModelContext %d", mWindow->orientation() );
   113         GLX_LOG_INFO1("GlxSlideShowView::setModelContext %d", mWindow->orientation() );
   113 
   114     
   114     if ( mWindow->orientation() == Qt::Horizontal ) {
   115         if ( mWindow->orientation() == Qt::Horizontal ) {
   115     mModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
   116             mModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
   116     }
   117         }
   117     else {
   118         else {
   118     mModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
   119             mModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
   119     }
   120         }
   120     }
   121     }
   121     }
   122 }
   122 
   123 
   123 void GlxSlideShowView::orientationChanged(Qt::Orientation)
   124 void GlxSlideShowView::orientationChanged(Qt::Orientation)
   124     {
   125 {
   125     TRACER("GlxSlideShowView::orientationChanged()");
   126     TRACER("GlxSlideShowView::orientationChanged()");
   126     QRect screenRect = mWindow->geometry(); 
       
   127     setModelContext();
   127     setModelContext();
   128     mSlideShowWidget->orientationChanged(screenRect);
   128     mSlideShowWidget->orientationChanged( screenGeometry() );
   129     }
   129 }
   130 
   130 
   131 void GlxSlideShowView::slideShowEventHandler( GlxSlideShowEvent e) 
   131 void GlxSlideShowView::slideShowEventHandler( GlxSlideShowEvent e) 
   132     {
   132 {
   133     TRACER("GlxSlideShowView::slideShowEventHandler()");
   133     TRACER("GlxSlideShowView::slideShowEventHandler()");
   134     GLX_LOG_INFO1("GlxSlideShowView::slideShowEventHandler() event %d", e);
   134     GLX_LOG_INFO1("GlxSlideShowView::slideShowEventHandler() event %d", e);
   135     switch ( e ) {
   135     switch ( e ) {
   136         case UI_ON_EVENT :
   136         case UI_ON_EVENT :
   137             mWindow->setItemVisible(Hb::AllItems, TRUE) ;
   137             setItemVisible(Hb::AllItems, TRUE) ;
   138             break;
   138             break;
   139 
   139 
   140         case UI_OFF_EVENT :
   140         case UI_OFF_EVENT :
   141             mWindow->setItemVisible(Hb::AllItems, false) ;
   141             setItemVisible(Hb::AllItems, false) ;
   142             break;
   142             break;
   143 
   143 
   144         case EMPTY_DATA_EVENT :
   144         case EMPTY_DATA_EVENT :
   145             emit actionTriggered( EGlxCmdEmptyData );
   145             emit actionTriggered( EGlxCmdEmptyData );
   146             break;
   146             break;
   147 
   147 
   148         default :
   148         default :
   149             break;        
   149             break;        
   150     }
   150     }
   151     }
   151 }
   152 
   152 
   153 void GlxSlideShowView::indexchanged()
   153 void GlxSlideShowView::indexchanged()
   154     {
   154 {
   155     TRACER("GlxSlideShowView::indexchanged()");
   155     TRACER("GlxSlideShowView::indexchanged()");
   156     SetImageToHdmiL();
   156     SetImageToHdmiL();
   157     }
   157 }
   158 
   158 
   159 bool GlxSlideShowView::event(QEvent *event)
   159 bool GlxSlideShowView::event(QEvent *event)
   160     {
   160 {
   161     TRACER("GlxSlideShowView::event()");
   161     TRACER("GlxSlideShowView::event()");
   162     GLX_LOG_INFO1("GlxSlideShowView::event() %d event type", event->type());
   162     GLX_LOG_INFO1("GlxSlideShowView::event() %d event type", event->type());
   163     if ( event->type() ==  QEvent::WindowActivate && mSlideShowWidget) {
   163     if ( event->type() ==  QEvent::WindowActivate && mSlideShowWidget) {
   164     mSlideShowWidget->startSlideShow();
   164         mSlideShowWidget->startSlideShow();
   165     }
   165     }
   166 
   166 
   167     if ( event->type() ==  QEvent::WindowDeactivate && mSlideShowWidget) {
   167     if ( event->type() ==  QEvent::WindowDeactivate && mSlideShowWidget) {
   168     mSlideShowWidget->stopSlideShow();
   168        mSlideShowWidget->stopSlideShow();
   169     }
   169     }
   170     return HbView::event(event);
   170     return HbView::event(event);
   171     }
   171 }
   172 
   172 
   173 void GlxSlideShowView::loadObjects()
   173 void GlxSlideShowView::loadObjects()
   174     {
   174 {
   175     TRACER("GlxSlideShowView::loadObjects");    
   175     TRACER("GlxSlideShowView::loadObjects");    
   176     //Load/Retrieve the widgets
   176     //Load/Retrieve the widgets
   177     HbView *view     = static_cast<GlxSlideShowView*>(mDocLoader->findWidget(GLXSLIDESHOW_VIEW));
   177     HbView *view     = static_cast<GlxSlideShowView*>(mDocLoader->findWidget(GLXSLIDESHOW_VIEW));
   178     mSlideShowWidget = static_cast<GlxSlideShowWidget*>(mDocLoader->findWidget(GLXSLIDESHOW_WIDGET));
   178     mSlideShowWidget = static_cast<GlxSlideShowWidget*>(mDocLoader->findWidget(GLXSLIDESHOW_WIDGET));
   179     
   179     
   180     //Initialise the Slideshow widget
   180     //Initialise the Slideshow widget
   181     mSlideShowWidget->setSlideShowWidget(mDocLoader);
   181     mSlideShowWidget->setSlideShowWidget(mDocLoader);
   182     mSlideShowWidget->setItemGeometry(mWindow->geometry());  
   182     mSlideShowWidget->setItemGeometry( screenGeometry() );  
   183     }
   183 }
   184 
   184 
   185 void GlxSlideShowView::SetImageToHdmiL()
   185 void GlxSlideShowView::SetImageToHdmiL()
   186     {
   186 {
   187     TRACER("GlxSlideShowView::SetImageToHdmiL() - CGlxHdmi 1" );
   187     TRACER("GlxSlideShowView::SetImageToHdmiL() - CGlxHdmi 1" );
   188     if (iHdmiController)
   188     if (iHdmiController) {
   189         {
       
   190         GLX_LOG_INFO("GlxSlideShowView::SetImageToHdmiL() - CGlxHdmi 2" );
   189         GLX_LOG_INFO("GlxSlideShowView::SetImageToHdmiL() - CGlxHdmi 2" );
   191         // Get the image uri
   190         // Get the image uri
   192         QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>();
   191         QString imagePath = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxUriRole)).value<QString>();
   193         if(imagePath.isNull())
   192         if(imagePath.isNull()) {
   194             {
       
   195             GLX_LOG_INFO("GlxSlideShowView::SetImageToHdmiL() path is null" );
   193             GLX_LOG_INFO("GlxSlideShowView::SetImageToHdmiL() path is null" );
   196             }
   194         }
   197         qDebug() << "GlxSlideShowView::SetImageToHdmiL() imagePath= " << imagePath;
   195         qDebug() << "GlxSlideShowView::SetImageToHdmiL() imagePath= " << imagePath;
   198         TPtrC aPtr = reinterpret_cast<const TUint16*>(imagePath.utf16());
   196         TPtrC aPtr = reinterpret_cast<const TUint16*>(imagePath.utf16());
   199 
   197 
   200         // Get the image Dimensions
   198         iHdmiController->SetImageL(aPtr);
   201         QSize imageDimension = (mModel->data(mModel->index(mModel->data(mModel->index(0,0),GlxFocusIndexRole).value<int>(),0),GlxDimensionsRole)).value<QSize>();
   199     }
   202         TSize imageSize(imageDimension.width(),imageDimension.height());
   200 }
   203         
       
   204         iHdmiController->SetImageL(aPtr,imageSize );
       
   205         }
       
   206     }