mpviewplugins/mpcollectionviewplugin/src/mpcollectionview.cpp
changeset 58 ed94e1e8390e
parent 54 c5b304f4d89b
child 59 cd9e40a08dda
equal deleted inserted replaced
54:c5b304f4d89b 58:ed94e1e8390e
   302 }
   302 }
   303 
   303 
   304 /*!
   304 /*!
   305  Opens or plays an item through collection container in order to keep track of the Artist / Album data used by infobar.
   305  Opens or plays an item through collection container in order to keep track of the Artist / Album data used by infobar.
   306  */
   306  */
   307 void MpCollectionView::openItem( int index )
   307 void MpCollectionView::openItem( const QModelIndex &index )
   308 {
   308 {
   309     TX_ENTRY_ARGS( "index = " << index );
   309     TX_ENTRY_ARGS( "index = " << index.row() );
   310     QModelIndex modelIndex;
   310     qobject_cast<MpCollectionListContainer*>(mCollectionContainer)->itemActivated( index );
   311     modelIndex = mCollectionDataModel->index( index );
       
   312     qobject_cast<MpCollectionListContainer*>(mCollectionContainer)->itemActivated( modelIndex );
       
   313     TX_EXIT
   311     TX_EXIT
   314 }
   312 }
   315 
   313 
   316 /*!
   314 /*!
   317  Shows the detailed metadata information for the song with \a index.
   315  Shows the detailed metadata information for the song with \a index.
   666             break;
   664             break;
   667     }
   665     }
   668 }
   666 }
   669 
   667 
   670 /*!
   668 /*!
       
   669  Slot to be called when 'New Playlist' is clicked by the user from the menu.
       
   670  */
       
   671 void MpCollectionView::createNewPlaylist() 
       
   672 {
       
   673     
       
   674     switch ( mCollectionContext ) {
       
   675         case ECollectionContextArtistAlbumsTBone:
       
   676         case ECollectionContextAlbumsTBone:
       
   677             mMpPopupHandler->openCreateNewPlaylistFromTBone();    
       
   678             break;
       
   679         default:
       
   680             //second parameter, means it is an not an isolated collection, 
       
   681             //ownership is  not transferred.
       
   682             mMpPopupHandler->openCreateNewPlaylist( mCollectionData, false );
       
   683             break;
       
   684     }
       
   685 }
       
   686 
       
   687 /*!
   671  Slot to be called when 'Delete' is clicked by the user from the menu.
   688  Slot to be called when 'Delete' is clicked by the user from the menu.
   672  */
   689  */
   673 void MpCollectionView::deleteSongs()
   690 void MpCollectionView::deleteSongs()
   674 {
   691 {
   675     mMpPopupHandler->openDeleteSongs( mCollectionDataModel );
   692     mMpPopupHandler->openDeleteSongs( mCollectionDataModel );
   738 
   755 
   739         if (ECollectionContextPlaylistSongs == mCollectionContext) {
   756         if (ECollectionContextPlaylistSongs == mCollectionContext) {
   740             mMpPopupHandler->openAddToCurrentPlaylist( collectionData );
   757             mMpPopupHandler->openAddToCurrentPlaylist( collectionData );
   741         }
   758         }
   742         else if (ECollectionContextPlaylists == mCollectionContext) {
   759         else if (ECollectionContextPlaylists == mCollectionContext) {
   743             mMpPopupHandler->openCreateNewPlaylist( collectionData );
   760             //second parameter, means it is an isolated collection, ownership is transferred.
       
   761             mMpPopupHandler->openCreateNewPlaylist( collectionData, true );
   744         }
   762         }
   745     }
   763     }
   746     TX_EXIT
   764     TX_EXIT
   747 }
   765 }
   748 
   766 
   755 }
   773 }
   756 
   774 
   757 /*!
   775 /*!
   758  Slot to be called when an item is long pressed by the user.
   776  Slot to be called when an item is long pressed by the user.
   759  */
   777  */
   760 void MpCollectionView::openContextMenu( int index, const QPointF &coords )
   778 void MpCollectionView::openContextMenu( const QModelIndex &index, const QPointF &coords )
   761 {
   779 {
   762     TX_ENTRY_ARGS( "index=" << index );
   780     TX_ENTRY_ARGS( "index=" << index.row() );
   763     switch ( mViewMode ) {
   781     switch ( mViewMode ) {
   764         case MpCommon::DefaultView:
   782         case MpCommon::DefaultView:
   765             mMpPopupHandler->openDefaultViewContextMenu( index, coords );
   783             mMpPopupHandler->openDefaultViewContextMenu( index, coords );
   766             break;
   784             break;
   767         case MpCommon::FetchView:
   785         case MpCommon::FetchView:
  1011                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1029                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1012                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1030                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1013                 if ( count <= 1 ) {
  1031                 if ( count <= 1 ) {
  1014                     mShuffleAction->setDisabled( true );
  1032                     mShuffleAction->setDisabled( true );
  1015                 }
  1033                 }
  1016                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1017                 if ( count && !mUsbBlocked ) {
  1034                 if ( count && !mUsbBlocked ) {
       
  1035                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
  1018                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
  1036                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
       
  1037                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
       
  1038                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( createNewPlaylist() ) );
  1019                 }
  1039                 }
  1020                 else {
  1040                 else {
       
  1041                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1042                     menuAction->setDisabled( true );
       
  1043                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
  1021                     menuAction->setDisabled( true );
  1044                     menuAction->setDisabled( true );
  1022                 }
  1045                 }
  1023                 addDefaultMenuOptions( myMenu, true, true );
  1046                 addDefaultMenuOptions( myMenu, true, true );
  1024                 break;
  1047                 break;
  1025             case ECollectionContextArtists:
  1048             case ECollectionContextArtists:
  1032                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1055                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1033                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1056                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1034                 if ( !mShuffleEnabled ) {
  1057                 if ( !mShuffleEnabled ) {
  1035                     mShuffleAction->setDisabled( true );
  1058                     mShuffleAction->setDisabled( true );
  1036                 }
  1059                 }
  1037                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1038                 if ( !mUsbBlocked ) {
  1060                 if ( !mUsbBlocked ) {
       
  1061                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
  1039                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
  1062                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
       
  1063                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
       
  1064                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( createNewPlaylist() ) );
  1040                 }
  1065                 }
  1041                 else {
  1066                 else {
       
  1067                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1068                     menuAction->setDisabled( true );
       
  1069                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
  1042                     menuAction->setDisabled( true );
  1070                     menuAction->setDisabled( true );
  1043                 }
  1071                 }
  1044                 addDefaultMenuOptions( myMenu, true, true );
  1072                 addDefaultMenuOptions( myMenu, true, true );
  1045                 break;
  1073                 break;
  1046             case ECollectionContextArtistAllSongs:
  1074             case ECollectionContextArtistAllSongs:
  1047                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1075                 mShuffleAction = myMenu->addAction( hbTrId( "txt_mus_opt_shuffle" ) );
  1048                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1076                 connect( mShuffleAction, SIGNAL( triggered() ), this, SLOT( shufflePlayAll() ) );
  1049                 if ( count <= 1 ) {
  1077                 if ( count <= 1 ) {
  1050                     mShuffleAction->setDisabled( true );
  1078                     mShuffleAction->setDisabled( true );
  1051                 }
  1079                 }
  1052                 menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1053                 if ( !mUsbBlocked ) {
  1080                 if ( !mUsbBlocked ) {
       
  1081                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
  1054                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
  1082                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( addToPlaylist() ) );
       
  1083                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
       
  1084                     connect( menuAction, SIGNAL( triggered() ), this, SLOT( createNewPlaylist() ) );
  1055                 }
  1085                 }
  1056                 else {
  1086                 else {
       
  1087                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_add_to_playlist" ) );
       
  1088                     menuAction->setDisabled( true );
       
  1089                     menuAction = myMenu->addAction( hbTrId( "txt_mus_opt_new_playlist" ) );
  1057                     menuAction->setDisabled( true );
  1090                     menuAction->setDisabled( true );
  1058                 }
  1091                 }
  1059                 addDefaultMenuOptions( myMenu, true, true );
  1092                 addDefaultMenuOptions( myMenu, true, true );
  1060                 break;
  1093                 break;
  1061             case ECollectionContextPlaylists:
  1094             case ECollectionContextPlaylists:
  1084                     }
  1117                     }
  1085                 }
  1118                 }
  1086                 addDefaultMenuOptions( myMenu, true, true );
  1119                 addDefaultMenuOptions( myMenu, true, true );
  1087                 break;
  1120                 break;
  1088             default:
  1121             default:
       
  1122                 //if we accidentally fall in an unknown context
       
  1123                 addDefaultMenuOptions( myMenu, false, true );
  1089                 break;
  1124                 break;
  1090         }
  1125         }
  1091     }
  1126     }
  1092     else if ( mViewMode == MpCommon::FetchView ) {
  1127     else if ( mViewMode == MpCommon::FetchView ) {
  1093         switch ( mCollectionContext ) {
  1128         switch ( mCollectionContext ) {
  1095             case ECollectionContextArtists:
  1130             case ECollectionContextArtists:
  1096             case ECollectionContextAlbums:
  1131             case ECollectionContextAlbums:
  1097                 addDefaultMenuOptions( myMenu, true, false );
  1132                 addDefaultMenuOptions( myMenu, true, false );
  1098                 break;
  1133                 break;
  1099             default:
  1134             default:
       
  1135                 //if we accidentally fall in an unknown context
       
  1136                 addDefaultMenuOptions( myMenu, false, true );
  1100                 break;
  1137                 break;
  1101         }
  1138         }
  1102     }
  1139     }
  1103 
  1140 
  1104     setMenu( myMenu );
  1141     setMenu( myMenu );