ui/views/gridview/src/glxgridview.cpp
changeset 44 aa2fa096cbfb
parent 43 72396548277c
child 45 863223ea6961
equal deleted inserted replaced
43:72396548277c 44:aa2fa096cbfb
    28 #include <xqserviceutil.h>
    28 #include <xqserviceutil.h>
    29 #include <hbcheckbox.h>
    29 #include <hbcheckbox.h>
    30 #include <hblabel.h>
    30 #include <hblabel.h>
    31 #include <QString>
    31 #include <QString>
    32 #include <hbframeitem.h>
    32 #include <hbframeitem.h>
    33 #include <QCoreApplication>
       
    34 
    33 
    35 //User Includes
    34 //User Includes
    36 #include "glxviewids.h"
    35 #include "glxviewids.h"
    37 #include "glxgridview.h"
    36 #include "glxgridview.h"
    38 #include "glxmodelparm.h"
    37 #include "glxmodelparm.h"
    39 #include "glxcommandhandlers.hrh"
    38 #include "glxcommandhandlers.hrh"
    40 #include "glxicondefs.h"
    39 #include "glxicondefs.h"
    41 #include "glxlocalisationstrings.h"
    40 #include "glxlocalisationstrings.h"
    42 #include "glxlog.h"
       
    43 #include "glxtracer.h"
       
    44 
       
    45 
    41 
    46 #include "OstTraceDefinitions.h"
    42 #include "OstTraceDefinitions.h"
    47 #ifdef OST_TRACE_COMPILER_IN_USE
    43 #ifdef OST_TRACE_COMPILER_IN_USE
    48 #include "glxgridviewTraces.h"
    44 #include "glxgridviewTraces.h"
    49 #endif
    45 #endif
    50 
    46 
    51 GlxGridView::GlxGridView(HbMainWindow *window) 
    47 GlxGridView::GlxGridView(HbMainWindow *window)
    52     : GlxView ( GLX_GRIDVIEW_ID ), 
    48     : GlxView ( GLX_GRIDVIEW_ID ),
    53       mWindow(window), 
    49       mWindow(window),
    54       mModel ( NULL), 
    50       mModel ( NULL),
    55       mWidget(NULL),
    51       mWidget(NULL),
    56       mSelectionModel(NULL),
    52       mSelectionModel(NULL),
    57       mModelWrapper(NULL),
    53       mModelWrapper(NULL),
    58       mUiOnButton(NULL),
    54       mUiOnButton(NULL),
    59       mCameraButton(NULL),
    55       mCameraButton(NULL),
    85         mUiOnButton->hide();
    81         mUiOnButton->hide();
    86     }
    82     }
    87     loadGridView();
    83     loadGridView();
    88 	connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection);
    84 	connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection);
    89     if(mCountItem == NULL) {
    85     if(mCountItem == NULL) {
    90         mCountItem = new HbLabel(this);        
    86         mCountItem = new HbLabel(this);
    91         HbFrameItem *frame = new HbFrameItem(this); //graphics for mCountItem
    87         HbFrameItem *frame = new HbFrameItem(this); //graphics for mCountItem
    92         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
    88         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
    93         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
    89         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
    94         frame->graphicsItem()->setOpacity(1);
    90         frame->graphicsItem()->setOpacity(1);
    95         mCountItem->setBackgroundItem(frame->graphicsItem(),-1);
    91         mCountItem->setBackgroundItem(frame->graphicsItem(),-1);
    96     }
    92         mCountItem->hide();
    97     QCoreApplication::instance()->installEventFilter(this);
    93     }
    98     OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
    94     OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
    99 }
    95 }
   100 
    96 
   101 void GlxGridView::deActivate()
    97 void GlxGridView::deActivate()
   102 {
    98 {
   103     OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
    99     OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
   104     mScrolling = FALSE;
   100     mScrolling = FALSE;
   105     if (mUiOnButton){
   101     if (mUiOnButton){
   106         mUiOnButton->hide();
   102         mUiOnButton->hide();
   107     }    
   103     }
   108     if(mIconItem) {
   104     if(mIconItem) {
   109         mIconItem->hide();
   105         mIconItem->hide();
   110         mIconItem->resetTransform();
   106         mIconItem->resetTransform();
   111         mIconItem->setOpacity(0);
   107         mIconItem->setOpacity(0);
   112         mIconItem->setZValue(mIconItem->zValue()-20);
   108         mIconItem->setZValue(mIconItem->zValue()-20);
   121         mZeroItemLabel->hide();
   117         mZeroItemLabel->hide();
   122     }
   118     }
   123     if(mCameraButton) {
   119     if(mCameraButton) {
   124         mCameraButton->hide();
   120         mCameraButton->hide();
   125     }
   121     }
   126     QCoreApplication::instance()->removeEventFilter(this);
       
   127     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
   122     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
   128     OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
   123     OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
   129 }
   124 }
   130 
   125 
   131 void GlxGridView::initializeView(QAbstractItemModel *model)
   126 void GlxGridView::initializeView(QAbstractItemModel *model)
   169         if (mWidget && variantimage.isValid() &&  variantimage.canConvert<QImage> () )
   164         if (mWidget && variantimage.isValid() &&  variantimage.canConvert<QImage> () )
   170             {
   165             {
   171             mWidget->setDefaultImage(variantimage.value<QImage>());
   166             mWidget->setDefaultImage(variantimage.value<QImage>());
   172             }
   167             }
   173         mModelWrapper->setModel(mModel);
   168         mModelWrapper->setModel(mModel);
   174         mWidget->setModel(mModelWrapper);  
   169         mWidget->setModel(mModelWrapper);
   175         if(!mSelectionModel)
   170         if(!mSelectionModel)
   176             {
   171             {
   177             mSelectionModel = new QItemSelectionModel(mModelWrapper, this);
   172             mSelectionModel = new QItemSelectionModel(mModelWrapper, this);
   178             connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &)));
   173             connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &)));
   179             mWidget->setSelectionModel(mSelectionModel);
   174             mWidget->setSelectionModel(mSelectionModel);
   194             mModel->setData(mModel->index(0,0),current.row(),GlxVisualWindowIndex);
   189             mModel->setData(mModel->index(0,0),current.row(),GlxVisualWindowIndex);
   195             }
   190             }
   196         }
   191         }
   197 }
   192 }
   198 
   193 
   199 void GlxGridView::addToolBar( HbToolBar *toolBar ) 
   194 void GlxGridView::addToolBar( HbToolBar *toolBar )
   200 {
   195 {
   201     OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY ); 
   196     OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY );
   202     setToolBar(toolBar);  
   197     setToolBar(toolBar);
   203     hideorshowitems(mWindow->orientation());
   198     hideorshowitems(mWindow->orientation());
   204     OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT );
   199     OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT );
   205 }
   200 }
   206 
   201 
   207 void GlxGridView::enableMarking()
   202 void GlxGridView::enableMarking()
   208 {
   203 {
   209     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
   204     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
   210     mWidget->setSelectionMode(HgWidget::MultiSelection);
   205     mWidget->setSelectionMode(HgWidget::MultiSelection);
   211     if (mMainLabel == NULL) {
   206     if (mMainLabel == NULL) {
   212         mMainLabel = new HbLabel("Select Photos", this);        
   207         mMainLabel = new HbLabel("Select Photos", this);
   213         HbFrameItem *frame1 = new HbFrameItem(this);    //graphics for mMainLabel
   208         HbFrameItem *frame1 = new HbFrameItem(this);    //graphics for mMainLabel
   214         frame1->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   209         frame1->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   215         frame1->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   210         frame1->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   216         frame1->graphicsItem()->setOpacity(1);
   211         frame1->graphicsItem()->setOpacity(1);
   217         mMainLabel->setBackgroundItem(frame1->graphicsItem(),-1);
   212         mMainLabel->setBackgroundItem(frame1->graphicsItem(),-1);
   218     }
   213     }
   219     if (mMarkCheckBox == NULL) {
   214     if (mMarkCheckBox == NULL) {
   220         mMarkCheckBox = new HbCheckBox(GLX_OPTION_MARK_ALL, this);        
   215         mMarkCheckBox = new HbCheckBox(GLX_OPTION_MARK_ALL, this);
   221         HbFrameItem *frame2 = new HbFrameItem(this);    //graphics for mMarkCheckBox
   216         HbFrameItem *frame2 = new HbFrameItem(this);    //graphics for mMarkCheckBox
   222         frame2->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   217         frame2->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   223         frame2->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   218         frame2->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   224         frame2->graphicsItem()->setOpacity(1);
   219         frame2->graphicsItem()->setOpacity(1);
   225         mMarkCheckBox->setBackgroundItem(frame2->graphicsItem(),-1);
   220         mMarkCheckBox->setBackgroundItem(frame2->graphicsItem(),-1);
   226     }
   221     }
   227     if (mCountLabel == NULL) {
   222     if (mCountLabel == NULL) {
   228         mCountLabel = new HbLabel(this);        
   223         mCountLabel = new HbLabel(this);
   229         HbFrameItem *frame3 = new HbFrameItem(this);    //graphics for mCountLabel
   224         HbFrameItem *frame3 = new HbFrameItem(this);    //graphics for mCountLabel
   230         frame3->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   225         frame3->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   231         frame3->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   226         frame3->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   232         frame3->graphicsItem()->setOpacity(1);
   227         frame3->graphicsItem()->setOpacity(1);
   233         mCountLabel->setBackgroundItem(frame3->graphicsItem(),-1);
   228         mCountLabel->setBackgroundItem(frame3->graphicsItem(),-1);
   238     connect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
   233     connect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
   239     connect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
   234     connect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
   240 
   235 
   241 }
   236 }
   242 
   237 
   243 void GlxGridView::disableMarking() 
   238 void GlxGridView::disableMarking()
   244 {
   239 {
   245     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
   240     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
   246     mWidget->setSelectionMode(HgWidget::NoSelection);
   241     mWidget->setSelectionMode(HgWidget::NoSelection);
   247     disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
   242     disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
   248     disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
   243     disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
   293             if(mCameraButton) {
   288             if(mCameraButton) {
   294                 mCameraButton->hide();
   289                 mCameraButton->hide();
   295             }
   290             }
   296             if(isItemVisible(Hb::TitleBarItem)) {
   291             if(isItemVisible(Hb::TitleBarItem)) {
   297                 QString text;
   292                 QString text;
   298                 if (getSubState() == ALL_ITEM_S) {
   293                 if(XQServiceUtil::isService())
       
   294                     {
       
   295                     showAlbumTitle(GLX_FETCHER_TITLE);
       
   296                     }
       
   297                 else if (getSubState() == ALL_ITEM_S) {
   299 					if (mAlbumName) {
   298 					if (mAlbumName) {
   300                     	mAlbumName->hide();
   299                     	mAlbumName->hide();
   301 					}
   300 					}
   302                     mCountItem->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
   301                     mCountItem->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
   303                     text = QString("%1 Items").arg( count );
   302                     text = QString("%1 Items").arg( count );
   335                     mCountItem->hide();
   334                     mCountItem->hide();
   336                 }
   335                 }
   337                 if (mAlbumName) {
   336                 if (mAlbumName) {
   338                     mAlbumName->hide();
   337                     mAlbumName->hide();
   339                 }
   338                 }
   340                 
   339 
   341                 showNoImageString();            
   340                 showNoImageString();
   342                 
   341 
   343                 if (getSubState() == ALBUM_ITEM_S) {                
   342                 if (getSubState() == ALBUM_ITEM_S) {
   344                     QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
   343                     QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
   345                     if (variant.toString() != NULL) {
   344                     if (variant.toString() != NULL) {
   346                         showAlbumTitle(variant.toString());
   345                         showAlbumTitle(variant.toString());
   347                     }
   346                     }
       
   347 				}	
       
   348                 else if(XQServiceUtil::isService()){
       
   349                     showAlbumTitle(GLX_FETCHER_TITLE);
   348                 }
   350                 }
   349             }
   351             }
   350         }
   352         }
   351     }
   353     }
   352 }
   354 }
   356     int count = mModel->rowCount();
   358     int count = mModel->rowCount();
   357     QSize deviceSize = HbDeviceProfile::current().logicalSize();
   359     QSize deviceSize = HbDeviceProfile::current().logicalSize();
   358     QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
   360     QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
   359                                                                    : QSize( deviceSize.height(), deviceSize.width() )  ;
   361                                                                    : QSize( deviceSize.height(), deviceSize.width() )  ;
   360     if(mAlbumName == NULL) {
   362     if(mAlbumName == NULL) {
   361         mAlbumName = new HbLabel(this);            
   363         mAlbumName = new HbLabel(this);
   362         HbFrameItem *frame = new HbFrameItem(this); //graphics for mAlbumName
   364         HbFrameItem *frame = new HbFrameItem(this); //graphics for mAlbumName
   363         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   365         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   364         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   366         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
   365         frame->graphicsItem()->setOpacity(1);
   367         frame->graphicsItem()->setOpacity(1);
   366         mAlbumName->setBackgroundItem(frame->graphicsItem(),-1);
   368         mAlbumName->setBackgroundItem(frame->graphicsItem(),-1);
   367     }
   369     }
   368     
   370     
   369     if(count && isItemVisible(Hb::TitleBarItem)) {        
   371 	//If fetcher service set only title text
   370         mAlbumName->setGeometry(QRectF(0,0,screenSize.width()/2,deviceSize.height()/24));
   372 	if((XQServiceUtil::isService() ) && isItemVisible(Hb::TitleBarItem)) {
   371         QString text = QString(aTitle);
       
   372         mAlbumName->setPlainText( text );
       
   373         mAlbumName->show();
       
   374         mCountItem->setGeometry(QRectF(screenSize.width()/2,0,screenSize.width()/2,deviceSize.height()/24));
       
   375         text = QString("(%1)").arg(count);
       
   376         mCountItem->setPlainText( text );
       
   377         mCountItem->setAlignment(Qt::AlignRight);
       
   378         mCountItem->show();
       
   379     }    
       
   380     else if((!count) && isItemVisible(Hb::TitleBarItem)) {
       
   381         mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
   373         mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
   382         QString text = QString(aTitle);
   374         QString text = QString(aTitle);
   383         mAlbumName->setPlainText( text );
   375         mAlbumName->setPlainText( text );
   384         mAlbumName->show();
   376         mAlbumName->show();
   385     }
   377     }
       
   378 	else{ //handle album tiltle and count display logic here
       
   379 	    if( count && isItemVisible(Hb::TitleBarItem)) {        
       
   380 	        mAlbumName->setGeometry(QRectF(0,0,screenSize.width()/2,deviceSize.height()/24));
       
   381 	        QString text = QString(aTitle);
       
   382 	        mAlbumName->setPlainText( text );
       
   383 	        mAlbumName->show();
       
   384 	        mCountItem->setGeometry(QRectF(screenSize.width()/2,0,screenSize.width()/2,deviceSize.height()/24));
       
   385 	        text = QString("(%1)").arg(count);
       
   386 	        mCountItem->setPlainText( text );
       
   387 	        mCountItem->setAlignment(Qt::AlignRight);
       
   388 	        mCountItem->show();
       
   389 	    }    
       
   390 	    else if((!count) && isItemVisible(Hb::TitleBarItem)) {
       
   391 	        mAlbumName->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
       
   392 	        QString text = QString(aTitle);
       
   393 	        mAlbumName->setPlainText( text );
       
   394 	        mAlbumName->show();
       
   395 	    }
       
   396 	}
   386 }
   397 }
   387 
   398 
   388 void GlxGridView::showNoImageString()
   399 void GlxGridView::showNoImageString()
   389 {
   400 {
   390     qreal chromeHeight = 0.0;
   401     qreal chromeHeight = 0.0;
   394     qreal midHeight = screenSize.height()/2;
   405     qreal midHeight = screenSize.height()/2;
   395     if (isItemVisible(Hb::TitleBarItem)) {
   406     if (isItemVisible(Hb::TitleBarItem)) {
   396         style()->parameter("hb-param-widget-chrome-height", chromeHeight);
   407         style()->parameter("hb-param-widget-chrome-height", chromeHeight);
   397         midHeight -= chromeHeight;
   408         midHeight -= chromeHeight;
   398     }
   409     }
   399     if (mZeroItemLabel == NULL) {                
   410     if (mZeroItemLabel == NULL) {
   400         mZeroItemLabel = new HbLabel("(No Images)\n To capture images Open", this);
   411         QString displayText(GLX_GRID_NO_IMAGE); 
       
   412         if(!XQServiceUtil::isService())
       
   413             {
       
   414             displayText.append(GLX_GRID_OPEN_CAMERA);
       
   415             }
       
   416         mZeroItemLabel = new HbLabel(displayText, this);
   401     }
   417     }
   402     mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32));
   418     mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32));
   403     mZeroItemLabel->setAlignment(Qt::AlignHCenter);
   419     mZeroItemLabel->setAlignment(Qt::AlignHCenter);
   404     mZeroItemLabel->show();
   420     mZeroItemLabel->show();
   405     if (mCameraButton == NULL) {
   421     if (mCameraButton == NULL) {
   406         mCameraButton = new HbPushButton(this);
   422         mCameraButton = new HbPushButton(this);
   407         mCameraButton->setIcon(HbIcon(GLXICON_CAMERA));
   423         mCameraButton->setIcon(HbIcon(GLXICON_CAMERA));
       
   424         mCameraButton->hide();
   408         connect(mCameraButton, SIGNAL(clicked(bool)), this, SLOT(cameraButtonClicked(bool)));
   425         connect(mCameraButton, SIGNAL(clicked(bool)), this, SLOT(cameraButtonClicked(bool)));
   409     }
   426     }
   410     mCameraButton->setGeometry(QRectF(screenSize.width()/2 - 3*deviceSize.height()/64, midHeight + deviceSize.height()/32, deviceSize.height()/32, deviceSize.height()/32));
   427     if(!XQServiceUtil::isService())
   411     mCameraButton->show();
   428         {
       
   429         mCameraButton->setGeometry(QRectF(screenSize.width()/2 - 3*deviceSize.height()/64, midHeight + deviceSize.height()/32, deviceSize.height()/32, deviceSize.height()/32));
       
   430         mCameraButton->show();
       
   431         }
   412 }
   432 }
   413 
   433 
   414 void GlxGridView::populated()
   434 void GlxGridView::populated()
   415 {
   435 {
   416     showItemCount();
   436     showItemCount();
   417 }
       
   418 
       
   419 bool GlxGridView::eventFilter(QObject *obj, QEvent *event)
       
   420 {
       
   421     TRACER("GlxGridView::eventFilter() ");
       
   422     GLX_LOG_INFO1("GlxGridView::eventFilter() %d event type", event->type());
       
   423     
       
   424     if ( event->type() ==  QEvent::ApplicationActivate ) {
       
   425         emit actionTriggered( EGlxCmdAppForeground );
       
   426     }
       
   427     if ( event->type() ==  QEvent::ApplicationDeactivate ) {
       
   428         emit actionTriggered( EGlxCmdAppBackground );
       
   429     }
       
   430     return HbView::eventFilter(obj,event);
       
   431 }
   437 }
   432 
   438 
   433 void GlxGridView::handleUserAction(qint32 commandId)
   439 void GlxGridView::handleUserAction(qint32 commandId)
   434 {
   440 {
   435     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" );
   441     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" );
   438             mWidget->selectAll();
   444             mWidget->selectAll();
   439             break;
   445             break;
   440 
   446 
   441         case EGlxCmdUnMarkAll :
   447         case EGlxCmdUnMarkAll :
   442             mWidget->clearSelection();
   448             mWidget->clearSelection();
   443             break;        
   449             break;
   444 
   450 
   445         default :
   451         default :
   446             break;
   452             break;
   447     }    
   453     }
   448 }
   454 }
   449 
   455 
   450 QItemSelectionModel * GlxGridView::getSelectionModel()
   456 QItemSelectionModel * GlxGridView::getSelectionModel()
   451 {
   457 {
   452     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" );
   458     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" );
   462         return mWidget;
   468         return mWidget;
   463     }
   469     }
   464 
   470 
   465     if ( transitionEffect == GRID_TO_FULLSCREEN )
   471     if ( transitionEffect == GRID_TO_FULLSCREEN )
   466         {
   472         {
   467         QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole );    
   473         QVariant variant = mModel->data( mModel->index(0,0), GlxFocusIndexRole );
   468         if ( variant.isValid() &&  variant.canConvert<int> () ) 
   474         if ( variant.isValid() &&  variant.canConvert<int> () )
   469             {
   475             {
   470             selIndex = variant.value<int>();  
   476             selIndex = variant.value<int>();
   471             } 
   477             }
   472         else 
   478         else
   473             {
   479             {
   474             return mWidget;
   480             return mWidget;
   475             }
   481             }
   476         QVariant variantimage = mModel->data(mModel->index(selIndex,0),Qt::DecorationRole);
   482         QVariant variantimage = mModel->data(mModel->index(selIndex,0),Qt::DecorationRole);
   477         if ( variantimage.isValid() &&  variantimage.canConvert<HbIcon> () )
   483         if ( variantimage.isValid() &&  variantimage.canConvert<HbIcon> () )
   491             HbIcon tmp = HbIcon( QIcon(tempPixmap)) ;
   497             HbIcon tmp = HbIcon( QIcon(tempPixmap)) ;
   492             mIconItem->setIcon(tmp);
   498             mIconItem->setIcon(tmp);
   493             mIconItem->setPos(itemRect.topLeft());
   499             mIconItem->setPos(itemRect.topLeft());
   494             mIconItem->setZValue(mIconItem->zValue() + 20);
   500             mIconItem->setZValue(mIconItem->zValue() + 20);
   495             mIconItem->show();
   501             mIconItem->show();
   496             return mIconItem;   
   502             return mIconItem;
   497             }
   503             }
   498         else
   504         else
   499             {
   505             {
   500             return mWidget;
   506             return mWidget;
   501             }
   507             }
   503 
   509 
   504     if ( transitionEffect == GRID_TO_ALBUMLIST  || transitionEffect == ALBUMLIST_TO_GRID ){
   510     if ( transitionEffect == GRID_TO_ALBUMLIST  || transitionEffect == ALBUMLIST_TO_GRID ){
   505         return mWidget;
   511         return mWidget;
   506     }
   512     }
   507     OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT );
   513     OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT );
   508     return NULL;    
   514     return NULL;
   509 }
   515 }
   510 
   516 
   511 void GlxGridView::loadGridView()
   517 void GlxGridView::loadGridView()
   512 {
   518 {
   513     OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY );
   519     OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY );
   516         mWindow->viewport()->grabGesture(Qt::PanGesture);
   522         mWindow->viewport()->grabGesture(Qt::PanGesture);
   517         mWindow->viewport()->grabGesture(Qt::TapGesture);
   523         mWindow->viewport()->grabGesture(Qt::TapGesture);
   518         mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture);
   524         mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture);
   519         mWidget = new HgGrid(orient);
   525         mWidget = new HgGrid(orient);
   520         mWidget->setLongPressEnabled(true);
   526         mWidget->setLongPressEnabled(true);
   521         mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);  
   527         mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);
   522         setWidget( mWidget );  
   528         setWidget( mWidget );
   523         addViewConnection();
   529         addViewConnection();
   524         hideorshowitems(orient);
   530         hideorshowitems(orient);
   525     }
   531     }
   526     OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
   532     OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
   527 }
   533 }
   530 {
   536 {
   531     hideorshowitems(orient);
   537     hideorshowitems(orient);
   532 }
   538 }
   533 void GlxGridView::hideorshowitems(Qt::Orientation orient)
   539 void GlxGridView::hideorshowitems(Qt::Orientation orient)
   534 {
   540 {
   535     if (mWidget && mWidget->selectionMode() == HgWidget::NoSelection) {
   541     if ( mWidget && mWidget->selectionMode() == HgWidget::NoSelection ) {
   536         if(orient == Qt::Horizontal)
   542         if( orient == Qt::Horizontal ) {
   537             {
       
   538 			setItemVisible(Hb::AllItems, FALSE) ;
   543 			setItemVisible(Hb::AllItems, FALSE) ;
   539         	setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
   544         	setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
       
   545             //To:Do remove it later, currently it is solving the problem of status bar is not
       
   546             //visible when tap on the screen first time
       
   547         	setItemVisible(Hb::AllItems, FALSE) ;
       
   548         	setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
   540         	showItemCount();
   549         	showItemCount();
   541             if (mUiOnButton)
   550             if (mUiOnButton) {
   542                 {
       
   543                 mUiOnButton->show();
   551                 mUiOnButton->show();
   544                 }
   552             }
   545             }
   553         }
   546         else
   554         else {
   547             {
       
   548             showHbItems();
   555             showHbItems();
   549             }
   556         }
   550     }
   557     }
   551 
   558     else if (mWidget && mWidget->selectionMode() == HgWidget::MultiSelection) {
   552     if (mWidget && mWidget->selectionMode() == HgWidget::MultiSelection) {
       
   553         setItemVisible(Hb::TitleBarItem, FALSE) ;
   559         setItemVisible(Hb::TitleBarItem, FALSE) ;
   554         if (mUiOnButton) {
   560         if (mUiOnButton) {
   555             mUiOnButton->hide();
   561             mUiOnButton->hide();
   556         }
   562         }
   557         if (mCountItem) {
   563         if (mCountItem) {
   576 
   582 
   577 void GlxGridView::scrolltofocus()
   583 void GlxGridView::scrolltofocus()
   578 {
   584 {
   579     if(mModelWrapper && mWidget)
   585     if(mModelWrapper && mWidget)
   580         {
   586         {
   581         QVariant variant = mModelWrapper->data( mModelWrapper->index(0,0), GlxFocusIndexRole );    
   587         QVariant variant = mModelWrapper->data( mModelWrapper->index(0,0), GlxFocusIndexRole );
   582         if ( variant.isValid() &&  variant.canConvert<int> () ) 
   588         if ( variant.isValid() &&  variant.canConvert<int> () )
   583             {
   589             {
   584             mWidget->scrollTo( mModelWrapper->index( variant.value<int>(),0) );
   590             mWidget->scrollTo( mModelWrapper->index( variant.value<int>(),0) );
   585             mModel->setData(mModel->index(0,0),variant.value<int>(),GlxVisualWindowIndex);
   591             mModel->setData(mModel->index(0,0),variant.value<int>(),GlxVisualWindowIndex);
   586             }
   592             }
   587         }
   593         }
   588 }
   594 }
   589 
   595 
   590 QVariant  GlxGridView::itemChange (GraphicsItemChange change, const QVariant &value) 
   596 QVariant  GlxGridView::itemChange (GraphicsItemChange change, const QVariant &value)
   591     {
   597     {
   592     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMCHANGE, "GlxGridView::itemChange" );    
   598     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ITEMCHANGE, "GlxGridView::itemChange" );
   593     static bool isEmit = true;
   599     static bool isEmit = true;
   594     if ( isEmit && change == QGraphicsItem::ItemVisibleHasChanged && value.toBool()  ) {
   600     if ( isEmit && change == QGraphicsItem::ItemVisibleHasChanged && value.toBool()  ) {
   595     emit actionTriggered( EGlxCmdSetupItem );
   601     emit actionTriggered( EGlxCmdSetupItem );
   596     isEmit = false;
   602     isEmit = false;
   597     }
   603     }
   625 
   631 
   626 
   632 
   627 void GlxGridView::itemSelected(const QModelIndex &  index)
   633 void GlxGridView::itemSelected(const QModelIndex &  index)
   628 {
   634 {
   629     OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() );
   635     OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() );
   630     if ( mWidget->selectionMode() == HgWidget::MultiSelection )
   636     if ( mWidget->selectionMode() == HgWidget::MultiSelection ) {
   631         { 
       
   632         return ;
   637         return ;
   633         }    
   638     }
   634    if(XQServiceUtil::isService()){
   639     if(XQServiceUtil::isService()){
   635         emit gridItemSelected(index);
   640         emit gridItemSelected(index);
   636         return;
   641         return;
   637     }    
   642     }
   638     OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" );    
   643     OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" );
   639     if ( mModel ) 
   644     if ( mModel ) {
   640         {
       
   641         mModel->setData( index, index.row(), GlxFocusIndexRole );
   645         mModel->setData( index, index.row(), GlxFocusIndexRole );
   642         }
   646     }
   643     setItemVisible(Hb::AllItems, FALSE);
   647     emit actionTriggered( EGlxCmdFullScreenOpen );
   644     emit actionTriggered( EGlxCmdFullScreenOpen ); 
       
   645     OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START );
   648     OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START );
   646 }
   649 }
   647 
   650 
   648 void GlxGridView::scrollingStarted()
   651 void GlxGridView::scrollingStarted()
   649 {
   652 {
   680         }
   683         }
   681     QModelIndex index = visibleIndex.at(0);
   684     QModelIndex index = visibleIndex.at(0);
   682     if (  index.row() < 0 || index.row() >= mModel->rowCount() )
   685     if (  index.row() < 0 || index.row() >= mModel->rowCount() )
   683         {
   686         {
   684         return;
   687         return;
   685         }    
   688         }
   686     if(mModel)
   689     if(mModel)
   687         {
   690         {
   688         mModel->setData( index, index.row(), GlxVisualWindowIndex);
   691         mModel->setData( index, index.row(), GlxVisualWindowIndex);
   689         mModel->setData( index, index.row(), GlxFocusIndexRole );
   692         mModel->setData( index, index.row(), GlxFocusIndexRole );
   690         }
   693         }
   720 }
   723 }
   721 
   724 
   722 void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords)
   725 void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords)
   723 {
   726 {
   724     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" );
   727     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" );
   725      
   728 
   726      if ( mWidget->selectionMode() == HgWidget::MultiSelection )
   729      if ( mWidget->selectionMode() == HgWidget::MultiSelection )
   727          { 
   730          {
   728          return;
   731          return;
   729          }     
   732          }
   730      if ( mModel ) 
   733      if ( mModel )
   731          {
   734          {
   732          mModel->setData( index, index.row(), GlxFocusIndexRole );
   735          mModel->setData( index, index.row(), GlxFocusIndexRole );
   733          }     
   736          }
   734      emit itemSpecificMenuTriggered(viewId(),coords);
   737      emit itemSpecificMenuTriggered(viewId(),coords);
   735 }
   738 }
   736 
   739 
   737 void GlxGridView::uiButtonClicked(bool /*checked*/)
   740 void GlxGridView::uiButtonClicked(bool /*checked*/)
   738 {
   741 {