339 MpCollectionTBoneListDataModel *model; |
349 MpCollectionTBoneListDataModel *model; |
340 model = new MpCollectionTBoneListDataModel( mMpEngine->collectionData() ); |
350 model = new MpCollectionTBoneListDataModel( mMpEngine->collectionData() ); |
341 //this item will be deleted when clearing permanent data. |
351 //this item will be deleted when clearing permanent data. |
342 model->setParent(mPermanentData); |
352 model->setParent(mPermanentData); |
343 model->refreshModel(); |
353 model->refreshModel(); |
344 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), model, |
354 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available |
|
355 hbTrId( "txt_common_button_add_dialog" ), |
|
356 model, |
345 SLOT( handleAddSongsToPlayList( HbAction* ) ) ); |
357 SLOT( handleAddSongsToPlayList( HbAction* ) ) ); |
346 TX_EXIT |
358 TX_EXIT |
347 } |
359 } |
348 |
360 |
349 /*! |
361 /*! |
350 Request to select songs to be deleted |
362 Request to select songs to be deleted |
351 */ |
363 */ |
352 void MpCollectionPopupHandler::openDeleteSongs( QAbstractItemModel* model ) |
364 void MpCollectionPopupHandler::openDeleteSongs( QAbstractItemModel* model ) |
353 { |
365 { |
354 TX_ENTRY |
366 TX_ENTRY |
355 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), model, |
367 //currently we can only get here from playlistsongs, no need to check for that. |
|
368 getModelIndexes( hbTrId( "txt_mus_title_remove_songs" ), |
|
369 hbTrId( "txt_common_button_remove_dialog" ), |
|
370 model, |
356 SLOT( handleDeleteSongs( HbAction* ) ) ); |
371 SLOT( handleDeleteSongs( HbAction* ) ) ); |
357 TX_EXIT |
372 TX_EXIT |
358 } |
373 } |
359 |
374 |
360 /*! |
375 /*! |
361 Request to select songs to be added to the current play list |
376 Request to select songs to be added to the current play list |
362 */ |
377 */ |
363 void MpCollectionPopupHandler::openAddToCurrentPlaylist( MpMpxCollectionData* collectionData ) |
378 void MpCollectionPopupHandler::openAddToCurrentPlaylist( MpMpxCollectionData* collectionData ) |
364 { |
379 { |
365 TX_ENTRY |
380 TX_ENTRY |
366 mPermanentData->mIsolatedCollectionData = collectionData; |
381 mPermanentData->mIsolatedOperation = true; |
|
382 mPermanentData->mCollectionData = collectionData; |
367 MpCollectionDataModel *collectionDataModel; |
383 MpCollectionDataModel *collectionDataModel; |
368 collectionDataModel = new MpCollectionDataModel( collectionData ); |
384 collectionDataModel = new MpCollectionDataModel( collectionData ); |
|
385 //this item will be deleted when clearing permanent data. |
|
386 collectionDataModel->setParent( mPermanentData ); |
369 collectionDataModel->refreshModel(); |
387 collectionDataModel->refreshModel(); |
370 mPermanentData->mAbstractItemModel = collectionDataModel; |
388 mPermanentData->mAbstractItemModel = collectionDataModel; |
371 |
389 |
372 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), collectionDataModel, |
390 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available |
|
391 hbTrId( "txt_common_button_add_dialog" ), |
|
392 collectionDataModel, |
373 SLOT( handleAddToCurrentPlaylist( HbAction* ) ) ); |
393 SLOT( handleAddToCurrentPlaylist( HbAction* ) ) ); |
374 TX_EXIT |
394 TX_EXIT |
375 } |
395 } |
376 |
396 |
377 /*! |
397 /*! |
378 Request to create a new play list and then add songs to it. |
398 Request to create a new play list and then add songs to it. |
379 */ |
399 */ |
380 void MpCollectionPopupHandler::openCreateNewPlaylist( MpMpxCollectionData* collectionData ) |
400 void MpCollectionPopupHandler::openCreateNewPlaylist( MpMpxCollectionData* collectionData, bool isolated ) |
381 { |
401 { |
382 TX_ENTRY |
402 TX_ENTRY |
383 mPermanentData->mIsolatedCollectionData = collectionData; |
403 mPermanentData->mIsolatedOperation = isolated; |
384 |
404 mPermanentData->mCollectionData = collectionData; |
385 MpCollectionDataModel *collectionDataModel; |
405 MpCollectionDataModel *collectionDataModel; |
|
406 //this item will be deleted when clearing permanent data. |
386 collectionDataModel = new MpCollectionDataModel( collectionData ); |
407 collectionDataModel = new MpCollectionDataModel( collectionData ); |
|
408 collectionDataModel->setParent( mPermanentData ); |
387 collectionDataModel->refreshModel(); |
409 collectionDataModel->refreshModel(); |
388 mPermanentData->mAbstractItemModel = collectionDataModel; |
410 mPermanentData->mAbstractItemModel = collectionDataModel; |
389 |
411 QStringList playlists; |
|
412 mMpEngine->findPlaylists( playlists ); |
|
413 queryNewPlaylistName( playlists, SLOT( handleCreateNewPlaylistGetTextFinished( HbAction* ) ) ); |
|
414 TX_EXIT |
|
415 } |
|
416 |
|
417 /*! |
|
418 Request to create a new playlist from TBone |
|
419 */ |
|
420 void MpCollectionPopupHandler::openCreateNewPlaylistFromTBone( ) |
|
421 { |
|
422 TX_ENTRY |
|
423 mPermanentData->mIsolatedOperation = false; |
|
424 MpCollectionTBoneListDataModel *model; |
|
425 model = new MpCollectionTBoneListDataModel( mMpEngine->collectionData() ); |
|
426 //this item will be deleted when clearing permanent data. |
|
427 model->setParent(mPermanentData); |
|
428 model->refreshModel(); |
|
429 mPermanentData->mAbstractItemModel = model; |
390 QStringList playlists; |
430 QStringList playlists; |
391 mMpEngine->findPlaylists( playlists ); |
431 mMpEngine->findPlaylists( playlists ); |
392 queryNewPlaylistName( playlists, SLOT( handleCreateNewPlaylistGetTextFinished( HbAction* ) ) ); |
432 queryNewPlaylistName( playlists, SLOT( handleCreateNewPlaylistGetTextFinished( HbAction* ) ) ); |
393 TX_EXIT |
433 TX_EXIT |
394 } |
434 } |
661 { |
673 { |
662 TX_ENTRY |
674 TX_ENTRY |
663 HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() ); |
675 HbSelectionDialog *dialog = qobject_cast<HbSelectionDialog *>( sender() ); |
664 clearOutstandingPopup( dialog ); |
676 clearOutstandingPopup( dialog ); |
665 |
677 |
666 if ( selectedAction ) { |
678 if ( selectedAction && selectedAction->objectName() == KOk ) { |
667 QString objectName = selectedAction->objectName(); |
679 QModelIndexList selectedModelIndexes; |
668 if ( objectName == KOk ) { |
680 selectedModelIndexes = dialog->selectedModelIndexes(); |
669 QModelIndexList selectedModelIndexes; |
681 if ( selectedModelIndexes.count() ) { |
670 selectedModelIndexes = dialog->selectedModelIndexes(); |
682 QList<int> selection; |
671 if ( selectedModelIndexes.count() ) { |
683 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) { |
672 QList<int> selection; |
684 selection.append( selectedModelIndexes.at( i ).row() ); |
673 for ( int i = 0; i < selectedModelIndexes.size(); ++i ) { |
|
674 selection.append( selectedModelIndexes.at( i ).row() ); |
|
675 } |
|
676 requestDelete( selection ); |
|
677 } |
685 } |
678 } |
686 mPermanentData->mSelectedItems = selection; |
679 } |
687 } |
680 |
688 //we have to delay the delete, so the list on the dialog does not get the update (flicker!) |
|
689 connect( dialog, SIGNAL( destroyed() ), this, SLOT( requestDelete() ) ); |
|
690 } |
|
691 else { |
|
692 mPermanentData->clear(); |
|
693 } |
681 //Dialog won't use CollectionView main model any more, return it to its original layout. |
694 //Dialog won't use CollectionView main model any more, return it to its original layout. |
682 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( dialog->model() ); |
695 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( dialog->model() ); |
683 if ( mpModel ) { |
696 if ( mpModel ) { |
684 //setLayout() only applies for MpCollectionDataModel where we need to |
697 //setLayout() only applies for MpCollectionDataModel where we need to |
685 //decide which layout to use for the secondary text. |
698 //decide which layout to use for the secondary text. |
726 void MpCollectionPopupHandler::handleCreateNewPlaylistGetTextFinished( HbAction *selectedAction ) |
743 void MpCollectionPopupHandler::handleCreateNewPlaylistGetTextFinished( HbAction *selectedAction ) |
727 { |
744 { |
728 TX_ENTRY |
745 TX_ENTRY |
729 HbInputDialog *dialog = qobject_cast<HbInputDialog *>( sender() ); |
746 HbInputDialog *dialog = qobject_cast<HbInputDialog *>( sender() ); |
730 clearOutstandingPopup( dialog ); |
747 clearOutstandingPopup( dialog ); |
731 bool operationCompleted( true ); |
748 |
732 |
749 if ( selectedAction && selectedAction->objectName() == KOk) { |
733 if ( selectedAction ) { |
750 QString newPlaylistName = dialog->value().toString(); |
734 QString objectName = selectedAction->objectName(); |
751 //Store the new playlist name and query for the items to be added |
735 if ( objectName == KOk ) { |
752 mPermanentData->mOriginalName = newPlaylistName; |
736 QString newPlaylistName = dialog->value().toString(); |
753 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ),//TODO:replace for "add songs" when string is available |
737 if ( newPlaylistName.length() ) { |
754 hbTrId( "txt_common_button_add_dialog" ), |
738 //Store the new playlist name and query for the items to be added |
755 mPermanentData->mAbstractItemModel, |
739 mPermanentData->mOriginalName = newPlaylistName; |
756 SLOT( handleCreateNewPlaylistGetModelIndexesFinished( HbAction* ) ) ); |
740 getModelIndexes( hbTrId( "txt_mus_title_select_songs" ), |
757 } |
741 mPermanentData->mAbstractItemModel, |
758 else { |
742 SLOT( handleCreateNewPlaylistGetModelIndexesFinished( HbAction* ) ) ); |
|
743 } |
|
744 else { |
|
745 //No valid name, prompt for one again. |
|
746 getText( hbTrId( "txt_mus_dialog_enter_name" ), newPlaylistName, |
|
747 SLOT( handleCreateNewPlaylistGetTextFinished( HbAction* ) ) ); |
|
748 } |
|
749 operationCompleted = false; |
|
750 } |
|
751 } |
|
752 |
|
753 if ( operationCompleted ) { |
|
754 mPermanentData->clear(); |
759 mPermanentData->clear(); |
755 } |
760 } |
756 TX_EXIT |
761 TX_EXIT |
757 } |
762 } |
758 |
763 |
894 } |
910 } |
895 TX_EXIT |
911 TX_EXIT |
896 } |
912 } |
897 |
913 |
898 /*! |
914 /*! |
|
915 Slot to be called when the text on an input dialog changes. |
|
916 */ |
|
917 void MpCollectionPopupHandler::inputDialogChanged( QString text ) |
|
918 { |
|
919 if ( !mOutstandingPopup ) { |
|
920 return; |
|
921 } |
|
922 //Attempt to cast the outstanding dialog as the input dialog that owns the |
|
923 //line edit that changed. If cast fails it means that the dialog is out of |
|
924 //scope and the operation is not needed anymore. |
|
925 HbInputDialog *dialog = qobject_cast<HbInputDialog *>( mOutstandingPopup ); |
|
926 HbLineEdit *dialogLineEdit = qobject_cast<HbLineEdit *>( sender() ); |
|
927 if ( dialog && dialogLineEdit && dialog->lineEdit() == dialogLineEdit ) { |
|
928 if ( dialog->actions().count() ) { |
|
929 dialog->actions()[0]->setEnabled( !text.isEmpty() ); |
|
930 } |
|
931 } |
|
932 } |
|
933 |
|
934 /*! |
899 \internal |
935 \internal |
900 sets \a popup as the current outstanding popup and cancels any other previous popup. |
936 Slot to be called to request a delete operation upon user confirmation. |
901 */ |
937 */ |
902 void MpCollectionPopupHandler::setOutstandingPopup( HbPopup *popup ) |
938 void MpCollectionPopupHandler::requestDelete() |
903 { |
|
904 TX_ENTRY |
|
905 if ( mOutstandingPopup ) { |
|
906 TX_LOG_ARGS( "Warning: Multiple popups attempted to be displayed" ); |
|
907 mOutstandingPopup->close(); |
|
908 } |
|
909 |
|
910 connect( popup, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) ); |
|
911 mOutstandingPopup = popup; |
|
912 TX_EXIT |
|
913 } |
|
914 |
|
915 /*! |
|
916 \internal |
|
917 clears and disconnects \a popup. In some cases it's needed to open a new dialog when a current one has just finished. |
|
918 */ |
|
919 void MpCollectionPopupHandler::clearOutstandingPopup( HbPopup *popup ) |
|
920 { |
|
921 TX_ENTRY |
|
922 disconnect( popup, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) ); |
|
923 mOutstandingPopup = 0; |
|
924 TX_EXIT |
|
925 } |
|
926 |
|
927 /*! |
|
928 \internal |
|
929 Launches the 'Add to playlist' dialog. |
|
930 */ |
|
931 void MpCollectionPopupHandler::launchAddToPlaylistDialog( QList<int> &selection ) |
|
932 { |
|
933 TX_ENTRY |
|
934 |
|
935 QStringList playlists; |
|
936 mPermanentData->mSelectedItems = selection; |
|
937 mMpEngine->findPlaylists( playlists ); |
|
938 if ( playlists.count() ) { |
|
939 //There are saved playlists, query for a saved playlist or new. |
|
940 HbAction *action; |
|
941 HbSelectionDialog *dialog = new HbSelectionDialog(); |
|
942 dialog->setStringItems( playlists ); |
|
943 dialog->setSelectionMode( HbAbstractItemView::SingleSelection ); |
|
944 dialog->setHeadingWidget(new HbLabel( hbTrId( "txt_mus_title_select_playlist" ) ) ); |
|
945 dialog->clearActions(); |
|
946 action = new HbAction( hbTrId( "txt_mus_button_new" ) ); |
|
947 action->setObjectName( KNew ); |
|
948 dialog->addAction( action ); |
|
949 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
950 action->setObjectName( KCancel ); |
|
951 dialog->addAction( action ); |
|
952 dialog->setObjectName( KAddToPlaylistSelectionDialog ); |
|
953 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
954 setOutstandingPopup( dialog ); |
|
955 dialog->open( this, SLOT( handleAddToPlaylistDialogFinished( HbAction* ) ) ); |
|
956 } |
|
957 else { |
|
958 //querying for a new playlist name. |
|
959 queryNewPlaylistName( playlists, SLOT( handleAddToPlaylistGetTextFinished( HbAction* ) ) ); |
|
960 } |
|
961 TX_EXIT |
|
962 } |
|
963 |
|
964 /*! |
|
965 \internal |
|
966 Trigger an imput text dialog with a suggested playlist name. |
|
967 uses \a playlists to generate a suggested playlist name |
|
968 \handler Slot that should be called when input dialog finished |
|
969 */ |
|
970 void MpCollectionPopupHandler::queryNewPlaylistName(const QStringList &playlists, |
|
971 const char *handler ) |
|
972 { |
|
973 TX_ENTRY |
|
974 int i = 0; |
|
975 for ( ; |
|
976 playlists.contains( hbTrId( "txt_mus_dialog_enter_name_entry_playlist_l1" ).arg( i ) ) ; |
|
977 i++ ) {}; |
|
978 QString suggestedPlaylistName = hbTrId( "txt_mus_dialog_enter_name_entry_playlist_l1" ).arg( i ); |
|
979 getText( hbTrId( "txt_mus_dialog_enter_name" ), suggestedPlaylistName, handler ); |
|
980 TX_EXIT |
|
981 } |
|
982 |
|
983 /*! |
|
984 \internal |
|
985 Launches an input text dialog. |
|
986 \a label Dialog title. |
|
987 \a text Suggested text. |
|
988 \a handler Slot to be called when input dialog finishes. |
|
989 */ |
|
990 void MpCollectionPopupHandler::getText( const QString &label, const QString &text, |
|
991 const char *handler ) |
|
992 { |
|
993 TX_ENTRY |
|
994 HbAction *action; |
|
995 HbInputDialog *dialog = new HbInputDialog(); |
|
996 dialog->setPromptText( label ); |
|
997 dialog->setInputMode( HbInputDialog::TextInput ); |
|
998 dialog->setValue( text ); |
|
999 dialog->clearActions(); |
|
1000 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
|
1001 action->setObjectName( KOk ); |
|
1002 dialog->addAction( action ); |
|
1003 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
1004 action->setObjectName( KCancel ); |
|
1005 dialog->addAction( action ); |
|
1006 dialog->setObjectName( KInputTextDialog ); |
|
1007 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1008 setOutstandingPopup( dialog ); |
|
1009 dialog->open( this, handler ); |
|
1010 TX_EXIT |
|
1011 } |
|
1012 |
|
1013 /*! |
|
1014 \internal |
|
1015 Launches a list dialog to select items. |
|
1016 \a label Dialog title. |
|
1017 \a model List model. |
|
1018 \a handler Slot to be called when list dialog finishes. |
|
1019 */ |
|
1020 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model, |
|
1021 const char *handler) |
|
1022 { |
|
1023 TX_ENTRY |
|
1024 |
|
1025 connectExternalEvents(); |
|
1026 |
|
1027 HbAction *action; |
|
1028 HbSelectionDialog *dialog = new HbSelectionDialog(); |
|
1029 dialog->setHeadingWidget( new HbLabel( label ) ); |
|
1030 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
|
1031 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model ); |
|
1032 if ( mpModel ) { |
|
1033 //setLayout() only applies for MpCollectionDataModel where we need to |
|
1034 //decide which layout to use for the secondary text. |
|
1035 //MpCollectionTBoneListDataModel doesn't have secondary text. |
|
1036 mpModel->setLayout( ECollectionSelectionDialog ); |
|
1037 } |
|
1038 dialog->setModel( model ); |
|
1039 dialog->clearActions(); |
|
1040 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
|
1041 action->setObjectName( KOk ); |
|
1042 dialog->addAction( action ); |
|
1043 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
1044 action->setObjectName( KCancel ); |
|
1045 dialog->addAction( action ); |
|
1046 dialog->setObjectName( KGetModelIndexesListDialog ); |
|
1047 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1048 setOutstandingPopup( dialog ); |
|
1049 dialog->open( this, handler ); |
|
1050 |
|
1051 TX_EXIT |
|
1052 } |
|
1053 |
|
1054 /*! |
|
1055 \internal |
|
1056 Launches a list dialog to reorder them. |
|
1057 */ |
|
1058 void MpCollectionPopupHandler::launchArrangeSongsDialog() |
|
1059 { |
|
1060 TX_ENTRY |
|
1061 |
|
1062 HbListView *listView = new HbListView(); |
|
1063 listView->setItemRecycling( true ); |
|
1064 listView->setScrollingStyle( HbListView::PanOrFlick ); |
|
1065 listView->setClampingStyle( HbListView::BounceBackClamping ); |
|
1066 HbScrollBar *scrollbar = listView->verticalScrollBar(); |
|
1067 scrollbar->show(); |
|
1068 scrollbar->setInteractive( true); |
|
1069 listView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
|
1070 MpCollectionDataModel *model; |
|
1071 //Ownership of the model is passed to the listView as a child object. |
|
1072 model = new MpCollectionDataModel( mMpEngine->collectionData() , mMpEngine->playbackData(), listView ); |
|
1073 model->refreshModel(); |
|
1074 connect( model, |
|
1075 SIGNAL( orderChanged( int, int, int, int ) ), |
|
1076 mMpEngine, |
|
1077 SLOT( reorderPlaylist( int, int, int, int ) ) ); |
|
1078 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model ); |
|
1079 if ( mpModel ) { |
|
1080 //setLayout() only applies for MpCollectionDataModel where we need to |
|
1081 //decide which layout to use for the secondary text. |
|
1082 //MpCollectionTBoneListDataModel doesn't have secondary text. |
|
1083 mpModel->setLayout( ECollectionArrangeSongsDialog ); |
|
1084 } |
|
1085 listView->setModel( model ); |
|
1086 listView->setArrangeMode( true ); |
|
1087 HbDialog *dialog = new HbDialog(); |
|
1088 dialog->setDismissPolicy( HbPopup::NoDismiss ); |
|
1089 dialog->setTimeout( HbPopup::NoTimeout ); |
|
1090 |
|
1091 HbLabel *label = new HbLabel( hbTrId( "txt_mus_title_arrange" ) ); |
|
1092 dialog->setHeadingWidget( label ); |
|
1093 dialog->setContentWidget( listView ); |
|
1094 dialog->clearActions(); |
|
1095 HbAction *action; |
|
1096 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
|
1097 dialog->addAction( action ); |
|
1098 dialog->setObjectName( KArrangeSongsDialog ); |
|
1099 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1100 setOutstandingPopup(dialog); |
|
1101 dialog->open( this, SLOT( handleArrangeSongs( HbAction* ) ) ); |
|
1102 |
|
1103 TX_EXIT |
|
1104 } |
|
1105 |
|
1106 /*! |
|
1107 \internal |
|
1108 Request a delete operation always it has been confirmed. |
|
1109 \a selection Items selected to be deleted. |
|
1110 */ |
|
1111 void MpCollectionPopupHandler::requestDelete( QList<int> &selection ) |
|
1112 { |
939 { |
1113 TX_ENTRY |
940 TX_ENTRY |
1114 QString message; |
941 QString message; |
1115 mPermanentData->mSelectedItems = selection; |
|
1116 bool needsConfirmation = true; |
942 bool needsConfirmation = true; |
1117 connectExternalEvents(); |
943 connectExternalEvents(); |
1118 |
944 |
1119 switch ( mMpEngine->collectionData()->context() ) { |
945 switch ( mMpEngine->collectionData()->context() ) { |
1120 case ECollectionContextAllSongs: |
946 case ECollectionContextAllSongs: |
1169 TX_EXIT |
995 TX_EXIT |
1170 } |
996 } |
1171 |
997 |
1172 /*! |
998 /*! |
1173 \internal |
999 \internal |
|
1000 sets \a popup as the current outstanding popup and cancels any other previous popup. |
|
1001 */ |
|
1002 void MpCollectionPopupHandler::setOutstandingPopup( HbPopup *popup ) |
|
1003 { |
|
1004 TX_ENTRY |
|
1005 if ( mOutstandingPopup ) { |
|
1006 TX_LOG_ARGS( "Warning: Multiple popups attempted to be displayed" ); |
|
1007 mOutstandingPopup->close(); |
|
1008 } |
|
1009 |
|
1010 connect( popup, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) ); |
|
1011 mOutstandingPopup = popup; |
|
1012 TX_EXIT |
|
1013 } |
|
1014 |
|
1015 /*! |
|
1016 \internal |
|
1017 clears and disconnects \a popup. In some cases it's needed to open a new dialog when a current one has just finished. |
|
1018 */ |
|
1019 void MpCollectionPopupHandler::clearOutstandingPopup( HbPopup *popup ) |
|
1020 { |
|
1021 TX_ENTRY |
|
1022 disconnect( popup, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) ); |
|
1023 mOutstandingPopup = 0; |
|
1024 TX_EXIT |
|
1025 } |
|
1026 |
|
1027 /*! |
|
1028 \internal |
|
1029 Launches the 'Add to playlist' dialog. |
|
1030 */ |
|
1031 void MpCollectionPopupHandler::launchAddToPlaylistDialog( QList<int> &selection ) |
|
1032 { |
|
1033 TX_ENTRY |
|
1034 |
|
1035 QStringList playlists; |
|
1036 mPermanentData->mSelectedItems = selection; |
|
1037 mMpEngine->findPlaylists( playlists ); |
|
1038 if ( playlists.count() ) { |
|
1039 //There are saved playlists, query for a saved playlist or new. |
|
1040 HbAction *action; |
|
1041 HbSelectionDialog *dialog = new HbSelectionDialog(); |
|
1042 dialog->setStringItems( playlists ); |
|
1043 dialog->setSelectionMode( HbAbstractItemView::SingleSelection ); |
|
1044 dialog->setSelectedItems( QList< QVariant >()); |
|
1045 dialog->setHeadingWidget(new HbLabel( hbTrId( "txt_mus_title_select_playlist" ) ) ); |
|
1046 dialog->clearActions(); |
|
1047 action = new HbAction( hbTrId( "txt_mus_button_new" ) ); |
|
1048 action->setObjectName( KNew ); |
|
1049 dialog->addAction( action ); |
|
1050 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
1051 action->setObjectName( KCancel ); |
|
1052 dialog->addAction( action ); |
|
1053 dialog->setObjectName( KAddToPlaylistSelectionDialog ); |
|
1054 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1055 setOutstandingPopup( dialog ); |
|
1056 dialog->open( this, SLOT( handleAddToPlaylistDialogFinished( HbAction* ) ) ); |
|
1057 } |
|
1058 else { |
|
1059 //querying for a new playlist name. |
|
1060 queryNewPlaylistName( playlists, SLOT( handleAddToPlaylistGetTextFinished( HbAction* ) ) ); |
|
1061 } |
|
1062 TX_EXIT |
|
1063 } |
|
1064 |
|
1065 /*! |
|
1066 \internal |
|
1067 Trigger an imput text dialog with a suggested playlist name. |
|
1068 uses \a playlists to generate a suggested playlist name |
|
1069 \handler Slot that should be called when input dialog finished |
|
1070 */ |
|
1071 void MpCollectionPopupHandler::queryNewPlaylistName(const QStringList &playlists, |
|
1072 const char *handler ) |
|
1073 { |
|
1074 TX_ENTRY |
|
1075 int i = 0; |
|
1076 for ( ; |
|
1077 playlists.contains( hbTrId( "txt_mus_dialog_enter_name_entry_playlist_l1" ).arg( i ) ) ; |
|
1078 i++ ) {}; |
|
1079 QString suggestedPlaylistName = hbTrId( "txt_mus_dialog_enter_name_entry_playlist_l1" ).arg( i ); |
|
1080 getText( hbTrId( "txt_mus_dialog_enter_name" ), |
|
1081 suggestedPlaylistName, |
|
1082 hbTrId( "txt_mus_button_create_new" ), |
|
1083 handler ); |
|
1084 TX_EXIT |
|
1085 } |
|
1086 |
|
1087 /*! |
|
1088 \internal |
|
1089 Launches an input text dialog. |
|
1090 \a label Dialog title. |
|
1091 \a text Suggested text. |
|
1092 \a confirmationActionLabel label for the first action on the dialog. |
|
1093 \a handler Slot to be called when input dialog finishes. |
|
1094 */ |
|
1095 void MpCollectionPopupHandler::getText( const QString &label, |
|
1096 const QString &text, |
|
1097 const QString &confirmationActionLabel, |
|
1098 const char *handler ) |
|
1099 { |
|
1100 TX_ENTRY |
|
1101 HbAction *action; |
|
1102 HbInputDialog *dialog = new HbInputDialog(); |
|
1103 dialog->setPromptText( label ); |
|
1104 dialog->setInputMode( HbInputDialog::TextInput ); |
|
1105 dialog->setValue( text ); |
|
1106 dialog->clearActions(); |
|
1107 action = new HbAction( confirmationActionLabel ); |
|
1108 action->setObjectName( KOk ); |
|
1109 dialog->addAction( action ); |
|
1110 |
|
1111 //we want to prevent the user from slecting an empty string. |
|
1112 HbLineEdit * lineEdit; |
|
1113 lineEdit = dialog->lineEdit(); |
|
1114 connect (lineEdit , SIGNAL(textChanged(QString)), SLOT(inputDialogChanged(QString)) ); |
|
1115 action->setEnabled( !lineEdit->text().isEmpty() ); |
|
1116 |
|
1117 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
1118 action->setObjectName( KCancel ); |
|
1119 dialog->addAction( action ); |
|
1120 dialog->setObjectName( KInputTextDialog ); |
|
1121 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1122 setOutstandingPopup( dialog ); |
|
1123 dialog->open( this, handler ); |
|
1124 TX_EXIT |
|
1125 } |
|
1126 |
|
1127 /*! |
|
1128 \internal |
|
1129 Launches a list dialog to select items. |
|
1130 \a label Dialog title. |
|
1131 \a confirmationActionLabel label for the first action on the dialog. |
|
1132 \a model List model. |
|
1133 \a handler Slot to be called when list dialog finishes. |
|
1134 */ |
|
1135 void MpCollectionPopupHandler::getModelIndexes( const QString &label, |
|
1136 const QString &confirmationActionLabel, |
|
1137 QAbstractItemModel* model, |
|
1138 const char *handler) |
|
1139 { |
|
1140 TX_ENTRY |
|
1141 |
|
1142 connectExternalEvents(); |
|
1143 |
|
1144 HbAction *action; |
|
1145 HbSelectionDialog *dialog = new HbSelectionDialog(); |
|
1146 dialog->setHeadingWidget( new HbLabel( label ) ); |
|
1147 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
|
1148 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model ); |
|
1149 if ( mpModel ) { |
|
1150 //setLayout() only applies for MpCollectionDataModel where we need to |
|
1151 //decide which layout to use for the secondary text. |
|
1152 //MpCollectionTBoneListDataModel doesn't have secondary text. |
|
1153 mpModel->setLayout( ECollectionSelectionDialog ); |
|
1154 } |
|
1155 dialog->setModel( model ); |
|
1156 dialog->clearActions(); |
|
1157 action = new HbAction( confirmationActionLabel ); |
|
1158 action->setObjectName( KOk ); |
|
1159 dialog->addAction( action ); |
|
1160 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
|
1161 action->setObjectName( KCancel ); |
|
1162 dialog->addAction( action ); |
|
1163 dialog->setObjectName( KGetModelIndexesListDialog ); |
|
1164 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1165 setOutstandingPopup( dialog ); |
|
1166 dialog->open( this, handler ); |
|
1167 |
|
1168 TX_EXIT |
|
1169 } |
|
1170 |
|
1171 /*! |
|
1172 \internal |
|
1173 Launches a list dialog to reorder them. |
|
1174 */ |
|
1175 void MpCollectionPopupHandler::launchArrangeSongsDialog() |
|
1176 { |
|
1177 TX_ENTRY |
|
1178 |
|
1179 HbListView *listView = new HbListView(); |
|
1180 listView->setItemRecycling( true ); |
|
1181 listView->setScrollingStyle( HbListView::PanOrFlick ); |
|
1182 listView->setClampingStyle( HbListView::BounceBackClamping ); |
|
1183 HbScrollBar *scrollbar = listView->verticalScrollBar(); |
|
1184 scrollbar->show(); |
|
1185 scrollbar->setInteractive( true); |
|
1186 listView->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded); |
|
1187 MpCollectionDataModel *model; |
|
1188 //Ownership of the model is passed to the listView as a child object. |
|
1189 model = new MpCollectionDataModel( mMpEngine->collectionData() , mMpEngine->playbackData(), listView ); |
|
1190 model->refreshModel(); |
|
1191 connect( model, |
|
1192 SIGNAL( orderChanged( int, int, int, int ) ), |
|
1193 mMpEngine, |
|
1194 SLOT( reorderPlaylist( int, int, int, int ) ) ); |
|
1195 MpCollectionDataModel *mpModel = qobject_cast<MpCollectionDataModel *>( model ); |
|
1196 if ( mpModel ) { |
|
1197 //setLayout() only applies for MpCollectionDataModel where we need to |
|
1198 //decide which layout to use for the secondary text. |
|
1199 //MpCollectionTBoneListDataModel doesn't have secondary text. |
|
1200 mpModel->setLayout( ECollectionArrangeSongsDialog ); |
|
1201 } |
|
1202 listView->setModel( model ); |
|
1203 listView->setArrangeMode( true ); |
|
1204 HbDialog *dialog = new HbDialog(); |
|
1205 dialog->setDismissPolicy( HbPopup::NoDismiss ); |
|
1206 dialog->setTimeout( HbPopup::NoTimeout ); |
|
1207 |
|
1208 HbLabel *label = new HbLabel( hbTrId( "txt_mus_title_arrange" ) ); |
|
1209 dialog->setHeadingWidget( label ); |
|
1210 dialog->setContentWidget( listView ); |
|
1211 dialog->clearActions(); |
|
1212 HbAction *action; |
|
1213 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
|
1214 dialog->addAction( action ); |
|
1215 dialog->setObjectName( KArrangeSongsDialog ); |
|
1216 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
|
1217 setOutstandingPopup(dialog); |
|
1218 dialog->open( this, SLOT( handleArrangeSongs( HbAction* ) ) ); |
|
1219 |
|
1220 TX_EXIT |
|
1221 } |
|
1222 |
|
1223 /*! |
|
1224 \internal |
1174 Launches a waiting progress note. |
1225 Launches a waiting progress note. |
1175 \a content String id to display in the dialog. |
1226 \a content String id to display in the dialog. |
1176 */ |
1227 */ |
1177 void MpCollectionPopupHandler::launchProgressDialog( const char *id ) |
1228 void MpCollectionPopupHandler::launchProgressDialog( const char *id ) |
1178 { |
1229 { |