diff -r 8192e5b5c935 -r c163ef0b758d mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontaineralbums.cpp --- a/mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontaineralbums.cpp Thu May 27 12:49:57 2010 +0300 +++ b/mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontaineralbums.cpp Fri Jun 11 13:36:36 2010 +0300 @@ -94,10 +94,20 @@ if ( mTBoneListModel == 0 ) { mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData); connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) ); + connect( mTBoneListModel, SIGNAL(albumDataAvailable()), this, SLOT(albumDataAvailable()) ); } mList->setModel(mTBoneListModel); - if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->albumSongsCount() > 1 ) { + emit shuffleEnabled(true); + } + else { + emit shuffleEnabled(false); + } + } + else { emit findAlbumSongs(mCurrentAlbumIndex); + emit shuffleEnabled(false); } } } @@ -139,10 +149,25 @@ // and the same album re-centers. mCurrentAlbumIndex = index.row(); TX_LOG_ARGS("mCurrentAlbumIndex=" << mCurrentAlbumIndex); - if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->albumSongsCount() > 1 ) { + emit shuffleEnabled(true); + } + // Enable context menu + mLongPressEnabled = true; + } + else { emit findAlbumSongs(mCurrentAlbumIndex); } } + else { + // Landed on the same album. Just update menu. + if ( mCollectionData->albumSongsCount() > 1 ) { + emit shuffleEnabled(true); + } + // Enable context menu + mLongPressEnabled = true; + } TX_EXIT } @@ -160,7 +185,12 @@ --mCurrentAlbumIndex; } mTBone->scrollTo( mDataModel->index(mCurrentAlbumIndex, 0) ); - if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) { + if ( mCollectionData->albumSongsCount() == 1 ) { + emit shuffleEnabled(false); + } + } + else { emit findAlbumSongs(mCurrentAlbumIndex); } } @@ -178,6 +208,35 @@ { TX_ENTRY emit findAlbumSongs(mCurrentAlbumIndex); + emit shuffleEnabled(false); + TX_EXIT +} + +/*! + Slot to be called TBone starts scrolling. + */ +void MpCollectionContainerAlbums::scrollingStarted() +{ + TX_ENTRY + // Disable shuffle action from the menu + emit shuffleEnabled(false); + // Disable context menu + mLongPressEnabled = false; + TX_EXIT +} + +/*! + Slot to be called album data is available. This is a result of findAlbumSongs signal. + */ +void MpCollectionContainerAlbums::albumDataAvailable() +{ + TX_ENTRY + int count = mCollectionData->albumSongsCount(); + if ( count > 1 ) { + emit shuffleEnabled(true); + } + // Enable context menu + mLongPressEnabled = true; TX_EXIT } @@ -240,6 +299,7 @@ mTBone->setDescriptionFontSpec( HbFontSpec(HbFontSpec::Secondary) ); mTBone->setScrollBarPolicy( HgWidget::ScrollBarAlwaysOff ); mTBone->enableReflections(true); + connect( mTBone, SIGNAL(scrollingStarted()), this, SLOT(scrollingStarted()) ); connect( mTBone, SIGNAL(scrollingEnded()), this, SLOT(albumCentered()) ); } }