videocollection/hgmyvideos/src/vcxhgmyvideosvideolistimpl.cpp
branchRCL_3
changeset 14 8970fbd719ec
parent 13 112a725ff2c2
child 16 7f2b2a65da29
equal deleted inserted replaced
13:112a725ff2c2 14:8970fbd719ec
   247 // CVcxHgMyVideosVideoListImpl::HandleOpenL()
   247 // CVcxHgMyVideosVideoListImpl::HandleOpenL()
   248 // -----------------------------------------------------------------------------
   248 // -----------------------------------------------------------------------------
   249 //
   249 //
   250 void CVcxHgMyVideosVideoListImpl::HandleOpenL( TInt /*aIndex*/ )
   250 void CVcxHgMyVideosVideoListImpl::HandleOpenL( TInt /*aIndex*/ )
   251     {
   251     {
       
   252     // Reset the visible selection of the list.
       
   253     iScroller->DrawDeferred();
       
   254     
   252     if ( iModel.TouchSupport() )
   255     if ( iModel.TouchSupport() )
   253         {    
   256         {    
   254         PlayCurrentVideoL();
   257         PlayCurrentVideoL();
   255         }
   258         }
   256     }
   259     }
   620             {
   623             {
   621             iVideoModel->HandleMarkCommandL( aMarkCommand );
   624             iVideoModel->HandleMarkCommandL( aMarkCommand );
   622             EndMarkingMode();
   625             EndMarkingMode();
   623             break;
   626             break;
   624             }
   627             }
       
   628         default:
       
   629             break;
   625         }
   630         }
   626     
   631     
   627     iView.DynInitMskL();
   632     iView.DynInitMskL();
   628     iView.DynInitRskL();
   633     iView.DynInitRskL();
   629     }
       
   630 
       
   631 // -----------------------------------------------------------------------------
       
   632 // CVcxHgMyVideosVideoListImpl::ShowMoveAndCopyMenuItemsL()
       
   633 // -----------------------------------------------------------------------------
       
   634 //
       
   635 void CVcxHgMyVideosVideoListImpl::ShowMoveAndCopyMenuItemsL( 
       
   636         TBool& aShowMoveAndCopySubmenu, TBool& aShowCopy, TBool& aShowMove )
       
   637     {
       
   638     RArray<TInt> operationTargets;
       
   639     CleanupClosePushL( operationTargets );
       
   640     
       
   641     TRAPD( error, GetOperationTargetIndexesL( operationTargets ) );
       
   642 
       
   643     if ( error != KErrNone )
       
   644         {
       
   645         aShowMoveAndCopySubmenu = aShowCopy = aShowMove = EFalse;
       
   646         }
       
   647 	else
       
   648         {
       
   649         iVideoCopier->ShowMenuItemsL( operationTargets, 
       
   650                                       aShowMoveAndCopySubmenu,
       
   651                                       aShowCopy,
       
   652                                       aShowMove );
       
   653         }
       
   654     
       
   655     CleanupStack::PopAndDestroy( &operationTargets );
       
   656     }
   634     }
   657 
   635 
   658 // -----------------------------------------------------------------------------
   636 // -----------------------------------------------------------------------------
   659 // CVcxHgMyVideosVideoListImpl::HandleMoveOrCopyCommandL() 
   637 // CVcxHgMyVideosVideoListImpl::HandleMoveOrCopyCommandL() 
   660 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   711         // Submenu was initialized by Aiw
   689         // Submenu was initialized by Aiw
   712         return;
   690         return;
   713         }
   691         }
   714 #endif
   692 #endif
   715 
   693 
   716     RArray<TInt> markedVideos;
       
   717     CleanupClosePushL( markedVideos );
       
   718     
       
   719     iVideoModel->MarkedVideosL( markedVideos );
       
   720     TInt highlight = Highlight();        
       
   721     TInt count = iVideoModel->VideoCount();
       
   722 
       
   723     TVcxMyVideosDownloadState dlState( EVcxMyVideosDlStateNone );
       
   724     TBool progressivePlay( EFalse );
       
   725     
       
   726     if ( count > 0 && highlight >= 0 )
       
   727         {
       
   728         dlState = iVideoModel->VideoDownloadState( highlight );
       
   729         progressivePlay = iVideoModel->IsProgressivePlayPossible( highlight );
       
   730         }
       
   731 
       
   732     // Check if there are marked items on the list that can be deleted
       
   733     TBool itemsToDelete( EFalse );
       
   734     
       
   735     for ( TInt i = 0; i < markedVideos.Count(); i++ )
       
   736         {
       
   737         if ( iVideoModel->VideoDownloadState( markedVideos[i] ) == EVcxMyVideosDlStateNone )
       
   738             {    
       
   739             itemsToDelete = ETrue;
       
   740             break;
       
   741             }
       
   742         }
       
   743 
       
   744     TBool showDelete = ( ( highlight >= 0 ) && ( count > 0 ) 
       
   745                          && ( ( dlState == EVcxMyVideosDlStateNone && markedVideos.Count() == 0 ) 
       
   746                          || itemsToDelete ) );
       
   747     
       
   748     if ( aResourceId == R_VCXHGMYVIDEOS_MAINVIEW_MENU )
   694     if ( aResourceId == R_VCXHGMYVIDEOS_MAINVIEW_MENU )
   749         {      
   695         {
       
   696         // Check if list has videos marked
       
   697         RArray<TInt> markedVideos;
       
   698         CleanupClosePushL( markedVideos );
       
   699         iVideoModel->MarkedVideosL( markedVideos );
       
   700         TBool videosMarked = ( markedVideos.Count() > 0 );
       
   701         CleanupStack::PopAndDestroy( &markedVideos );
       
   702 
       
   703         TInt highlight = Highlight();
       
   704         TInt count = iVideoModel->VideoCount();
       
   705 
       
   706         // Show play menuitem for non-touch
   750         if ( ! iModel.TouchSupport() )
   707         if ( ! iModel.TouchSupport() )
   751             {
   708             {
   752             TBool showPlay = ( ( markedVideos.Count() == 0 ) && ( highlight >= 0 ) && ( count > 0 )
   709             TBool showPlay = ( !videosMarked && ( highlight >= 0 ) && ( count > 0 ) );
   753                            && ( ( dlState == EVcxMyVideosDlStateNone ) || ( progressivePlay ) ) );
       
   754             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdPlay, ! showPlay );
   710             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdPlay, ! showPlay );
   755             }
   711             }
   756 
   712 
   757         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdDelete, ! showDelete );
   713         if ( count > 0 )
   758 
   714             {
   759         TBool showCancel = ( ( markedVideos.Count() == 0 ) && ( highlight >= 0 ) && ( count > 0 )
   715             // Video details.
   760                              && ( dlState != EVcxMyVideosDlStateNone ) );
   716             TBool showVideoDetails = ( !videosMarked && highlight >= 0 );
   761         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCancelDownload, ! showCancel );
   717             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdVideoDetails, !showVideoDetails );
   762 
   718 
   763         TBool showResume = showCancel && ( ( dlState == EVcxMyVideosDlStatePaused ) ||
   719             // UPnP menu item. Item's behaviour follows video details item.
   764                                            ( dlState == EVcxMyVideosDlStateFailed ) );
   720             if ( showVideoDetails && iUPnP->IsApplicable() )
   765         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdResumeDownload, ! showResume );
       
   766 
       
   767         TBool showVideoDetails = ( ( markedVideos.Count() == 0 ) &&
       
   768                                    ( highlight >= 0 ) && 
       
   769                                    ( count > 0 ) && 
       
   770                                    ( ( dlState == EVcxMyVideosDlStateNone ) ||
       
   771                                      ( progressivePlay ) ) );        
       
   772         
       
   773         // Dont show file details if file isn't downloaded yet.
       
   774         if( ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStateDownloading ) ||
       
   775             ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStateFailed ) ||
       
   776             ( VideoModel().VideoDownloadState( Highlight() ) == EVcxMyVideosDlStatePaused ) )
       
   777             {
       
   778             showVideoDetails = EFalse;
       
   779             }
       
   780         
       
   781         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdVideoDetails, ! showVideoDetails );        
       
   782 
       
   783         // UPnP menu item. Item's behaviour follows video details item.     
       
   784         if ( showVideoDetails && count > 0 && highlight >= 0 && iUPnP->IsApplicable() )
       
   785             {
       
   786             if ( iUPnP->IsStarted() )
       
   787                 {
   721                 {
   788                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdStopShowViaHomenet, EFalse);
   722                 if ( iUPnP->IsStarted() )
       
   723                     {
       
   724                     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdStopShowViaHomenet, EFalse);
       
   725                     }
       
   726                 else
       
   727                     {
       
   728                     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdShowViaHomenet, EFalse );
       
   729                     }
       
   730                 }
       
   731 
       
   732             // Move, copy, delete
       
   733             DynInitMenuPaneFileOperationsL( aMenuPane, videosMarked );
       
   734 
       
   735             // Send item
       
   736             if ( highlight >= 0 || videosMarked )
       
   737                 {
       
   738                 AddSendItemToMenuPaneL( aMenuPane, videosMarked );
       
   739                 }
       
   740 
       
   741 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   742             // Assign (use as) menu item
       
   743             if ( !videosMarked && highlight >= 0 )
       
   744                 {
       
   745                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, EFalse );
   789                 }
   746                 }
   790             else
   747             else
   791                 {
   748                 {
   792                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdShowViaHomenet, EFalse );
   749                 // Hide Assign (use as) menu item
       
   750                 aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, ETrue );
   793                 }
   751                 }
   794             }
       
   795         
       
   796         // Send menu item.
       
   797         if ( ( highlight >= 0 ) && ( count > 0 ) &&
       
   798                 ( dlState == EVcxMyVideosDlStateNone ) )
       
   799             {
       
   800             // Get total size for marked videos
       
   801             RArray<TInt> operationTargets;
       
   802             CleanupClosePushL( operationTargets );
       
   803             
       
   804             GetOperationTargetIndexesL( operationTargets );
       
   805             TInt64 attachmentsTotalSize( 0 );
       
   806             for ( TInt i = 0; i < operationTargets.Count(); i++ )
       
   807                 {
       
   808                 attachmentsTotalSize += iVideoModel->GetVideoSize( operationTargets[i] );
       
   809                 }
       
   810 
       
   811             IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::DynInitMenuPaneL() %d files with total size %ld", operationTargets.Count(), attachmentsTotalSize );
       
   812             
       
   813             // SendUi uses TInt for size, hide Send menu item for over 2GB attachments
       
   814             if ( attachmentsTotalSize > 0 && attachmentsTotalSize < KMaxTInt )
       
   815                 {
       
   816                 // Place Send menu item on top of "Use as" (Assign) submenu
       
   817                 TInt sendItemIndex = 0;
       
   818 #ifdef RD_VIDEO_AS_RINGING_TONE                
       
   819                 aMenuPane->ItemAndPos( EVcxHgMyVideosCmdAiwAssign, sendItemIndex );
       
   820 #else
       
   821                 aMenuPane->ItemAndPos( EVcxHgMyVideosCmdSortSubMenu, sendItemIndex );
       
   822 #endif
   752 #endif
   823                 // Add Send item to menu
   753 
   824                 TSendingCapabilities capabilities(
   754             // Marking submenu
   825                     0,
       
   826                     attachmentsTotalSize,
       
   827                     TSendingCapabilities::ESupportsAttachments );
       
   828                 SendUiL()->AddSendMenuItemL(
       
   829                         *aMenuPane,
       
   830                         sendItemIndex,
       
   831                         EVcxHgMyVideosCmdSend,
       
   832                         capabilities );
       
   833                 aMenuPane->SetItemSpecific( EVcxHgMyVideosCmdSend, ETrue );
       
   834 
       
   835                 // The Send item also needs to be flagged as a list query.
       
   836                 CEikMenuPaneItem::SData& itemData = aMenuPane->ItemData( EVcxHgMyVideosCmdSend );
       
   837                 itemData.iFlags |= EEikMenuItemSpecificListQuery;
       
   838                 }
       
   839             CleanupStack::PopAndDestroy( &operationTargets );
       
   840             }
       
   841 
       
   842 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   843         // Assign (use as) menu item
       
   844         if ( ( markedVideos.Count() == 0 ) &&
       
   845                 ( highlight >= 0 ) && ( count > 0 ) &&
       
   846                 ( ( dlState == EVcxMyVideosDlStateNone ) ) )
       
   847             {
       
   848             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, EFalse );
       
   849             }
       
   850         else
       
   851             {
       
   852             // Hide Assign (use as) menu item
       
   853             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, ETrue );
       
   854             }
       
   855 #endif
       
   856 
       
   857         // Marking submenu
       
   858         if( count > 0 )
       
   859             {
       
   860             // Show "Mark/Unmark" only if there are videos in the list
   755             // Show "Mark/Unmark" only if there are videos in the list
   861             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMarkUnmarkSubMenu, EFalse);
   756             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMarkUnmarkSubMenu, EFalse);
   862             }
   757             }
   863 
   758 
   864         // "Sort by" submenu
   759         // "Sort by" submenu
   865         if( count == 0 )
   760         if( count == 0 )
   866             {
   761             {
   867             // Dont show "Sort by" if list is empty.
   762             // Dont show "Sort by" if list is empty.
   868             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdSortSubMenu, ETrue );
   763             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdSortSubMenu, ETrue );
   869             }
   764             }
   870         
   765 
   871         // Hide "Settings" menu item
   766         // Hide "Settings" menu item
   872         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdOpenSettings, ETrue );
   767         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdOpenSettings, ETrue );
   873         }
   768         }
       
   769 
   874 #ifdef RD_VIDEO_AS_RINGING_TONE
   770 #ifdef RD_VIDEO_AS_RINGING_TONE
   875     else if ( aResourceId == R_VCXHGMYVIDEOS_USE_AS_SUBMENU )
   771     else if ( aResourceId == R_VCXHGMYVIDEOS_USE_AS_SUBMENU )
   876         {
   772         {
   877         RArray<TInt> operationTargets;
   773         RArray<TInt> operationTargets;
   878         CleanupClosePushL( operationTargets );
   774         CleanupClosePushL( operationTargets );
   893             CleanupStack::PopAndDestroy( videoUri );
   789             CleanupStack::PopAndDestroy( videoUri );
   894             }
   790             }
   895         CleanupStack::PopAndDestroy( &operationTargets );
   791         CleanupStack::PopAndDestroy( &operationTargets );
   896         }
   792         }
   897 #endif
   793 #endif
   898     CleanupStack::PopAndDestroy( &markedVideos );
       
   899     }
   794     }
   900 
   795 
   901 // -----------------------------------------------------------------------------
   796 // -----------------------------------------------------------------------------
   902 // CVcxHgMyVideosVideoListImpl::SetEmptyListTextL()
   797 // CVcxHgMyVideosVideoListImpl::SetEmptyListTextL()
   903 // -----------------------------------------------------------------------------
   798 // -----------------------------------------------------------------------------
  1170             {
  1065             {
  1171             aOperationTargetIds.Append( iVideoModel->GetVideoId( aOperationTargetIndexes[i] ) );
  1066             aOperationTargetIds.Append( iVideoModel->GetVideoId( aOperationTargetIndexes[i] ) );
  1172             }
  1067             }
  1173         }
  1068         }
  1174     }
  1069     }
       
  1070 
       
  1071 // ---------------------------------------------------------------------------
       
  1072 // CVcxHgMyVideosVideoListImpl::AddSendItemToMenuPaneL()
       
  1073 // ---------------------------------------------------------------------------
       
  1074 //
       
  1075 void CVcxHgMyVideosVideoListImpl::AddSendItemToMenuPaneL(
       
  1076         CEikMenuPane* aMenuPane,
       
  1077         TBool aAddToOptions )
       
  1078     {
       
  1079     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::AddSendItemToMenuPaneL() enter" );
       
  1080     // Get total size of the videos that we're about to send
       
  1081     RArray<TInt> operationTargets;
       
  1082     CleanupClosePushL( operationTargets );
       
  1083 
       
  1084     GetOperationTargetIndexesL( operationTargets );
       
  1085     TInt64 attachmentsTotalSize( 0 );
       
  1086     for ( TInt i = 0; i < operationTargets.Count(); i++ )
       
  1087         {
       
  1088         attachmentsTotalSize += iVideoModel->GetVideoSize( operationTargets[i] );
       
  1089         }
       
  1090 
       
  1091     IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::AddSendItemToMenuPaneL() %d files with total size %ld", operationTargets.Count(), attachmentsTotalSize );
       
  1092 
       
  1093     // SendUi uses TInt for size, hide Send menu item for over 2GB attachments
       
  1094     if ( attachmentsTotalSize > 0 && attachmentsTotalSize < KMaxTInt )
       
  1095         {
       
  1096         // Find place for Send menu item on top of "Use as" (Assign) or Sort submenu
       
  1097         TInt sendItemIndex = 0;
       
  1098 #ifdef RD_VIDEO_AS_RINGING_TONE
       
  1099         aMenuPane->ItemAndPos( EVcxHgMyVideosCmdAiwAssign, sendItemIndex );
       
  1100 #else
       
  1101         aMenuPane->ItemAndPos( EVcxHgMyVideosCmdSortSubMenu, sendItemIndex );
       
  1102 #endif
       
  1103         // Add Send item to context menu
       
  1104         TSendingCapabilities capabilities(
       
  1105             0,
       
  1106             attachmentsTotalSize,
       
  1107             TSendingCapabilities::ESupportsAttachments );
       
  1108         SendUiL()->AddSendMenuItemL(
       
  1109                 *aMenuPane,
       
  1110                 sendItemIndex,
       
  1111                 EVcxHgMyVideosCmdSend,
       
  1112                 capabilities );
       
  1113         aMenuPane->SetItemSpecific( EVcxHgMyVideosCmdSend, ETrue );
       
  1114         // The Send item also needs to be flagged as a list query.
       
  1115         CEikMenuPaneItem::SData& itemData = aMenuPane->ItemData( EVcxHgMyVideosCmdSend );
       
  1116         itemData.iFlags |= EEikMenuItemSpecificListQuery;
       
  1117 
       
  1118         // Add Send to Options menu
       
  1119         if ( aAddToOptions )
       
  1120             {
       
  1121             SendUiL()->AddSendMenuItemL(
       
  1122                     *aMenuPane,
       
  1123                     sendItemIndex,
       
  1124                     EVcxHgMyVideosCmdSendMarked,
       
  1125                     capabilities );
       
  1126             aMenuPane->SetItemSpecific( EVcxHgMyVideosCmdSendMarked, EFalse );
       
  1127             }
       
  1128         }
       
  1129     CleanupStack::PopAndDestroy( &operationTargets );
       
  1130     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosVideoListImpl::AddSendItemToMenuPaneL() return" );
       
  1131     }
       
  1132 
       
  1133 // ---------------------------------------------------------------------------
       
  1134 // CVcxHgMyVideosVideoListImpl::DynInitMenuPaneFileOperationsL()
       
  1135 // ---------------------------------------------------------------------------
       
  1136 //
       
  1137 void CVcxHgMyVideosVideoListImpl::DynInitMenuPaneFileOperationsL(
       
  1138         CEikMenuPane* aMenuPane,
       
  1139         TBool aItemsMarked )
       
  1140     {
       
  1141     // Delete
       
  1142     TBool showDelete = ( ( Highlight() >= 0 ) || aItemsMarked );
       
  1143 
       
  1144     // Move and copy
       
  1145     RArray<TInt> operationTargets;
       
  1146     CleanupClosePushL( operationTargets );
       
  1147 
       
  1148     TRAPD( error, GetOperationTargetIndexesL( operationTargets ) );
       
  1149 
       
  1150     TBool showMoveAndCopySubmenu( EFalse );
       
  1151     TBool showCopy( EFalse );
       
  1152     TBool showMove( EFalse );
       
  1153 
       
  1154     if ( error == KErrNone )
       
  1155         {
       
  1156         iVideoCopier->ShowMenuItemsL( operationTargets,
       
  1157                                       showMoveAndCopySubmenu,
       
  1158                                       showCopy,
       
  1159                                       showMove );
       
  1160         }
       
  1161 
       
  1162     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCopy, !showCopy );
       
  1163     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMove, !showMove );
       
  1164     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdDelete, !showDelete );
       
  1165     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCopyMarked, !showCopy || !aItemsMarked );
       
  1166     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMoveMarked, !showMove || !aItemsMarked );
       
  1167     aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdDeleteMarked, !showDelete || !aItemsMarked );
       
  1168 
       
  1169     CleanupStack::PopAndDestroy( &operationTargets );
       
  1170     }