28 #include "mpenginefactory.h" |
29 #include "mpenginefactory.h" |
29 #include "mpcollectionview.h" |
30 #include "mpcollectionview.h" |
30 #include "mpmpxcollectiondata.h" |
31 #include "mpmpxcollectiondata.h" |
31 #include "mpcollectiondatamodel.h" |
32 #include "mpcollectiondatamodel.h" |
32 #include "mpcollectiontbonelistdatamodel.h" |
33 #include "mpcollectiontbonelistdatamodel.h" |
33 #include "mpmpxcollectionviewdefs.h" |
|
34 #include "mpcollectionpopuphandler.h" |
34 #include "mpcollectionpopuphandler.h" |
35 #include "mptrace.h" |
35 #include "mptrace.h" |
36 |
36 |
37 const int KNullIndex = -1; |
37 const int KNullIndex = -1; |
|
38 const int KSongsToDisplayProgressDlg = 100; |
|
39 |
|
40 // Popups launched by this class |
|
41 const QString KContextMenu = QString( "ContextMenu" ); |
|
42 const QString KProgressDialog = QString( "ProgressDialog" ); |
|
43 const QString KAddToPlaylistSelectionDialog = QString( "AddToPlaylistSelectionDialog" ); |
|
44 const QString KInputTextDialog = QString( "InputTextDialog" ); |
|
45 const QString KGetModelIndexesListDialog = QString( "GetModelIndexesListDialog" ); |
|
46 const QString KArrangeSongsDialog = QString( "ArrangeSongsDialog" ); |
|
47 const QString KRequestDeleteMessageBox = QString( "RequestDeleteMessageBox" ); |
|
48 |
|
49 // Popups Actions |
|
50 const QString KOk = QString( "Ok" ); |
|
51 const QString KCancel = QString( "Cancel" ); |
|
52 const QString KNew = QString( "New" ); |
|
53 const QString KOpen = QString( "Open" ); |
|
54 const QString KAdd = QString( "Add" ); |
|
55 const QString KDelete = QString( "Delete" ); |
|
56 const QString KRenamePlayList = QString( "RenamePlayList" ); |
|
57 |
|
58 |
|
59 //------------------------------------------------------------------ |
|
60 // MpPopupHandlerPermanentData |
|
61 //------------------------------------------------------------------ |
|
62 |
|
63 /*! |
|
64 \class MpPopupHandlerPermanentData. This class is used by MpCollectionPopupHandler to |
|
65 store permanent data needed during asynchronous popups operation. |
|
66 |
|
67 */ |
|
68 |
|
69 class MpPopupHandlerPermanentData : public QObject |
|
70 { |
|
71 public: |
|
72 MpPopupHandlerPermanentData( QObject *parent=0 ); |
|
73 virtual ~MpPopupHandlerPermanentData(); |
|
74 void clear(); |
|
75 public: |
|
76 MpMpxCollectionData *mIsolatedCollectionData; // Not own |
|
77 QAbstractItemModel *mAbstractItemModel; // Own |
|
78 QList<int> mSelectedItems; |
|
79 QString mOriginalName; |
|
80 int mContextMenuIndex; |
|
81 }; |
|
82 |
|
83 /*! |
|
84 Constructs the popup handler permanent data. |
|
85 */ |
|
86 MpPopupHandlerPermanentData::MpPopupHandlerPermanentData( QObject *parent ) |
|
87 : QObject( parent ), |
|
88 mIsolatedCollectionData( 0 ), |
|
89 mAbstractItemModel( 0 ), |
|
90 mContextMenuIndex( KNullIndex ) |
|
91 { |
|
92 TX_ENTRY |
|
93 mSelectedItems.clear(); |
|
94 mOriginalName.clear(); |
|
95 TX_EXIT |
|
96 } |
|
97 |
|
98 /*! |
|
99 Destructs the popup handler permanent data. |
|
100 */ |
|
101 MpPopupHandlerPermanentData::~MpPopupHandlerPermanentData() |
|
102 { |
|
103 TX_ENTRY |
|
104 clear(); |
|
105 TX_EXIT |
|
106 } |
|
107 |
|
108 /*! |
|
109 \internal |
|
110 Clears all permanent data. |
|
111 */ |
|
112 void MpPopupHandlerPermanentData::clear() |
|
113 { |
|
114 TX_ENTRY |
|
115 mSelectedItems.clear(); |
|
116 mOriginalName.clear(); |
|
117 mContextMenuIndex = KNullIndex; |
|
118 if ( mIsolatedCollectionData ) { |
|
119 MpEngineFactory::sharedEngine()->releaseIsolatedCollection(); |
|
120 mIsolatedCollectionData = 0; |
|
121 } |
|
122 if ( mAbstractItemModel ) { |
|
123 delete mAbstractItemModel; |
|
124 mAbstractItemModel = 0; |
|
125 } |
|
126 //clearing any child Objects. |
|
127 foreach (QObject* child, children()) { |
|
128 child->deleteLater(); |
|
129 } |
|
130 TX_EXIT |
|
131 } |
|
132 |
|
133 |
|
134 //------------------------------------------------------------------ |
|
135 // MpCollectionPopupHandler |
|
136 //------------------------------------------------------------------ |
38 |
137 |
39 /*! |
138 /*! |
40 \class MpCollectionPopupHandler |
139 \class MpCollectionPopupHandler |
41 \brief Music Player collection popup handler. |
140 \brief Music Player collection popup handler. |
42 |
141 |
74 Default view context menu. |
174 Default view context menu. |
75 */ |
175 */ |
76 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords ) |
176 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords ) |
77 { |
177 { |
78 TX_ENTRY |
178 TX_ENTRY |
79 HbMenu *contextMenu = 0; |
179 |
80 HbAction *action; |
180 if ( mView->isActivated() ) { |
81 bool usbBlocked = mMpEngine->verifyUsbBlocking(); |
181 |
82 |
182 HbMenu *contextMenu = 0; |
83 switch ( mMpEngine->collectionData()->context() ) { |
183 HbAction *action; |
84 case ECollectionContextAllSongs: |
184 bool usbBlocked = mMpEngine->verifyUsbBlocking(); |
85 case ECollectionContextArtistAllSongs: |
185 |
86 case ECollectionContextArtistAlbumsTBone: |
186 switch ( mMpEngine->collectionData()->context() ) { |
87 case ECollectionContextAlbumsTBone: |
187 case ECollectionContextAllSongs: |
88 contextMenu = new HbMenu(); |
188 case ECollectionContextArtistAllSongs: |
89 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
189 case ECollectionContextArtistAlbumsTBone: |
90 action->setObjectName( "open" ); |
190 case ECollectionContextAlbumsTBone: |
91 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
191 contextMenu = new HbMenu(); |
92 action->setObjectName( "add" ); |
192 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
93 action->setEnabled( !usbBlocked ); |
193 action->setObjectName( KOpen ); |
94 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
194 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
95 action->setObjectName( "delete" ); |
195 action->setObjectName( KAdd ); |
96 action->setEnabled( !usbBlocked ); |
196 action->setEnabled( !usbBlocked ); |
97 break; |
197 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
98 case ECollectionContextAlbums: |
198 action->setObjectName( KDelete ); |
99 case ECollectionContextArtists: |
199 action->setEnabled( !usbBlocked ); |
100 case ECollectionContextArtistAlbums: |
200 break; |
101 contextMenu = new HbMenu(); |
201 case ECollectionContextAlbums: |
102 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
202 case ECollectionContextArtists: |
103 action->setObjectName( "open" ); |
203 case ECollectionContextArtistAlbums: |
104 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
|
105 action->setObjectName( "add" ); |
|
106 action->setEnabled( !usbBlocked ); |
|
107 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
|
108 action->setObjectName( "delete" ); |
|
109 action->setEnabled( !usbBlocked ); |
|
110 break; |
|
111 case ECollectionContextPlaylists: |
|
112 if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) { |
|
113 contextMenu = new HbMenu(); |
204 contextMenu = new HbMenu(); |
114 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
205 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
115 action->setObjectName( "open" ); |
206 action->setObjectName( KOpen ); |
|
207 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
|
208 action->setObjectName( KAdd ); |
|
209 action->setEnabled( !usbBlocked ); |
116 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
210 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
117 action->setObjectName("delete"); |
211 action->setObjectName( KDelete ); |
118 action->setEnabled( !usbBlocked ); |
212 action->setEnabled( !usbBlocked ); |
119 action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) ); |
213 break; |
120 action->setObjectName( "rename playlist" ); |
214 case ECollectionContextPlaylists: |
121 action->setEnabled( !usbBlocked ); |
215 if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) { |
122 } |
216 contextMenu = new HbMenu(); |
123 break; |
217 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
124 case ECollectionContextPlaylistSongs: |
218 action->setObjectName( KOpen ); |
125 if ( !mMpEngine->collectionData()->isAutoPlaylist() ) { |
219 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
|
220 action->setObjectName(KDelete); |
|
221 action->setEnabled( !usbBlocked ); |
|
222 action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) ); |
|
223 action->setObjectName( KRenamePlayList ); |
|
224 action->setEnabled( !usbBlocked ); |
|
225 } |
|
226 break; |
|
227 case ECollectionContextPlaylistSongs: |
|
228 if ( !mMpEngine->collectionData()->isAutoPlaylist() ) { |
|
229 contextMenu = new HbMenu(); |
|
230 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
|
231 action->setObjectName( KOpen ); |
|
232 action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) ); |
|
233 action->setObjectName( KDelete ); |
|
234 action->setEnabled( !usbBlocked ); |
|
235 } |
|
236 break; |
|
237 default: |
|
238 break; |
|
239 } |
|
240 |
|
241 if ( contextMenu ) { |
|
242 mPermanentData->mContextMenuIndex = index; |
|
243 contextMenu->setPreferredPos( coords ); |
|
244 contextMenu->setObjectName( KContextMenu ); |
|
245 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
|
246 setOutstandingPopup( contextMenu ); |
|
247 contextMenu->open( this, SLOT( defaultContextMenuOptionSelected( HbAction* ) ) ); |
|
248 } |
|
249 } |
|
250 |
|
251 TX_EXIT |
|
252 } |
|
253 |
|
254 /*! |
|
255 Fetch view context menu |
|
256 */ |
|
257 void MpCollectionPopupHandler::openFetchViewContextMenu( int index, const QPointF &coords ) |
|
258 { |
|
259 TX_ENTRY_ARGS( "index=" << index ); |
|
260 |
|
261 if ( mView->isActivated() ) { |
|
262 |
|
263 HbAction *action; |
|
264 HbMenu *contextMenu = 0; |
|
265 |
|
266 switch ( mMpEngine->collectionData()->context() ) { |
|
267 case ECollectionContextAllSongs: |
|
268 case ECollectionContextArtistAlbumsTBone: |
|
269 case ECollectionContextArtistAllSongs: |
|
270 case ECollectionContextAlbumsTBone: |
|
271 case ECollectionContextPlaylistSongs: |
126 contextMenu = new HbMenu(); |
272 contextMenu = new HbMenu(); |
127 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
273 action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") ); |
128 action->setObjectName( "open" ); |
274 action->setEnabled( !mMpEngine->verifyUsbBlocking() ); |
129 action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) ); |
275 break; |
130 action->setObjectName( "delete" ); |
276 default: |
131 action->setEnabled( !usbBlocked ); |
277 break; |
132 } |
278 } |
133 break; |
279 |
134 default: |
280 if ( contextMenu ) { |
135 break; |
|
136 } |
|
137 |
|
138 if ( contextMenu ) { |
|
139 if ( mView->isActivated() ) { |
|
140 mPermanentData->mContextMenuIndex = index; |
281 mPermanentData->mContextMenuIndex = index; |
141 contextMenu->setPreferredPos( coords ); |
282 contextMenu->setPreferredPos( coords ); |
142 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
283 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
|
284 contextMenu->setObjectName( KContextMenu ); |
143 setOutstandingPopup( contextMenu ); |
285 setOutstandingPopup( contextMenu ); |
144 contextMenu->open( this, SLOT( defaultContextMenuOptionSelected( HbAction* ) ) ); |
286 contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) ); |
145 } |
|
146 else { |
|
147 delete contextMenu; |
|
148 contextMenu = 0; |
|
149 } |
|
150 } |
|
151 |
|
152 TX_EXIT |
|
153 } |
|
154 |
|
155 /*! |
|
156 Fetch view context menu |
|
157 */ |
|
158 void MpCollectionPopupHandler::openFetchViewContextMenu( int index, const QPointF &coords ) |
|
159 { |
|
160 TX_ENTRY_ARGS( "index=" << index ); |
|
161 |
|
162 HbAction *action; |
|
163 HbMenu *contextMenu = 0; |
|
164 |
|
165 switch ( mMpEngine->collectionData()->context() ) { |
|
166 case ECollectionContextAllSongs: |
|
167 case ECollectionContextArtistAlbumsTBone: |
|
168 case ECollectionContextArtistAllSongs: |
|
169 case ECollectionContextAlbumsTBone: |
|
170 case ECollectionContextPlaylistSongs: |
|
171 contextMenu = new HbMenu(); |
|
172 action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") ); |
|
173 action->setEnabled( !mMpEngine->verifyUsbBlocking() ); |
|
174 break; |
|
175 default: |
|
176 break; |
|
177 } |
|
178 |
|
179 if ( contextMenu ) { |
|
180 if ( mView->isActivated() ) { |
|
181 mPermanentData->mContextMenuIndex = index; |
|
182 contextMenu->setPreferredPos( coords ); |
|
183 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
|
184 setOutstandingPopup( contextMenu ); |
|
185 contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) ); |
|
186 } |
|
187 else { |
|
188 delete contextMenu; |
|
189 contextMenu = 0; |
|
190 } |
287 } |
191 } |
288 } |
192 |
289 |
193 TX_EXIT |
290 TX_EXIT |
194 } |
291 } |
704 HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() ); |
799 HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() ); |
705 clearOutstandingPopup( dialog ); |
800 clearOutstandingPopup( dialog ); |
706 |
801 |
707 if ( selectedAction ) { |
802 if ( selectedAction ) { |
708 QString objectName = selectedAction->objectName(); |
803 QString objectName = selectedAction->objectName(); |
709 if ( objectName == "ok" ) { |
804 if ( objectName == KOk ) { |
710 mMpEngine->deleteSongs( mPermanentData->mSelectedItems ); |
805 mMpEngine->deleteSongs( mPermanentData->mSelectedItems ); |
711 } |
806 } |
712 selectedAction->setEnabled( false ); |
807 selectedAction->setEnabled( false ); |
713 } |
808 } |
714 |
809 |
715 mPermanentData->clear(); |
810 mPermanentData->clear(); |
716 |
811 |
|
812 TX_EXIT |
|
813 } |
|
814 |
|
815 /*! |
|
816 Slot called upon notification from MpEngine indicating start of |
|
817 deleting process. |
|
818 */ |
|
819 void MpCollectionPopupHandler::handleDeleteStarted( TCollectionContext context, int count ) |
|
820 { |
|
821 TX_ENTRY |
|
822 if ( context == ECollectionContextPlaylistSongs ) { |
|
823 if (count >= KSongsToDisplayProgressDlg) { //show progress dialog if removing more than 100 songs |
|
824 launchProgressDialog( "txt_mus_info_removing_songs" ); |
|
825 } |
|
826 } |
|
827 else if (context != ECollectionContextPlaylists ) { //no progress dialog for delete playlist |
|
828 launchProgressDialog( "txt_mus_info_deleting" ); |
|
829 } |
|
830 TX_EXIT |
|
831 } |
|
832 |
|
833 /*! |
|
834 Slot called upon notification from MpEngine indicating 'count' songs are going to be added. |
|
835 */ |
|
836 void MpCollectionPopupHandler::handleAddingSongs( int count ) |
|
837 { |
|
838 TX_ENTRY |
|
839 if ( count >= KSongsToDisplayProgressDlg ) |
|
840 { |
|
841 HbProgressDialog *addSongsWaitNote = new HbProgressDialog( HbProgressDialog::WaitDialog ); |
|
842 connect( addSongsWaitNote, SIGNAL( cancelled() ), mMpEngine, SLOT( cancelCollectionRequest() ) ); |
|
843 addSongsWaitNote->setModal( true ); |
|
844 addSongsWaitNote->setText( hbTrId( "txt_mus_info_adding_songs" ) ); |
|
845 addSongsWaitNote->setObjectName( KProgressDialog ); |
|
846 addSongsWaitNote->setAttribute( Qt::WA_DeleteOnClose ); |
|
847 setOutstandingPopup( addSongsWaitNote ); |
|
848 addSongsWaitNote->show(); |
|
849 } |
|
850 TX_EXIT |
|
851 } |
|
852 |
|
853 /*! |
|
854 Slot called upon notification from MpEngine indicating end of |
|
855 deleting or adding process. |
|
856 */ |
|
857 void MpCollectionPopupHandler::handleOperationEnded( bool success ) |
|
858 { |
|
859 TX_ENTRY |
|
860 Q_UNUSED( success ); |
|
861 if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KProgressDialog ) ) { |
|
862 HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup ); |
|
863 dialog->cancel(); |
|
864 } |
717 TX_EXIT |
865 TX_EXIT |
718 } |
866 } |
719 |
867 |
720 /*! |
868 /*! |
721 Slot to be called when a popup is getting closed. Usefull when a dialog is closed before it finishes |
869 Slot to be called when a popup is getting closed. Usefull when a dialog is closed before it finishes |
829 */ |
974 */ |
830 void MpCollectionPopupHandler::getText( const QString &label, const QString &text, |
975 void MpCollectionPopupHandler::getText( const QString &label, const QString &text, |
831 const char *handler ) |
976 const char *handler ) |
832 { |
977 { |
833 TX_ENTRY |
978 TX_ENTRY |
834 if ( !mView->isActivated() ) { |
|
835 mPermanentData->clear(); |
|
836 return; |
|
837 } |
|
838 |
|
839 HbAction *action; |
979 HbAction *action; |
840 HbInputDialog *dialog = new HbInputDialog(); |
980 HbInputDialog *dialog = new HbInputDialog(); |
841 dialog->setPromptText( label ); |
981 dialog->setPromptText( label ); |
842 dialog->setInputMode( HbInputDialog::TextInput ); |
982 dialog->setInputMode( HbInputDialog::TextInput ); |
843 dialog->setValue( text ); |
983 dialog->setValue( text ); |
844 dialog->clearActions(); |
984 dialog->clearActions(); |
845 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
985 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
846 action->setObjectName( "ok" ); |
986 action->setObjectName( KOk ); |
847 dialog->addAction( action ); |
987 dialog->addAction( action ); |
848 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
988 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
849 action->setObjectName( "cancel" ); |
989 action->setObjectName( KCancel ); |
850 dialog->addAction( action ); |
990 dialog->addAction( action ); |
|
991 dialog->setObjectName( KInputTextDialog ); |
851 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
992 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
852 setOutstandingPopup( dialog ); |
993 setOutstandingPopup( dialog ); |
853 dialog->open( this, handler ); |
994 dialog->open( this, handler ); |
854 TX_EXIT |
995 TX_EXIT |
855 } |
996 } |
864 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model, |
1005 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model, |
865 const char *handler) |
1006 const char *handler) |
866 { |
1007 { |
867 TX_ENTRY |
1008 TX_ENTRY |
868 |
1009 |
869 if ( !mView->isActivated() ) { |
1010 connectExternalEvents(); |
870 mPermanentData->clear(); |
|
871 return; |
|
872 } |
|
873 |
1011 |
874 HbAction *action; |
1012 HbAction *action; |
875 HbSelectionDialog *dialog = new HbSelectionDialog(); |
1013 HbSelectionDialog *dialog = new HbSelectionDialog(); |
876 dialog->setHeadingWidget( new HbLabel( label ) ); |
1014 dialog->setHeadingWidget( new HbLabel( label ) ); |
877 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
1015 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
878 dialog->setModel( model ); |
1016 dialog->setModel( model ); |
879 dialog->clearActions(); |
1017 dialog->clearActions(); |
880 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
1018 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
881 action->setObjectName( "ok" ); |
1019 action->setObjectName( KOk ); |
882 dialog->addAction( action ); |
1020 dialog->addAction( action ); |
883 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
1021 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
884 action->setObjectName( "cancel" ); |
1022 action->setObjectName( KCancel ); |
885 dialog->addAction( action ); |
1023 dialog->addAction( action ); |
|
1024 dialog->setObjectName( KGetModelIndexesListDialog ); |
886 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
1025 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
887 setOutstandingPopup( dialog ); |
1026 setOutstandingPopup( dialog ); |
888 dialog->open( this, handler ); |
1027 dialog->open( this, handler ); |
889 |
1028 |
890 TX_EXIT |
1029 TX_EXIT |
980 TX_LOG_ARGS( "Invalid Collection Context" ); |
1117 TX_LOG_ARGS( "Invalid Collection Context" ); |
981 break; |
1118 break; |
982 } |
1119 } |
983 |
1120 |
984 if ( needsConfirmation ) { |
1121 if ( needsConfirmation ) { |
985 if ( !mView->isActivated() ) { |
|
986 mPermanentData->clear(); |
|
987 return; |
|
988 } |
|
989 |
|
990 HbAction *action; |
1122 HbAction *action; |
991 HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion ); |
1123 HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion ); |
992 |
1124 |
993 dialog->setText( message ); |
1125 dialog->setText( message ); |
994 dialog->setTimeout( HbPopup::NoTimeout ); |
1126 dialog->setTimeout( HbPopup::NoTimeout ); |
995 dialog->clearActions(); |
1127 dialog->clearActions(); |
996 action = new HbAction( hbTrId( "txt_common_button_yes" ) ); |
1128 action = new HbAction( hbTrId( "txt_common_button_yes" ) ); |
997 action->setObjectName( "ok" ); |
1129 action->setObjectName( KOk ); |
998 dialog->addAction( action ); |
1130 dialog->addAction( action ); |
999 action = new HbAction( hbTrId( "txt_common_button_no" ) ); |
1131 action = new HbAction( hbTrId( "txt_common_button_no" ) ); |
1000 action->setObjectName( "cancel" ); |
1132 action->setObjectName( KCancel ); |
1001 dialog->addAction( action ); |
1133 dialog->addAction( action ); |
|
1134 dialog->setObjectName( KRequestDeleteMessageBox ); |
1002 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
1135 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
1003 setOutstandingPopup( dialog ); |
1136 setOutstandingPopup( dialog ); |
1004 dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) ); |
1137 dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) ); |
1005 } |
1138 } |
1006 |
1139 |
1007 TX_EXIT |
1140 TX_EXIT |
1008 } |
1141 } |
1009 |
1142 |
1010 |
|
1011 //------------------------------------------------------------------ |
|
1012 // MpPopupHandlerPermanentData |
|
1013 //------------------------------------------------------------------ |
|
1014 /*! |
|
1015 Constructs the popup handler permanent data. |
|
1016 */ |
|
1017 MpCollectionPopupHandler::MpPopupHandlerPermanentData::MpPopupHandlerPermanentData( QObject *parent ) |
|
1018 : QObject( parent ), |
|
1019 mIsolatedCollectionData( 0 ), |
|
1020 mAbstractItemModel( 0 ), |
|
1021 mContextMenuIndex( KNullIndex ) |
|
1022 { |
|
1023 TX_ENTRY |
|
1024 mSelectedItems.clear(); |
|
1025 mOriginalName.clear(); |
|
1026 TX_EXIT |
|
1027 } |
|
1028 |
|
1029 /*! |
|
1030 Destructs the popup handler permanent data. |
|
1031 */ |
|
1032 MpCollectionPopupHandler::MpPopupHandlerPermanentData::~MpPopupHandlerPermanentData() |
|
1033 { |
|
1034 TX_ENTRY |
|
1035 clear(); |
|
1036 TX_EXIT |
|
1037 } |
|
1038 |
|
1039 /*! |
1143 /*! |
1040 \internal |
1144 \internal |
1041 Clears all permanent data. |
1145 Launches a waiting progress note. |
1042 */ |
1146 \a content String id to display in the dialog. |
1043 void MpCollectionPopupHandler::MpPopupHandlerPermanentData::clear() |
1147 */ |
1044 { |
1148 void MpCollectionPopupHandler::launchProgressDialog( const char *id ) |
1045 TX_ENTRY |
1149 { |
1046 mSelectedItems.clear(); |
1150 HbProgressDialog *deleteProgressNote = new HbProgressDialog( HbProgressDialog::WaitDialog ); |
1047 mOriginalName.clear(); |
1151 connect( deleteProgressNote, SIGNAL( cancelled() ), mMpEngine, SLOT( cancelCollectionRequest() ) ); |
1048 mContextMenuIndex = KNullIndex; |
1152 deleteProgressNote->setModal( true ); |
1049 if ( mIsolatedCollectionData ) { |
1153 deleteProgressNote->setDismissPolicy( HbPopup::NoDismiss ); |
1050 MpEngineFactory::sharedEngine()->releaseIsolatedCollection(); |
1154 deleteProgressNote->setText( hbTrId( id ) ); |
1051 mIsolatedCollectionData = 0; |
1155 deleteProgressNote->setObjectName( KProgressDialog ); |
1052 } |
1156 deleteProgressNote->setAttribute( Qt::WA_DeleteOnClose ); |
1053 if ( mAbstractItemModel ) { |
1157 setOutstandingPopup( deleteProgressNote ); |
1054 delete mAbstractItemModel; |
1158 deleteProgressNote->show(); |
1055 mAbstractItemModel = 0; |
1159 } |
1056 } |
1160 |
1057 //clearing any child Objects. |
1161 /*! |
1058 foreach (QObject* child, children()) { |
1162 \internal |
1059 child->deleteLater(); |
1163 Connects MpEngine signals on demand in order to save time at start up. |
1060 } |
1164 */ |
1061 TX_EXIT |
1165 void MpCollectionPopupHandler::connectExternalEvents() |
1062 } |
1166 { |
|
1167 if ( !mExternalEventsConnected ) { |
|
1168 connect( mMpEngine, SIGNAL( deleteStarted( TCollectionContext, int ) ), |
|
1169 this, SLOT( handleDeleteStarted( TCollectionContext, int ) ) ); |
|
1170 connect( mMpEngine, SIGNAL( songsDeleted( bool ) ), this, SLOT( handleOperationEnded( bool ) ) ); |
|
1171 connect( mMpEngine, SIGNAL( aboutToAddSongs( int ) ), this, SLOT( handleAddingSongs( int ) ) ); |
|
1172 connect( mMpEngine, SIGNAL( playlistSaved( bool ) ), this, SLOT( handleOperationEnded( bool ) ) ); |
|
1173 mExternalEventsConnected = true; |
|
1174 } |
|
1175 } |
|
1176 |