17 |
17 |
18 // INCLUDE FILES |
18 // INCLUDE FILES |
19 #include <hbaction.h> |
19 #include <hbaction.h> |
20 #include <hbmenu.h> |
20 #include <hbmenu.h> |
21 #include <hbmessagebox.h> |
21 #include <hbmessagebox.h> |
|
22 #include <hbprogressdialog.h> |
22 #include <hbselectiondialog.h> |
23 #include <hbselectiondialog.h> |
23 #include <hbinputdialog.h> |
24 #include <hbinputdialog.h> |
24 #include <hblabel.h> |
25 #include <hblabel.h> |
25 #include <hblistview.h> |
26 #include <hblistview.h> |
26 #include <hbscrollbar.h> |
27 #include <hbscrollbar.h> |
27 |
28 |
28 #include "mpengine.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 "mpmpxcollectionviewdefs.h" |
33 #include "mpcollectiontbonelistdatamodel.h" |
33 #include "mpcollectionpopuphandler.h" |
34 #include "mpcollectionpopuphandler.h" |
34 #include "mptrace.h" |
35 #include "mptrace.h" |
35 |
36 |
36 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 //------------------------------------------------------------------ |
37 |
137 |
38 /*! |
138 /*! |
39 \class MpCollectionPopupHandler |
139 \class MpCollectionPopupHandler |
40 \brief Music Player collection popup handler. |
140 \brief Music Player collection popup handler. |
41 |
141 |
73 Default view context menu. |
174 Default view context menu. |
74 */ |
175 */ |
75 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords ) |
176 void MpCollectionPopupHandler::openDefaultViewContextMenu( int index, const QPointF &coords ) |
76 { |
177 { |
77 TX_ENTRY |
178 TX_ENTRY |
78 HbMenu *contextMenu = 0; |
179 |
79 HbAction *action; |
180 if ( mView->isActivated() ) { |
80 bool usbBlocked = mMpEngine->verifyUsbBlocking(); |
181 |
81 |
182 HbMenu *contextMenu = 0; |
82 switch ( mMpEngine->collectionData()->context() ) { |
183 HbAction *action; |
83 case ECollectionContextAllSongs: |
184 bool usbBlocked = mMpEngine->verifyUsbBlocking(); |
84 case ECollectionContextArtistSongs: |
185 |
85 case ECollectionContextAlbumSongs: |
186 switch ( mMpEngine->collectionData()->context() ) { |
86 contextMenu = new HbMenu(); |
187 case ECollectionContextAllSongs: |
87 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
188 case ECollectionContextArtistAllSongs: |
88 action->setObjectName( "open" ); |
189 case ECollectionContextArtistAlbumsTBone: |
89 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
190 case ECollectionContextAlbumsTBone: |
90 action->setObjectName( "add" ); |
191 contextMenu = new HbMenu(); |
91 action->setEnabled( !usbBlocked ); |
192 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
92 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
193 action->setObjectName( KOpen ); |
93 action->setObjectName( "delete" ); |
194 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
94 action->setEnabled( !usbBlocked ); |
195 action->setObjectName( KAdd ); |
95 break; |
196 action->setEnabled( !usbBlocked ); |
96 case ECollectionContextAlbums: |
197 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
97 case ECollectionContextArtists: |
198 action->setObjectName( KDelete ); |
98 case ECollectionContextArtistAlbums: |
199 action->setEnabled( !usbBlocked ); |
99 contextMenu = new HbMenu(); |
200 break; |
100 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
201 case ECollectionContextAlbums: |
101 action->setObjectName( "open" ); |
202 case ECollectionContextArtists: |
102 action = contextMenu->addAction( hbTrId( "txt_mus_menu_add_to_playlist" ) ); |
203 case ECollectionContextArtistAlbums: |
103 action->setObjectName( "add" ); |
|
104 action->setEnabled( !usbBlocked ); |
|
105 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
|
106 action->setObjectName( "delete" ); |
|
107 action->setEnabled( !usbBlocked ); |
|
108 break; |
|
109 case ECollectionContextPlaylists: |
|
110 if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) { |
|
111 contextMenu = new HbMenu(); |
204 contextMenu = new HbMenu(); |
112 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
205 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
113 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 ); |
114 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
210 action = contextMenu->addAction( hbTrId( "txt_common_menu_delete" ) ); |
115 action->setObjectName("delete"); |
211 action->setObjectName( KDelete ); |
116 action->setEnabled( !usbBlocked ); |
212 action->setEnabled( !usbBlocked ); |
117 action = contextMenu->addAction( hbTrId( "txt_common_menu_rename_item" ) ); |
213 break; |
118 action->setObjectName( "rename playlist" ); |
214 case ECollectionContextPlaylists: |
119 action->setEnabled( !usbBlocked ); |
215 if ( !mMpEngine->collectionData()->isAutoPlaylist( index ) ) { |
120 } |
216 contextMenu = new HbMenu(); |
121 break; |
217 action = contextMenu->addAction( hbTrId( "txt_common_menu_open" ) ); |
122 case ECollectionContextPlaylistSongs: |
218 action->setObjectName( KOpen ); |
123 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: |
124 contextMenu = new HbMenu(); |
272 contextMenu = new HbMenu(); |
125 action = contextMenu->addAction( hbTrId( "txt_common_menu_play_music" ) ); |
273 action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") ); |
126 action->setObjectName( "open" ); |
274 action->setEnabled( !mMpEngine->verifyUsbBlocking() ); |
127 action = contextMenu->addAction( hbTrId( "txt_common_menu_remove" ) ); |
275 break; |
128 action->setObjectName( "delete" ); |
276 default: |
129 action->setEnabled( !usbBlocked ); |
277 break; |
130 } |
278 } |
131 break; |
279 |
132 default: |
280 if ( contextMenu ) { |
133 break; |
|
134 } |
|
135 |
|
136 if ( contextMenu ) { |
|
137 if ( mView->isActivated() ) { |
|
138 mPermanentData->mContextMenuIndex = index; |
281 mPermanentData->mContextMenuIndex = index; |
139 contextMenu->setPreferredPos( coords ); |
282 contextMenu->setPreferredPos( coords ); |
140 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
283 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
|
284 contextMenu->setObjectName( KContextMenu ); |
141 setOutstandingPopup( contextMenu ); |
285 setOutstandingPopup( contextMenu ); |
142 contextMenu->open( this, SLOT( defaultContextMenuOptionSelected( HbAction* ) ) ); |
286 contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) ); |
143 } |
|
144 else { |
|
145 delete contextMenu; |
|
146 contextMenu = 0; |
|
147 } |
|
148 } |
|
149 |
|
150 TX_EXIT |
|
151 } |
|
152 |
|
153 /*! |
|
154 Fetch view context menu |
|
155 */ |
|
156 void MpCollectionPopupHandler::openFetchViewContextMenu( int index, const QPointF &coords ) |
|
157 { |
|
158 TX_ENTRY_ARGS( "index=" << index ); |
|
159 |
|
160 HbAction *action; |
|
161 HbMenu *contextMenu = 0; |
|
162 |
|
163 switch ( mMpEngine->collectionData()->context() ) { |
|
164 case ECollectionContextAllSongs: |
|
165 case ECollectionContextArtistSongs: |
|
166 case ECollectionContextAlbumSongs: |
|
167 case ECollectionContextPlaylistSongs: |
|
168 case ECollectionContextGenreSongs: |
|
169 contextMenu = new HbMenu(); |
|
170 action = contextMenu->addAction( hbTrId("txt_common_menu_play_music") ); |
|
171 action->setEnabled( mMpEngine->verifyUsbBlocking() ); |
|
172 break; |
|
173 default: |
|
174 break; |
|
175 } |
|
176 |
|
177 if ( contextMenu ) { |
|
178 if ( mView->isActivated() ) { |
|
179 mPermanentData->mContextMenuIndex = index; |
|
180 contextMenu->setPreferredPos( coords ); |
|
181 contextMenu->setAttribute( Qt::WA_DeleteOnClose ); |
|
182 setOutstandingPopup( contextMenu ); |
|
183 contextMenu->open( this, SLOT( fetcherContextMenuOptionSelected( HbAction* ) ) ); |
|
184 } |
|
185 else { |
|
186 delete contextMenu; |
|
187 contextMenu = 0; |
|
188 } |
287 } |
189 } |
288 } |
190 |
289 |
191 TX_EXIT |
290 TX_EXIT |
192 } |
291 } |
273 } |
388 } |
274 |
389 |
275 /*! |
390 /*! |
276 Request to reorder songs |
391 Request to reorder songs |
277 */ |
392 */ |
278 void MpCollectionPopupHandler::openArrangeSongs( MpMpxCollectionData* collectionData ) |
393 void MpCollectionPopupHandler::openArrangeSongs( ) |
279 { |
394 { |
280 TX_ENTRY |
395 TX_ENTRY |
281 launchArrangeSongsDialog( collectionData ); |
396 launchArrangeSongsDialog(); |
282 TX_EXIT |
397 TX_EXIT |
283 } |
398 } |
284 |
399 |
285 /*! |
400 /*! |
286 Closes any active popup |
401 Closes any active popup |
287 */ |
402 */ |
288 void MpCollectionPopupHandler::cancelOngoingPopup() |
403 void MpCollectionPopupHandler::cancelOngoingPopup( bool onlyContextMenu ) |
289 { |
404 { |
290 TX_ENTRY |
405 TX_ENTRY |
291 if ( mOutstandingPopup ) { |
406 if ( mOutstandingPopup ) { |
292 mOutstandingPopup->close(); |
407 if ( onlyContextMenu ) { |
293 |
408 if ( mOutstandingPopup->objectName() == KContextMenu ) { |
294 //Delete/Clear permanent data until current popup gets deleted |
409 mOutstandingPopup->close(); |
295 mPermanentData->setParent( mOutstandingPopup ); |
410 mPermanentData->clear(); |
296 //Generate new permanent data for future popups |
411 } |
297 mPermanentData = new MpPopupHandlerPermanentData( this ); |
412 } |
|
413 else { |
|
414 mOutstandingPopup->close(); |
|
415 //Delete/Clear permanent data until current popup gets deleted |
|
416 mPermanentData->setParent( mOutstandingPopup ); |
|
417 //Generate new permanent data for future popups |
|
418 mPermanentData = new MpPopupHandlerPermanentData( this ); |
|
419 } |
298 } |
420 } |
299 else { |
421 else { |
300 mPermanentData->clear(); |
422 mPermanentData->clear(); |
301 } |
423 } |
302 |
424 TX_EXIT |
303 TX_EXIT |
|
304 } |
|
305 |
|
306 /*! |
|
307 TODO: Workaround for HbListView multiple events: longPress and activated. Remove once HbListView get fixed (wk16) |
|
308 */ |
|
309 bool MpCollectionPopupHandler::showingPopup() |
|
310 { |
|
311 return mOutstandingPopup; |
|
312 } |
425 } |
313 |
426 |
314 /*! |
427 /*! |
315 Slot to be called when an option has been selected from default context menu. |
428 Slot to be called when an option has been selected from default context menu. |
316 */ |
429 */ |
683 HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() ); |
799 HbMessageBox *dialog = qobject_cast<HbMessageBox *>( sender() ); |
684 clearOutstandingPopup( dialog ); |
800 clearOutstandingPopup( dialog ); |
685 |
801 |
686 if ( selectedAction ) { |
802 if ( selectedAction ) { |
687 QString objectName = selectedAction->objectName(); |
803 QString objectName = selectedAction->objectName(); |
688 if ( objectName == "ok" ) { |
804 if ( objectName == KOk ) { |
689 mMpEngine->deleteSongs( mPermanentData->mSelectedItems ); |
805 mMpEngine->deleteSongs( mPermanentData->mSelectedItems ); |
690 } |
806 } |
691 selectedAction->setEnabled( false ); |
807 selectedAction->setEnabled( false ); |
692 } |
808 } |
693 |
809 |
694 mPermanentData->clear(); |
810 mPermanentData->clear(); |
695 |
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 } |
696 TX_EXIT |
865 TX_EXIT |
697 } |
866 } |
698 |
867 |
699 /*! |
868 /*! |
700 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 |
808 */ |
974 */ |
809 void MpCollectionPopupHandler::getText( const QString &label, const QString &text, |
975 void MpCollectionPopupHandler::getText( const QString &label, const QString &text, |
810 const char *handler ) |
976 const char *handler ) |
811 { |
977 { |
812 TX_ENTRY |
978 TX_ENTRY |
813 if ( !mView->isActivated() ) { |
|
814 mPermanentData->clear(); |
|
815 return; |
|
816 } |
|
817 |
|
818 HbAction *action; |
979 HbAction *action; |
819 HbInputDialog *dialog = new HbInputDialog(); |
980 HbInputDialog *dialog = new HbInputDialog(); |
820 dialog->setPromptText( label ); |
981 dialog->setPromptText( label ); |
821 dialog->setInputMode( HbInputDialog::TextInput ); |
982 dialog->setInputMode( HbInputDialog::TextInput ); |
822 dialog->setValue( text ); |
983 dialog->setValue( text ); |
823 dialog->clearActions(); |
984 dialog->clearActions(); |
824 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
985 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
825 action->setObjectName( "ok" ); |
986 action->setObjectName( KOk ); |
826 dialog->addAction( action ); |
987 dialog->addAction( action ); |
827 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
988 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
828 action->setObjectName( "cancel" ); |
989 action->setObjectName( KCancel ); |
829 dialog->addAction( action ); |
990 dialog->addAction( action ); |
|
991 dialog->setObjectName( KInputTextDialog ); |
830 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
992 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
831 setOutstandingPopup( dialog ); |
993 setOutstandingPopup( dialog ); |
832 dialog->open( this, handler ); |
994 dialog->open( this, handler ); |
833 TX_EXIT |
995 TX_EXIT |
834 } |
996 } |
843 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model, |
1005 void MpCollectionPopupHandler::getModelIndexes( const QString &label, QAbstractItemModel* model, |
844 const char *handler) |
1006 const char *handler) |
845 { |
1007 { |
846 TX_ENTRY |
1008 TX_ENTRY |
847 |
1009 |
848 if ( !mView->isActivated() ) { |
1010 connectExternalEvents(); |
849 mPermanentData->clear(); |
|
850 return; |
|
851 } |
|
852 |
1011 |
853 HbAction *action; |
1012 HbAction *action; |
854 HbSelectionDialog *dialog = new HbSelectionDialog(); |
1013 HbSelectionDialog *dialog = new HbSelectionDialog(); |
855 dialog->setHeadingWidget( new HbLabel( label ) ); |
1014 dialog->setHeadingWidget( new HbLabel( label ) ); |
856 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
1015 dialog->setSelectionMode( HbAbstractItemView::MultiSelection ); |
857 dialog->setModel( model ); |
1016 dialog->setModel( model ); |
858 dialog->clearActions(); |
1017 dialog->clearActions(); |
859 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
1018 action = new HbAction( hbTrId( "txt_common_button_ok" ) ); |
860 action->setObjectName( "ok" ); |
1019 action->setObjectName( KOk ); |
861 dialog->addAction( action ); |
1020 dialog->addAction( action ); |
862 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
1021 action = new HbAction( hbTrId( "txt_common_button_cancel" ) ); |
863 action->setObjectName( "cancel" ); |
1022 action->setObjectName( KCancel ); |
864 dialog->addAction( action ); |
1023 dialog->addAction( action ); |
|
1024 dialog->setObjectName( KGetModelIndexesListDialog ); |
865 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
1025 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
866 setOutstandingPopup( dialog ); |
1026 setOutstandingPopup( dialog ); |
867 dialog->open( this, handler ); |
1027 dialog->open( this, handler ); |
868 |
1028 |
869 TX_EXIT |
1029 TX_EXIT |
870 } |
1030 } |
871 |
1031 |
872 /*! |
1032 /*! |
873 \internal |
1033 \internal |
874 Launches a list dialog to reorder them. |
1034 Launches a list dialog to reorder them. |
875 \a collectionData Base to generate dialog's model. |
1035 */ |
876 */ |
1036 void MpCollectionPopupHandler::launchArrangeSongsDialog() |
877 void MpCollectionPopupHandler::launchArrangeSongsDialog( MpMpxCollectionData* collectionData ) |
|
878 { |
1037 { |
879 TX_ENTRY |
1038 TX_ENTRY |
880 |
|
881 if ( !mView->isActivated() ) { |
|
882 return; |
|
883 } |
|
884 |
1039 |
885 HbListView *listView = new HbListView(); |
1040 HbListView *listView = new HbListView(); |
886 listView->setItemRecycling( true ); |
1041 listView->setItemRecycling( true ); |
887 listView->setScrollingStyle( HbListView::PanOrFlick ); |
1042 listView->setScrollingStyle( HbListView::PanOrFlick ); |
888 listView->setClampingStyle( HbListView::BounceBackClamping ); |
1043 listView->setClampingStyle( HbListView::BounceBackClamping ); |
961 TX_LOG_ARGS( "Invalid Collection Context" ); |
1117 TX_LOG_ARGS( "Invalid Collection Context" ); |
962 break; |
1118 break; |
963 } |
1119 } |
964 |
1120 |
965 if ( needsConfirmation ) { |
1121 if ( needsConfirmation ) { |
966 if ( !mView->isActivated() ) { |
|
967 mPermanentData->clear(); |
|
968 return; |
|
969 } |
|
970 |
|
971 HbAction *action; |
1122 HbAction *action; |
972 HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion ); |
1123 HbMessageBox *dialog = new HbMessageBox( HbMessageBox::MessageTypeQuestion ); |
973 |
1124 |
974 dialog->setText( message ); |
1125 dialog->setText( message ); |
975 dialog->setTimeout( HbPopup::NoTimeout ); |
1126 dialog->setTimeout( HbPopup::NoTimeout ); |
976 dialog->clearActions(); |
1127 dialog->clearActions(); |
977 action = new HbAction( hbTrId( "txt_common_button_yes" ) ); |
1128 action = new HbAction( hbTrId( "txt_common_button_yes" ) ); |
978 action->setObjectName( "ok" ); |
1129 action->setObjectName( KOk ); |
979 dialog->addAction( action ); |
1130 dialog->addAction( action ); |
980 action = new HbAction( hbTrId( "txt_common_button_no" ) ); |
1131 action = new HbAction( hbTrId( "txt_common_button_no" ) ); |
981 action->setObjectName( "cancel" ); |
1132 action->setObjectName( KCancel ); |
982 dialog->addAction( action ); |
1133 dialog->addAction( action ); |
|
1134 dialog->setObjectName( KRequestDeleteMessageBox ); |
983 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
1135 dialog->setAttribute( Qt::WA_DeleteOnClose ); |
984 setOutstandingPopup( dialog ); |
1136 setOutstandingPopup( dialog ); |
985 dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) ); |
1137 dialog->open( this, SLOT( handleRequestDelete( HbAction* ) ) ); |
986 } |
1138 } |
987 |
1139 |
988 TX_EXIT |
1140 TX_EXIT |
989 } |
1141 } |
990 |
1142 |
991 |
|
992 //------------------------------------------------------------------ |
|
993 // MpPopupHandlerPermanentData |
|
994 //------------------------------------------------------------------ |
|
995 /*! |
|
996 Constructs the popup handler permanent data. |
|
997 */ |
|
998 MpCollectionPopupHandler::MpPopupHandlerPermanentData::MpPopupHandlerPermanentData( QObject *parent ) |
|
999 : QObject( parent ), |
|
1000 mIsolatedCollectionData( 0 ), |
|
1001 mAbstractItemModel( 0 ), |
|
1002 mContextMenuIndex( KNullIndex ) |
|
1003 { |
|
1004 TX_ENTRY |
|
1005 mSelectedItems.clear(); |
|
1006 mOriginalName.clear(); |
|
1007 TX_EXIT |
|
1008 } |
|
1009 |
|
1010 /*! |
|
1011 Destructs the popup handler permanent data. |
|
1012 */ |
|
1013 MpCollectionPopupHandler::MpPopupHandlerPermanentData::~MpPopupHandlerPermanentData() |
|
1014 { |
|
1015 TX_ENTRY |
|
1016 clear(); |
|
1017 TX_EXIT |
|
1018 } |
|
1019 |
|
1020 /*! |
1143 /*! |
1021 \internal |
1144 \internal |
1022 Clears all permanent data. |
1145 Launches a waiting progress note. |
1023 */ |
1146 \a content String id to display in the dialog. |
1024 void MpCollectionPopupHandler::MpPopupHandlerPermanentData::clear() |
1147 */ |
1025 { |
1148 void MpCollectionPopupHandler::launchProgressDialog( const char *id ) |
1026 TX_ENTRY |
1149 { |
1027 mSelectedItems.clear(); |
1150 HbProgressDialog *deleteProgressNote = new HbProgressDialog( HbProgressDialog::WaitDialog ); |
1028 mOriginalName.clear(); |
1151 connect( deleteProgressNote, SIGNAL( cancelled() ), mMpEngine, SLOT( cancelCollectionRequest() ) ); |
1029 mContextMenuIndex = KNullIndex; |
1152 deleteProgressNote->setModal( true ); |
1030 if ( mIsolatedCollectionData ) { |
1153 deleteProgressNote->setDismissPolicy( HbPopup::NoDismiss ); |
1031 MpEngine::instance()->releaseIsolatedCollection(); |
1154 deleteProgressNote->setText( hbTrId( id ) ); |
1032 mIsolatedCollectionData = 0; |
1155 deleteProgressNote->setObjectName( KProgressDialog ); |
1033 } |
1156 deleteProgressNote->setAttribute( Qt::WA_DeleteOnClose ); |
1034 if ( mAbstractItemModel ) { |
1157 setOutstandingPopup( deleteProgressNote ); |
1035 delete mAbstractItemModel; |
1158 deleteProgressNote->show(); |
1036 mAbstractItemModel = 0; |
1159 } |
1037 } |
1160 |
1038 TX_EXIT |
1161 /*! |
1039 } |
1162 \internal |
|
1163 Connects MpEngine signals on demand in order to save time at start up. |
|
1164 */ |
|
1165 void MpCollectionPopupHandler::connectExternalEvents() |
|
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 |