ui/views/gridview/src/glxgridview.cpp
author hgs
Thu, 14 Oct 2010 17:54:23 +0530
changeset 72 0a8e959402e5
parent 71 27f2d7aec52a
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:   ?Description
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
//Includes
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <hbmainwindow.h>
40
hgs
parents: 26
diff changeset
    22
#include <hggrid.h>
hgs
parents: 26
diff changeset
    23
#include <glxmodelwrapper.h>
hgs
parents: 26
diff changeset
    24
#include <hbpushbutton.h>
65
hgs
parents: 58
diff changeset
    25
#include <HbToolBar> 
hgs
parents: 58
diff changeset
    26
#include <HbAction>
40
hgs
parents: 26
diff changeset
    27
#include <hbiconitem.h>
hgs
parents: 26
diff changeset
    28
#include <hbicon.h>
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <xqserviceutil.h>
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    30
#include <hbcheckbox.h>
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    31
#include <hblabel.h>
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    32
#include <QString>
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    33
#include <hbframeitem.h>
54
hgs
parents: 50
diff changeset
    34
#include <hbgroupbox.h>
hgs
parents: 50
diff changeset
    35
#include <hbparameterlengthlimiter.h>
hgs
parents: 50
diff changeset
    36
#include <QGraphicsLinearLayout>
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
//User Includes
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "glxviewids.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "glxgridview.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "glxmodelparm.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include "glxcommandhandlers.hrh"
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    43
#include "glxicondefs.h"
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    44
#include "glxlocalisationstrings.h"
50
hgs
parents: 45
diff changeset
    45
#include "glxsettinginterface.h"
40
hgs
parents: 26
diff changeset
    46
54
hgs
parents: 50
diff changeset
    47
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include "OstTraceDefinitions.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#ifdef OST_TRACE_COMPILER_IN_USE
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include "glxgridviewTraces.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
#endif
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
72
hgs
parents: 71
diff changeset
    53
GlxGridView::GlxGridView( HbMainWindow *window )
44
hgs
parents: 43
diff changeset
    54
    : GlxView ( GLX_GRIDVIEW_ID ),
72
hgs
parents: 71
diff changeset
    55
      mWindow( window ),
hgs
parents: 71
diff changeset
    56
      mModel ( NULL ),
hgs
parents: 71
diff changeset
    57
      mWidget( NULL ),
hgs
parents: 71
diff changeset
    58
      mSelectionModel( NULL ),
hgs
parents: 71
diff changeset
    59
      mModelWrapper( NULL ),
hgs
parents: 71
diff changeset
    60
      mUiOnButton( NULL ),      
hgs
parents: 71
diff changeset
    61
      mScrolling( FALSE ),
hgs
parents: 71
diff changeset
    62
      mIconItem( NULL ),
hgs
parents: 71
diff changeset
    63
      mBackGroundItem( NULL ),
hgs
parents: 71
diff changeset
    64
      mMarkCheckBox( NULL ),
hgs
parents: 71
diff changeset
    65
      mTotalImagesCountGrpBox( NULL ),
hgs
parents: 71
diff changeset
    66
      mMarkSelectHeading( NULL ),
hgs
parents: 71
diff changeset
    67
      mMarkCountLabel( NULL ),
hgs
parents: 71
diff changeset
    68
      mZeroItemLabel( NULL ),
hgs
parents: 71
diff changeset
    69
      mMarkContainer( NULL ),
hgs
parents: 71
diff changeset
    70
      mMarkingWidget( NULL ),
65
hgs
parents: 58
diff changeset
    71
      mToolBar( NULL ),
hgs
parents: 58
diff changeset
    72
      mCurrentToolBar( NULL )
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    73
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    OstTraceFunctionEntry0( GLXGRIDVIEW_GLXGRIDVIEW_ENTRY );
40
hgs
parents: 26
diff changeset
    75
    mModelWrapper = new GlxModelWrapper();
hgs
parents: 26
diff changeset
    76
    mModelWrapper->setRoles(GlxQImageSmall);
hgs
parents: 26
diff changeset
    77
    mIconItem = new HbIconItem(this);
50
hgs
parents: 45
diff changeset
    78
    mSettings = GlxSettingInterface::instance() ;
54
hgs
parents: 50
diff changeset
    79
    
hgs
parents: 50
diff changeset
    80
    mUiOnButton = new HbPushButton(this);
hgs
parents: 50
diff changeset
    81
    connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
hgs
parents: 50
diff changeset
    82
    mUiOnButton->setGeometry(QRectF(590,0,40,40));
hgs
parents: 50
diff changeset
    83
    mUiOnButton->setZValue(1);
hgs
parents: 50
diff changeset
    84
    mUiOnButton->setIcon(HbIcon(GLXICON_WALL_UI_ON));
hgs
parents: 50
diff changeset
    85
    mUiOnButton->setObjectName( "UiOn Button" );
hgs
parents: 50
diff changeset
    86
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    OstTraceFunctionExit0( GLXGRIDVIEW_GLXGRIDVIEW_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    88
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
void GlxGridView::activate()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    91
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    OstTraceFunctionEntry0( GLXGRIDVIEW_ACTIVATE_ENTRY );
40
hgs
parents: 26
diff changeset
    93
    loadGridView();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    94
	connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)),Qt::UniqueConnection);
72
hgs
parents: 71
diff changeset
    95
    if(mTotalImagesCountGrpBox == NULL) {
hgs
parents: 71
diff changeset
    96
        mTotalImagesCountGrpBox = new HbGroupBox(this);
hgs
parents: 71
diff changeset
    97
        mTotalImagesCountGrpBox->setObjectName( "Count" );
hgs
parents: 71
diff changeset
    98
        mTotalImagesCountGrpBox->hide();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
    99
    }
72
hgs
parents: 71
diff changeset
   100
    resetTransform();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    OstTraceFunctionExit0( GLXGRIDVIEW_ACTIVATE_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   102
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
void GlxGridView::deActivate()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   105
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
    OstTraceFunctionEntry0( GLXGRIDVIEW_DEACTIVATE_ENTRY );
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   107
    mScrolling = FALSE;
43
hgs
parents: 42
diff changeset
   108
    if (mUiOnButton){
40
hgs
parents: 26
diff changeset
   109
        mUiOnButton->hide();
44
hgs
parents: 43
diff changeset
   110
    }
43
hgs
parents: 42
diff changeset
   111
    if(mIconItem) {
40
hgs
parents: 26
diff changeset
   112
        mIconItem->hide();
hgs
parents: 26
diff changeset
   113
        mIconItem->resetTransform();
hgs
parents: 26
diff changeset
   114
        mIconItem->setOpacity(0);
hgs
parents: 26
diff changeset
   115
        mIconItem->setZValue(mIconItem->zValue()-20);
43
hgs
parents: 42
diff changeset
   116
    }
72
hgs
parents: 71
diff changeset
   117
    if (mTotalImagesCountGrpBox) {
hgs
parents: 71
diff changeset
   118
        mTotalImagesCountGrpBox->hide();
43
hgs
parents: 42
diff changeset
   119
    }
hgs
parents: 42
diff changeset
   120
    if(mZeroItemLabel) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   121
        mZeroItemLabel->hide();
43
hgs
parents: 42
diff changeset
   122
    }
54
hgs
parents: 50
diff changeset
   123
    
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   124
    disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(orientationchanged(Qt::Orientation)));
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   125
    OstTraceFunctionExit0( GLXGRIDVIEW_DEACTIVATE_EXIT );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   126
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
50
hgs
parents: 45
diff changeset
   128
