ui/views/slideshowview/src/glxslideshowwidget.cpp
author hgs
Fri, 23 Jul 2010 20:41:04 +0530
changeset 52 a3a4c0de738e
parent 50 a0f57508af73
child 54 0f0f3f26f787
permissions -rw-r--r--
201029
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
//Includes
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QDebug>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <QTimer>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <e32base.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <hbiconitem.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <hbpushbutton.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <hbmainwindow.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <hbdocumentloader.h>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <QAbstractItemModel>
40
hgs
parents: 24
diff changeset
    29
#include <QGesture>
hgs
parents: 24
diff changeset
    30
#include <hbpangesture.h>
50
hgs
parents: 45
diff changeset
    31
#include <hblabel.h>
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
//User Includes
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    34
#include "glxicondefs.h" //Contains the icon names/Ids
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "glxmodelparm.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "glxeffectengine.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "glxdocloaderdefs.h"
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "glxslideshowwidget.h"
43
hgs
parents: 40
diff changeset
    39
#include "glxsettinginterface.h"
50
hgs
parents: 45
diff changeset
    40
#include "glxlocalisationstrings.h"
43
hgs
parents: 40
diff changeset
    41
#include "glxlog.h"
hgs
parents: 40
diff changeset
    42
#include "glxtracer.h"
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
40
hgs
parents: 24
diff changeset
    45
GlxSlideShowWidget::GlxSlideShowWidget( QGraphicsItem *parent ) 
50
hgs
parents: 45
diff changeset
    46
    : HbWidget( parent ), 
hgs
parents: 45
diff changeset
    47
      mEffectEngine( NULL ), 
43
hgs
parents: 40
diff changeset
    48
      mSettings( NULL ),
52
hgs
parents: 50
diff changeset
    49
      mBackGroundItem( NULL ),
50
hgs
parents: 45
diff changeset
    50
      mContinueButton( NULL ), 
hgs
parents: 45
diff changeset
    51
      mErrorNote( NULL ),
hgs
parents: 45
diff changeset
    52
      mItemIndex( 1 ),  
hgs
parents: 45
diff changeset
    53
      mSlideTimer( NULL ), 
hgs
parents: 45
diff changeset
    54
      mModel( NULL ), 
hgs
parents: 45
diff changeset
    55
      mSlideShowItemCount( 0 )
40
hgs
parents: 24
diff changeset
    56
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
    TRACER("GlxSlideShowWidget::GlxSlideShowWidget()");
43
hgs
parents: 40
diff changeset
    58
    mSettings = GlxSettingInterface::instance() ; //no owner ship
40
hgs
parents: 24
diff changeset
    59
    grabGesture( Qt::PanGesture );
hgs
parents: 24
diff changeset
    60
    grabGesture( Qt::TapGesture );
hgs
parents: 24
diff changeset
    61
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
void GlxSlideShowWidget::setSlideShowWidget(HbDocumentLoader *DocLoader)
43
hgs
parents: 40
diff changeset
    64
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    //To:Do error handling
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    66
    TRACER("GlxSlideShowWidget::setSlideShowWidget()");   
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    67
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    //create the effect engine
43
hgs
parents: 40
diff changeset
    69
    mEffectEngine = new GlxEffectEngine();
52
hgs
parents: 50
diff changeset
    70
    
hgs
parents: 50
diff changeset
    71
    mBackGroundItem = new HbIconItem( this );
