mpviewplugins/mpcollectionviewplugin/src/mpcollectioncontainerartists.cpp
changeset 36 a0afa279b8fe
parent 35 fdb31ab341af
child 37 eb79a7c355bf
equal deleted inserted replaced
35:fdb31ab341af 36:a0afa279b8fe
   134                 mTBone->setModel(dataModel);
   134                 mTBone->setModel(dataModel);
   135                 mTBone->scrollTo( dataModel->index(mCurrentAlbumIndex - mAlbumIndexOffset, 0) );
   135                 mTBone->scrollTo( dataModel->index(mCurrentAlbumIndex - mAlbumIndexOffset, 0) );
   136                 if ( mTBoneListModel == 0 ) {
   136                 if ( mTBoneListModel == 0 ) {
   137                     mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData);
   137                     mTBoneListModel = new MpCollectionTBoneListDataModel(mCollectionData);
   138                     connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) );
   138                     connect( mTBoneListModel, SIGNAL(albumDataChanged()), this, SLOT(albumDataChanged()) );
       
   139                     connect( mTBoneListModel, SIGNAL(albumDataAvailable()), this, SLOT(albumDataAvailable()) );
   139                 }
   140                 }
   140                 mList->setModel(mTBoneListModel);
   141                 mList->setModel(mTBoneListModel);
   141 
   142                 if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
   142                 if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
   143                     if ( mCollectionData->albumSongsCount() > 1 ) {
       
   144                         emit shuffleEnabled(true);
       
   145                     }
       
   146                     else {
       
   147                         emit shuffleEnabled(false);
       
   148                     }
       
   149                 }
       
   150                 else {
   143                     emit findAlbumSongs(mCurrentAlbumIndex);
   151                     emit findAlbumSongs(mCurrentAlbumIndex);
       
   152                     emit shuffleEnabled(false);
   144                 }
   153                 }
   145             }
   154             }
   146             break;
   155             break;
   147         case ECollectionContextArtistAllSongs:
   156         case ECollectionContextArtistAllSongs:
   148             if ( mList ) {
   157             if ( mList ) {
   203     if ( mCurrentAlbumIndex != index ) {
   212     if ( mCurrentAlbumIndex != index ) {
   204         // Prevent reloading if user just moves the center album a little
   213         // Prevent reloading if user just moves the center album a little
   205         // and the same album re-centers.
   214         // and the same album re-centers.
   206         mCurrentAlbumIndex = index;
   215         mCurrentAlbumIndex = index;
   207         TX_LOG_ARGS("mCurrentAlbumIndex=" << mCurrentAlbumIndex);
   216         TX_LOG_ARGS("mCurrentAlbumIndex=" << mCurrentAlbumIndex);
   208         if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
   217         if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
       
   218             if ( mCollectionData->albumSongsCount() > 1 ) {
       
   219                 emit shuffleEnabled(true);
       
   220             }
       
   221             // Enable context menu
       
   222             mLongPressEnabled = true;
       
   223         }
       
   224         else {
   209             emit findAlbumSongs(mCurrentAlbumIndex);
   225             emit findAlbumSongs(mCurrentAlbumIndex);
   210         }
   226         }
   211     }
   227     }
   212     TX_EXIT
   228     else {
   213 }
   229         // Landed on the same album. Just update menu.
   214 
   230         if ( mCollectionData->albumSongsCount() > 1 ) {
   215 /*!
   231             emit shuffleEnabled(true);
   216  Slot to be called data model has new data. This occurs after a delete operation is complete.
   232         }
       
   233         // Enable context menu
       
   234         mLongPressEnabled = true;
       
   235     }
       
   236     TX_EXIT
       
   237 }
       
   238 
       
   239 /*!
       
   240  Slot to be called when data model has new data. This occurs after a delete operation is complete.
   217  Two cases:
   241  Two cases:
   218      1) User deleted an artist.
   242      1) User deleted an artist.
   219 	 2) User deleted last song in an album.
   243 	 2) User deleted last song in an album.
   220  */
   244  */
   221 void MpCollectionContainerArtists::dataReloaded()
   245 void MpCollectionContainerArtists::dataReloaded()
   224     if ( mCollectionContext == ECollectionContextArtistAlbumsTBone ) {
   248     if ( mCollectionContext == ECollectionContextArtistAlbumsTBone ) {
   225         if ( mCurrentAlbumIndex > 0 ) {
   249         if ( mCurrentAlbumIndex > 0 ) {
   226             --mCurrentAlbumIndex;
   250             --mCurrentAlbumIndex;
   227         }
   251         }
   228         mTBone->scrollTo( mDataModel->index(mCurrentAlbumIndex - mAlbumIndexOffset, 0) );
   252         mTBone->scrollTo( mDataModel->index(mCurrentAlbumIndex - mAlbumIndexOffset, 0) );
   229         if ( !mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
   253         if ( mCollectionData->setCurrentAlbum(mCurrentAlbumIndex) ) {
       
   254             if ( mCollectionData->albumSongsCount() == 1 ) {
       
   255                 emit shuffleEnabled(false);
       
   256             }
       
   257         }
       
   258         else {
   230             emit findAlbumSongs(mCurrentAlbumIndex);
   259             emit findAlbumSongs(mCurrentAlbumIndex);
   231         }
   260         }
   232     }
   261     }
   233     else {
   262     else {
   234         MpCollectionListContainer::dataReloaded();
   263         MpCollectionListContainer::dataReloaded();
   235     }
   264     }
   236     TX_EXIT
   265     TX_EXIT
   237 }
   266 }
   238 
   267 
   239 /*!
   268 /*!
   240  Slot to be called data model has new data.
   269  Slot to be called when data model has new data.
   241  User has deleted one of the songs from TBone list.
   270  User has deleted one of the songs from TBone list.
   242  */
   271  */
   243 void MpCollectionContainerArtists::albumDataChanged()
   272 void MpCollectionContainerArtists::albumDataChanged()
   244 {
   273 {
   245     TX_ENTRY
   274     TX_ENTRY
   246     emit findAlbumSongs(mCurrentAlbumIndex);
   275     emit findAlbumSongs(mCurrentAlbumIndex);
       
   276     emit shuffleEnabled(false);
       
   277     TX_EXIT
       
   278 }
       
   279 
       
   280 /*!
       
   281  Slot to be called TBone starts scrolling.
       
   282  */
       
   283 void MpCollectionContainerArtists::scrollingStarted()
       
   284 {
       
   285     TX_ENTRY
       
   286     // Disable shuffle action from the menu
       
   287     emit shuffleEnabled(false);
       
   288     // Disable context menu
       
   289     mLongPressEnabled = false;
       
   290     TX_EXIT
       
   291 }
       
   292 
       
   293 /*!
       
   294  Slot to be called album data is available. This is a result of findAlbumSongs signal.
       
   295  */
       
   296 void MpCollectionContainerArtists::albumDataAvailable()
       
   297 {
       
   298     TX_ENTRY
       
   299     int count = mCollectionData->albumSongsCount();
       
   300     if ( count > 1 ) {
       
   301         emit shuffleEnabled(true);
       
   302     }
       
   303     // Enable context menu
       
   304     mLongPressEnabled = true;
   247     TX_EXIT
   305     TX_EXIT
   248 }
   306 }
   249 
   307 
   250 /*!
   308 /*!
   251  Sets up the container by organizing widgets according to its layout.
   309  Sets up the container by organizing widgets according to its layout.
   330                 mTBone->setDefaultImage( defaultIcon.pixmap().toImage() );
   388                 mTBone->setDefaultImage( defaultIcon.pixmap().toImage() );
   331                 mTBone->setTitleFontSpec( HbFontSpec(HbFontSpec::Primary) );
   389                 mTBone->setTitleFontSpec( HbFontSpec(HbFontSpec::Primary) );
   332                 mTBone->setDescriptionFontSpec( HbFontSpec(HbFontSpec::Secondary) );
   390                 mTBone->setDescriptionFontSpec( HbFontSpec(HbFontSpec::Secondary) );
   333                 mTBone->setScrollBarPolicy( HgWidget::ScrollBarAlwaysOff );
   391                 mTBone->setScrollBarPolicy( HgWidget::ScrollBarAlwaysOff );
   334                 mTBone->enableReflections(true);
   392                 mTBone->enableReflections(true);
       
   393                 connect( mTBone, SIGNAL(scrollingStarted()), this, SLOT(scrollingStarted()) );
   335                 connect( mTBone, SIGNAL(scrollingEnded()), this, SLOT(albumCentered()) );
   394                 connect( mTBone, SIGNAL(scrollingEnded()), this, SLOT(albumCentered()) );
   336                 }
   395                 }
   337                 break;
   396                 break;
   338             case ECollectionContextArtistAllSongs:
   397             case ECollectionContextArtistAllSongs:
   339                 // No need to load anything. Just reuse the section "artistAlbums" loaded
   398                 // No need to load anything. Just reuse the section "artistAlbums" loaded