void GlxGridView::initializeView( QAbstractItemModel *model, GlxView *preView )
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   129
{
50
hgs
parents: 45
diff changeset
   130
    Q_UNUSED( preView )
40
hgs
parents: 26
diff changeset
   131
    activate();
hgs
parents: 26
diff changeset
   132
    setModel(model);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   133
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   135
void GlxGridView::clearCurrentModel()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   136
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   137
    if ( mModel ) {
65
hgs
parents: 58
diff changeset
   138
        disconnect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted() ) );
hgs
parents: 58
diff changeset
   139
        disconnect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsRemoved() ) );
hgs
parents: 58
diff changeset
   140
        disconnect( mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel() ) );
hgs
parents: 58
diff changeset
   141
        disconnect( mModel, SIGNAL( albumTitleAvailable( QString ) ), this, SLOT( showAlbumTitle( QString ) ) );
hgs
parents: 58
diff changeset
   142
        disconnect( mModel, SIGNAL( populated() ), this, SLOT( populated() ) );
hgs
parents: 58
diff changeset
   143
        mModel = NULL;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   144
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   145
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   146
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   147
void GlxGridView::initializeNewModel()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   148
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   149
    if ( mModel ) {
65
hgs
parents: 58
diff changeset
   150
        connect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( rowsInserted() ) );
hgs
parents: 58
diff changeset
   151
        connect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( rowsRemoved() ) );
hgs
parents: 58
diff changeset
   152
        connect( mModel, SIGNAL(destroyed()), this, SLOT( clearCurrentModel() ) );
hgs
parents: 58
diff changeset
   153
        if ( getSubState() == ALBUM_ITEM_S ) {
hgs
parents: 58
diff changeset
   154
            connect( mModel, SIGNAL( albumTitleAvailable( QString ) ), this, SLOT( showAlbumTitle( QString ) ) );
54
hgs
parents: 50
diff changeset
   155
        }
65
hgs
parents: 58
diff changeset
   156
        connect( mModel, SIGNAL( populated() ), this, SLOT( populated() ) );
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   157
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   158
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   159
65
hgs
parents: 58
diff changeset
   160