hgs
parents: 50
diff changeset
    72
    mBackGroundItem->setBrush( QBrush( Qt::black ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
    // Now load the view and the contents.
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    75
    // and then set the play icon to the button
50
hgs
parents: 45
diff changeset
    76
    mContinueButton = static_cast<HbPushButton*>( DocLoader->findWidget( GLXSLIDESHOW_PB ) );
hgs
parents: 45
diff changeset
    77
    mContinueButton->setIcon( HbIcon( GLXICON_PLAY ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
    mContinueButton->hide();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    mIsPause = false;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
    for ( int i = 0; i < NBR_ITEM ; i++) {
50
hgs
parents: 45
diff changeset
    82
        mSelIndex[ i ] = -1;
hgs
parents: 45
diff changeset
    83
        mIconItems[ i ] = new HbIconItem( this );
hgs
parents: 45
diff changeset
    84
        mIconItems[ i ]->setAlignment( Qt::AlignCenter );
hgs
parents: 45
diff changeset
    85
        mIconItems[ i ]->setObjectName( QString( "SlideShowIcon%1" ).arg( i ) );
52
hgs
parents: 50
diff changeset
    86
    }    
hgs
parents: 50
diff changeset
    87
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    mSlideTimer = new QTimer();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    mItemList.clear();    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    //Add the signal-slot for this widget.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    addConnections();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    //Create the settings for the effects 
43
hgs
parents: 40
diff changeset
    95
    mEffectEngine->registerEffect( QString("HbIconItem") );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    //provide the xml info for the effect to take place
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    HbEffect::add( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    HbEffect::add( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    HbEffect::add( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
43
hgs
parents: 40
diff changeset
   101
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
GlxSlideShowWidget::~GlxSlideShowWidget()
43
hgs
parents: 40
diff changeset
   104
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    TRACER("GlxSlideShowWidget::~GlxSlideShowWidget()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    //Delete the resources allocated
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    cleanUp();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
43
hgs
parents: 40
diff changeset
   110
    if(mContinueButton) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
        delete mContinueButton;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
        mContinueButton = NULL;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    }
43
hgs
parents: 40
diff changeset
   114
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
void GlxSlideShowWidget::cleanUp()
43
hgs
parents: 40
diff changeset
   117
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
    TRACER("GlxSlideShowWidget::cleanUp()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    removeConnections();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
50
hgs
parents: 45
diff changeset
   121
    if( mEffectEngine ) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
        mEffectEngine->deRegisterEffect( QString("HbIconItem") );    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
        delete mEffectEngine;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
        mEffectEngine = NULL;
43
hgs
parents: 40
diff changeset
   125
    }     
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   126
    
43
hgs
parents: 40
diff changeset
   127
    for ( int i = 0; i < NBR_ITEM ; i++) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
        delete mIconItems[i] ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
        mIconItems[i] = NULL;
43
hgs
parents: 40
diff changeset
   130
    }
52
hgs
parents: 50
diff changeset
   131
    
hgs
parents: 50
diff changeset
   132
    delete mBackGroundItem ;
hgs
parents: 50
diff changeset
   133
    mBackGroundItem = NULL;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
50
hgs
parents: 45
diff changeset
   135
    if( mSlideTimer ) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
        delete mSlideTimer;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
        mSlideTimer = NULL;
43
hgs
parents: 40
diff changeset
   138
    }
50
hgs
parents: 45
diff changeset
   139
    
hgs
parents: 45
diff changeset
   140
    if ( mErrorNote ) {
hgs
parents: 45
diff changeset
   141
        delete mErrorNote ;
hgs
parents: 45
diff changeset
   142
        mErrorNote = NULL;
hgs
parents: 45
diff changeset
   143
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    clearCurrentModel();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    HbEffect::remove( QString("HbIconItem"), QString(":/data/transition.fxml"), QString( "Move" ));
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
    HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionleft.fxml"), QString( "LeftMove" ));
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
    HbEffect::remove( QString("HbIconItem"), QString(":/data/transitionright.fxml"), QString( "RightMove" ));
43
hgs
parents: 40
diff changeset
   149
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
52
hgs
parents: 50
diff changeset
   151
void GlxSlideShowWidget::setModel ( QAbstractItemModel *model )
43
hgs
parents: 40
diff changeset
   152
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
    TRACER("GlxSlideShowWidget::setModel()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    if ( model == mModel ) {
43
hgs
parents: 40
diff changeset
   155
        return ;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    clearCurrentModel();   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
    mModel = model;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    initializeNewModel();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    resetSlideShow();
43
hgs
parents: 40
diff changeset
   161
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
52
hgs
parents: 50
diff changeset
   163
void GlxSlideShowWidget::setItemGeometry( QRect screenRect )
43
hgs
parents: 40
diff changeset
   164
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    TRACER("GlxSlideShowWidget::setItemGeometry()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    int index = mItemIndex;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    mScreenRect = screenRect;   
52
hgs
parents: 50
diff changeset
   168
    mIconItems[ index ]->setGeometry( mScreenRect );
hgs
parents: 50
diff changeset
   169
    index = ( mItemIndex + 1 ) % NBR_ITEM;
hgs
parents: 50
diff changeset
   170
    mIconItems[ index ]->setGeometry( QRect( mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
    index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;    
52
hgs
parents: 50
diff changeset
   172
    mIconItems[ index ]->setGeometry( QRect( -mScreenRect.width(), mScreenRect.top(), mScreenRect.width(), mScreenRect.height() ) );
hgs
parents: 50
diff changeset
   173
    mBackGroundItem->setGeometry( mScreenRect );
43
hgs
parents: 40
diff changeset
   174
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
void GlxSlideShowWidget::triggeredEffect()
43
hgs
parents: 40
diff changeset
   177
{ 
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    TRACER("GlxSlideShowWidget::triggeredEffect()"); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    int index = mItemIndex;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    mSlideTimer->stop();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    mItemList.clear();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
    User::ResetInactivityTime();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   184
    mItemList.append( mIconItems[index] );
43
hgs
parents: 40
diff changeset
   185
    index = ( mItemIndex + 1 ) % NBR_ITEM;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   186
    mItemList.append( mIconItems[index] );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   188
    GLX_LOG_INFO3("GlxSlideShowWidget::triggeredEffect() image selected index %d array index %d index %d", mSelIndex, mItemIndex, index);  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   189
    mEffectEngine->runEffect( mItemList, QString("HbIconItem") );
43
hgs
parents: 40
diff changeset
   190
    emit slideShowEvent( EFFECT_STARTED );
44
hgs
parents: 43
diff changeset
   191
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
void GlxSlideShowWidget::effectFinshed()
43
hgs
parents: 40
diff changeset
   194
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
    GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() before image selected index %d array index %d", mSelIndex, mItemIndex); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
    mItemIndex = ( ++mItemIndex ) % NBR_ITEM;
50
hgs
parents: 45
diff changeset
   198
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole );
hgs
parents: 45
diff changeset
   199
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex );
hgs
parents: 45
diff changeset
   200
    setNextItemIcon();
43
hgs
parents: 40
diff changeset
   201
  
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
    GLX_LOG_INFO2("GlxSlideShowWidget::effectFinshed() after image selected index %d array index %d ", mSelIndex, mItemIndex);
43
hgs
parents: 40
diff changeset
   203
    
50
hgs
parents: 45
diff changeset
   204
    startSlideShow();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
    mItemList.clear();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    emit indexchanged(); // on each item change
43
hgs
parents: 40
diff changeset
   207
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
void GlxSlideShowWidget::cancelEffect()
43
hgs
parents: 40
diff changeset
   210
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    TRACER("GlxSlideShowWidget::cancelEffect()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    mEffectEngine->cancelEffect( mItemList );
43
hgs
parents: 40
diff changeset
   213
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
void GlxSlideShowWidget::pauseSlideShow()
43
hgs
parents: 40
diff changeset
   216
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
    TRACER("GlxSlideShowWidget::pauseSlideShow()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    GLX_LOG_INFO1("GlxSlideShowWidget::pauseSlideShow() %d", this->zValue());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    mIsPause = true;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    mSlideTimer->stop();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    cancelEffect();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    mContinueButton->setZValue( this->zValue() + 2);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    mContinueButton->show() ;
50
hgs
parents: 45
diff changeset
   224
    emit slideShowEvent( UI_ON_EVENT );
43
hgs
parents: 40
diff changeset
   225
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
void GlxSlideShowWidget::continueSlideShow(bool checked)
43
hgs
parents: 40
diff changeset
   228
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    Q_UNUSED( checked )
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    TRACER("GlxSlideShowWidget::continueSlideShow()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    mIsPause = false;
50
hgs
parents: 45
diff changeset
   232
    if ( mModel &&  mSlideShowItemCount > 1 ) {
43
hgs
parents: 40
diff changeset
   233
        mSlideTimer->start( mSettings->slideShowDelayTime() ); 
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    mContinueButton->hide(); 
50
hgs
parents: 45
diff changeset
   236
    emit slideShowEvent( UI_OFF_EVENT );
43
hgs
parents: 40
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 GlxSlideShowWidget::dataChanged(QModelIndex startIndex, QModelIndex endIndex)
43
hgs
parents: 40
diff changeset
   240
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    Q_UNUSED( endIndex )
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    TRACER("GlxSlideShowWidget::dataChanged()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    GLX_LOG_INFO2("GlxSlideShowWidget::dataChanged startIndex = %d mSelIndex = %d ", startIndex.row(), mSelIndex  );
43
hgs
parents: 40
diff changeset
   244
    
50
hgs
parents: 45
diff changeset
   245
    for( int i = 0; i < NBR_ITEM; ++i ) {
hgs
parents: 45
diff changeset
   246
        if ( mSelIndex[ i ] == startIndex.row() ) {
hgs
parents: 45
diff changeset
   247
            mIconItems[ i ]->setIcon( getIcon( startIndex.row() ) );
43
hgs
parents: 40
diff changeset
   248
        }
50
hgs
parents: 45
diff changeset
   249
    }
43
hgs
parents: 40
diff changeset
   250
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
void GlxSlideShowWidget::rowsInserted(const QModelIndex &parent, int start, int end)
43
hgs
parents: 40
diff changeset
   253
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    TRACER("GlxSlideShowWidget::rowsInserted()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    Q_UNUSED(parent);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    Q_UNUSED(start);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
    Q_UNUSED(end);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    resetSlideShow();  
43
hgs
parents: 40
diff changeset
   259
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
void GlxSlideShowWidget::rowsRemoved(const QModelIndex &parent, int start, int end)
43
hgs
parents: 40
diff changeset
   262
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    TRACER("GlxSlideShowWidget::rowsRemoved()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    Q_UNUSED(parent);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
    Q_UNUSED(start);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    Q_UNUSED(end);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    GLX_LOG_INFO1( "GlxSlideShowWidget::rowsRemoved row count = %d ", mModel->rowCount()  );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    if ( mModel->rowCount() <= 0 ) {
43
hgs
parents: 40
diff changeset
   271
        clearCurrentModel();
hgs
parents: 40
diff changeset
   272
        emit slideShowEvent( EMPTY_DATA_EVENT );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    else {
43
hgs
parents: 40
diff changeset
   275
        resetSlideShow();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    }
43
hgs
parents: 40
diff changeset
   277
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
void GlxSlideShowWidget::modelDestroyed()
43
hgs
parents: 40
diff changeset
   280
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
    TRACER("GlxSlideShowWidget::modelDestroyed()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    clearCurrentModel();
43
hgs
parents: 40
diff changeset
   283
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
void GlxSlideShowWidget::orientationChanged(QRect screenRect)
40
hgs
parents: 24
diff changeset
   287
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    TRACER("GlxSlideShowWidget::orientationChanged()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
    cancelEffect();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    setItemGeometry( screenRect);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    resetSlideShow();
40
hgs
parents: 24
diff changeset
   292
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
void GlxSlideShowWidget::leftGesture(int value)
40
hgs
parents: 24
diff changeset
   295
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
    Q_UNUSED(value)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    TRACER("GlxSlideShowWidget::leftGesture()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    int index = ( mItemIndex + 1 ) % NBR_ITEM;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    moveImage( index, mScreenRect.width(), QString("LeftMove"), "leftMoveEffectFinished");
40
hgs
parents: 24
diff changeset
   301
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
void GlxSlideShowWidget::rightGesture(int value)
40
hgs
parents: 24
diff changeset
   304
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    Q_UNUSED(value)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    TRACER ("GlxSlideShowWidget::rightGesture()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    int index = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    moveImage( index, -mScreenRect.width(), QString("RightMove"), "rightMoveEffectFinished"); 
40
hgs
parents: 24
diff changeset
   310
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
void GlxSlideShowWidget::leftMoveEffectFinished( const HbEffect::EffectStatus &status )
43
hgs
parents: 40
diff changeset
   313
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
    Q_UNUSED(status)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    TRACER("GlxSlideShowWidget::leftMoveEffectFinished()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    GLX_LOG_INFO1("GlxSlideShowWidget::leftMoveEffectFinished() %d status", status.reason);
50
hgs
parents: 45
diff changeset
   317
   
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
    mItemIndex = ( ++mItemIndex ) % NBR_ITEM;
50
hgs
parents: 45
diff changeset
   319
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole );
hgs
parents: 45
diff changeset
   320
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex );
hgs
parents: 45
diff changeset
   321
    setNextItemIcon();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    startSlideShow();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
    emit indexchanged(); // on left swipe
43
hgs
parents: 40
diff changeset
   324
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
void GlxSlideShowWidget::rightMoveEffectFinished( const HbEffect::EffectStatus &status )
43
hgs
parents: 40
diff changeset
   327
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
    Q_UNUSED(status)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
    TRACER ( "GlxSlideShowWidget::rightMoveEffectFinished( ) ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
    GLX_LOG_INFO1("GlxSlideShowWidget::rightMoveEffectFinished() %d status", status.reason);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
    mItemIndex = mItemIndex ? mItemIndex - 1 : NBR_ITEM - 1;
50
hgs
parents: 45
diff changeset
   333
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxFocusIndexRole );
hgs
parents: 45
diff changeset
   334
    mModel->setData( mModel->index( 0, 0 ), mSelIndex[ mItemIndex ], GlxVisualWindowIndex );
hgs
parents: 45
diff changeset
   335
    setPreItemIcon();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    startSlideShow();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
    emit indexchanged(); // on right swipe
43
hgs
parents: 40
diff changeset
   338
} 
40
hgs
parents: 24
diff changeset
   339
 
hgs
parents: 24
diff changeset
   340
void GlxSlideShowWidget::gestureEvent(QGestureEvent *event)
hgs
parents: 24
diff changeset
   341
{  
hgs
parents: 24
diff changeset
   342
    if( QTapGesture *gesture = static_cast<QTapGesture *>( event->gesture( Qt::TapGesture ) ) ) {        
hgs
parents: 24
diff changeset
   343
        if ( gesture->state() == Qt::GestureFinished ) {
hgs
parents: 24
diff changeset
   344
            if ( mIsPause == false ) {
hgs
parents: 24
diff changeset
   345
                pauseSlideShow();
hgs
parents: 24
diff changeset
   346
            }
hgs
parents: 24
diff changeset
   347
            event->accept(gesture);
hgs
parents: 24
diff changeset
   348
        }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
    }
40
hgs
parents: 24
diff changeset
   350
      
hgs
parents: 24
diff changeset
   351
    if (QPanGesture *panningGesture = qobject_cast<QPanGesture*>(event->gesture(Qt::PanGesture))) {
hgs
parents: 24
diff changeset
   352
        HbPanGesture *hbPanGesture = qobject_cast<HbPanGesture *>(panningGesture);
hgs
parents: 24
diff changeset
   353
        if ( hbPanGesture ) {
hgs
parents: 24
diff changeset
   354
            if( hbPanGesture->state() == Qt::GestureFinished ) {
hgs
parents: 24
diff changeset
   355
                QPointF delta( hbPanGesture->sceneDelta() );
hgs
parents: 24
diff changeset
   356
                if ( delta.x() > 0 ) {
hgs
parents: 24
diff changeset
   357
                    rightGesture( delta.x() );
hgs
parents: 24
diff changeset
   358
                }
hgs
parents: 24
diff changeset
   359
                else {
hgs
parents: 24
diff changeset
   360
                    leftGesture( delta.x() );
hgs
parents: 24
diff changeset
   361
                }
hgs
parents: 24
diff changeset
   362
            }
hgs
parents: 24
diff changeset
   363
            event->accept(panningGesture);
hgs
parents: 24
diff changeset
   364
        }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    }
40
hgs
parents: 24
diff changeset
   366
}    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
void GlxSlideShowWidget::startSlideShow ( )
43
hgs
parents: 40
diff changeset
   369
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
    TRACER ( "GlxSlideShowWidget::startSlideShow( ) ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    GLX_LOG_INFO1 ( "GlxSlideShowWidget::startSlideShow( ) is pause %d", mIsPause);    
50
hgs
parents: 45
diff changeset
   372
    
hgs
parents: 45
diff changeset
   373
    if ( mSlideShowItemCount == 0 ) { 
hgs
parents: 45
diff changeset
   374
        showErrorNote();
hgs
parents: 45
diff changeset
   375
    }
hgs
parents: 45
diff changeset
   376
    if ( mIsPause == false && mModel &&  mSlideShowItemCount > 1 ) {
43
hgs
parents: 40
diff changeset
   377
        mSlideTimer->start( mSettings->slideShowDelayTime() );  
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    }    
43
hgs
parents: 40
diff changeset
   379
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
void GlxSlideShowWidget::stopSlideShow (  )
43
hgs
parents: 40
diff changeset
   382
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
    TRACER ( "GlxSlideShowWidget::stopSlideShow( ) ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    cancelEffect();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    mSlideTimer->stop();                
43
hgs
parents: 40
diff changeset
   386
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
void GlxSlideShowWidget::clearCurrentModel()
43
hgs
parents: 40
diff changeset
   389
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    TRACER ( "GlxSlideShowWidget::clearCurrentModel( ) ");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
    if ( mModel ) {
43
hgs
parents: 40
diff changeset
   392
        disconnect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) );
hgs
parents: 40
diff changeset
   393
        disconnect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int)));
hgs
parents: 40
diff changeset
   394
        disconnect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int)));
hgs
parents: 40
diff changeset
   395
        disconnect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed()));
hgs
parents: 40
diff changeset
   396
        mModel = NULL ;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    }
43
hgs
parents: 40
diff changeset
   398
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
void GlxSlideShowWidget::initializeNewModel()
43
hgs
parents: 40
diff changeset
   401
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
    TRACER("GlxSlideShowWidget::initializeNewModel" );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
    if ( mModel ) {
43
hgs
parents: 40
diff changeset
   404
        connect( mModel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ), this, SLOT( dataChanged(QModelIndex,QModelIndex) ) );
hgs
parents: 40
diff changeset
   405
        connect(mModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int)));
hgs
parents: 40
diff changeset
   406
        connect(mModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int)));
hgs
parents: 40
diff changeset
   407
        connect(mModel, SIGNAL(destroyed()), this, SLOT( modelDestroyed()));
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    }	
43
hgs
parents: 40
diff changeset
   409
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
void GlxSlideShowWidget::resetSlideShow()
43
hgs
parents: 40
diff changeset
   412
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
    TRACER("GlxSlideShowWidget::resetSlideShow()" );
50
hgs
parents: 45
diff changeset
   414
	if(  mModel == NULL || mModel->rowCount() == 0 ) {
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   415
		return;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   416
	}
50
hgs
parents: 45
diff changeset
   417
	
hgs
parents: 45
diff changeset
   418
	mSlideShowItemCount = mModel->rowCount();
hgs
parents: 45
diff changeset
   419
	setFocusItemIcon() ;
hgs
parents: 45
diff changeset
   420
	setNextItemIcon() ;
hgs
parents: 45
diff changeset
   421
	setPreItemIcon() ;
hgs
parents: 45
diff changeset
   422
	startSlideShow();
hgs
parents: 45
diff changeset
   423
	
hgs
parents: 45
diff changeset
   424
	qDebug( "GlxSlideShowWidget::resetSlideShow slide show item count %d" , mSlideShowItemCount );
hgs
parents: 45
diff changeset
   425
	if ( mErrorNote && mErrorNote->isVisible() && mSlideShowItemCount > 1 ){
hgs
parents: 45
diff changeset
   426
	    hideErrorNote();
hgs
parents: 45
diff changeset
   427
	}
43
hgs
parents: 40
diff changeset
   428
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
void GlxSlideShowWidget::moveImage(int nextIndex, int posX, const QString & move, char * callBack)
43
hgs
parents: 40
diff changeset
   431
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    TRACER("GlxSlideShowWidget::MoveImage()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
50
hgs
parents: 45
diff changeset
   434
    if ( mSlideShowItemCount <= 1 || mEffectEngine->isEffectRuning( mItemList ) ) {
43
hgs
parents: 40
diff changeset
   435
        return ;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    mSlideTimer->stop();
43
hgs
parents: 40
diff changeset
   439
    HbEffect::start( mIconItems[mItemIndex], QString("HbIconItem"), move );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    mIconItems[nextIndex]->setPos( posX, mScreenRect.top());
43
hgs
parents: 40
diff changeset
   441
    mIconItems[nextIndex]->setOpacity(1);
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
    HbEffect::start(mIconItems[nextIndex], QString("HbIconItem"), QString("Move"), this, callBack );    
43
hgs
parents: 40
diff changeset
   443
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
void GlxSlideShowWidget::addConnections()
43
hgs
parents: 40
diff changeset
   446
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    TRACER("GlxSlideShowWidget::addConnections()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    if ( mEffectEngine )  {
43
hgs
parents: 40
diff changeset
   449
        connect( mEffectEngine, SIGNAL( effectFinished() ), this, SLOT( effectFinshed() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    if ( mSlideTimer ) {
43
hgs
parents: 40
diff changeset
   452
        connect( mSlideTimer, SIGNAL(timeout()), this, SLOT( triggeredEffect() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    if ( mContinueButton ) {
43
hgs
parents: 40
diff changeset
   455
        connect( mContinueButton, SIGNAL( clicked(bool) ), this, SLOT( continueSlideShow(bool) ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    }
43
hgs
parents: 40
diff changeset
   457
}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
void GlxSlideShowWidget::removeConnections()
43
hgs
parents: 40
diff changeset
   460
{
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    TRACER("GlxSlideShowWidget::removeConnections()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    if ( mEffectEngine )  {
43
hgs
parents: 40
diff changeset
   463
        disconnect( mEffectEngine, SIGNAL( effectFinished() ), this, SLOT( effectFinshed() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    if ( mSlideTimer ) {
43
hgs
parents: 40
diff changeset
   466
        disconnect( mSlideTimer, SIGNAL(timeout()), this, SLOT( triggeredEffect() ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
    if ( mContinueButton ) {
43
hgs
parents: 40
diff changeset
   469
        disconnect( mContinueButton, SIGNAL( clicked(bool) ), this, SLOT( continueSlideShow(bool) ) );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
    }
43
hgs
parents: 40
diff changeset
   471
}
50
hgs
parents: 45
diff changeset
   472
hgs
parents: 45
diff changeset
   473
int GlxSlideShowWidget::getFocusIndex( )
hgs
parents: 45
diff changeset
   474
{
hgs
parents: 45
diff changeset
   475
    QVariant variant = mModel->data( mModel->index( 0, 0 ), GlxFocusIndexRole ) ;
hgs
parents: 45
diff changeset
   476
    if ( variant.isValid() && variant.canConvert< int > () ) {
hgs
parents: 45
diff changeset
   477
        return variant.value< int > ();
hgs
parents: 45
diff changeset
   478
    }
hgs
parents: 45
diff changeset
   479
    return -1;
hgs
parents: 45
diff changeset
   480
}
hgs
parents: 45
diff changeset
   481
hgs
parents: 45
diff changeset
   482
HbIcon GlxSlideShowWidget::getIcon( int index )
hgs
parents: 45
diff changeset
   483
{
hgs
parents: 45
diff changeset
   484
    QVariant variant = mModel->data( mModel->index( index, 0 ), GlxFsImageRole );
hgs
parents: 45
diff changeset
   485
    if ( variant.isValid() &&  variant.canConvert< HbIcon > () ) {
hgs
parents: 45
diff changeset
   486
        return variant.value< HbIcon > () ;       
hgs
parents: 45
diff changeset
   487
    }
hgs
parents: 45
diff changeset
   488
    return HbIcon() ;
hgs
parents: 45
diff changeset
   489
}
hgs
parents: 45
diff changeset
   490
hgs
parents: 45
diff changeset
   491
bool GlxSlideShowWidget::isCorrupt( int index )
hgs
parents: 45
diff changeset
   492
{
hgs
parents: 45
diff changeset
   493
    QVariant variant = mModel->data( mModel->index( index, 0 ), GlxImageCorruptRole );
hgs
parents: 45
diff changeset
   494
    if ( variant.isValid() && variant.canConvert< bool> () ) {
hgs
parents: 45
diff changeset
   495
        return variant.value< bool > () ;
hgs
parents: 45
diff changeset
   496
    }
hgs
parents: 45
diff changeset
   497
    return false ;    
hgs
parents: 45
diff changeset
   498
}
hgs
parents: 45
diff changeset
   499
hgs
parents: 45
diff changeset
   500
bool GlxSlideShowWidget::setFocusItemIcon( )
hgs
parents: 45
diff changeset
   501
{
hgs
parents: 45
diff changeset
   502
    int nbrItem = mModel->rowCount();
hgs
parents: 45
diff changeset
   503
    int focusIndex = getFocusIndex();
hgs
parents: 45
diff changeset
   504
    
hgs
parents: 45
diff changeset
   505
    for ( int i = 0; i < nbrItem ; ++i ) {
hgs
parents: 45
diff changeset
   506
        if ( isCorrupt( focusIndex  ) == false ) {  
hgs
parents: 45
diff changeset
   507
            qDebug( "GlxSlideShowWidget::setFocusItemIcon1 focus index %d" , focusIndex );
hgs
parents: 45
diff changeset
   508
            mIconItems[ mItemIndex ]->setIcon( getIcon( focusIndex ) ) ;
hgs
parents: 45
diff changeset
   509
            mSelIndex[ mItemIndex ] = focusIndex ;
hgs
parents: 45
diff changeset
   510
            if (  i != 0 ) {
hgs
parents: 45
diff changeset
   511
                mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxFocusIndexRole );
hgs
parents: 45
diff changeset
   512
                mModel->setData( mModel->index( 0, 0 ), focusIndex, GlxVisualWindowIndex );
hgs
parents: 45
diff changeset
   513
            }
hgs
parents: 45
diff changeset
   514
            return true;
hgs
parents: 45
diff changeset
   515
        }
hgs
parents: 45
diff changeset
   516
        focusIndex = ( focusIndex + 1 ) % nbrItem;
hgs
parents: 45
diff changeset
   517
    }
hgs
parents: 45
diff changeset
   518
    mSlideShowItemCount = 0;
hgs
parents: 45
diff changeset
   519
    return false;    
hgs
parents: 45
diff changeset
   520
}
hgs
parents: 45
diff changeset
   521
hgs
parents: 45
diff changeset
   522
bool GlxSlideShowWidget::setNextItemIcon( )
hgs
parents: 45
diff changeset
   523
{
hgs
parents: 45
diff changeset
   524
    int nbrItem = mModel->rowCount();
hgs
parents: 45
diff changeset
   525
    int imageIndex = ( mSelIndex[ mItemIndex ] + 1 ) % nbrItem ;
hgs
parents: 45
diff changeset
   526
    int itemIndex = ( mItemIndex + 1 ) % NBR_ITEM ;
hgs
parents: 45
diff changeset
   527
    
hgs
parents: 45
diff changeset
   528
    for( int i = 1; i < nbrItem; ++i ) {
hgs
parents: 45
diff changeset
   529
       if ( isCorrupt( imageIndex ) == false ) {
hgs
parents: 45
diff changeset
   530
           mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) );
hgs
parents: 45
diff changeset
   531
           mSelIndex[ itemIndex ] = imageIndex ;
hgs
parents: 45
diff changeset
   532
           return true;
hgs
parents: 45
diff changeset
   533
       }
hgs
parents: 45
diff changeset
   534
       imageIndex = ( imageIndex + 1 ) % nbrItem ;
hgs
parents: 45
diff changeset
   535
    }
hgs
parents: 45
diff changeset
   536
    
hgs
parents: 45
diff changeset
   537
    if ( isCorrupt( imageIndex ) ) {
hgs
parents: 45
diff changeset
   538
        mSlideShowItemCount = 0;
hgs
parents: 45
diff changeset
   539
    }
hgs
parents: 45
diff changeset
   540
    else {
hgs
parents: 45
diff changeset
   541
        mSlideShowItemCount = 1;
hgs
parents: 45
diff changeset
   542
    }
hgs
parents: 45
diff changeset
   543
    return false ;
hgs
parents: 45
diff changeset
   544
}
hgs
parents: 45
diff changeset
   545
hgs
parents: 45
diff changeset
   546
bool GlxSlideShowWidget::setPreItemIcon()
hgs
parents: 45
diff changeset
   547
{
hgs
parents: 45
diff changeset
   548
    int nbrItem = mModel->rowCount() ;
hgs
parents: 45
diff changeset
   549
    int imageIndex = mSelIndex[ mItemIndex ] > 0 ? mSelIndex[ mItemIndex ] - 1 : nbrItem - 1 ;
hgs
parents: 45
diff changeset
   550
    int itemIndex = mItemIndex > 0 ? mItemIndex - 1 : mItemIndex  ;
hgs
parents: 45
diff changeset
   551
    
hgs
parents: 45
diff changeset
   552
    for( int i = 1; i < nbrItem; ++i ) {
hgs
parents: 45
diff changeset
   553
        if ( isCorrupt( imageIndex ) == false ) {
hgs
parents: 45
diff changeset
   554
            mIconItems[ itemIndex ]->setIcon( getIcon( imageIndex ) ) ;
hgs
parents: 45
diff changeset
   555
            mSelIndex[ itemIndex ] = imageIndex ;
hgs
parents: 45
diff changeset
   556
            return true;        
hgs
parents: 45
diff changeset
   557
        }
hgs
parents: 45
diff changeset
   558
        imageIndex = imageIndex > 0 ? imageIndex - 1 : nbrItem - 1 ; 
hgs
parents: 45
diff changeset
   559
    }
hgs
parents: 45
diff changeset
   560
    if ( isCorrupt( imageIndex ) ) {
hgs
parents: 45
diff changeset
   561
        mSlideShowItemCount = 0;
hgs
parents: 45
diff changeset
   562
    }
hgs
parents: 45
diff changeset
   563
    else {
hgs
parents: 45
diff changeset
   564
        mSlideShowItemCount = 1;
hgs
parents: 45
diff changeset
   565
    }
hgs
parents: 45
diff changeset
   566
    return false;
hgs
parents: 45
diff changeset
   567
}
hgs
parents: 45
diff changeset
   568
hgs
parents: 45
diff changeset
   569
void GlxSlideShowWidget::showErrorNote()
hgs
parents: 45
diff changeset
   570
{
hgs
parents: 45
diff changeset
   571
    if ( mErrorNote == NULL ){
hgs
parents: 45
diff changeset
   572
        mErrorNote = new HbLabel( QString( GLX_NOIMAGE_PLAY_SLIDESHOW ), this);
hgs
parents: 45
diff changeset
   573
        mErrorNote->setObjectName( "No Image" );
hgs
parents: 45
diff changeset
   574
        mErrorNote->setGeometry( mIconItems[ 0 ]->geometry() );
hgs
parents: 45
diff changeset
   575
        mErrorNote->setAlignment( Qt::AlignCenter );
hgs
parents: 45
diff changeset
   576
    }
hgs
parents: 45
diff changeset
   577
    
hgs
parents: 45
diff changeset
   578
    for( int i = 0; i < NBR_ITEM; ++i ){
hgs
parents: 45
diff changeset
   579
        mIconItems[ i ]->setVisible( false );
hgs
parents: 45
diff changeset
   580
    }
hgs
parents: 45
diff changeset
   581
    mErrorNote->setVisible( true );
hgs
parents: 45
diff changeset
   582
    emit slideShowEvent( UI_ON_EVENT );
hgs
parents: 45
diff changeset
   583
}
hgs
parents: 45
diff changeset
   584
hgs
parents: 45
diff changeset
   585
void GlxSlideShowWidget::hideErrorNote()
hgs
parents: 45
diff changeset
   586
{
hgs
parents: 45
diff changeset
   587
    for( int i = 0; i < NBR_ITEM; ++i ){
hgs
parents: 45
diff changeset
   588
        mIconItems[ i ]->setVisible( true );
hgs
parents: 45
diff changeset
   589
    }
hgs
parents: 45
diff changeset
   590
    mErrorNote->setVisible( false );
hgs
parents: 45
diff changeset
   591
    emit slideShowEvent( UI_OFF_EVENT );
hgs
parents: 45
diff changeset
   592
}
hgs
parents: 45
diff changeset
   593