ui/viewmanagement/statehandler/src/glxstatemanager.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 18 Aug 2010 09:48:53 +0300
changeset 55 fb37077c270f
parent 49 f291796e213d
child 70 a91aa46552be
permissions -rw-r--r--
Revision: 201031 Kit: 201033
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
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    18
//include
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <QApplication>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QDebug>
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QItemSelectionModel>
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
    22
#include <hbnotificationdialog.h>
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
    23
#include <QProcess>
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    24
#include <hbinstance.h>
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
    25
#include <HbActivityManager.h>
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
    26
#include <hbapplication.h>
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    27
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    28
//user includes
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    29
#include "glxstatemanager.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    30
#include "glxviewmanager.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    31
#include "glxviewids.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    32
#include "glxmediamodel.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    33
#include "glxgridstate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    34
#include "glxliststate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    35
#include "glxfullscreenstate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    36
#include "glxdetailstate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    37
#include "glxslideshowsettingsstate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    38
#include "glxslideshowstate.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    39
#include "glxtnobserver.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    40
#include "glxmodelparm.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    41
#include "glxcollectionpluginall.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    42
#include "glxcollectionplugincamera.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    43
#include "glxcollectionpluginalbums.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    44
#include "glxcollectionpluginimageviewer.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    45
#include "glxexternalutility.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    46
#include "glxalbummodel.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    47
#include "glxloggerenabler.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    48
#include "glxmediaid.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    49
#include "glxactionhandler.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    50
#include "glxcommandhandlers.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    51
#include "glxplugincommandid.hrh"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    52
#include "glxlog.h"
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
    53
#include "glxtracer.h"
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
    54
#include <glximageviewermanager.h>
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    55
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    56
GlxStateManager::GlxStateManager() 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    57
    : mAllMediaModel( NULL ), 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    58
      mAlbumGridMediaModel( NULL ),
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    59
      mAlbumMediaModel( NULL ),
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    60
      mImageviewerMediaModel( NULL ), 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    61
      mCurrentModel( NULL ), 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    62
      mCurrentState( NULL ), 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    63
      mActionHandler( NULL ),
36
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
    64
      mTNObserver ( NULL ),
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
    65
      isProgressbarRunning ( false )
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    qDebug("GlxStateManager::GlxStateManager");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
    PERFORMANCE_ADV ( d1, "view manager creation time") {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
        mViewManager = new GlxViewManager();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
    }
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    71
    mTNObserver = new GlxTNObserver();
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    72
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
    connect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ), Qt::QueuedConnection );
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    74
    connect ( mViewManager, SIGNAL(actionTriggered( qint32 )), this, SLOT(actionTriggered( qint32 )), Qt::QueuedConnection );
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
    75
    connect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) );
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
    76
    connect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData()));
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
	//TO:DO TBD through exception when it is null
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
void GlxStateManager::enterMarkingMode()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
    mViewManager->enterMarkingMode(mCurrentState->id());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