void GlxGridView::setModel( QAbstractItemModel *model )
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   161
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    OstTraceFunctionEntry0( GLXGRIDVIEW_SETMODEL_ENTRY );
65
hgs
parents: 58
diff changeset
   163
    if( model ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   164
        clearCurrentModel();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   165
        mModel = model;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   166
        initializeNewModel();
65
hgs
parents: 58
diff changeset
   167
        
40
hgs
parents: 26
diff changeset
   168
        QVariant variantimage = mModel->data(mModel->index(0,0),GlxDefaultImage);
65
hgs
parents: 58
diff changeset
   169
        if ( variantimage.isValid() && variantimage.canConvert<QImage> () ) {
hgs
parents: 58
diff changeset
   170
            mWidget->setDefaultImage( variantimage.value<QImage>() );
hgs
parents: 58
diff changeset
   171
        }
hgs
parents: 58
diff changeset
   172
        
hgs
parents: 58
diff changeset
   173
        mModelWrapper->setModel( mModel );
hgs
parents: 58
diff changeset
   174
        mWidget->setModel( mModelWrapper );
hgs
parents: 58
diff changeset
   175
        
hgs
parents: 58
diff changeset
   176
        if( !mSelectionModel ) {
hgs
parents: 58
diff changeset
   177
            mSelectionModel = new QItemSelectionModel( mModelWrapper, this );
hgs
parents: 58
diff changeset
   178
            connect( mSelectionModel, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( visibleIndexChanged( const QModelIndex &, const QModelIndex & ) ) );
hgs
parents: 58
diff changeset
   179
            mWidget->setSelectionModel( mSelectionModel );
hgs
parents: 58
diff changeset
   180
        }
hgs
parents: 58
diff changeset
   181
        
hgs
parents: 58
diff changeset
   182
        scrolltofocus(); // Need to do it here ?
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   183
        showItemCount();
65
hgs
parents: 58
diff changeset
   184
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
    OstTraceFunctionExit0( GLXGRIDVIEW_SETMODEL_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   186
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
40
hgs
parents: 26
diff changeset
   188
void GlxGridView::visibleIndexChanged(const QModelIndex& current, const QModelIndex& previous)
hgs
parents: 26
diff changeset
   189
{
hgs
parents: 26
diff changeset
   190
    if(mScrolling)
hgs
parents: 26
diff changeset
   191
        {
hgs
parents: 26
diff changeset
   192
        Q_UNUSED(previous);
hgs
parents: 26
diff changeset
   193
        if(current.row() >= 0 || current.row() < mModel->rowCount())
hgs
parents: 26
diff changeset
   194
            {
hgs
parents: 26
diff changeset
   195
            mModel->setData(mModel->index(0,0),current.row(),GlxVisualWindowIndex);
hgs
parents: 26
diff changeset
   196
            }
hgs
parents: 26
diff changeset
   197
        }
hgs
parents: 26
diff changeset
   198
}
hgs
parents: 26
diff changeset
   199
44
hgs
parents: 43
diff changeset
   200
void GlxGridView::addToolBar( HbToolBar *toolBar )
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   201
{
44
hgs
parents: 43
diff changeset
   202
    OstTraceFunctionEntry0( GLXGRIDVIEW_ADDTOOLBAR_ENTRY );
65
hgs
parents: 58
diff changeset
   203
    
hgs
parents: 58
diff changeset
   204
    //For album grid view, add and remove from album tool bar will be shown
hgs
parents: 58
diff changeset
   205
    int subState = getSubState();
hgs
parents: 58
diff changeset
   206
    if ( subState == ALBUM_ITEM_S && mWidget->selectionMode() == HgWidget::NoSelection ) {
hgs
parents: 58
diff changeset
   207
        if ( !mToolBar ) {
hgs
parents: 58
diff changeset
   208
            createAlbumGridToolBar();
hgs
parents: 58
diff changeset
   209
        }
hgs
parents: 58
diff changeset
   210
        if ( mToolBar ) {
hgs
parents: 58
diff changeset
   211
            //remove from action will be disable if number of images in the album grid is zero.
hgs
parents: 58
diff changeset
   212
            if ( mModel->rowCount()  ) {
hgs
parents: 58
diff changeset
   213
                mToolBar->actions().at(0)->setEnabled( true ); //To:Do remove once selection dialog is implemented
hgs
parents: 58
diff changeset
   214
                mToolBar->actions().at(1)->setEnabled( true );
hgs
parents: 58
diff changeset
   215
            }
hgs
parents: 58
diff changeset
   216
            else {
hgs
parents: 58
diff changeset
   217
                mToolBar->actions().at(0)->setEnabled( false );
hgs
parents: 58
diff changeset
   218
                mToolBar->actions().at(1)->setEnabled( false );
hgs
parents: 58
diff changeset
   219
            }
hgs
parents: 58
diff changeset
   220
            if ( mToolBar != mCurrentToolBar ) {
hgs
parents: 58
diff changeset
   221
                takeToolBar();
hgs
parents: 58
diff changeset
   222
                setToolBar( mToolBar );
hgs
parents: 58
diff changeset
   223
                mCurrentToolBar = mToolBar;
hgs
parents: 58
diff changeset
   224
            }
hgs
parents: 58
diff changeset
   225
        }
hgs
parents: 58
diff changeset
   226
    }
hgs
parents: 58
diff changeset
   227
    else {
hgs
parents: 58
diff changeset
   228
        if ( toolBar != mCurrentToolBar ) {
hgs
parents: 58
diff changeset
   229
            takeToolBar();
hgs
parents: 58
diff changeset
   230
            setToolBar( toolBar );
hgs
parents: 58
diff changeset
   231
            mCurrentToolBar = toolBar;
hgs
parents: 58
diff changeset
   232
        }
hgs
parents: 58
diff changeset
   233
    }
hgs
parents: 58
diff changeset
   234
    
54
hgs
parents: 50
diff changeset
   235
    showHbItems();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    OstTraceFunctionExit0( GLXGRIDVIEW_ADDTOOLBAR_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   237
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
void GlxGridView::enableMarking()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   240
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ENABLEMARKING, "GlxGridView::enableMarking" );
40
hgs
parents: 26
diff changeset
   242
    mWidget->setSelectionMode(HgWidget::MultiSelection);
54
hgs
parents: 50
diff changeset
   243
   
69
hgs
parents: 65
diff changeset
   244
    if (mMarkingWidget == NULL) {
54
hgs
parents: 50
diff changeset
   245
        mMarkingWidget = new HbWidget(this);
hgs
parents: 50
diff changeset
   246
        mMarkContainer = new QGraphicsLinearLayout(Qt::Horizontal, 0);
hgs
parents: 50
diff changeset
   247
        mMarkingWidget->setLayout(mMarkContainer);
hgs
parents: 50
diff changeset
   248
hgs
parents: 50
diff changeset
   249
        mMarkSelectHeading = new HbGroupBox(this);
hgs
parents: 50
diff changeset
   250
        mMarkSelectHeading->setHeading(GLX_SELECT_IMAGES);
hgs
parents: 50
diff changeset
   251
        mMarkSelectHeading->setObjectName("Select Photos");
hgs
parents: 50
diff changeset
   252
               
hgs
parents: 50
diff changeset
   253
        mMarkCountLabel = new HbLabel(mMarkingWidget);
hgs
parents: 50
diff changeset
   254
        mMarkCountLabel->setObjectName("MarkCount");
hgs
parents: 50
diff changeset
   255
        mMarkCountLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
hgs
parents: 50
diff changeset
   256
        
hgs
parents: 50
diff changeset
   257
        mMarkCheckBox = new HbCheckBox(GLX_LABEL_MARK_ALL, mMarkingWidget);
hgs
parents: 50
diff changeset
   258
        mMarkCheckBox->setObjectName("CheckB MarkAll");
hgs
parents: 50
diff changeset
   259
       
hgs
parents: 50
diff changeset
   260
        mMarkContainer->addItem(mMarkCheckBox);
hgs
parents: 50
diff changeset
   261
        mMarkContainer->addItem(mMarkCountLabel);        
69
hgs
parents: 65
diff changeset
   262
    }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   263
69
hgs
parents: 65
diff changeset
   264
    hideorshowitems( mWindow->orientation() );
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   265
69
hgs
parents: 65
diff changeset
   266
    connect( mWidget->selectionModel() , SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
hgs
parents: 65
diff changeset
   267
    connect( mMarkCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( stateChanged( int ) ));
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   268
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
44
hgs
parents: 43
diff changeset
   270
void GlxGridView::disableMarking()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   271
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_DISABLEMARKING, "GlxGridView::disableMarking" );
40
hgs
parents: 26
diff changeset
   273
    mWidget->setSelectionMode(HgWidget::NoSelection);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   274
    disconnect( mWidget->selectionModel() , SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection& ) ), this, SLOT( showMarkedItemCount() ) );
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   275
    disconnect(mMarkCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( stateChanged(int)));
54
hgs
parents: 50
diff changeset
   276
    
hgs
parents: 50
diff changeset
   277
    if (mMarkSelectHeading) {
hgs
parents: 50
diff changeset
   278
        mMarkSelectHeading->hide();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   279
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   280
54
hgs
parents: 50
diff changeset
   281
    if (mMarkingWidget) {
hgs
parents: 50
diff changeset
   282
        mMarkingWidget->hide();
58
hgs
parents: 54
diff changeset
   283
    }     
54
hgs
parents: 50
diff changeset
   284
    
58
hgs
parents: 54
diff changeset
   285
    if (mMarkCheckBox) {
hgs
parents: 54
diff changeset
   286
       mMarkCheckBox->setCheckState(Qt::Unchecked);
hgs
parents: 54
diff changeset
   287
    }
hgs
parents: 54
diff changeset
   288
	
54
hgs
parents: 50
diff changeset
   289
    showHbItems();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   290
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   291
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   292
void GlxGridView::stateChanged(int state)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   293
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   294
    if(state)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   295
        handleUserAction(EGlxCmdMarkAll);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   296
    else
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   297
        handleUserAction(EGlxCmdUnMarkAll);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   298
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   299
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   300
void GlxGridView::showMarkedItemCount()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   301
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   302
    int count = mModel->rowCount();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   303
    QModelIndexList indexList = mWidget->selectionModel()->selectedIndexes();
69
hgs
parents: 65
diff changeset
   304
    int markItemCount = indexList.count();
hgs
parents: 65
diff changeset
   305
    QString text = HbParameterLengthLimiter(GLX_LABEL_MARK_COUNT).arg(markItemCount).arg(count);
hgs
parents: 65
diff changeset
   306
    mMarkCountLabel->setPlainText(text);
hgs
parents: 65
diff changeset
   307
hgs
parents: 65
diff changeset
   308
    //Block The signals generated by the CheckBox
hgs
parents: 65
diff changeset
   309
    //if we dont block the signals  , then when we call setCheckState to selected and unselect the CheckBox
hgs
parents: 65
diff changeset
   310
    //it causes state change signal to emit which will cause either mark all or un mark all of teh images.
hgs
parents: 65
diff changeset
   311
    mMarkCheckBox->blockSignals(TRUE);
hgs
parents: 65
diff changeset
   312
    if (markItemCount != count && mMarkCheckBox->checkState() == Qt::Checked) {
hgs
parents: 65
diff changeset
   313
        //if the mark all option was checked  and then the user un marks an slected item
hgs
parents: 65
diff changeset
   314
        //Then we have to un check the Mark All check Box
hgs
parents: 65
diff changeset
   315
        mMarkCheckBox->setCheckState(Qt::Unchecked);
hgs
parents: 65
diff changeset
   316
    }
hgs
parents: 65
diff changeset
   317
    else if (markItemCount == count) {
hgs
parents: 65
diff changeset
   318
        //if all the images are selected/marked Indiduvally
hgs
parents: 65
diff changeset
   319
        //Then the the Mark All check Box has to checked/Selected
hgs
parents: 65
diff changeset
   320
        mMarkCheckBox->setCheckState(Qt::Checked);
hgs
parents: 65
diff changeset
   321
    }
hgs
parents: 65
diff changeset
   322
    //UnBlock The signals generated by the CheckBox
hgs
parents: 65
diff changeset
   323
    mMarkCheckBox->blockSignals(FALSE);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   324
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   325
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   326
void GlxGridView::showItemCount()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   327
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   328
    int count = 0;
65
hgs
parents: 58
diff changeset
   329
    if( mModel ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   330
        count = mModel->rowCount();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   331
        QSize deviceSize = HbDeviceProfile::current().logicalSize();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   332
        QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   333
                                                                       : QSize( deviceSize.height(), deviceSize.width() )  ;
65
hgs
parents: 58
diff changeset
   334
        if( count ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   335
            if(mZeroItemLabel) {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   336
                mZeroItemLabel->hide();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   337
            }
54
hgs
parents: 50
diff changeset
   338
            
65
hgs
parents: 58
diff changeset
   339
            if( isItemVisible( Hb::TitleBarItem ) ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   340
                QString text;
71
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   341
				if(XQServiceUtil::isService() && (0 == XQServiceUtil::interfaceName().compare(QLatin1String("com.nokia.symbian.IImageFetch")))) {
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   342
					showAlbumTitle(GLX_SELECT_IMAGE);
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   343
				}
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   344
                else if ( getSubState() == ALL_ITEM_S || ( getSubState() == FETCHER_ITEM_S)) {
72
hgs
parents: 71
diff changeset
   345
                    text = HbParameterLengthLimiter(GLX_GRID_VIEW_COUNT_LABEL).arg(count); 
hgs
parents: 71
diff changeset
   346
                    mTotalImagesCountGrpBox->setHeading ( text );
hgs
parents: 71
diff changeset
   347
                    mTotalImagesCountGrpBox->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
hgs
parents: 71
diff changeset
   348
                    mTotalImagesCountGrpBox->show();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   349
                }
72
hgs
parents: 71
diff changeset
   350
                else if ( getSubState() == ALBUM_ITEM_S || (getSubState() ==  FETCHER_ALBUM_ITEM_S) ) {
hgs
parents: 71
diff changeset
   351
                    mTotalImagesCountGrpBox->hide();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   352
                    QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   353
                    if (variant.toString() != NULL) {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   354
                        showAlbumTitle(variant.toString());
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   355
                    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   356
                }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   357
            }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   358
            else {
72
hgs
parents: 71
diff changeset
   359
                if (mTotalImagesCountGrpBox) {
hgs
parents: 71
diff changeset
   360
                    mTotalImagesCountGrpBox->hide();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   361
                }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   362
            }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   363
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   364
        }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   365
        else {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   366
            bool populated = FALSE;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   367
            QVariant variant = mModel->data(mModel->index(0,0),GlxPopulated);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   368
            if (variant.isValid() &&  variant.canConvert<bool>() )
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   369
                {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   370
                populated = variant.value<bool>();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   371
                }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   372
            if(populated) {
44
hgs
parents: 43
diff changeset
   373
                showNoImageString();
72
hgs
parents: 71
diff changeset
   374
                if(!(XQServiceUtil::isService() && 
hgs
parents: 71
diff changeset
   375
                        (0 == XQServiceUtil::interfaceName().compare(QLatin1String("com.nokia.symbian.IImageFetch")))))
hgs
parents: 71
diff changeset
   376
                    {
hgs
parents: 71
diff changeset
   377
                    if( getSubState() == ALL_ITEM_S ||  getSubState() == FETCHER_ITEM_S) {
hgs
parents: 71
diff changeset
   378
                        QString text;
hgs
parents: 71
diff changeset
   379
                        text = HbParameterLengthLimiter(GLX_GRID_VIEW_COUNT_LABEL).arg(count); 
hgs
parents: 71
diff changeset
   380
                        mTotalImagesCountGrpBox->setHeading ( text );
hgs
parents: 71
diff changeset
   381
                        mTotalImagesCountGrpBox->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));
hgs
parents: 71
diff changeset
   382
                        mTotalImagesCountGrpBox->show();
hgs
parents: 71
diff changeset
   383
                    }
hgs
parents: 71
diff changeset
   384
                    else if (getSubState() == ALBUM_ITEM_S || getSubState() ==  FETCHER_ALBUM_ITEM_S) {
hgs
parents: 71
diff changeset
   385
                        QVariant variant = mModel->data(mModel->index(0,0),GlxViewTitle);
hgs
parents: 71
diff changeset
   386
                        if (variant.toString() != NULL) {
hgs
parents: 71
diff changeset
   387
                            showAlbumTitle(variant.toString());
hgs
parents: 71
diff changeset
   388
                        }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   389
                    }
44
hgs
parents: 43
diff changeset
   390
				}	
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   391
            }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   392
        }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   393
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   394
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   395
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   396
void GlxGridView::showAlbumTitle(QString aTitle)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   397
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   398
    int count = mModel->rowCount();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   399
    QSize deviceSize = HbDeviceProfile::current().logicalSize();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   400
    QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   401
                                                                   : QSize( deviceSize.height(), deviceSize.width() )  ;
54
hgs
parents: 50
diff changeset
   402
    //If fetcher service set only title text
72
hgs
parents: 71
diff changeset
   403
    if ((XQServiceUtil::isService()) && isItemVisible(Hb::TitleBarItem) &&
hgs
parents: 71
diff changeset
   404
            (0 == XQServiceUtil::interfaceName().compare(QLatin1String("com.nokia.symbian.IImageFetch"))))
69
hgs
parents: 65
diff changeset
   405
        {       
72
hgs
parents: 71
diff changeset
   406
        mTotalImagesCountGrpBox->setHeading(aTitle);
hgs
parents: 71
diff changeset
   407
        mTotalImagesCountGrpBox->setGeometry(QRectF(0, 0, screenSize.width(),deviceSize.height() / 24));       
hgs
parents: 71
diff changeset
   408
        mTotalImagesCountGrpBox->show();
54
hgs
parents: 50
diff changeset
   409
        }
hgs
parents: 50
diff changeset
   410
    else
hgs
parents: 50
diff changeset
   411
        { //handle album tiltle and count display logic here
58
hgs
parents: 54
diff changeset
   412
        if (isItemVisible(Hb::TitleBarItem))
54
hgs
parents: 50
diff changeset
   413
            {
69
hgs
parents: 65
diff changeset
   414
            QString text = HbParameterLengthLimiter(GLX_ALBUM_NAME_COUNT_LABEL).arg(aTitle).arg(count);    
72
hgs
parents: 71
diff changeset
   415
            mTotalImagesCountGrpBox->setHeading(text);
hgs
parents: 71
diff changeset
   416
            mTotalImagesCountGrpBox->setGeometry(QRectF(0, 0, screenSize.width(),deviceSize.height()/24));                 
hgs
parents: 71
diff changeset
   417
            mTotalImagesCountGrpBox->show();
54
hgs
parents: 50
diff changeset
   418
            }
hgs
parents: 50
diff changeset
   419
        }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   420
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   421
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   422
void GlxGridView::showNoImageString()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   423
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   424
    qreal chromeHeight = 0.0;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   425
    QSize deviceSize = HbDeviceProfile::current().logicalSize();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   426
    QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   427
                                                                   : QSize( deviceSize.height(), deviceSize.width() )  ;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   428
    qreal midHeight = screenSize.height()/2;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   429
    if (isItemVisible(Hb::TitleBarItem)) {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   430
        style()->parameter("hb-param-widget-chrome-height", chromeHeight);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   431
        midHeight -= chromeHeight;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   432
    }
44
hgs
parents: 43
diff changeset
   433
    if (mZeroItemLabel == NULL) {
hgs
parents: 43
diff changeset
   434
        QString displayText(GLX_GRID_NO_IMAGE); 
hgs
parents: 43
diff changeset
   435
        mZeroItemLabel = new HbLabel(displayText, this);
45
hgs
parents: 44
diff changeset
   436
        mZeroItemLabel->setObjectName( "No Image" );
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   437
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   438
    mZeroItemLabel->setGeometry(QRectF(0, midHeight - deviceSize.height()/16, screenSize.width(), 3*deviceSize.height()/32));
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   439
    mZeroItemLabel->setAlignment(Qt::AlignHCenter);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   440
    mZeroItemLabel->show();
54
hgs
parents: 50
diff changeset
   441
   
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   442
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   443
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   444
void GlxGridView::populated()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   445
{
65
hgs
parents: 58
diff changeset
   446
    QVariant variant = mModelWrapper->data(mModelWrapper->index(0,0), GlxVisualWindowIndex );
hgs
parents: 58
diff changeset
   447
    int visualIndex = 0;
hgs
parents: 58
diff changeset
   448
    if ( variant.isValid() &&  variant.canConvert<int> () )  {
hgs
parents: 58
diff changeset
   449
        visualIndex = variant.value<int>();
hgs
parents: 58
diff changeset
   450
    }
hgs
parents: 58
diff changeset
   451
    mWidget->scrollTo(mModelWrapper->index(visualIndex,0));
hgs
parents: 58
diff changeset
   452
    showItemCount();
hgs
parents: 58
diff changeset
   453
}
hgs
parents: 58
diff changeset
   454
hgs
parents: 58
diff changeset
   455
void GlxGridView::rowsInserted()
hgs
parents: 58
diff changeset
   456
{
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   457
    showItemCount();
65
hgs
parents: 58
diff changeset
   458
    if( getSubState() == ALBUM_ITEM_S  && mToolBar ) {
hgs
parents: 58
diff changeset
   459
        mToolBar->actions().at(0)->setEnabled( true ); //To:Do remove once selection dialog is implemented
hgs
parents: 58
diff changeset
   460
        mToolBar->actions().at(1)->setEnabled( true );
hgs
parents: 58
diff changeset
   461
    }
hgs
parents: 58
diff changeset
   462
}
hgs
parents: 58
diff changeset
   463
hgs
parents: 58
diff changeset
   464
void GlxGridView::rowsRemoved()
hgs
parents: 58
diff changeset
   465
{
hgs
parents: 58
diff changeset
   466
    showItemCount(); 
hgs
parents: 58
diff changeset
   467
    if( getSubState() == ALBUM_ITEM_S  && mModel->rowCount() == 0 && mToolBar ) {
hgs
parents: 58
diff changeset
   468
        mToolBar->actions().at(0)->setEnabled( false ); //To:Do remove once selection dialog is implemented
hgs
parents: 58
diff changeset
   469
        mToolBar->actions().at(1)->setEnabled( false );
hgs
parents: 58
diff changeset
   470
    }    
hgs
parents: 58
diff changeset
   471
}
hgs
parents: 58
diff changeset
   472
hgs
parents: 58
diff changeset
   473
void GlxGridView::handleToolBarAction()
hgs
parents: 58
diff changeset
   474
{
hgs
parents: 58
diff changeset
   475
    HbAction *action = qobject_cast<HbAction*>( sender() );
hgs
parents: 58
diff changeset
   476
    qint32 commandId = action->data().toInt();
hgs
parents: 58
diff changeset
   477
    emit actionTriggered( commandId );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   478
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
void GlxGridView::handleUserAction(qint32 commandId)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   481
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_HANDLEUSERACTION, "GlxGridView::handleUserAction" );
40
hgs
parents: 26
diff changeset
   483
    switch( commandId ) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
        case EGlxCmdMarkAll :
40
hgs
parents: 26
diff changeset
   485
            mWidget->selectAll();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
            break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
        case EGlxCmdUnMarkAll :
40
hgs
parents: 26
diff changeset
   489
            mWidget->clearSelection();
44
hgs
parents: 43
diff changeset
   490
            break;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
50
hgs
parents: 45
diff changeset
   492
        case EGlxCmd3DEffectOn:
hgs
parents: 45
diff changeset
   493
            mSettings->setmediaWall3DEffect(1);
hgs
parents: 45
diff changeset
   494
            if(mWidget && !mWidget->effect3dEnabled())
hgs
parents: 45
diff changeset
   495
                mWidget->setEffect3dEnabled(ETrue);
hgs
parents: 45
diff changeset
   496
            break;
hgs
parents: 45
diff changeset
   497
            
hgs
parents: 45
diff changeset
   498
        case EGlxCmd3DEffectOff:
hgs
parents: 45
diff changeset
   499
            mSettings->setmediaWall3DEffect(0);
hgs
parents: 45
diff changeset
   500
            if(mWidget && mWidget->effect3dEnabled())
hgs
parents: 45
diff changeset
   501
                mWidget->setEffect3dEnabled(EFalse);
hgs
parents: 45
diff changeset
   502
            break;
hgs
parents: 45
diff changeset
   503
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
        default :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
            break;
44
hgs
parents: 43
diff changeset
   506
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   507
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
QItemSelectionModel * GlxGridView::getSelectionModel()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   510
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_GETSELECTIONMODEL, "GlxGridView::getSelectionModel" );
40
hgs
parents: 26
diff changeset
   512
    return mWidget->selectionModel();
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   513
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
QGraphicsItem * GlxGridView::getAnimationItem(GlxEffect transitionEffect)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   516
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    OstTraceFunctionEntry0( GLXGRIDVIEW_GETANIMATIONITEM_ENTRY );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    int selIndex = -1;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
69
hgs
parents: 65
diff changeset
   520
    if ( transitionEffect == FULLSCREEN_TO_GRID  || transitionEffect == FULLSCREEN_TO_GRID_PORTRAIT ) {
72
hgs
parents: 71
diff changeset
   521
        if ( !mBackGroundItem ) {
hgs
parents: 71
diff changeset
   522
            mBackGroundItem = new HbIconItem();
hgs
parents: 71
diff changeset
   523
            setBackgroundItem( mBackGroundItem );            
hgs
parents: 71
diff changeset
   524
        }
hgs
parents: 71
diff changeset
   525
        HbIcon icon = HbIcon( mWindow->backgroundImageName( mWindow->orientation() ) );
hgs
parents: 71
diff changeset
   526
        mBackGroundItem->setIcon( icon );
hgs
parents: 71
diff changeset
   527
        return this;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
69
hgs
parents: 65
diff changeset
   530
    if ( transitionEffect == GRID_TO_FULLSCREEN ) {
hgs
parents: 65
diff changeset
   531
        QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole );
hgs
parents: 65
diff changeset
   532
        if ( variant.isValid() && variant.canConvert<int> () ) {
hgs
parents: 65
diff changeset
   533
            selIndex = variant.value<int> ();
hgs
parents: 65
diff changeset
   534
        }
hgs
parents: 65
diff changeset
   535
        else {
40
hgs
parents: 26
diff changeset
   536
            return mWidget;
69
hgs
parents: 65
diff changeset
   537
        }
hgs
parents: 65
diff changeset
   538
        QVariant variantimage = mModel->data( mModel->index( selIndex, 0 ), Qt::DecorationRole );
hgs
parents: 65
diff changeset
   539
        if ( variantimage.isValid() && variantimage.canConvert<HbIcon> () ) {
40
hgs
parents: 26
diff changeset
   540
            QPolygonF poly;
69
hgs
parents: 65
diff changeset
   541
            if ( mModelWrapper && !mWidget->getItemOutline( mModelWrapper->index( selIndex, 0 ), poly ) ) {
40
hgs
parents: 26
diff changeset
   542
                return mWidget;
69
hgs
parents: 65
diff changeset
   543
            }
40
hgs
parents: 26
diff changeset
   544
            QRectF itemRect = poly.boundingRect();
hgs
parents: 26
diff changeset
   545
69
hgs
parents: 65
diff changeset
   546
            mIconItem->setSize( QSize( 120, 120 ) );
hgs
parents: 65
diff changeset
   547
            HbIcon tempIcon = variantimage.value<HbIcon> ();
hgs
parents: 65
diff changeset
   548
            QPixmap tempPixmap = tempIcon.qicon().pixmap( 120, 120 );
hgs
parents: 65
diff changeset
   549
            QSize sz = QSize( 120, 120 );
hgs
parents: 65
diff changeset
   550
            tempPixmap = tempPixmap.scaled( sz, Qt::IgnoreAspectRatio );
hgs
parents: 65
diff changeset
   551
            HbIcon tmp = HbIcon( QIcon( tempPixmap ) );
hgs
parents: 65
diff changeset
   552
            mIconItem->setIcon( tmp );
hgs
parents: 65
diff changeset
   553
            mIconItem->setPos( itemRect.topLeft() );
hgs
parents: 65
diff changeset
   554
            mIconItem->setZValue( mIconItem->zValue() + 20 );
40
hgs
parents: 26
diff changeset
   555
            mIconItem->show();
69
hgs
parents: 65
diff changeset
   556
            if ( mToolBar ) {
hgs
parents: 65
diff changeset
   557
                mToolBar->setZValue( mIconItem->zValue() - 5 );
40
hgs
parents: 26
diff changeset
   558
            }
69
hgs
parents: 65
diff changeset
   559
            return mIconItem;
hgs
parents: 65
diff changeset
   560
        }
hgs
parents: 65
diff changeset
   561
        else {
40
hgs
parents: 26
diff changeset
   562
            return mWidget;
hgs
parents: 26
diff changeset
   563
        }
69
hgs
parents: 65
diff changeset
   564
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
69
hgs
parents: 65
diff changeset
   566
    if ( transitionEffect == GRID_TO_ALBUMLIST || transitionEffect == ALBUMLIST_TO_GRID ) {
72
hgs
parents: 71
diff changeset
   567
        return this;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
    OstTraceFunctionExit0( GLXGRIDVIEW_GETANIMATIONITEM_EXIT );
44
hgs
parents: 43
diff changeset
   570
    return NULL;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   571
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
40
hgs
parents: 26
diff changeset
   573
void GlxGridView::loadGridView()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   574
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    OstTraceFunctionEntry0( GLXGRIDVIEW_LOADGRIDVIEW_ENTRY );
40
hgs
parents: 26
diff changeset
   576
    if(mWidget == NULL) {
hgs
parents: 26
diff changeset
   577
        Qt::Orientation orient = mWindow->orientation();
hgs
parents: 26
diff changeset
   578
        mWindow->viewport()->grabGesture(Qt::PanGesture);
hgs
parents: 26
diff changeset
   579
        mWindow->viewport()->grabGesture(Qt::TapGesture);
hgs
parents: 26
diff changeset
   580
        mWindow->viewport()->grabGesture(Qt::TapAndHoldGesture);
hgs
parents: 26
diff changeset
   581
        mWidget = new HgGrid(orient);
45
hgs
parents: 44
diff changeset
   582
        mWidget->setObjectName( "Media Wall" );
40
hgs
parents: 26
diff changeset
   583
        mWidget->setLongPressEnabled(true);
44
hgs
parents: 43
diff changeset
   584
        mWidget->setScrollBarPolicy(HgWidget::ScrollBarAutoHide);
72
hgs
parents: 71
diff changeset
   585
        if(XQServiceUtil::isService()) {
50
hgs
parents: 45
diff changeset
   586
            mWidget->setEffect3dEnabled(EFalse);
72
hgs
parents: 71
diff changeset
   587
        }
hgs
parents: 71
diff changeset
   588
        else {
50
hgs
parents: 45
diff changeset
   589
            mWidget->setEffect3dEnabled(mSettings->mediaWall3DEffect());
72
hgs
parents: 71
diff changeset
   590
        }
44
hgs
parents: 43
diff changeset
   591
        setWidget( mWidget );
40
hgs
parents: 26
diff changeset
   592
        addViewConnection();
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   593
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
    OstTraceFunctionExit0( GLXGRIDVIEW_LOADGRIDVIEW_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   595
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
40
hgs
parents: 26
diff changeset
   597
void GlxGridView::orientationchanged(Qt::Orientation orient)
hgs
parents: 26
diff changeset
   598
{
54
hgs
parents: 50
diff changeset
   599
    if (mWidget && mWidget->selectionMode() == HgWidget::MultiSelection) {
hgs
parents: 50
diff changeset
   600
        hideorshowitems(orient);
hgs
parents: 50
diff changeset
   601
    }
hgs
parents: 50
diff changeset
   602
    showHbItems();
40
hgs
parents: 26
diff changeset
   603
}
54
hgs
parents: 50
diff changeset
   604
40
hgs
parents: 26
diff changeset
   605
void GlxGridView::hideorshowitems(Qt::Orientation orient)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   606
{
44
hgs
parents: 43
diff changeset
   607
    if ( mWidget && mWidget->selectionMode() == HgWidget::NoSelection ) {
hgs
parents: 43
diff changeset
   608
        if( orient == Qt::Horizontal ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   609
			setItemVisible(Hb::AllItems, FALSE) ;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   610
        	setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
45
hgs
parents: 44
diff changeset
   611
            showItemCount();
hgs
parents: 44
diff changeset
   612
            if(mUiOnButton == NULL) {
hgs
parents: 44
diff changeset
   613
                mUiOnButton = new HbPushButton(this);
hgs
parents: 44
diff changeset
   614
                connect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
hgs
parents: 44
diff changeset
   615
                mUiOnButton->setGeometry(QRectF(590,0,40,40));
hgs
parents: 44
diff changeset
   616
                mUiOnButton->setZValue(1);
hgs
parents: 44
diff changeset
   617
                mUiOnButton->setIcon(HbIcon(GLXICON_WALL_UI_ON));
hgs
parents: 44
diff changeset
   618
                mUiOnButton->setObjectName( "UiOn Button" );
40
hgs
parents: 26
diff changeset
   619
            }
45
hgs
parents: 44
diff changeset
   620
            mUiOnButton->show();
44
hgs
parents: 43
diff changeset
   621
        }
hgs
parents: 43
diff changeset
   622
        else {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   623
            showHbItems();
44
hgs
parents: 43
diff changeset
   624
        }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   625
    }
44
hgs
parents: 43
diff changeset
   626
    else if (mWidget && mWidget->selectionMode() == HgWidget::MultiSelection) {
54
hgs
parents: 50
diff changeset
   627
        setItemVisible(Hb::AllItems, FALSE) ;
hgs
parents: 50
diff changeset
   628
        setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   629
        if (mUiOnButton) {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   630
            mUiOnButton->hide();
40
hgs
parents: 26
diff changeset
   631
        }
72
hgs
parents: 71
diff changeset
   632
        if (mTotalImagesCountGrpBox) {
hgs
parents: 71
diff changeset
   633
            mTotalImagesCountGrpBox->hide();
40
hgs
parents: 26
diff changeset
   634
        }
54
hgs
parents: 50
diff changeset
   635
        
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   636
        QSize deviceSize = HbDeviceProfile::current().logicalSize();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   637
        QSize screenSize = ( mWindow->orientation() == Qt::Vertical ) ? QSize( deviceSize.width(), deviceSize.height() )
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   638
                                                                       : QSize( deviceSize.height(), deviceSize.width() )  ;
54
hgs
parents: 50
diff changeset
   639
        
hgs
parents: 50
diff changeset
   640
        mMarkSelectHeading->setGeometry(QRectF(0,0,screenSize.width(),deviceSize.height()/24));       
hgs
parents: 50
diff changeset
   641
        mMarkingWidget->setGeometry(QRectF(0,deviceSize.height()/24,screenSize.width(),deviceSize.height()/72));          
hgs
parents: 50
diff changeset
   642
              
hgs
parents: 50
diff changeset
   643
        mMarkSelectHeading->show();
69
hgs
parents: 65
diff changeset
   644
        mMarkingWidget->show();        
hgs
parents: 65
diff changeset
   645
        showMarkedItemCount();        
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   646
    }
40
hgs
parents: 26
diff changeset
   647
}
hgs
parents: 26
diff changeset
   648
hgs
parents: 26
diff changeset
   649
void GlxGridView::scrolltofocus()
hgs
parents: 26
diff changeset
   650
{
hgs
parents: 26
diff changeset
   651
    if(mModelWrapper && mWidget)
hgs
parents: 26
diff changeset
   652
        {
44
hgs
parents: 43
diff changeset
   653
        QVariant variant = mModelWrapper->data( mModelWrapper->index(0,0), GlxFocusIndexRole );
hgs
parents: 43
diff changeset
   654
        if ( variant.isValid() &&  variant.canConvert<int> () )
40
hgs
parents: 26
diff changeset
   655
            {
hgs
parents: 26
diff changeset
   656
            mWidget->scrollTo( mModelWrapper->index( variant.value<int>(),0) );
hgs
parents: 26
diff changeset
   657
            mModel->setData(mModel->index(0,0),variant.value<int>(),GlxVisualWindowIndex);
hgs
parents: 26
diff changeset
   658
            }
hgs
parents: 26
diff changeset
   659
        }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   660
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
40
hgs
parents: 26
diff changeset
   663
void GlxGridView::addViewConnection()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   664
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_ADDVIEWCONNECTION, "GlxGridView::addViewConnection" );
40
hgs
parents: 26
diff changeset
   666
    //connect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
hgs
parents: 26
diff changeset
   667
    connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
hgs
parents: 26
diff changeset
   668
    connect(mWidget, SIGNAL(activated(const QModelIndex &)), SLOT( itemSelected(const QModelIndex &)));
hgs
parents: 26
diff changeset
   669
    connect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
hgs
parents: 26
diff changeset
   670
    connect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
hgs
parents: 26
diff changeset
   671
    connect(mWidget, SIGNAL(longPressed(const QModelIndex &, QPointF)), SLOT( indicateLongPress(const QModelIndex &, QPointF) ) );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   672
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
void GlxGridView::removeViewConnection ()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   675
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_REMOVEVIEWCONNECTION, "GlxGridView::removeViewConnection" );
40
hgs
parents: 26
diff changeset
   677
    if(mWidget)
hgs
parents: 26
diff changeset
   678
        {
hgs
parents: 26
diff changeset
   679
        //disconnect(mWindow, SIGNAL(aboutToChangeOrientation()), mWidget, SLOT(aboutToChangeOrientation()));
hgs
parents: 26
diff changeset
   680
        disconnect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), mWidget, SLOT(orientationChanged(Qt::Orientation)));
hgs
parents: 26
diff changeset
   681
        disconnect(mWidget, SIGNAL(activated(const QModelIndex &)),this, SLOT( itemSelected(const QModelIndex &)));
hgs
parents: 26
diff changeset
   682
        disconnect(mWidget, SIGNAL( scrollingStarted() ), this, SLOT( scrollingStarted() ) );
hgs
parents: 26
diff changeset
   683
        disconnect(mWidget, SIGNAL( scrollingEnded() ), this, SLOT( scrollingEnded() ) );
hgs
parents: 26
diff changeset
   684
        disconnect(mWidget,  SIGNAL(longPressed(const QModelIndex &, QPointF)),this, SLOT( indicateLongPress(const QModelIndex &, QPointF) ) );
hgs
parents: 26
diff changeset
   685
        }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   686
}
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   687
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
void GlxGridView::itemSelected(const QModelIndex &  index)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   690
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
    OstTrace1( TRACE_NORMAL, GLXGRIDVIEW_ITEMSELECTED, "GlxGridView::itemSelected;index=%d", index.row() );
44
hgs
parents: 43
diff changeset
   692
    if ( mWidget->selectionMode() == HgWidget::MultiSelection ) {
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   693
        return ;
44
hgs
parents: 43
diff changeset
   694
    }
hgs
parents: 43
diff changeset
   695
    OstTraceEventStart0( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START, "Fullscreen Launch Time" );
hgs
parents: 43
diff changeset
   696
    if ( mModel ) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
        mModel->setData( index, index.row(), GlxFocusIndexRole );
44
hgs
parents: 43
diff changeset
   698
    }
71
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   699
    if(XQServiceUtil::isService() ){
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   700
		if(0 == XQServiceUtil::interfaceName().compare(QLatin1String("com.nokia.symbian.IImageFetch"))){
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   701
	        qDebug("GlxGridView::itemSelected actionTriggered( EGlxCmdFetcherSelect )" );
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   702
	        emit actionTriggered( EGlxCmdFetcherSelect );
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   703
		}
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   704
		else{
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   705
			emit actionTriggered( EGlxCmdBrowseFullScreenOpen);
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   706
		}
54
hgs
parents: 50
diff changeset
   707
    }
71
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   708
	else{
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   709
		emit actionTriggered( EGlxCmdFullScreenOpen );
27f2d7aec52a 201039_01
hgs
parents: 69
diff changeset
   710
	}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    OstTraceEventStop( EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_STOP, "Fullscreen Launch Time", EVENT_DUP1_GLXGRIDVIEW_ITEMSELECTED_START );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   712
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
40
hgs
parents: 26
diff changeset
   714
void GlxGridView::scrollingStarted()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   715
{
54
hgs
parents: 50
diff changeset
   716
    if ((mWindow->orientation() == Qt::Horizontal)/* && mWidget->selectionMode() == HgWidget::NoSelection*/)
40
hgs
parents: 26
diff changeset
   717
        {
hgs
parents: 26
diff changeset
   718
        setItemVisible(Hb::AllItems, FALSE) ;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   719
        setViewFlags(viewFlags() | HbView::ViewTitleBarHidden | HbView::ViewStatusBarHidden);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   720
        if (mUiOnButton)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   721
            {
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   722
            mUiOnButton->hide();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   723
            }
72
hgs
parents: 71
diff changeset
   724
		if (mTotalImagesCountGrpBox) {
hgs
parents: 71
diff changeset
   725
			mTotalImagesCountGrpBox->hide();
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   726
		}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   727
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   728
40
hgs
parents: 26
diff changeset
   729
    mScrolling = TRUE;
hgs
parents: 26
diff changeset
   730
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
40
hgs
parents: 26
diff changeset
   732
void GlxGridView::scrollingEnded()
hgs
parents: 26
diff changeset
   733
{
hgs
parents: 26
diff changeset
   734
    mScrolling = FALSE;
65
hgs
parents: 58
diff changeset
   735
    if ( mUiOnButton && ( mWindow->orientation() == Qt::Horizontal ) ) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   736
        mUiOnButton->show();
65
hgs
parents: 58
diff changeset
   737
    }
hgs
parents: 58
diff changeset
   738
    
40
hgs
parents: 26
diff changeset
   739
    QList<QModelIndex> visibleIndex = mWidget->getVisibleItemIndices();
65
hgs
parents: 58
diff changeset
   740
    if ( visibleIndex.count() <= 0 ) {
40
hgs
parents: 26
diff changeset
   741
        return;
65
hgs
parents: 58
diff changeset
   742
    }
40
hgs
parents: 26
diff changeset
   743
    QModelIndex index = visibleIndex.at(0);
65
hgs
parents: 58
diff changeset
   744
hgs
parents: 58
diff changeset
   745
    if(mModel) {
hgs
parents: 58
diff changeset
   746
        if ( index.row() < 0 || index.row() >= mModel->rowCount() ) {
hgs
parents: 58
diff changeset
   747
            return;
44
hgs
parents: 43
diff changeset
   748
        }
65
hgs
parents: 58
diff changeset
   749
        mModel->setData( index, index.row(), GlxVisualWindowIndex );
hgs
parents: 58
diff changeset
   750
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   751
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
GlxGridView::~GlxGridView()
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   754
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
    OstTraceFunctionEntry0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_ENTRY );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
    removeViewConnection();
40
hgs
parents: 26
diff changeset
   757
    if(mSelectionModel)
hgs
parents: 26
diff changeset
   758
        {
hgs
parents: 26
diff changeset
   759
        disconnect(mSelectionModel, SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(visibleIndexChanged(const QModelIndex &, const QModelIndex &)));
hgs
parents: 26
diff changeset
   760
        delete mSelectionModel;
hgs
parents: 26
diff changeset
   761
        }
hgs
parents: 26
diff changeset
   762
    delete mWidget;
hgs
parents: 26
diff changeset
   763
    delete mModelWrapper;
hgs
parents: 26
diff changeset
   764
    if(mUiOnButton) {
hgs
parents: 26
diff changeset
   765
        disconnect(mUiOnButton, SIGNAL(clicked(bool)), this, SLOT(uiButtonClicked(bool)));
hgs
parents: 26
diff changeset
   766
        delete mUiOnButton;
hgs
parents: 26
diff changeset
   767
    }
54
hgs
parents: 50
diff changeset
   768
    
40
hgs
parents: 26
diff changeset
   769
    delete mIconItem;
72
hgs
parents: 71
diff changeset
   770
    delete mTotalImagesCountGrpBox;
54
hgs
parents: 50
diff changeset
   771
    delete mMarkSelectHeading;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   772
    delete mMarkCheckBox;
54
hgs
parents: 50
diff changeset
   773
    delete mMarkCountLabel;
hgs
parents: 50
diff changeset
   774
    delete mMarkingWidget;
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   775
    delete mZeroItemLabel;
65
hgs
parents: 58
diff changeset
   776
    delete mToolBar;
54
hgs
parents: 50
diff changeset
   777
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
    OstTraceFunctionExit0( DUP1_GLXGRIDVIEW_GLXGRIDVIEW_EXIT );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   779
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
40
hgs
parents: 26
diff changeset
   781
void GlxGridView::indicateLongPress(const QModelIndex& index, QPointF coords)
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   782
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
    OstTrace0( TRACE_NORMAL, GLXGRIDVIEW_INDICATELONGPRESS, "GlxGridView::indicateLongPress" );
44
hgs
parents: 43
diff changeset
   784
40
hgs
parents: 26
diff changeset
   785
     if ( mWidget->selectionMode() == HgWidget::MultiSelection )
44
hgs
parents: 43
diff changeset
   786
         {
40
hgs
parents: 26
diff changeset
   787
         return;
44
hgs
parents: 43
diff changeset
   788
         }
hgs
parents: 43
diff changeset
   789
     if ( mModel )
40
hgs
parents: 26
diff changeset
   790
         {
hgs
parents: 26
diff changeset
   791
         mModel->setData( index, index.row(), GlxFocusIndexRole );
44
hgs
parents: 43
diff changeset
   792
         }
40
hgs
parents: 26
diff changeset
   793
     emit itemSpecificMenuTriggered(viewId(),coords);
hgs
parents: 26
diff changeset
   794
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
40
hgs
parents: 26
diff changeset
   796
void GlxGridView::uiButtonClicked(bool /*checked*/)
hgs
parents: 26
diff changeset
   797
{
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   798
    showHbItems();
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   799
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   800
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   801
void GlxGridView::showHbItems()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   802
{
54
hgs
parents: 50
diff changeset
   803
    if(mWidget && mWidget->selectionMode() == HgWidget::NoSelection) {
hgs
parents: 50
diff changeset
   804
        setItemVisible( Hb::TitleBarItem, TRUE );
hgs
parents: 50
diff changeset
   805
        setItemVisible( Hb::StatusBarItem, TRUE );
hgs
parents: 50
diff changeset
   806
        setViewFlags(viewFlags() &~ HbView::ViewTitleBarHidden &~ HbView::ViewStatusBarHidden);
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   807
        showItemCount();
54
hgs
parents: 50
diff changeset
   808
    }    
hgs
parents: 50
diff changeset
   809
    updateToolBar();
hgs
parents: 50
diff changeset
   810
    if (mUiOnButton) {
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   811
        mUiOnButton->hide();
54
hgs
parents: 50
diff changeset
   812
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   813
}
40
hgs
parents: 26
diff changeset
   814
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   815
void GlxGridView::cameraButtonClicked(bool /*checked*/)
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   816
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   817
    emit actionTriggered(EGlxCmdCameraOpen);
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   818
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   819
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   820
int GlxGridView::getSubState()
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   821
{
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   822
    int substate = NO_GRID_S;
54
hgs
parents: 50
diff changeset
   823
    if ( mModel ) {
hgs
parents: 50
diff changeset
   824
        QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole );
hgs
parents: 50
diff changeset
   825
        if ( variant.isValid() &&  variant.canConvert<int> ()  ) {
hgs
parents: 50
diff changeset
   826
            substate = variant.value<int>();
hgs
parents: 50
diff changeset
   827
        }
42
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   828
    }
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   829
    return substate;
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   830
}
5e1df1b52eb3 201019_01
hgs
parents: 40
diff changeset
   831
54
hgs
parents: 50
diff changeset
   832
void GlxGridView::updateToolBar()
hgs
parents: 50
diff changeset
   833
{
hgs
parents: 50
diff changeset
   834
    //In the case of multiselection show the tool bar.
hgs
parents: 50
diff changeset
   835
    if ( mWidget && mWidget->selectionMode() == HgWidget::MultiSelection ) {
hgs
parents: 50
diff changeset
   836
        setItemVisible( Hb::ToolBarItem, TRUE ) ;
hgs
parents: 50
diff changeset
   837
        return ;
hgs
parents: 50
diff changeset
   838
    }
hgs
parents: 50
diff changeset
   839
    
65
hgs
parents: 58
diff changeset
   840
    //In the case of fetcher, there is no tool bar for album grid view
54
hgs
parents: 50
diff changeset
   841
    int subState = getSubState();
65
hgs
parents: 58
diff changeset
   842
    if ( subState == FETCHER_ALBUM_ITEM_S ) {
54
hgs
parents: 50
diff changeset
   843
        setItemVisible( Hb::ToolBarItem, FALSE ) ;
hgs
parents: 50
diff changeset
   844
    }
hgs
parents: 50
diff changeset
   845
    else {
hgs
parents: 50
diff changeset
   846
        setItemVisible( Hb::ToolBarItem, TRUE );
hgs
parents: 50
diff changeset
   847
    }
hgs
parents: 50
diff changeset
   848
}
hgs
parents: 50
diff changeset
   849
65
hgs
parents: 58
diff changeset
   850
void GlxGridView::createAlbumGridToolBar()
hgs
parents: 58
diff changeset
   851
{
hgs
parents: 58
diff changeset
   852
    mToolBar = new HbToolBar();
hgs
parents: 58
diff changeset
   853
    mToolBar->setOrientation( Qt::Horizontal );
hgs
parents: 58
diff changeset
   854
    mToolBar->setVisible(true);
hgs
parents: 58
diff changeset
   855
    mToolBar->clearActions();
hgs
parents: 58
diff changeset
   856
    
hgs
parents: 58
diff changeset
   857
    HbAction *action = new HbAction();
hgs
parents: 58
diff changeset
   858
    action->setData( EGlxCmdAddToAlbum );
hgs
parents: 58
diff changeset
   859
    action->setIcon( HbIcon( GLXICON_ADD ) );
hgs
parents: 58
diff changeset
   860
    action->setObjectName( "Add Action" );
hgs
parents: 58
diff changeset
   861
    mToolBar->addAction( action );
hgs
parents: 58
diff changeset
   862
    connect( action, SIGNAL( triggered( ) ), this, SLOT( handleToolBarAction( ) ) );
hgs
parents: 58
diff changeset
   863
    
hgs
parents: 58
diff changeset
   864
    action = new HbAction();
hgs
parents: 58
diff changeset
   865
    action->setData( EGlxCmdRemoveFrom );
hgs
parents: 58
diff changeset
   866
    action->setIcon( HbIcon( GLXICON_REMOVE ) );
hgs
parents: 58
diff changeset
   867
    action->setObjectName( "Remove Action" );
hgs
parents: 58
diff changeset
   868
    mToolBar->addAction( action );
hgs
parents: 58
diff changeset
   869
    connect( action, SIGNAL( triggered( ) ), this, SLOT( handleToolBarAction( ) ) );
hgs
parents: 58
diff changeset
   870
}
hgs
parents: 58
diff changeset
   871