ui/views/gridview/src/glxgridview.cpp
changeset 33 1ee2af37811f
parent 29 2c833fc9e98f
child 36 6481344a6d67
equal deleted inserted replaced
29:2c833fc9e98f 33:1ee2af37811f
    24 #include <hbpushbutton.h>
    24 #include <hbpushbutton.h>
    25 #include <HbToolBar> // Temp
    25 #include <HbToolBar> // Temp
    26 #include <hbiconitem.h>
    26 #include <hbiconitem.h>
    27 #include <hbicon.h>
    27 #include <hbicon.h>
    28 #include <xqserviceutil.h>
    28 #include <xqserviceutil.h>
       
    29 #include <hbcheckbox.h>
       
    30 #include <hblabel.h>
       
    31 #include <QString>
       
    32 #include <hbframeitem.h>
    29 
    33 
    30 //User Includes
    34 //User Includes
    31 #include "glxviewids.h"
    35 #include "glxviewids.h"
    32 #include "glxgridview.h"
    36 #include "glxgridview.h"
    33 #include "glxmodelparm.h"
    37 #include "glxmodelparm.h"
    34 #include "glxcommandhandlers.hrh"
    38 #include "glxcommandhandlers.hrh"
    35 
    39 #include "glxicondefs.h"
       
    40 #include "glxlocalisationstrings.h"
    36 
    41 
    37 #include "OstTraceDefinitions.h"
    42 #include "OstTraceDefinitions.h"
    38 #ifdef OST_TRACE_COMPILER_IN_USE
    43 #ifdef OST_TRACE_COMPILER_IN_USE
    39 #include "glxgridviewTraces.h"
    44 #include "glxgridviewTraces.h"
    40 #endif
    45 #endif
    45       mModel ( NULL), 
    50       mModel ( NULL), 
    46       mWidget(NULL),
    51       mWidget(NULL),
    47       mSelectionModel(NULL),
    52       mSelectionModel(NULL),
    48       mModelWrapper(NULL),
    53       mModelWrapper(NULL),
    49       mUiOnButton(NULL),
    54       mUiOnButton(NULL),
       
    55       mCameraButton(NULL),
    50       mScrolling(FALSE),
    56       mScrolling(FALSE),
    51       mIconItem(NULL)
    57       mIconItem(NULL),
       
    58       mMarkCheckBox(NULL),
       
    59       mCountItem(NULL),
       
    60       mMainLabel(NULL),
       
    61       mCountLabel(NULL),
       
    62       mZeroItemLabel(NULL),
       
    63       mAlbumName(NULL)
    52 {
    64 {
    53     OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY );
    65     OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY );
    54     mModelWrapper = new GlxModelWrapper();
    66     mModelWrapper = new GlxModelWrapper();
    55     mModelWrapper->setRoles(GlxQImageSmall);
    67     mModelWrapper->setRoles(GlxQImageSmall);
    56     mIconItem = new HbIconItem(this);
    68     mIconItem = new HbIconItem(this);
    59 
    71 
    60 void GlxGridView::activate()
    72 void GlxGridView::activate()
    61 {
    73 {
    62     OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY );
    74     OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY );
    63     if(mUiOnButton == NULL) {
    75     if(mUiOnButton == NULL) {
    64         mUiOnButton = new HbPushButton("UI",this);
    76         mUiOnButton = new HbPushButton(this);
    65         connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
    77         connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
    66         mUiOnButton->setGeometry(QRectF(610,0,15,15));
    78         mUiOnButton->setGeometry(QRectF(590,0,40,40));
    67         mUiOnButton->setZValue(1);
    79         mUiOnButton->setZValue(1);
       
    80         mUiOnButton->setIcon(HbIcon(GLXICON_WALL_UI_ON));
    68         mUiOnButton->hide();
    81         mUiOnButton->hide();
    69     }
    82     }
    70     loadGridView();
    83     loadGridView();
       
    84 	connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection);
       
    85     if(mCountItem == NULL) {
       
    86         mCountItem = new HbLabel(this);        
       
    87         HbFrameItem *frame = new HbFrameItem(this); //graphics for mCountItem
       
    88         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
    89         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
    90         frame->graphicsItem()->setOpacity(1);
       
    91         mCountItem->setBackgroundItem(frame->graphicsItem(),-1);
       
    92     }
    71     OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
    93     OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
    72 }
    94 }
    73 
    95 
    74 void GlxGridView::deActivate()
    96 void GlxGridView::deActivate()
    75 {
    97 {
    76     OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
    98     OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
    77     if (mUiOnButton && mUiOnButton->isVisible())
    99     mScrolling = FALSE;
       
   100     if (mUiOnButton)
    78         {
   101         {
    79         mUiOnButton->hide();
   102         mUiOnButton->hide();
    80         }    
   103         }    
    81     if(mIconItem)
   104     if(mIconItem)
    82         {
   105         {
    83         mIconItem->hide();
   106         mIconItem->hide();
    84         mIconItem->resetTransform();
   107         mIconItem->resetTransform();
    85         mIconItem->setOpacity(0);
   108         mIconItem->setOpacity(0);
    86         mIconItem->setZValue(mIconItem->zValue()-20);
   109         mIconItem->setZValue(mIconItem->zValue()-20);
    87         }
   110         }
       
   111     if (mCountItem) 
       
   112         {
       
   113         mCountItem->hide();
       
   114         }
       
   115     if (mAlbumName) 
       
   116         {
       
   117         mAlbumName->hide();
       
   118         }
       
   119     if(mZeroItemLabel) 
       
   120         {
       
   121         mZeroItemLabel->hide();
       
   122         }
       
   123     if(mCameraButton) 
       
   124         {
       
   125         mCameraButton->hide();
       
   126         }
       
   127     disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
    88     OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
   128     OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
    89 }
   129 }
    90 
   130 
    91 void GlxGridView::initializeView(QAbstractItemModel *model)
   131 void GlxGridView::initializeView(QAbstractItemModel *model)
    92 {
   132 {
    93     activate();
   133     activate();
    94     setModel(model);
   134     setModel(model);
    95 }
   135 }
    96 
   136 
    97 void GlxGridView::setModel(QAbstractItemModel *model) 
   137 void GlxGridView::clearCurrentModel()
       
   138 {
       
   139     if ( mModel ) {
       
   140         disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount()));
       
   141         disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount()));
       
   142         disconnect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel()));
       
   143         disconnect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString)));
       
   144         disconnect(mModel, SIGNAL(populated()), this, SLOT( populated()));
       
   145         mModel = NULL ;
       
   146     }
       
   147 }
       
   148 
       
   149 void GlxGridView::initializeNewModel()
       
   150 {
       
   151     if ( mModel ) {
       
   152         connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(showItemCount()));
       
   153         connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(showItemCount()));
       
   154         connect(mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel()));
       
   155         connect(mModel, SIGNAL(albumTitleAvailable(QString)), this, SLOT(showAlbumTitle(QString)));
       
   156         connect(mModel, SIGNAL(populated()), this, SLOT( populated()));
       
   157     }
       
   158 }
       
   159 
       
   160 void GlxGridView::setModel(QAbstractItemModel *model)
    98 {
   161 {
    99     OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY );
   162     OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY );
   100     if(model)
   163     if(model)
   101         {
   164         {
   102         mModel =  model;
   165         clearCurrentModel();
       
   166         mModel = model;
       
   167         initializeNewModel();
   103         QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage);
   168         QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage);
   104         if (mWidget && variantimage.isValid() &&  variantimage.canConvert<QImage> () )
   169         if (mWidget && variantimage.isValid() &&  variantimage.canConvert<QImage> () )
   105             {
   170             {
   106             mWidget->setDefaultImage(variantimage.value<QImage>());
   171             mWidget->setDefaultImage(variantimage.value<QImage>());
   107             }
   172             }
   112             mSelectionModel = new QItemSelectionModel(mModelWrapper, this);
   177             mSelectionModel = new QItemSelectionModel(mModelWrapper, this);
   113             connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &)));
   178             connect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &)));
   114             mWidget->setSelectionModel(mSelectionModel);
   179             mWidget->setSelectionModel(mSelectionModel);
   115             }
   180             }
   116         scrolltofocus();  // Need to do it here ?
   181         scrolltofocus();  // Need to do it here ?
       
   182         showItemCount();
   117         }
   183         }
   118     OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT );
   184     OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT );
   119 }
   185 }
   120 
   186 
   121 void GlxGridView::visibleIndexChanged(const QModelIndex& current, const QModelIndex& previous)
   187 void GlxGridView::visibleIndexChanged(const QModelIndex& current, const QModelIndex& previous)
   140 
   206 
   141 void GlxGridView::enableMarking()
   207 void GlxGridView::enableMarking()
   142 {
   208 {
   143     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
   209     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
   144     mWidget->setSelectionMode(HgWidget::MultiSelection);
   210     mWidget->setSelectionMode(HgWidget::MultiSelection);
       
   211     if (mMainLabel == NULL) {
       
   212         mMainLabel = new HbLabel("Select Photos", this);        
       
   213         HbFrameItem *frame1 = new HbFrameItem(this);    //graphics for mMainLabel
       
   214         frame1->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   215         frame1->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   216         frame1->graphicsItem()->setOpacity(1);
       
   217         mMainLabel->setBackgroundItem(frame1->graphicsItem(),-1);
       
   218     }
       
   219     if (mMarkCheckBox == NULL) {
       
   220         mMarkCheckBox = new HbCheckBox(GLX_OPTION_MARK_ALL, this);        
       
   221         HbFrameItem *frame2 = new HbFrameItem(this);    //graphics for mMarkCheckBox
       
   222         frame2->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   223         frame2->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   224         frame2->graphicsItem()->setOpacity(1);
       
   225         mMarkCheckBox->setBackgroundItem(frame2->graphicsItem(),-1);
       
   226     }
       
   227     if (mCountLabel == NULL) {
       
   228         mCountLabel = new HbLabel(this);        
       
   229         HbFrameItem *frame3 = new HbFrameItem(this);    //graphics for mCountLabel
       
   230         frame3->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   231         frame3->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   232         frame3->graphicsItem()->setOpacity(1);
       
   233         mCountLabel->setBackgroundItem(frame3->graphicsItem(),-1);
       
   234     }
       
   235 
       
   236     hideorshowitems(mWindow->orientation());
       
   237 
       
   238     connect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
       
   239     connect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
       
   240 
   145 }
   241 }
   146 
   242 
   147 void GlxGridView::disableMarking() 
   243 void GlxGridView::disableMarking() 
   148 {
   244 {
   149     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
   245     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
   150     mWidget->setSelectionMode(HgWidget::NoSelection);
   246     mWidget->setSelectionMode(HgWidget::NoSelection);
       
   247     disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
       
   248     disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
       
   249     if (mMainLabel) {
       
   250         mMainLabel->hide();
       
   251     }
       
   252     if (mMarkCheckBox) {
       
   253         mMarkCheckBox->setCheckState(Qt::Unchecked);
       
   254         mMarkCheckBox->hide();
       
   255     }
       
   256     if (mCountLabel) {
       
   257         mCountLabel->hide();
       
   258     }
       
   259 
       
   260     hideorshowitems(mWindow->orientation());
       
   261 }
       
   262 
       
   263 void GlxGridView::stateChanged(int state)
       
   264 {
       
   265     if(state)
       
   266         handleUserAction(EGlxCmdMarkAll);
       
   267     else
       
   268         handleUserAction(EGlxCmdUnMarkAll);
       
   269 }
       
   270 
       
   271 void GlxGridView::showMarkedItemCount()
       
   272 {
       
   273     int count = mModel->rowCount();
       
   274     QModelIndexList indexList = mWidget->selectionModel()->selectedIndexes();
       
   275     int markItemCount = indexList.count();
       
   276 
       
   277     QString text= QString("%1 / %2").arg( markItemCount ).arg( count );
       
   278     mCountLabel->setPlainText( text );
       
   279 }
       
   280 
       
   281 void GlxGridView::showItemCount()
       
   282 {
       
   283     int count = 0;
       
   284     if(mModel) {
       
   285         count = mModel->rowCount();
       
   286         QSize deviceSize = HbDeviceProfile::current().logicalSize();
       
   287         QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
       
   288                                                                        : QSize( deviceSize.height(), deviceSize.width() )  ;
       
   289         if(count) {
       
   290             if(mZeroItemLabel) {
       
   291                 mZeroItemLabel->hide();
       
   292             }
       
   293             if(mCameraButton) {
       
   294                 mCameraButton->hide();
       
   295             }
       
   296             if(isItemVisible(Hb::TitleBarItem)) {
       
   297                 QString text;
       
   298                 if (getSubState() == ALL_ITEM_S) {
       
   299 					if (mAlbumName) {
       
   300                     	mAlbumName->hide();
       
   301 					}
       
   302                     mCountItem->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
       
   303                     text = QString("%1 Items").arg( count );
       
   304                     mCountItem->setPlainText( text );
       
   305                     mCountItem->setAlignment(Qt::AlignLeft);
       
   306                     mCountItem->show();
       
   307                 }
       
   308                 else if (getSubState() == ALBUM_ITEM_S) {
       
   309                     mCountItem->hide();
       
   310                     QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
       
   311                     if (variant.toString() != NULL) {
       
   312                         showAlbumTitle(variant.toString());
       
   313                     }
       
   314                 }
       
   315             }
       
   316             else {
       
   317                 if (mCountItem) {
       
   318                     mCountItem->hide();
       
   319                 }
       
   320                 if (mAlbumName) {
       
   321                     mAlbumName->hide();
       
   322                 }
       
   323             }
       
   324 
       
   325         }
       
   326         else {
       
   327             bool populated = FALSE;
       
   328             QVariant variant = mModel->data(mModel->index(0,0),GlxPopulated);
       
   329             if (variant.isValid() &&  variant.canConvert<bool>() )
       
   330                 {
       
   331                 populated = variant.value<bool>();
       
   332                 }
       
   333             if(populated) {
       
   334                 if (mCountItem) {
       
   335                     mCountItem->hide();
       
   336                 }
       
   337                 if (mAlbumName) {
       
   338                     mAlbumName->hide();
       
   339                 }
       
   340                 
       
   341                 showNoImageString();            
       
   342                 
       
   343                 if (getSubState() == ALBUM_ITEM_S) {                
       
   344                     QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
       
   345                     if (variant.toString() != NULL) {
       
   346                         showAlbumTitle(variant.toString());
       
   347                     }
       
   348                 }
       
   349             }
       
   350         }
       
   351     }
       
   352 }
       
   353 
       
   354 void GlxGridView::showAlbumTitle(QString aTitle)
       
   355 {
       
   356     int count = mModel->rowCount();
       
   357     QSize deviceSize = HbDeviceProfile::current().logicalSize();
       
   358     QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
       
   359                                                                    : QSize( deviceSize.height(), deviceSize.width() )  ;
       
   360     if(mAlbumName == NULL) {
       
   361         mAlbumName = new HbLabel(this);            
       
   362         HbFrameItem *frame = new HbFrameItem(this); //graphics for mAlbumName
       
   363         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   364         frame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
       
   365         frame->graphicsItem()->setOpacity(1);
       
   366         mAlbumName->setBackgroundItem(frame->graphicsItem(),-1);
       
   367     }
       
   368     
       
   369     if(count && isItemVisible(Hb::TitleBarItem)) {        
       
   370         mAlbumName->setGeometry(QRectF(0,0,screenSize.width()/2,deviceSize.height()/24));
       
   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));
       
   382         QString text = QString(aTitle);
       
   383         mAlbumName->setPlainText( text );
       
   384         mAlbumName->show();
       
   385     }
       
   386 }
       
   387 
       
   388 void GlxGridView::showNoImageString()
       
   389 {
       
   390     qreal chromeHeight = 0.0;
       
   391     QSize deviceSize = HbDeviceProfile::current().logicalSize();
       
   392     QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
       
   393                                                                    : QSize( deviceSize.height(), deviceSize.width() )  ;
       
   394     qreal midHeight = screenSize.height()/2;
       
   395     if (isItemVisible(Hb::TitleBarItem)) {
       
   396         style()->parameter("hb-param-widget-chrome-height", chromeHeight);
       
   397         midHeight -= chromeHeight;
       
   398     }
       
   399     if (mZeroItemLabel == NULL) {                
       
   400         mZeroItemLabel = new HbLabel("(No Images)\n To capture images Open", this);
       
   401     }
       
   402     mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32));
       
   403     mZeroItemLabel->setAlignment(Qt::AlignHCenter);
       
   404     mZeroItemLabel->show();
       
   405     if (mCameraButton == NULL) {
       
   406         mCameraButton = new HbPushButton(this);
       
   407         mCameraButton->setIcon(HbIcon(GLXICON_CAMERA));
       
   408         connect(mCameraButton, SIGNAL(clicked(bool)), this, SLOT(cameraButtonClicked(bool)));
       
   409     }
       
   410     mCameraButton->setGeometry(QRectF(screenSize.width()/2 - 3*deviceSize.height()/64, midHeight + deviceSize.height()/32, deviceSize.height()/32, deviceSize.height()/32));
       
   411     mCameraButton->show();
       
   412 }
       
   413 
       
   414 void GlxGridView::populated()
       
   415 {
       
   416     showItemCount();
   151 }
   417 }
   152 
   418 
   153 void GlxGridView::handleUserAction(qint32 commandId)
   419 void GlxGridView::handleUserAction(qint32 commandId)
   154 {
   420 {
   155     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" );
   421     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" );
   237         mWindow->viewport()->grabGesture(Qt::TapGesture);
   503         mWindow->viewport()->grabGesture(Qt::TapGesture);
   238         mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture);
   504         mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture);
   239         mWidget = new HgGrid(orient);
   505         mWidget = new HgGrid(orient);
   240         mWidget->setLongPressEnabled(true);
   506         mWidget->setLongPressEnabled(true);
   241         mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);  
   507         mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);  
   242         //mWidget->setItemSize(QSizeF(120,120));
       
   243         setWidget( mWidget );  
   508         setWidget( mWidget );  
   244         addViewConnection();
   509         addViewConnection();
   245         //hideorshowitems(orient);
   510         hideorshowitems(orient);
   246     }
   511     }
   247     OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
   512     OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
   248 }
   513 }
   249 
   514 
   250 void GlxGridView::orientationchanged(Qt::Orientation orient)
   515 void GlxGridView::orientationchanged(Qt::Orientation orient)
   251 {
   516 {
   252     hideorshowitems(orient);
   517     hideorshowitems(orient);
   253 }
   518 }
   254 void GlxGridView::hideorshowitems(Qt::Orientation orient)
   519 void GlxGridView::hideorshowitems(Qt::Orientation orient)
   255 {
   520 {
   256     if(orient == Qt::Horizontal) 
   521     if (mWidget->selectionMode() == HgWidget::NoSelection) {
   257         {
   522         if(orient == Qt::Horizontal)
   258         if (mUiOnButton)
   523             {
   259             {
   524 			setItemVisible(Hb::AllItems, FALSE) ;
   260             mUiOnButton->show();
   525         	setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
   261             }
   526         	showItemCount();
   262         setItemVisible(Hb::AllItems, FALSE) ;
   527             if (mUiOnButton)
   263         }
   528                 {
   264     else
   529                 mUiOnButton->show();
   265         {
   530                 }
   266         if (mUiOnButton)
   531             }
   267             {
   532         else
       
   533             {
       
   534             showHbItems();
       
   535             }
       
   536     }
       
   537 
       
   538     if (mWidget->selectionMode() == HgWidget::MultiSelection) {
       
   539         setItemVisible(Hb::TitleBarItem, FALSE) ;
       
   540         if (mUiOnButton) {
   268             mUiOnButton->hide();
   541             mUiOnButton->hide();
   269             }
   542         }
   270         setItemVisible(Hb::AllItems, TRUE) ;
   543         if (mCountItem) {
   271         }
   544             mCountItem->hide();
       
   545         }
       
   546         if (mAlbumName) {
       
   547             mAlbumName->hide();
       
   548         }
       
   549         QSize deviceSize = HbDeviceProfile::current().logicalSize();
       
   550         QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
       
   551                                                                        : QSize( deviceSize.height(), deviceSize.width() )  ;
       
   552         mMainLabel->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
       
   553         mMarkCheckBox->setGeometry(QRectF(0,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/72));
       
   554         mCountLabel->setGeometry(QRectF(screenSize.width()/2,deviceSize.height()/24,screenSize.width()/2,deviceSize.height()/12 - 3));
       
   555         mCountLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
       
   556         mMainLabel->show();
       
   557         mMarkCheckBox->show();
       
   558         mCountLabel->show();
       
   559         showMarkedItemCount();
       
   560     }
   272 }
   561 }
   273 
   562 
   274 void GlxGridView::scrolltofocus()
   563 void GlxGridView::scrolltofocus()
   275 {
   564 {
   276     if(mModelWrapper && mWidget)
   565     if(mModelWrapper && mWidget)
   296     }
   585     }
   297 
   586 
   298 void GlxGridView::addViewConnection()
   587 void GlxGridView::addViewConnection()
   299 {
   588 {
   300     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" );
   589     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" );
   301     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
       
   302     //connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
   590     //connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
   303     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
   591     connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
   304     connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &)));
   592     connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &)));
   305     connect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
   593     connect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
   306     connect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
   594     connect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
   310 void GlxGridView::removeViewConnection ()
   598 void GlxGridView::removeViewConnection ()
   311 {
   599 {
   312     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" );
   600     OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" );
   313     if(mWidget)
   601     if(mWidget)
   314         {
   602         {
   315         disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
       
   316         //disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
   603         //disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
   317         disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
   604         disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
   318         disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &)));
   605         disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &)));
   319         disconnect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
   606         disconnect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
   320         disconnect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
   607         disconnect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
   344     OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START );
   631     OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START );
   345 }
   632 }
   346 
   633 
   347 void GlxGridView::scrollingStarted()
   634 void GlxGridView::scrollingStarted()
   348 {
   635 {
   349     if ((mWindow->orientation() == Qt::Horizontal))
   636     if ((mWindow->orientation() == Qt::Horizontal) && mWidget->selectionMode() == HgWidget::NoSelection)
   350         {
   637         {
   351         setItemVisible(Hb::AllItems, FALSE) ;
   638         setItemVisible(Hb::AllItems, FALSE) ;
   352         }    
   639         setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
       
   640         if (mUiOnButton)
       
   641             {
       
   642             mUiOnButton->hide();
       
   643             }
       
   644 		if (mCountItem) {
       
   645 			mCountItem->hide();
       
   646 		}
       
   647 		if (mAlbumName) {
       
   648             mAlbumName->hide();
       
   649 		}
       
   650     }
       
   651 
   353     mScrolling = TRUE;
   652     mScrolling = TRUE;
   354 }
   653 }
   355 
   654 
   356 void GlxGridView::scrollingEnded()
   655 void GlxGridView::scrollingEnded()
   357 {
   656 {
   358     mScrolling = FALSE;
   657     mScrolling = FALSE;
       
   658     if (mUiOnButton && (mWindow->orientation() == Qt::Horizontal))
       
   659         {
       
   660         mUiOnButton->show();
       
   661         }
   359     QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices();
   662     QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices();
   360     if (visibleIndex.count() <= 0)
   663     if (visibleIndex.count() <= 0)
   361         {
   664         {
   362         return;
   665         return;
   363         }
   666         }
   367         return;
   670         return;
   368         }    
   671         }    
   369     if(mModel)
   672     if(mModel)
   370         {
   673         {
   371         mModel->setData( index, index.row(), GlxVisualWindowIndex);
   674         mModel->setData( index, index.row(), GlxVisualWindowIndex);
       
   675         mModel->setData( index, index.row(), GlxFocusIndexRole );
   372         }
   676         }
   373 }
   677 }
   374 
   678 
   375 GlxGridView::~GlxGridView()
   679 GlxGridView::~GlxGridView()
   376 {
   680 {
   385     delete mModelWrapper;
   689     delete mModelWrapper;
   386     if(mUiOnButton) {
   690     if(mUiOnButton) {
   387         disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
   691         disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
   388         delete mUiOnButton;
   692         delete mUiOnButton;
   389     }
   693     }
       
   694     if(mCameraButton) {
       
   695         disconnect(mCameraButton, SIGNAL(clicked()), this, SLOT(cameraButtonClicked()));
       
   696         delete mCameraButton;
       
   697     }
   390     delete mIconItem;
   698     delete mIconItem;
       
   699     delete mCountItem;
       
   700     delete mAlbumName;
       
   701     delete mMainLabel;
       
   702     delete mMarkCheckBox;
       
   703     delete mCountLabel;
       
   704     delete mZeroItemLabel;
   391     OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT );
   705     OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT );
   392 }
   706 }
   393 
   707 
   394 void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords)
   708 void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords)
   395 {
   709 {
   406      emit itemSpecificMenuTriggered(viewId(),coords);
   720      emit itemSpecificMenuTriggered(viewId(),coords);
   407 }
   721 }
   408 
   722 
   409 void GlxGridView::uiButtonClicked(bool /*checked*/)
   723 void GlxGridView::uiButtonClicked(bool /*checked*/)
   410 {
   724 {
   411     if (isItemVisible(Hb::TitleBarItem))  // W16  All item is Not Working , So Temp Fix
   725     showHbItems();
   412         {
   726 }
   413         setItemVisible(Hb::AllItems, FALSE) ;
   727 
   414         }
   728 void GlxGridView::showHbItems()
   415     else
   729 {
   416         {
       
   417         setItemVisible(Hb::AllItems, TRUE) ;
   730         setItemVisible(Hb::AllItems, TRUE) ;
   418         }
   731     setViewFlags(viewFlags() &~ HbView::ViewTitleBarHidden &~ HbView::ViewStatusBarHidden);
   419 }
   732         showItemCount();
   420 
   733 		toolBar()->resetTransform(); // Temp, this is for HbToolbar issue to get fixed
       
   734         toolBar()->show();
       
   735     if (mUiOnButton)
       
   736         {
       
   737         mUiOnButton->hide();
       
   738         }
       
   739 }
       
   740 
       
   741 void GlxGridView::cameraButtonClicked(bool /*checked*/)
       
   742 {
       
   743     emit actionTriggered(EGlxCmdCameraOpen);
       
   744 }
       
   745 
       
   746 int GlxGridView::getSubState()
       
   747 {
       
   748     int substate = NO_GRID_S;
       
   749     QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );
       
   750     if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
       
   751         substate = variant.value<int>();
       
   752     }
       
   753     return substate;
       
   754 }
       
   755