void GlxStateManager::exitMarkingMode()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    mViewManager->exitMarkingMode(mCurrentState->id());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
}
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
bool GlxStateManager::executeCommand(qint32 commandId)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    qDebug( "GlxStateManager::executeCommand() : command ID %d", commandId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    QItemSelectionModel * selectionModel = mViewManager->getSelectionModel(mCurrentState->id());
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    if ( selectionModel == NULL )
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
        return FALSE;
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
    QModelIndexList indexList = selectionModel->selectedIndexes();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    //if no item is selected then do nothing
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
    if (indexList.count() == 0) 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
        return FALSE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    for ( int i = 0; i < indexList.count(); i++) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
        qDebug( "GlxGridView::doneAction() : index %d", indexList[i].row());            
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
        mCurrentModel->setData( indexList[i], indexList[i].row(), GlxSelectedIndexRole );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   106
    mActionHandler->handleAction(commandId, mCollectionId,indexList);
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    return TRUE;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   110
bool GlxStateManager::eventFilter(QObject *obj, QEvent *event)
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   111
{
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   112
    TRACER("GlxStateManager::eventFilter() ");
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   113
    GLX_LOG_INFO1("GlxStateManager::eventFilter() %d event type", event->type());
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   114
    
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   115
    if ( event->type() ==  QEvent::ApplicationActivate ) {
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   116
        mTNObserver->startTNMDaemon();
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   117
    }
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   118
    if ( event->type() ==  QEvent::ApplicationDeactivate ) {
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   119
        mTNObserver->stopTNMDaemon();
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   120
    }
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   121
    return QObject::eventFilter(obj, event);
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   122
}
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   123
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   124
void GlxStateManager::launchFetcher()
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   125
{
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   126
    qDebug("GlxStateManager::launchFetcher");
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   127
    mCurrentState = createState(GLX_GRIDVIEW_ID);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   128
    mCurrentState->setState(FETCHER_ITEM_S);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   129
    
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   130
    createModel(GLX_GRIDVIEW_ID);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   131
    mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   132
}
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   133
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
void GlxStateManager::launchApplication()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
{
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   136
    qDebug("GlxStateManager::launchApplication");   
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   137
    bool activitySuccess = false;  
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   138
    //To:Do use it in future once performance code is removed nextState(GLX_GRIDVIEW_ID, ALL_ITEM_S)
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   139
    HbApplication* app = qobject_cast<HbApplication*>(qApp);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   140
    if(app->activateReason() == Hb::ActivationReasonActivity) {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   141
        activitySuccess = launchActivity();
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   142
    }
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   143
    
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   144
    if( !activitySuccess ) { 
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   145
        mCurrentState = createState( GLX_GRIDVIEW_ID );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   146
        mCurrentState->setState( ALL_ITEM_S );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   147
       
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   148
        int leftCount = mTNObserver->getTNLeftCount() ;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   149
        if (  leftCount > 0  ) {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   150
            mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   151
            launchProgressDialog();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   152
        }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   153
        else {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   154
            createModel( GLX_GRIDVIEW_ID );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   155
            mViewManager->launchApplication( GLX_GRIDVIEW_ID, mCurrentModel );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   156
        }    
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   157
        mTNObserver->startTNObserving() ; 
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   158
    }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   159
    
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   160
    HbActivityManager* activityManager = app->activityManager();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   161
    bool ok = activityManager->removeActivity("PhotosMainView");
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   162
    if ( !ok )
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   163
    {
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   164
         qDebug("launchapplication::Remove activity failed" );
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   165
    } 
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   166
}
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   167
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   168
bool GlxStateManager::launchActivity()
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   169
{
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   170
    HbApplication* app = qobject_cast<HbApplication*>(qApp);
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   171
    bool ok = app->activityManager()->waitActivity();
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   172
    if ( !ok )
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   173
    {
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   174
        qDebug("subscribing to activity manager failed" );
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   175
    }
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   176
    QVariant data = app->activityManager()->activityData( "PhotosMainView" );
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   177
    QByteArray serializedModel = data.toByteArray();
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   178
    QDataStream stream(&serializedModel, QIODevice::ReadOnly);
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   179
    
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   180
    //Fetch the data from the activity Manager
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   181
    stream >> mSaveActivity;  
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   182
    qint32 stateId = mSaveActivity.value("ID");
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   183
    mCurrentState = createState(stateId);
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   184
    mCurrentState->setState( mSaveActivity.value("InternalState") );
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   185
    createModel( stateId);
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   186
	/*Model might not be populated yet to set the visibleWindowIndex right away.
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   187
	*So, let us store the visible index as a temporary Variable, so that  visible Window Index 
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   188
	*is set once the model is populated.
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   189
    */
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   190
    mCurrentModel->setData(QModelIndex(), mSaveActivity.value("VisibleIndex") , GlxTempVisualWindowIndex );
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   191
    mViewManager->launchApplication(stateId, mCurrentModel); 
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   192
    return true;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
void GlxStateManager::launchFromExternal()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
{
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   197
    qDebug("GlxStateManager::launchFromExternal");
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    mCurrentState = createState(GLX_FULLSCREENVIEW_ID);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    mCurrentState->setState(IMAGEVIEWER_S);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    createModel(GLX_FULLSCREENVIEW_ID);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
    mCurrentModel->setData( mCurrentModel->index(0,0), 0, GlxFocusIndexRole );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
    mViewManager->launchApplication( GLX_FULLSCREENVIEW_ID, mCurrentModel);
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   204
	setupItems();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
void GlxStateManager::actionTriggered(qint32 id)
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
    qDebug("GlxStateManager::actionTriggered action ID = %d", id);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
    mCurrentState->eventHandler(id);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    if (id != EGlxCmdHandled ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
        eventHandler(id);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    }
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
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
void GlxStateManager::setupItems()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
{    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
    qDebug("GlxStateManager::setupItems()");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
    mActionHandler = new GlxActionHandler();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    connect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    mViewManager->setupItems();
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   222
    switch( mSaveActivity.value( "ID" ) ){
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   223
        case GLX_LISTVIEW_ID:
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   224
            mViewManager->updateToolBarIcon(GLX_ALBUM_ACTION_ID);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   225
            break;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   226
            
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   227
        case GLX_GRIDVIEW_ID:
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   228
        default:
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   229
            mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   230
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   233
void GlxStateManager::updateTNProgress( int count)
36
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   234
{    
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   235
    TRACER("GlxStateManager::updateTNProgress() ");
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   236
    // this is case when progress bar is not showing
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   237
    // in the case of rename of an image or capture the single item
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   238
    // it is also launching the progress bar, to avoid this scenario add the check of count more than 5
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   239
    if ( mCurrentModel && ( count > 5  ) ) { 
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   240
         goBack( GLX_GRIDVIEW_ID, ALL_ITEM_S ) ;
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   241
         cleanAllModel();
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   242
         launchProgressDialog();
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   243
    }
36
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   244
    
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   245
    if ( isProgressbarRunning ){
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   246
        if ( count == 0 ) {
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   247
            vanishProgressDialog();
36
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   248
        }
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   249
        else {
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   250
            mViewManager->updateProgressDialog( count );
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   251
        }
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   252
    }   
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   253
}
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   254
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   255
void GlxStateManager::thumbnailPopulated()
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   256
{
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   257
    mViewManager->setModel( mCurrentModel );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   258
    isProgressbarRunning = false;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   259
    mViewManager->updateProgressDialog( 0 );  
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   260
    disconnect ( mCurrentModel, SIGNAL( thumbnailPopulated() ), this, SLOT( thumbnailPopulated() ) );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   261
}
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   262
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   263
void GlxStateManager::saveData()
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   264
{
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   265
    if( (mCurrentState->id() == GLX_GRIDVIEW_ID && mCurrentState->state() == ALL_ITEM_S) || mCurrentState->id() == GLX_LISTVIEW_ID ) {
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   266
        mSaveActivity.insert("ID",mCurrentState->id()); 
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   267
        mSaveActivity.insert("InternalState",mCurrentState->state());
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   268
        if(mCurrentModel) {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   269
            QVariant variant = mCurrentModel->data( mCurrentModel->index(0,0), GlxVisualWindowIndex );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   270
            if ( variant.isValid() &&  variant.canConvert<int> () ) {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   271
                mSaveActivity.insert("VisibleIndex",variant.value<int>());
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   272
            }
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   273
 		}
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   274
 		else {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   275
 			mSaveActivity.insert("VisibleIndex",0);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   276
 		}
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   277
    
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   278
        HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   279
        QVariantHash metadata;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   280
        HbMainWindow *window = hbInstance->allMainWindows().first();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   281
        metadata.insert("screenshot", QPixmap::grabWidget(window, window->rect()));
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   282
        
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   283
        QByteArray serializedModel;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   284
        QDataStream stream(&serializedModel, QIODevice::WriteOnly | QIODevice::Append);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   285
        stream << mSaveActivity;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   286
        
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   287
        bool ok = activityManager->addActivity("PhotosMainView", serializedModel, metadata);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   288
        if ( !ok )
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   289
        {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   290
            qDebug("SaveData::Add activity failed" );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   291
        }
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   292
    }
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   293
}
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   294
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
void GlxStateManager::nextState(qint32 state, int internalState)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    qDebug("GlxStateManager::nextState next state = %u", state);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
    GlxEffect effect = NO_EFFECT ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    GlxViewEffect viewEffect = NO_VIEW ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    PERFORMANCE ( d1, State Creation Time ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
        mCurrentState = createState(state); //create a new state
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
        mCurrentState->setState(internalState); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    createModel(state); //model should created after the internal state was set.
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
    PERFORMANCE ( d2, view launch time ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
        mCurrentState->setTranstionParameter( FORWARD_DIR, effect, viewEffect); // to run the transtion effect
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
        if ( viewEffect == NO_VIEW ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
            mViewManager->launchView( state, mCurrentModel );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
        else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
            mViewManager->launchView( state, mCurrentModel, effect, viewEffect);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
void GlxStateManager::previousState()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    qDebug("GlxStateManager::previousState");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
    GlxEffect effect = NO_EFFECT ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
    GlxViewEffect viewEffect = NO_VIEW ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
    GlxState *state = mCurrentState; // To delete the current state later  
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
    if ( mCurrentState->previousState() == NULL ) { //In the case only one state in stack then exit from the application
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   328
        saveImage(); // save image if it is in private folder
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
        exitApplication() ;
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   330
        return ;
23
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
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
        //effect parameter should be set here other wise there is no way to know from where it come from
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
        mCurrentState->setTranstionParameter( BACKWARD_DIR, effect, viewEffect);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
        mCurrentState = mCurrentState->previousState(); //get the pervious state
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
        createModel( mCurrentState->id(), BACKWARD_DIR ); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
        if ( viewEffect == NO_VIEW ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
            mViewManager->launchView( mCurrentState->id(), mCurrentModel );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
        else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
            mViewManager->launchView( mCurrentState->id(), mCurrentModel, effect, viewEffect);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
    delete state;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   346
}
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   347
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   348
void GlxStateManager::saveImage()
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   349
    {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   350
    CGlxImageViewerManager *imageViewerInstance = CGlxImageViewerManager::InstanceL();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   351
    if(imageViewerInstance->IsPrivate())
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   352
        {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   353
        HBufC* imagePath = imageViewerInstance->ImageUri();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   354
		QString srcPath = QString::fromUtf16(imagePath->Des().Ptr(),imagePath->Length());
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   355
		QString imageName = srcPath.section('\\', -1);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   356
		QString imagesFolderPath("c:/data/images/");
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   357
		QString destPath;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   358
		destPath.append(imagesFolderPath);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   359
		destPath.append(imageName);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   360
		int cnt = 1;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   361
		qDebug() << "GlxStateManager::saveImage path before while = "<< destPath;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   362
		while(!QFile::copy(srcPath,destPath))
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   363
			{
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   364
			QString filename = imageName.section('.', 0,0);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   365
			QString ext = imageName.section('.', -1);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   366
			destPath.clear();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   367
			destPath = imagesFolderPath + filename + QString::number(cnt) + "." + ext;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   368
			qDebug() << "GlxStateManager::saveImage path = "<< destPath;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   369
			cnt++;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   370
			}
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   371
        }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   372
    imageViewerInstance->Close();
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   373
    }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   374
	
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
void GlxStateManager::goBack(qint32 stateId, int internalState)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    qDebug("GlxStateManager::goBack()");
36
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   378
    
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   379
    //if current state and it internal state is same then no need to do any thing
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   380
    if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   381
        return ;
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   382
    }
6481344a6d67 Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 33
diff changeset
   383
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    GlxState *state = mCurrentState;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   386
    while ( mCurrentState ) {
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   387
        if ( mCurrentState->id() == stateId  && mCurrentState->state() == internalState ) {
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   388
            break ;           
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   389
        }
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   390
        
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        mCurrentState = mCurrentState->previousState(); // set pervious state to the current state
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
        delete state; //delete the current state
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   393
        state = mCurrentState;    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
    //case when new state is not hierarchy then create a new state
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    if ( mCurrentState == NULL ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
        mCurrentState = createState(stateId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
        mCurrentState->setState( internalState );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    }   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
    qDebug("GlxStateManager::goBack() state %u", mCurrentState);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
    createModel( mCurrentState->id() ); //model should created after the internal state was set.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
    mViewManager->launchView( mCurrentState->id(), mCurrentModel );   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
void GlxStateManager::changeState(qint32 stateId, int internalState)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
    qDebug("GlxStateManager::changeState %d", stateId);	
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
    GlxState *state = mCurrentState;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
    GlxEffect effect = NO_EFFECT ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
    GlxViewEffect viewEffect = NO_VIEW ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    mCurrentState = mCurrentState->previousState();//pervious state of current state become the pervious state of new state 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    mCurrentState = createState(stateId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    mCurrentState->setState( internalState );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
    createModel( stateId ); //model should created after the internal state was set.
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    mCurrentState->setTranstionParameter( NO_DIR, effect, viewEffect); //set the transition parameter    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    if ( viewEffect == NO_VIEW ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
        mViewManager->launchView( mCurrentState->id(), mCurrentModel );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
        mViewManager->launchView( mCurrentState->id(), mCurrentModel, effect, viewEffect);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    delete state;
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
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
void GlxStateManager::removeCurrentModel()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
{
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   433
    TRACER("GlxStateManager::removeCurrentModel() ");
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    if ( mCurrentModel == mAllMediaModel ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
        qDebug("GlxStateManager::removeCurrentModel() remove all media model");	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
        delete mAllMediaModel ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
        mAllMediaModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
        mCurrentModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
    else if ( mCurrentModel == mAlbumGridMediaModel ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
        qDebug("GlxStateManager::removeCurrentModel() remove album grid media model");	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
        delete mAlbumGridMediaModel ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
        mAlbumGridMediaModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
        mCurrentModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
    else if ( mCurrentModel == mAlbumMediaModel ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
        qDebug("GlxStateManager::removeCurrentModel() remove  model");	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
        delete mAlbumMediaModel ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
        mAlbumMediaModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
        mCurrentModel = NULL ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
    else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    	qDebug("GlxStateManager::removeCurrentModel() do nothing");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    	//do nothing
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   458
void GlxStateManager::cleanAllModel()
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   459
{
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   460
    TRACER("GlxStateManager::cleanAllModel() ");
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   461
    delete mAllMediaModel ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   462
    mAllMediaModel = NULL ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   463
    delete mAlbumMediaModel ; 
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   464
    mAlbumMediaModel = NULL ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   465
    delete mAlbumGridMediaModel ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   466
    mAlbumGridMediaModel = NULL ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   467
    delete mImageviewerMediaModel ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   468
    mImageviewerMediaModel = NULL ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   469
    mCurrentModel = NULL ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   470
}
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   471
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   472
void GlxStateManager::launchProgressDialog()
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   473
{
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   474
    TRACER("GlxStateManager::launchProgressDialog() ");
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   475
    
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   476
    QCoreApplication::instance()->installEventFilter( this );
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   477
    if ( isProgressbarRunning ) {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   478
        mViewManager->updateProgressDialog( mTNObserver->getTNLeftCount() );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   479
    }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   480
    else {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   481
        mViewManager->launchProgressDialog( mTNObserver->getTNLeftCount() );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   482
    }
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   483
    isProgressbarRunning = true ;
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   484
}
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   485
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   486
void GlxStateManager::vanishProgressDialog()
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   487
{
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   488
    TRACER("GlxStateManager::vanishProgressDialog() ");
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   489
    QCoreApplication::instance()->removeEventFilter( this );
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   490
    createModel( mCurrentState->id() );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   491
    connect ( mCurrentModel, SIGNAL( thumbnailPopulated() ), this, SLOT( thumbnailPopulated() ) );
48
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   492
}
d0b4e67b3a60 Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 36
diff changeset
   493
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
GlxState * GlxStateManager::createState(qint32 stateId)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    qDebug("GlxStateManager::createState state id = %d", stateId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
    switch( stateId ) {    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    case GLX_GRIDVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
        return new GlxGridState( this, mCurrentState );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    case GLX_LISTVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
        return new GlxListState( mCurrentState );    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
    case GLX_FULLSCREENVIEW_ID :
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   506
        return new GlxFullScreenState( this, mCurrentState );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    case GLX_DETAILSVIEW_ID:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
        return new GlxDetailState( mCurrentState );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    case GLX_SLIDESHOWVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
        return new GlxSlideShowState( this, mCurrentState );
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   513
    case GLX_SLIDESHOWSETTINGSVIEW_ID :
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   514
        return new GlxSlideShowSettingsState(this, mCurrentState );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    default :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
        return NULL;		
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    } 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
void GlxStateManager::createModel(qint32 stateId, NavigationDir dir)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    switch( stateId ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    case GLX_GRIDVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
        createGridModel( mCurrentState->state(), dir );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    case GLX_LISTVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
    	//To:Do change the code when integrate the album list model
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
        if (mAlbumMediaModel == NULL) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
            GlxModelParm modelParm (KGlxCollectionPluginAlbumsImplementationUid, 0);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
            mAlbumMediaModel = new GlxAlbumModel (modelParm);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
        mCurrentModel = mAlbumMediaModel;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   535
        mCollectionId = KGlxCollectionPluginAlbumsImplementationUid;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
        mCurrentModel->setData(QModelIndex(), (int)GlxContextPtList, GlxContextRole );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
        mViewManager->updateToolBarIcon(GLX_ALBUM_ACTION_ID);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
    case GLX_FULLSCREENVIEW_ID :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
		if ( mCurrentState->state() == IMAGEVIEWER_S) {
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   542
            GlxModelParm modelParm (KGlxCollectionPluginImageViewerImplementationUid, 0);
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   543
            mCurrentModel = mImageviewerMediaModel = new GlxMediaModel (modelParm);
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   544
            mCollectionId = KGlxCollectionPluginImageViewerImplementationUid;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
		}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
        else if ( mCurrentState->state() == EXTERNAL_S) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
            if(!mAllMediaModel) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
                GlxModelParm modelParm (KGlxCollectionPluginAllImplementationUid, 0);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
                mCurrentModel = mAllMediaModel = new GlxMediaModel (modelParm);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
            }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
            else {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
                mCurrentModel = mAllMediaModel;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
            }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   554
            mCollectionId = KGlxCollectionPluginAllImplementationUid;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
        }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   556
		setFullScreenContext();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
    case GLX_DETAILSVIEW_ID :
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   560
        setFullScreenContext();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
    case GLX_SLIDESHOWVIEW_ID :
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   564
        if ( mCurrentState->state() == SLIDESHOW_ALBUM_ITEM_S ) {
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
            GlxModelParm modelParm ( KGlxAlbumsMediaId , 0);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
            mCurrentModel = mAlbumGridMediaModel = new GlxMediaModel( modelParm );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
        }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   568
        setFullScreenContext();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
    	    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
    default :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   574
    mCurrentModel->setData( QModelIndex(), mCurrentState->state(), GlxSubStateRole );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
void GlxStateManager::createGridModel(int internalState, NavigationDir dir)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    GlxModelParm modelParm;
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   580
    GlxContextMode mode;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   581
    
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   582
    if ( mViewManager->orientation() == Qt::Horizontal ) {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   583
        mode = GlxContextLsGrid ;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   584
    }
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   585
    else {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   586
        mode = GlxContextPtGrid ;
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   587
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
    switch( internalState) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    case ALL_ITEM_S :
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   591
	case FETCHER_ITEM_S:
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
        if ( mAllMediaModel == NULL ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
            modelParm.setCollection( KGlxCollectionPluginAllImplementationUid );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
            modelParm.setDepth(0);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   595
            modelParm.setContextMode( mode ) ;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
            mAllMediaModel = new GlxMediaModel( modelParm );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
        mCollectionId = KGlxCollectionPluginAllImplementationUid;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
        mCurrentModel = mAllMediaModel;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
        mViewManager->updateToolBarIcon(GLX_ALL_ACTION_ID);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
    case ALBUM_ITEM_S :
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   604
    case FETCHER_ALBUM_ITEM_S :    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
        if ( dir != BACKWARD_DIR ) { 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
            modelParm.setCollection( KGlxAlbumsMediaId );
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   607
            modelParm.setDepth(0);
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   608
            modelParm.setContextMode( mode ) ;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
            mAlbumGridMediaModel = new GlxMediaModel( modelParm );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
        }               
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
        mCollectionId = KGlxAlbumsMediaId;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
        mCurrentModel = mAlbumGridMediaModel ;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
        mViewManager->updateToolBarIcon(NO_ACTION_ID);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
    default :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
    }
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   619
    
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   620
    mCurrentModel->setData(QModelIndex(), (int)mode, GlxContextRole );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   621
}
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   622
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   623
void GlxStateManager::setFullScreenContext()
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   624
{
29
2c833fc9e98f Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 26
diff changeset
   625
    if ( mViewManager->orientation() == Qt::Horizontal || mCurrentState->id() == GLX_SLIDESHOWVIEW_ID ) {
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   626
        mCurrentModel->setData(QModelIndex(), (int)GlxContextLsFs, GlxContextRole );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   627
    }
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   628
    else {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   629
        mCurrentModel->setData(QModelIndex(), (int)GlxContextPtFs, GlxContextRole );
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   630
    }    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
void GlxStateManager::eventHandler(qint32 &id)
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
    qDebug("GlxStateManager::eventHandler action id = %d", id);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    switch(id) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
    case EGlxCmdAllGridOpen :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
        changeState( GLX_GRIDVIEW_ID, ALL_ITEM_S );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
        break;
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   641
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   642
    case EGlxCmdFetcherAllGridOpen :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   643
        changeState( GLX_GRIDVIEW_ID, FETCHER_ITEM_S );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   644
        id = EGlxCmdHandled;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   645
        break;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
    case EGlxCmdAlbumListOpen:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
        changeState( GLX_LISTVIEW_ID, -1 );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
        break;
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   651
    case EGlxCmdFetcherAlbumListOpen:
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   652
        changeState( GLX_LISTVIEW_ID, FETCHER_ALBUM_S );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   653
        id = EGlxCmdHandled;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   654
        break;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   655
        
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
    case EGlxCmdAlbumGridOpen:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
        nextState( GLX_GRIDVIEW_ID, ALBUM_ITEM_S );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
        break;
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   660
    case EGlxCmdFetcherAlbumGridOpen:
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   661
        nextState( GLX_GRIDVIEW_ID, FETCHER_ALBUM_ITEM_S );
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   662
        id = EGlxCmdHandled;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   663
        break;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   664
        
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
    case EGlxCmdFirstSlideshow :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
        //play the slide show with first item
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
        mCurrentModel->setData( mCurrentModel->index(0, 0), 0, GlxFocusIndexRole );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
        nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_GRID_ITEM_S );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
    case EGlxCmdSelectSlideshow:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
        //play the slide show with selected item
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
        nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_GRID_ITEM_S );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    case EGlxCmdAlbumSlideShow:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        //play the slide show for a album
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
        nextState( GLX_SLIDESHOWVIEW_ID, SLIDESHOW_ALBUM_ITEM_S );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
        
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   684
    case EGlxCmdSlideshowSettings:
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   685
        nextState(GLX_SLIDESHOWSETTINGSVIEW_ID,-1 );
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   686
        id = EGlxCmdHandled;
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   687
        break;
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   688
        
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
    case EGlxCmdDetailsOpen:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
        qDebug("GlxStateManager::eventHandler EGlxCmdDetailsOpen");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
        nextState( GLX_DETAILSVIEW_ID, -1 );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
        
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   695
    case EGlxCmdEmptyData : {
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   696
        GlxState *tmpState = mCurrentState ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   697
        while ( tmpState->id() != GLX_GRIDVIEW_ID ) {
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   698
            tmpState = tmpState->previousState() ;
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   699
        }
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   700
        
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   701
        goBack( GLX_GRIDVIEW_ID, tmpState->state() );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
        break;
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   704
    }
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
    	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
    case EGlxCmdBack :
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   707
    case EGlxCmdSlideShowBack :
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    	previousState();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
    	id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    	break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    	
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   712
    case EGlxCmdCameraOpen:
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
		{
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   714
		QProcess::startDetached(QString("cxui.exe"));
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   715
		id = EGlxCmdHandled;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
		}
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   717
        break;	
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   718
        
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
    case EGlxCmdOviOpen:
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
		{
26
c499df2dbb33 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 24
diff changeset
   721
		HbNotificationDialog::launchDialog("Not Implemented");
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
        id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
		}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
        break;	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
   case EGlxCmdDelete :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
		{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
        GlxExternalData* externalItems = GlxExternalUtility::instance()->getExternalData();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
        if(externalItems){
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
            QVariant variant = mCurrentModel->data( mCurrentModel->index(0,0), GlxFocusIndexRole );    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
            if ( variant.isValid() &&  variant.canConvert<int> () ) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
                int selIndex = variant.value<int>(); 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
                int externalDataCount = externalItems->count();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
                if(selIndex < externalDataCount){
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
                    GlxInterfaceParams tmp = externalItems->value(selIndex);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
                    tmp.isSelected = true;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
                    externalItems->replace(selIndex,tmp);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
                    emit externalCommand(EGlxPluginCmdDelete);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
                    return;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
                }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
            }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
        }
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
        mActionHandler->handleAction(id,mCollectionId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
		}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
        break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
        
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   747
   case EGlxCmdMarkAll :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   748
   case EGlxCmdUnMarkAll :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   749
   case EGlxCmd3DEffectOn :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   750
   case EGlxCmd3DEffectOff :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   751
   case EGlxCmdPlayBackAnim :
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   752
       mViewManager->handleUserAction( mCurrentState->id(), id );
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
       id = EGlxCmdHandled;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
       break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
       
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
   case EGlxCmdSetupItem :
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
       emit setupItemsSignal();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
       break;
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   759
   
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   760
   case EGlxCmdFetcherSelect: 
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   761
       {
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   762
       QModelIndex selectedIndex = mCurrentModel->index(mCurrentModel->data(mCurrentModel->index(0,0),GlxFocusIndexRole).value<int>(),0);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   763
       emit gridItemSelected(selectedIndex,*mCurrentModel);
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   764
       id = EGlxCmdHandled;
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   765
       }
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   766
       break;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
       
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   768
   default :
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
        mActionHandler->handleAction(id,mCollectionId);
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
    	break;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
    }	
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
void GlxStateManager::exitApplication()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
{
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   776
    
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   777
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
    //To:Do memory cleanup
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
        QApplication::quit();
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   780
     
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
GlxStateManager::~GlxStateManager()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
    qDebug("GlxStateManager::~GlxStateManager");
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   786
    cleanAllModel();
55
fb37077c270f Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 49
diff changeset
   787
    mSaveActivity.clear();
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
    delete mActionHandler;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
    qDebug("GlxStateManager::~GlxStateManager delete Model");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
    disconnect ( mViewManager, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionTriggered(qint32 )) );
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    disconnect ( mViewManager, SIGNAL(externalCommand(int )), this, SIGNAL(externalCommand(int )) );
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   793
    disconnect ( mTNObserver, SIGNAL( leftTNCount( int ) ), this, SLOT( updateTNProgress( int ) ) );
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   794
    disconnect ( this, SIGNAL( setupItemsSignal() ), this, SLOT( setupItems() ) );
49
f291796e213d Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 48
diff changeset
   795
    disconnect ( qobject_cast<HbApplication*>(qApp), SIGNAL (aboutToQuit()), this, SLOT(saveData()));
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   796
    
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   797
    delete mTNObserver;
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
    delete mViewManager; 
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
    qDebug("GlxStateManager::~GlxStateManager delete view manager");
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   800
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
    GlxState *tmp;   
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
    while (mCurrentState) {
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
        tmp = mCurrentState;
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
        mCurrentState = mCurrentState->previousState();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
        delete tmp;        
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
    }
33
1ee2af37811f Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 29
diff changeset
   807
    
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
    qDebug("GlxStateManager::~GlxStateManager Exit");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
}
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
void GlxStateManager::cleanupExternal()
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
{
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
    qDebug("GlxStateManager::cleanupExternal");
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
    mViewManager->deactivateCurrentView();
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
    GlxMediaModel *glxModel = dynamic_cast<GlxMediaModel *>(mCurrentModel);
24
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   816
    if(glxModel) {
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   817
		glxModel->clearExternalItems();  
99ad1390cd33 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   818
	}
23
74c9f037fd5d Revision: 201007
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
}