mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp
changeset 29 8192e5b5c935
parent 25 3ec52facab4d
child 32 c163ef0b758d
equal deleted inserted replaced
25:3ec52facab4d 29:8192e5b5c935
    16 */
    16 */
    17 
    17 
    18 // INCLUDE FILES
    18 // INCLUDE FILES
    19 #include <time.h>
    19 #include <time.h>
    20 #include <cstdlib>
    20 #include <cstdlib>
    21 #include <qtcore>
    21 #include <QtCore>
    22 
    22 
    23 #include <hbinstance.h>
    23 #include <hbinstance.h>
    24 #include <hbapplication.h>
    24 #include <hbapplication.h>
    25 #include <hbaction.h>
    25 #include <hbaction.h>
    26 #include <hbtoolbar.h>
    26 #include <hbtoolbar.h>
    35 #include "mpcollectionview.h"
    35 #include "mpcollectionview.h"
    36 #include "mpcollectiondocumentloader.h"
    36 #include "mpcollectiondocumentloader.h"
    37 #include "mpcollectioncontainerfactory.h"
    37 #include "mpcollectioncontainerfactory.h"
    38 #include "mpcollectioncontainer.h"
    38 #include "mpcollectioncontainer.h"
    39 #include "mpcollectiondatamodel.h"
    39 #include "mpcollectiondatamodel.h"
    40 #include "mpengine.h"
    40 #include "mpenginefactory.h"
    41 #include "mpmpxcollectiondata.h"
    41 #include "mpmpxcollectiondata.h"
    42 #include "mpnowplayingwidget.h"
    42 #include "mpnowplayingwidget.h"
    43 #include "mpcommondefs.h"
    43 #include "mpcommondefs.h"
    44 #include "mptrace.h"
    44 #include "mptrace.h"
    45 #include "mpsnapshotwidget.h"
    45 #include "mpsnapshotwidget.h"
    88       mCollectionContainer( 0 ),
    88       mCollectionContainer( 0 ),
    89       mCollectionDataModel( 0 ),
    89       mCollectionDataModel( 0 ),
    90       mActivated( false ),
    90       mActivated( false ),
    91       mNowPlayingBanner( 0 ),
    91       mNowPlayingBanner( 0 ),
    92       mBannerAttached( false ),
    92       mBannerAttached( false ),
    93       mNavigationQuit( 0 ),
    93       mSoftKeyQuit( 0 ),
    94       mNavigationBack( 0 ),
    94       mSoftKeyBack( 0 ),
    95       mDocumentLoader( 0 ),
    95       mDocumentLoader( 0 ),
    96       mMainContainer( 0 ),
    96       mMainContainer( 0 ),
    97       mMainToolBar( 0 ),
    97       mMainToolBar( 0 ),
    98       mPlaylistToolBar( 0 ),
    98       mPlaylistToolBar( 0 ),
    99       mSnapshot( 0 ),
    99       mSnapshot( 0 ),
   111  */
   111  */
   112 MpCollectionView::~MpCollectionView()
   112 MpCollectionView::~MpCollectionView()
   113 {
   113 {
   114     TX_ENTRY
   114     TX_ENTRY
   115     delete mSnapshot;
   115     delete mSnapshot;
   116     delete mNavigationQuit;
   116     delete mSoftKeyQuit;
   117     delete mNavigationBack;
   117     delete mSoftKeyBack;
   118 
   118 
   119     HbToolBar *toolBar = takeToolBar();
   119     HbToolBar *toolBar = takeToolBar();
   120     if ( mMainToolBar != toolBar && mPlaylistToolBar != toolBar ) {
   120     if ( mMainToolBar != toolBar && mPlaylistToolBar != toolBar ) {
   121         delete toolBar;
   121         delete toolBar;
   122     }
   122     }
   125     }
   125     }
   126     if ( mPlaylistToolBar ) {
   126     if ( mPlaylistToolBar ) {
   127         mPlaylistToolBar->deleteLater();
   127         mPlaylistToolBar->deleteLater();
   128     }
   128     }
   129 
   129 
   130     delete mCollectionDataModel;
       
   131     delete mCollectionContainer;
   130     delete mCollectionContainer;
   132     delete mContainerFactory;
   131     delete mContainerFactory;
       
   132     delete mCollectionDataModel;
   133     delete mDocumentLoader;
   133     delete mDocumentLoader;
   134     delete mMpTranslator;
   134     delete mMpTranslator;
   135     delete mCommonTranslator;
   135     delete mCommonTranslator;
   136     TX_EXIT
   136     TX_EXIT
   137 }
   137 }
   163     }
   163     }
   164 
   164 
   165     mWindow = mainWindow();
   165     mWindow = mainWindow();
   166 
   166 
   167     // Create softkey actions
   167     // Create softkey actions
   168     mNavigationQuit = new HbAction( Hb::QuitNaviAction, this );
   168     mSoftKeyQuit = new HbAction( Hb::QuitNaviAction, this );
   169     connect( mNavigationQuit, SIGNAL( triggered() ), this, SLOT( back() ) );
   169     connect( mSoftKeyQuit, SIGNAL( triggered() ), this, SLOT( back() ) );
   170 
   170 
   171     mNavigationBack = new HbAction( Hb::BackNaviAction, this );
   171     mSoftKeyBack = new HbAction( Hb::BackNaviAction, this );
   172     connect( mNavigationBack, SIGNAL( triggered() ), this, SLOT( back() ) );
   172     connect( mSoftKeyBack, SIGNAL( triggered() ), this, SLOT( back() ) );
   173 
   173 
   174     mMpEngine = MpEngine::instance();
   174     mMpEngine = MpEngineFactory::sharedEngine();
   175     
   175 
   176     connect( mMpEngine,
   176     connect( mMpEngine, SIGNAL( collectionPlaylistOpened() ),
   177             SIGNAL( collectionPlaylistOpened() ),
   177             this, SLOT( startPlaybackView() ) );
   178             this,
   178     connect( mMpEngine, SIGNAL( playlistSaved( bool ) ),
   179             SLOT( startPlaybackView() ) );
   179             this, SLOT( playlistSaved( bool ) ) );
   180     connect( mMpEngine,
   180     connect( mMpEngine, SIGNAL( songsDeleted( bool ) ),
   181             SIGNAL( playlistSaved( bool ) ),
   181             this, SLOT( songsDeleted( bool ) ) );
   182             this,
   182     connect( mMpEngine, SIGNAL( playlistsRenamed( bool ) ),
   183             SLOT( playlistSaved( bool ) ) );
   183             this, SLOT( playlistsRenamed( bool ) ) );
   184     connect( mMpEngine,
   184     connect( mMpEngine, SIGNAL( isolatedCollectionOpened( MpMpxCollectionData* ) ),
   185             SIGNAL( songsDeleted( bool ) ),
   185             this, SLOT( handleIsolatedCollectionOpened( MpMpxCollectionData* ) ) );
   186             this,
       
   187             SLOT( songsDeleted( bool ) ) );
       
   188     connect( mMpEngine,
       
   189             SIGNAL( playlistsRenamed( bool ) ),
       
   190             this,
       
   191             SLOT( playlistsRenamed( bool ) ) );
       
   192     connect( mMpEngine,
       
   193             SIGNAL( isolatedCollectionOpened( MpMpxCollectionData* ) ),
       
   194             this,
       
   195             SLOT( handleIsolatedCollectionOpened( MpMpxCollectionData* ) ) );
       
   196 
   186 
   197     mCollectionData = mMpEngine->collectionData();
   187     mCollectionData = mMpEngine->collectionData();
   198     qRegisterMetaType<TCollectionContext>("TCollectionContext");
   188     qRegisterMetaType<TCollectionContext>("TCollectionContext");
   199     connect( mCollectionData, SIGNAL( contextChanged( TCollectionContext ) ), 
   189     connect( mCollectionData, SIGNAL( contextChanged( TCollectionContext ) ), 
   200              this, SLOT( setContext( TCollectionContext ) ), Qt::QueuedConnection );
   190              this, SLOT( setContext( TCollectionContext ) ), Qt::QueuedConnection );
   214             // from playback preview. Disable the banner from updating.
   204             // from playback preview. Disable the banner from updating.
   215             mNowPlayingBanner->setEnabled( false );
   205             mNowPlayingBanner->setEnabled( false );
   216         }
   206         }
   217         else {
   207         else {
   218             connect( mNowPlayingBanner, SIGNAL( clicked() ), this, SLOT( startPlaybackView() ) );
   208             connect( mNowPlayingBanner, SIGNAL( clicked() ), this, SLOT( startPlaybackView() ) );
   219             connect( mNowPlayingBanner, SIGNAL( playbackAttachmentChanged( bool ) ), this, SLOT( attachNowPlayingBanner( bool ) ) );
   209             connect( mNowPlayingBanner, SIGNAL( playbackAttachmentChanged( bool ) ),
       
   210                      this, SLOT( attachNowPlayingBanner( bool ) ) );
   220         }
   211         }
   221 
   212 
   222         widget = mDocumentLoader->findWidget( QString( "mainContainer" ) );
   213         widget = mDocumentLoader->findWidget( QString( "mainContainer" ) );
   223         mMainContainer = qobject_cast<HbWidget*>( widget );
   214         mMainContainer = qobject_cast<HbWidget*>( widget );
   224 
   215 
   419     }
   410     }
   420     TX_EXIT
   411     TX_EXIT
   421 }
   412 }
   422 
   413 
   423 /*!
   414 /*!
   424  Slot to be called when 'Genres' action is triggered from the toolbar.
       
   425  */
       
   426 void MpCollectionView::openGenres()
       
   427 {
       
   428     TX_ENTRY
       
   429     if ( mCollectionContext != ECollectionContextGenres ) {
       
   430         mMpEngine->openCollection( ECollectionContextGenres );
       
   431     }
       
   432     TX_EXIT
       
   433 }
       
   434 
       
   435 /*!
       
   436  Slot to be called when 'Find' action is triggered from the toolbar.
   415  Slot to be called when 'Find' action is triggered from the toolbar.
   437  */
   416  */
   438 void MpCollectionView::find()
   417 void MpCollectionView::find()
   439 {
   418 {
   440     // Todo
   419     // Todo
   465     bool doOpen = true;
   444     bool doOpen = true;
   466     if ( mViewMode == MpCommon::FetchView ) {
   445     if ( mViewMode == MpCommon::FetchView ) {
   467         QString songUri;
   446         QString songUri;
   468         switch ( mCollectionContext ) {
   447         switch ( mCollectionContext ) {
   469             case ECollectionContextAllSongs:
   448             case ECollectionContextAllSongs:
   470             case ECollectionContextArtistSongs:
   449             case ECollectionContextArtistAllSongs:
   471             case ECollectionContextAlbumSongs:
       
   472             case ECollectionContextPlaylistSongs:
   450             case ECollectionContextPlaylistSongs:
   473             case ECollectionContextGenreSongs:
       
   474                 doOpen = false;
   451                 doOpen = false;
   475                 songUri = mCollectionData->itemData( index, MpMpxCollectionData::Uri );
   452                 songUri = mCollectionData->itemData( index, MpMpxCollectionData::Uri );
   476                 emit songSelected( songUri );
   453                 emit songSelected( songUri );
   477                 break;
   454                 break;
       
   455             case ECollectionContextArtistAlbumsTBone:
       
   456             case ECollectionContextAlbumsTBone:
       
   457                 doOpen = false;
       
   458                 songUri = mCollectionData->albumSongData( index, MpMpxCollectionData::Uri );
       
   459                 emit songSelected( songUri );
       
   460                 break;
   478             default:
   461             default:
   479                 break;
   462                 break;
   480         }
   463         }
   481     }
   464     }
   482     if ( doOpen ) {
   465     // TODO: "showingPopup()" used as workaround for HbListView multiple events: longPress and activated.
   483         // TODO: "if" used as workaround for HbListView multiple events: longPress and activated.
   466     //       Remove once HbListView get fixed (wk16)
   484         //       Remove once HbListView get fixed (wk14 or 16)
   467     if ( doOpen && !mMpPopupHandler->showingPopup() ) {
   485         if ( !mMpPopupHandler->showingPopup() ) {
   468         if ( mCollectionContext == ECollectionContextArtistAlbums ) {
       
   469             if ( (mCollectionData->count() > 1) && (index == 0) ) {
       
   470                 mMpEngine->openCollectionItem( index );
       
   471             }
       
   472             else {
       
   473                 // Artist-Album view going into T-bone. We don't actually open the
       
   474                 // collection. Just fake an open.
       
   475                 mCollectionData->setContext( ECollectionContextArtistAlbumsTBone );
       
   476             }
       
   477         }
       
   478         else if ( mCollectionContext == ECollectionContextAlbums ) {
       
   479             // Album view going into T-bone. We don't actually open the
       
   480             // collection. Just fake an open.
       
   481             mCollectionData->setContext( ECollectionContextAlbumsTBone );
       
   482         }
       
   483         else {
       
   484             // Real open. Forward it to the engine.
   486             mMpEngine->openCollectionItem( index );
   485             mMpEngine->openCollectionItem( index );
   487         }
   486         }
       
   487     }
       
   488     TX_EXIT
       
   489 }
       
   490 
       
   491 /*!
       
   492  Slot to be called when an album is centered in T-Bone view and we need to
       
   493  find the songs beloging to album with \a index.
       
   494  */
       
   495 void MpCollectionView::findAlbumSongs( int index )
       
   496 {
       
   497     TX_ENTRY_ARGS( "index=" << index );
       
   498     mMpEngine->findAlbumSongs(index);
       
   499     TX_EXIT
       
   500 }
       
   501 
       
   502 /*!
       
   503  Slot to be called when a song is selected in T-Bone view and we need to
       
   504  play album with \a albumIndex starting with the songs with \a songIndex.
       
   505  */
       
   506 void MpCollectionView::playAlbumSongs( int albumIndex, int songIndex )
       
   507 {
       
   508     TX_ENTRY_ARGS( "albumIndex=" << albumIndex << "songIndex=" << songIndex );
       
   509     // TODO: "showingPopup()" used as workaround for HbListView multiple events: longPress and activated.
       
   510     //       Remove once HbListView get fixed (wk16)
       
   511     if ( !mMpPopupHandler->showingPopup() ) {
       
   512         mMpEngine->playAlbumSongs(albumIndex, songIndex);
   488     }
   513     }
   489     TX_EXIT
   514     TX_EXIT
   490 }
   515 }
   491 
   516 
   492 /*!
   517 /*!
   499     switch ( mCollectionContext ) {
   524     switch ( mCollectionContext ) {
   500         case ECollectionContextAllSongs:
   525         case ECollectionContextAllSongs:
   501         case ECollectionContextArtists: 
   526         case ECollectionContextArtists: 
   502         case ECollectionContextAlbums:
   527         case ECollectionContextAlbums:
   503         case ECollectionContextPlaylists:
   528         case ECollectionContextPlaylists:
   504         case ECollectionContextGenres:
       
   505             // Exit from these levels.
   529             // Exit from these levels.
   506             doExit = true;
   530             doExit = true;
   507             break;
   531             break;
   508         case ECollectionContextAlbumSongs:
       
   509         case ECollectionContextArtistAlbums:
   532         case ECollectionContextArtistAlbums:
   510         case ECollectionContextArtistSongs:
   533         case ECollectionContextArtistAllSongs:
   511         case ECollectionContextPlaylistSongs:
   534         case ECollectionContextPlaylistSongs:
   512         case ECollectionContextGenreSongs:
       
   513             mMpEngine->back();
   535             mMpEngine->back();
       
   536             break;
       
   537         case ECollectionContextArtistAlbumsTBone:
       
   538             if ( mCollectionData->count() > 1 ) {
       
   539                 // Going from T-Bone to Artist-Album view; Need to fake back.
       
   540                 mCollectionData->setContext(ECollectionContextArtistAlbums);
       
   541             }
       
   542             else {
       
   543                 // There only 1 album under this artist. Return to artist view.
       
   544                 mMpEngine->back();
       
   545             }
       
   546             break;
       
   547         case ECollectionContextAlbumsTBone:
       
   548             // Going from T-Bone to Album view; Need to fake back.
       
   549             mCollectionData->setContext(ECollectionContextAlbums);
   514             break;
   550             break;
   515         default:
   551         default:
   516             doExit = true;
   552             doExit = true;
   517             break;
   553             break;
   518     }
   554     }
   522             // Send an empty string to indicate that user has cancelled
   558             // Send an empty string to indicate that user has cancelled
   523             // the fetch operation
   559             // the fetch operation
   524             emit songSelected( "" );
   560             emit songSelected( "" );
   525         }
   561         }
   526         else {
   562         else {
   527             emit command( MpCommon::Exit );
   563             emit command( MpCommon::SendToBackground );
   528         }
   564         }
   529     }
   565     }
   530     TX_EXIT
   566     TX_EXIT
   531 }
   567 }
   532 
   568 
   598 /*!
   634 /*!
   599  Slot to be called when 'Add to playlist' is clicked by the user from the menu.
   635  Slot to be called when 'Add to playlist' is clicked by the user from the menu.
   600  */
   636  */
   601 void MpCollectionView::addToPlaylist()
   637 void MpCollectionView::addToPlaylist()
   602 {
   638 {
   603     mMpPopupHandler->openAddSongsToPlaylist( mCollectionDataModel );
   639     switch ( mCollectionContext ) {
       
   640         case ECollectionContextArtistAlbumsTBone:
       
   641         case ECollectionContextAlbumsTBone:
       
   642             mMpPopupHandler->openAddSongsToPlaylistFromTBone();    
       
   643             break;
       
   644         default:
       
   645             mMpPopupHandler->openAddSongsToPlaylist( mCollectionDataModel );
       
   646             break;
       
   647     }
   604 }
   648 }
   605 
   649 
   606 /*!
   650 /*!
   607  Slot to be called when 'Delete' is clicked by the user from the menu.
   651  Slot to be called when 'Delete' is clicked by the user from the menu.
   608  */
   652  */
   625 /*!
   669 /*!
   626  Slot to be called when 'Add to playlist' operation has completed.
   670  Slot to be called when 'Add to playlist' operation has completed.
   627  */
   671  */
   628 void MpCollectionView::playlistSaved( bool success )
   672 void MpCollectionView::playlistSaved( bool success )
   629 {
   673 {
   630     if ( success &&
   674     if ( success
   631             ( ECollectionContextPlaylists == mCollectionContext ||
   675          && ( ECollectionContextPlaylists == mCollectionContext
   632             ECollectionContextPlaylistSongs == mCollectionContext ) ) {
   676               || ECollectionContextPlaylistSongs == mCollectionContext ) ) {
   633         mMpEngine->reopenCollection();
   677         mMpEngine->reopenCollection();
   634     }
   678     }
   635 }
   679 }
   636 
   680 
   637 /*!
   681 /*!
   685 /*!
   729 /*!
   686  Slot to be called to arrange songs in a playlist.
   730  Slot to be called to arrange songs in a playlist.
   687  */
   731  */
   688 void MpCollectionView::arrangeSongs( )
   732 void MpCollectionView::arrangeSongs( )
   689 {
   733 {
   690     mMpPopupHandler->openArrangeSongs( mCollectionData );
   734     mMpPopupHandler->openArrangeSongs();
   691 }
   735 }
   692 
   736 
   693 /*!
   737 /*!
   694  Slot to be called when an item is long pressed by the user.
   738  Slot to be called when an item is long pressed by the user.
   695  */
   739  */
   787 
   831 
   788         // Playlists
   832         // Playlists
   789         action = createToolBarAction( actionsGroup, "qtg_mono_playlist" );
   833         action = createToolBarAction( actionsGroup, "qtg_mono_playlist" );
   790         connect( action, SIGNAL( triggered( bool ) ), this, SLOT( openPlaylists() ) );
   834         connect( action, SIGNAL( triggered( bool ) ), this, SLOT( openPlaylists() ) );
   791         mMainToolBar->addAction( action );
   835         mMainToolBar->addAction( action );
   792 
   836         
   793         // Genres
       
   794         action = createToolBarAction( actionsGroup, "qtg_mono_search" );
       
   795         connect( action, SIGNAL( triggered( bool ) ), this, SLOT( find() ) );
       
   796         mMainToolBar->addAction( action );
       
   797 
       
   798         if ( mViewMode != MpCommon::FetchView ) {
   837         if ( mViewMode != MpCommon::FetchView ) {
   799             // Music Store
   838             // Music Store
   800             action = createToolBarAction(actionsGroup, "qtg_mono_ovistore" );
   839             action = createToolBarAction(actionsGroup, "qtg_mono_ovistore" );
   801             connect( action, SIGNAL( triggered( bool ) ), this, SLOT( openMusicStore() ) );
   840             connect( action, SIGNAL( triggered( bool ) ), this, SLOT( openMusicStore() ) );
   802             mMainToolBar->addAction( action );
   841             mMainToolBar->addAction( action );
   806     switch ( mCollectionContext ) {
   845     switch ( mCollectionContext ) {
   807         case ECollectionContextAllSongs:
   846         case ECollectionContextAllSongs:
   808             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarAll] );
   847             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarAll] );
   809             break;
   848             break;
   810         case ECollectionContextArtists:
   849         case ECollectionContextArtists:
   811         case ECollectionContextArtistAlbums:
       
   812             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarArtists] );
   850             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarArtists] );
   813             break;
   851             break;
   814         case ECollectionContextAlbums:
   852         case ECollectionContextAlbums:
   815         case ECollectionContextAlbumSongs:
       
   816             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarAlbums] );
   853             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarAlbums] );
   817             break;
   854             break;
   818         case ECollectionContextPlaylists:
   855         case ECollectionContextPlaylists:
   819         case ECollectionContextPlaylistSongs:
       
   820             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarPlaylists] );
   856             action = qobject_cast<HbAction*>( mMainToolBar->actions()[KMainToolBarPlaylists] );
   821             break;
   857             break;
   822     }
   858     }
   823     if ( action ) {
   859     if ( action ) {
   824         action->setChecked( true );
   860         action->setChecked( true );
   952                     menuAction->setDisabled( true );
   988                     menuAction->setDisabled( true );
   953                 }
   989                 }
   954                 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
   990                 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
   955                 break;
   991                 break;
   956             case ECollectionContextAlbums:
   992             case ECollectionContextAlbums:
   957                 //connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
       
   958                 // Todo: View as coverflow
       
   959                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
   993                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
   960                 if ( !mUsbBlocked ) {
   994                 if ( !mUsbBlocked ) {
   961                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
   995                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
   962                 }
   996                 }
   963                 else {
   997                 else {
   964                     menuAction->setDisabled( true );
   998                     menuAction->setDisabled( true );
   965                 }
   999                 }
   966                 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
  1000                 connect( myMenu->addAction(hbTrId("txt_common_opt_exit")), SIGNAL(triggered()), this, SLOT(exit()) );
   967                 break;
  1001                 break;
   968             case ECollectionContextArtistSongs:
  1002             case ECollectionContextArtistAlbumsTBone:
   969             case ECollectionContextAlbumSongs:
  1003             case ECollectionContextArtistAllSongs:
   970                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ); 
  1004             case ECollectionContextAlbumsTBone:
       
  1005                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
   971                 if ( !mUsbBlocked ) {
  1006                 if ( !mUsbBlocked ) {
   972                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
  1007                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
   973                 }
  1008                 }
   974                 else {
  1009                 else {
   975                     menuAction->setDisabled( true );
  1010                     menuAction->setDisabled( true );
  1000                 break;
  1035                 break;
  1001         }
  1036         }
  1002     }
  1037     }
  1003     else if ( mViewMode == MpCommon::FetchView ) {
  1038     else if ( mViewMode == MpCommon::FetchView ) {
  1004         switch ( mCollectionContext ) {
  1039         switch ( mCollectionContext ) {
  1005             case ECollectionContextAllSongs:                
  1040             case ECollectionContextAllSongs:
  1006                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) ); 
  1041             case ECollectionContextArtists:
  1007                 if ( !mUsbBlocked ) {
       
  1008                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );                
       
  1009                 }
       
  1010                 else {
       
  1011                     menuAction->setDisabled( true );
       
  1012                 }
       
  1013                 break;
       
  1014             case ECollectionContextAlbums:
  1042             case ECollectionContextAlbums:
  1015                 //connect( myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) ), SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
       
  1016                 // Todo: View as coverflow
       
  1017                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
  1043                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_refresh_library" ) );
  1018                 if ( !mUsbBlocked ) {
  1044                 if ( !mUsbBlocked ) {
  1019                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
  1045                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( refreshLibrary() ) );
  1020                 }
  1046                 }
  1021                 else {
  1047                 else {
  1048                 takeToolBar();
  1074                 takeToolBar();
  1049                 setToolBar( new HbToolBar );
  1075                 setToolBar( new HbToolBar );
  1050             }
  1076             }
  1051             break;
  1077             break;
  1052         case ECollectionContextArtistAlbums:
  1078         case ECollectionContextArtistAlbums:
  1053         case ECollectionContextArtistSongs:
  1079         case ECollectionContextArtistAlbumsTBone:
  1054         case ECollectionContextAlbumSongs:
  1080         case ECollectionContextArtistAllSongs:
  1055         case ECollectionContextGenreSongs:
  1081         case ECollectionContextAlbumsTBone:
  1056             if ( !toolBar()->actions().empty() ) {
  1082             if ( !toolBar()->actions().empty() ) {
  1057                 takeToolBar();
  1083                 takeToolBar();
  1058                 setToolBar( new HbToolBar );
  1084                 setToolBar( new HbToolBar );
  1059             }
  1085             }
  1060             break;
  1086             break;
  1072 void MpCollectionView::setSoftkey()
  1098 void MpCollectionView::setSoftkey()
  1073 {
  1099 {
  1074     if ( mViewMode == MpCommon::FetchView ) {
  1100     if ( mViewMode == MpCommon::FetchView ) {
  1075         // 'Back' is used in all views in fetch mode because we must
  1101         // 'Back' is used in all views in fetch mode because we must
  1076         // appear as an embedded application.
  1102         // appear as an embedded application.
  1077         setNavigationAction( mNavigationBack );
  1103         setNavigationAction( mSoftKeyBack );
  1078     }
  1104     }
  1079     else {
  1105     else {
  1080         switch ( mCollectionContext ) {
  1106         switch ( mCollectionContext ) {
  1081             case ECollectionContextAllSongs:
  1107             case ECollectionContextAllSongs:
  1082             case ECollectionContextArtists:
  1108             case ECollectionContextArtists:
  1083             case ECollectionContextAlbums:
  1109             case ECollectionContextAlbums:
  1084             case ECollectionContextPlaylists:
  1110             case ECollectionContextPlaylists:
  1085             case ECollectionContextGenres:
  1111                 setNavigationAction( mSoftKeyQuit );
  1086                 setNavigationAction( mNavigationQuit );
       
  1087                 break;
  1112                 break;
  1088             default:
  1113             default:
  1089                 setNavigationAction( mNavigationBack );
  1114                 setNavigationAction( mSoftKeyBack );
  1090                 break;
  1115                 break;
  1091         }
  1116         }
  1092     }
  1117     }
  1093 }
  1118 }
  1094 
  1119 
  1146     }
  1171     }
  1147     mSnapshot->capture( mWindow, mMainContainer );
  1172     mSnapshot->capture( mWindow, mMainContainer );
  1148     mWindow->scene()->addItem( mSnapshot );
  1173     mWindow->scene()->addItem( mSnapshot );
  1149 
  1174 
  1150 
  1175 
  1151     if ( ( contextFrom == ECollectionContextAlbums && contextTo == ECollectionContextAlbumSongs ) ||
  1176     if ( ( contextFrom == ECollectionContextAlbums && contextTo == ECollectionContextAlbumsTBone ) ||
  1152             ( contextFrom == ECollectionContextArtists && contextTo == ECollectionContextArtistAlbums ) ||
  1177          ( contextFrom == ECollectionContextArtists && contextTo == ECollectionContextArtistAlbums ) ||
  1153             ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextAlbumSongs ) ||
  1178          ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtistAlbumsTBone ) ||
  1154             ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtistSongs ) ||
  1179          ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtistAllSongs ) ||
  1155             ( contextFrom == ECollectionContextPlaylists && contextTo == ECollectionContextPlaylistSongs ) ||
  1180          ( contextFrom == ECollectionContextPlaylists && contextTo == ECollectionContextPlaylistSongs ) ) {
  1156             ( contextFrom == ECollectionContextGenres && contextTo == ECollectionContextGenreSongs ) ) {
       
  1157         HbEffect::start( mSnapshot,
  1181         HbEffect::start( mSnapshot,
  1158                 QString( "container" ),
  1182                 QString( "container" ),
  1159                 QString( "slide_out_to_left" ),
  1183                 QString( "slide_out_to_left" ),
  1160                 this,
  1184                 this,
  1161                 "containerTransitionComplete",
  1185                 "containerTransitionComplete",
  1166                 QString( "slide_in_to_left_and_fade_in" ),
  1190                 QString( "slide_in_to_left_and_fade_in" ),
  1167                 this,
  1191                 this,
  1168                 "containerTransitionComplete",
  1192                 "containerTransitionComplete",
  1169                 QString( "mainContainer_effect") );
  1193                 QString( "mainContainer_effect") );
  1170     }
  1194     }
  1171     else if( ( contextFrom == ECollectionContextAlbumSongs && contextTo == ECollectionContextAlbums ) ||
  1195     else if( ( contextFrom == ECollectionContextAlbumsTBone && contextTo == ECollectionContextAlbums ) ||
  1172             ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtists ) ||
  1196              ( contextFrom == ECollectionContextArtistAlbums && contextTo == ECollectionContextArtists ) ||
  1173             ( contextFrom == ECollectionContextAlbumSongs && contextTo == ECollectionContextArtistAlbums ) ||
  1197              ( contextFrom == ECollectionContextArtistAlbumsTBone && contextTo == ECollectionContextArtistAlbums ) ||
  1174             ( contextFrom == ECollectionContextArtistSongs && contextTo == ECollectionContextArtistAlbums ) ||
  1198              ( contextFrom == ECollectionContextArtistAllSongs && contextTo == ECollectionContextArtistAlbums ) ||
  1175             ( contextFrom == ECollectionContextPlaylistSongs && contextTo == ECollectionContextPlaylists ) ||
  1199              ( contextFrom == ECollectionContextPlaylistSongs && contextTo == ECollectionContextPlaylists ) ) {
  1176             ( contextFrom == ECollectionContextGenreSongs && contextTo == ECollectionContextGenres ) ) {
       
  1177         HbEffect::start( mSnapshot,
  1200         HbEffect::start( mSnapshot,
  1178                 QString( "container" ),
  1201                 QString( "container" ),
  1179                 QString( "slide_out_to_right" ),
  1202                 QString( "slide_out_to_right" ),
  1180                 this,
  1203                 this,
  1181                 "containerTransitionComplete",
  1204                 "containerTransitionComplete",
  1201                 QString( "slide_in_to_top_and_fade_in" ),
  1224                 QString( "slide_in_to_top_and_fade_in" ),
  1202                 this,
  1225                 this,
  1203                 "containerTransitionComplete",
  1226                 "containerTransitionComplete",
  1204                 QString( "mainContainer_effect") );
  1227                 QString( "mainContainer_effect") );
  1205     }
  1228     }
  1206 
       
  1207 }
  1229 }
  1208 
  1230 
  1209 /*!
  1231 /*!
  1210  \internal
  1232  \internal
  1211  Closes any active dialog or menu.
  1233  Closes any active dialog or menu.