diff -r f291796e213d -r fb37077c270f ui/viewmanagement/viewmanager/src/glxviewmanager.cpp --- a/ui/viewmanagement/viewmanager/src/glxviewmanager.cpp Tue Jul 06 14:16:16 2010 +0300 +++ b/ui/viewmanagement/viewmanager/src/glxviewmanager.cpp Wed Aug 18 09:48:53 2010 +0300 @@ -40,7 +40,8 @@ #include #include #include - +#include +#include "glxmodelroles.h" GlxViewManager::GlxViewManager() : mBackAction( NULL ), @@ -52,22 +53,23 @@ mProgressDialog( NULL ) { qDebug("GlxViewManager::GlxViewManager() "); - PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { - //check the case when application launch through some other application (view plugin) - mMainWindow = GlxExternalUtility::instance()->getMainWindow(); - if(mMainWindow == NULL) { - mMainWindow = new HbMainWindow(); - connect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() )); - } - //Without this Zoom Does not work - mWindowEventFilter = new GlxMainWindowEventFilter; - mMainWindow->scene()->installEventFilter(mWindowEventFilter); - mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); - mMainWindow->viewport()->grabGesture(Qt::PinchGesture); + //check the case when application launch through some other application (view plugin) + mMainWindow = GlxExternalUtility::instance()->getMainWindow(); + if(mMainWindow == NULL) { + mMainWindow = new HbMainWindow(); } + connect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() )); + //Without this Zoom Does not work + + mWindowEventFilter = new GlxMainWindowEventFilter; + mMainWindow->scene()->installEventFilter(mWindowEventFilter); + mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); + mMainWindow->viewport()->grabGesture(Qt::PinchGesture); + HbStyleLoader::registerFilePath(":/data/photos.css"); } + void GlxViewManager::handleReadyView() { emit actionTriggered( EGlxCmdSetupItem ); @@ -77,21 +79,18 @@ void GlxViewManager::setupItems( ) { - mMenuManager = new GlxMenuManager(mMainWindow); addBackSoftKeyAction(); - addConnection(); - mMenuManager->addMenu( mView->viewId(), mView->menu() ); - mMenuManager->setModel( mModel ); + addConnection(); } void GlxViewManager::launchApplication(qint32 id, QAbstractItemModel *model) { mModel = model; - PERFORMANCE_ADV ( viewMgrD1, "View Creation time" ) { - mView = resolveView(id); - } + mMenuManager = new GlxMenuManager( mMainWindow ); //menu manager should be created before view. + mMenuManager->setModel( mModel ); + mView = resolveView( id ); + createToolBar(); - mView->addToolBar(mViewToolBar); /* We are showing the toolBar before activating the * view. This is done to avoid the animation effect seen otherwise @@ -103,14 +102,11 @@ * */ mView->activate(); - - PERFORMANCE_ADV ( viewMgrD3, "Set Model time") - mView->setModel(mModel); - - PERFORMANCE_ADV( viewMgrD4, "View Display time") { - mMainWindow->setCurrentView(mView, false); - mMainWindow->showFullScreen(); - } + mView->setModel( mModel ); + //visibility of tool bar dependes of view internal state so add the toolbar after setting model + mView->addToolBar( mViewToolBar ); + mMainWindow->setCurrentView( mView, false ); + mMainWindow->showFullScreen(); } void GlxViewManager::handleMenuAction(qint32 commandId) @@ -121,6 +117,7 @@ void GlxViewManager::handleAction() { HbAction *action = qobject_cast(sender()); + action->setChecked( TRUE ); qint32 commandId = action->data().toInt(); emit actionTriggered(commandId); } @@ -129,8 +126,8 @@ { qDebug("GlxViewManager::addBackSoftKeyAction "); //create the back soft key action and set the data - mBackAction = new HbAction(Hb::BackNaviAction, this); - mBackAction->setData(EGlxCmdBack); + mBackAction = new HbAction( Hb::BackNaviAction, this ); + mBackAction->setData( EGlxCmdBack ); mBackAction->setObjectName( "App Back" ); mView->setNavigationAction( mBackAction ); } @@ -140,16 +137,13 @@ return mMainWindow->orientation(); } -void GlxViewManager::launchView(qint32 id, QAbstractItemModel *model) +void GlxViewManager::launchView( qint32 id, QAbstractItemModel *model ) { - qDebug("GlxViewManager::launchView Id = %d ", id); + qDebug( "GlxViewManager::launchView Id = %d ", id ); mModel = model; deActivateView(); - - PERFORMANCE_ADV ( viewMgrD1, "View Creation time" ) { - mView = resolveView(id); - } - + mMenuManager->setModel( mModel ); //set the model to get the item type info and row count info + mView = resolveView( id ); activateView(); } @@ -176,10 +170,11 @@ //partially clean the view so that animation run smoothly GlxView *curr_view = (GlxView *) mMainWindow->currentView(); curr_view->resetView(); - + + mMenuManager->setModel( model ); //set the model to get the item type info and row count info mView = resolveView(id); //partially initialise the view so that animation run smoothly - mView->initializeView( model); + mView->initializeView( model, curr_view ); mModel = model; if ( viewEffect == CURRENT_VIEW || viewEffect == BOTH_VIEW ) { @@ -201,6 +196,10 @@ } } + if ( effect == GRID_TO_FULLSCREEN ) { + mViewToolBar->setZValue( item->zValue() - 5 ); + } + //error check if ( itemList.count() > 0 ) { mEffectEngine->runEffect(itemList, effect); @@ -247,38 +246,8 @@ //To:Do temp code remove later if ( mProgressDialog ) { i = ++i % 10; - switch ( i ) { - case 0 : - icon = HbIcon( QString(":/data/Image1.jpg") ); - break; - case 1 : - icon = HbIcon( QString(":/data/Image2.jpg") ); - break; - case 2 : - icon = HbIcon( QString(":/data/Image3.jpg") ); - break; - case 3 : - icon = HbIcon( QString(":/data/Image4.jpg") ); - break; - case 4 : - icon = HbIcon( QString(":/data/Image5.jpg") ); - break; - case 5 : - icon = HbIcon( QString(":/data/Image6.jpg") ); - break; - case 6 : - icon = HbIcon( QString(":/data/Image7.jpg") ); - break; - case 7 : - icon = HbIcon( QString(":/data/Image8.jpg") ); - break; - case 8 : - icon = HbIcon( QString(":/data/Image9.jpg") ); - break; - case 9 : - icon = HbIcon( QString(":/data/Image10.jpg") ); - break; - } + icon = HbIcon( QString( ":/data/Wait/qgn_graf_ring_wait_%1.svg" ).arg( i + 1, 2, 10, QChar( '0' ) ) ); + mProgressDialog->setIcon(icon); int max = mProgressDialog->maximum() ; if ( currentValue > max ) { @@ -286,10 +255,8 @@ max = currentValue ; } - mProgressDialog->setIcon(icon); - if ( currentValue < 0 ) { - mProgressDialog->setText( QString( "Refreshing" ) ); //To:Do string will change later + mProgressDialog->setText( QString( GLX_REFRESHING ) ); //To:Do string will change later mProgressDialog->setProgressValue( 0 ); } else { @@ -317,22 +284,18 @@ qDebug("GlxViewManager::updateToolBarIcon() action ID list %d count %d", id, count); - for ( int i = 0; i < count ; i++ ) - { + for ( int i = 0; i < count ; i++ ) { qDebug("GlxViewManager::updateToolBarIcon() toolBarActionId %d value %d", toolBarActionId, ( id & toolBarActionId ) ); //check and get the icon path - if ( ( id & toolBarActionId ) == toolBarActionId ) - { - mActionList[i]->setCheckable(TRUE); + if ( ( id & toolBarActionId ) == toolBarActionId ) { mActionList[i]->setChecked(TRUE); - } - else - { + } + else { mActionList[i]->setChecked(FALSE); - } + } //to get it the next action id to verify it is selecter or not toolBarActionId = toolBarActionId << 1; - } + } } void GlxViewManager::checkMarked() @@ -343,7 +306,6 @@ if( mMarkingActionList.at(i)->data()==EGlxCmdSelect) { bool noSelection=selectedModelIndex.empty(); mMarkingActionList.at(i)->setDisabled(noSelection); - mMenuManager->disableAction(mView->menu(),noSelection); break; } } @@ -417,23 +379,22 @@ } } -GlxView * GlxViewManager::resolveView(qint32 id) +GlxView * GlxViewManager::resolveView( qint32 id ) { - qDebug("GlxViewManager::resolveView %d", id); + qDebug("GlxViewManager::resolveView %d", id ); GlxView *view = findView ( id ); if ( view ) { return view ; } - view = GlxViewsFactory::createView(id, mMainWindow); + view = GlxViewsFactory::createView( id, mMainWindow ); if ( view ) { - connect ( view, SIGNAL(actionTriggered(qint32 )), this, SLOT(actionProcess(qint32 )), Qt::QueuedConnection ); - connect ( view, SIGNAL(itemSpecificMenuTriggered(qint32,QPointF ) ), this, SLOT( itemSpecificMenuTriggered(qint32,QPointF ) ), Qt::QueuedConnection ); - mViewList.append(view); - mMainWindow->addView(view); - if ( mMenuManager ) { - mMenuManager->addMenu( id, view->menu()); - } + connect ( view, SIGNAL( actionTriggered( qint32 ) ), this, SLOT( actionProcess( qint32 ) ), Qt::QueuedConnection ); + connect ( view, SIGNAL( itemSpecificMenuTriggered( qint32, QPointF ) ), this, SLOT( itemSpecificMenuTriggered( qint32, QPointF ) ), Qt::QueuedConnection ); + mViewList.append( view ); + mMainWindow->addView( view ); + mMenuManager->addMenu( id, view->menu() ); + if ( mBackAction ) { view->setNavigationAction( mBackAction ); } @@ -488,42 +449,53 @@ void GlxViewManager::activateView() { qDebug("GlxViewManager::activateView()"); - - PERFORMANCE_ADV ( viewMgrD2, "View Activation time") { - mView->addToolBar(mViewToolBar); - mView->activate(); - mView->show(); - mMenuManager->setModel( mModel ); //set the model to get the item type info and row count info - } - - PERFORMANCE_ADV ( viewMgrD3, "Set Model time") - mView->setModel(mModel); - - PERFORMANCE_ADV( viewMgrD4, "View Display time") { - mMainWindow->setCurrentView(mView, false); - mMainWindow->showFullScreen(); - } + + mView->activate(); + mView->show(); + mView->setModel( mModel ); + //visibility of tool bar dependes of view internal state so add the toolbar after setting model + mView->addToolBar( mViewToolBar ); + mMainWindow->setCurrentView(mView, false); + mMainWindow->showFullScreen(); } void GlxViewManager::createActions() { qDebug("GlxViewManager::createActions() " ); mActionList.clear(); + + int curSubstate = getSubState(); //create the All tool bar button action HbAction* allAction = new HbAction( this ); - allAction->setData( EGlxCmdAllGridOpen ); + + if( curSubstate == FETCHER_ITEM_S ) { + allAction->setData( EGlxCmdFetcherAllGridOpen ); + }else{ + allAction->setData( EGlxCmdAllGridOpen ); + } + mActionList.append( allAction ); allAction->setIcon( HbIcon( GLXICON_ALL ) ) ; allAction->setObjectName( "All Action" ); //create the Album tool bar button action HbAction* albumAction = new HbAction( this ); - albumAction->setData( EGlxCmdAlbumListOpen ); + + if( curSubstate == FETCHER_ITEM_S ) { + albumAction->setData( EGlxCmdFetcherAlbumListOpen ); + }else{ + albumAction->setData( EGlxCmdAlbumListOpen ); + } + mActionList.append( albumAction ); albumAction->setIcon( HbIcon( GLXICON_ALBUMS ) ) ; albumAction->setObjectName( "Album Action" ); - + + //in case of fetcher no need to create other actions + if( curSubstate == FETCHER_ITEM_S ) { + return; + } //create the album tool bar button action HbAction* cameraAction = new HbAction( this ); cameraAction->setData( EGlxCmdCameraOpen ); @@ -607,6 +579,7 @@ int count = mActionList.count(); for ( int i = 0; i < count; i++ ) { connect( mActionList.at(i), SIGNAL(triggered( )), this, SLOT(handleAction( )) ); + mActionList.at(i)->setCheckable( TRUE ); mViewToolBar->addAction( mActionList.at(i) ); } qDebug("GlxViewManager::createToolBar() exit" ); @@ -705,7 +678,7 @@ } if( mMainWindow != GlxExternalUtility::instance()->getMainWindow() ){ - qDebug("GlxViewManager::~GlxViewManager remove view"); + qDebug("GlxViewManager::~GlxViewManager delete mainwindow"); delete mMainWindow; } delete mWindowEventFilter; @@ -713,3 +686,15 @@ qDebug("GlxViewManager::~GlxViewManager Exit"); } +int GlxViewManager::getSubState() +{ + int curSubstate = NO_GRID_S; + + if ( mModel ) { + QVariant variant = mModel->data( mModel->index(0,0), GlxSubStateRole ); + if ( variant.isValid() && variant.canConvert () ) { + curSubstate = variant.value(); + } + } + return curSubstate; +}