13 * |
13 * |
14 * Description: Handles deletion |
14 * Description: Handles deletion |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // System includes |
18 |
19 #include <QString> |
19 // INCLUDES |
20 #include <QtGui> |
20 #include <Calendar.rsg> |
21 #include <hbdatetimepicker.h> |
21 #include <calendateutils.h> |
22 #include <hbdialog.h> |
22 #include <calenagendautils.h> |
23 #include <hbmessagebox.h> |
23 #include <aknnotewrappers.h> |
24 #include <hbaction.h> |
24 #include <AknWaitDialog.h> |
25 #include <hblabel.h> |
25 #include <calcommon.h> |
26 #include <hbradiobuttonlist.h> |
26 #include <calentryview.h> |
|
27 #include <calinstance.h> |
|
28 #include <calinstanceview.h> |
|
29 #include <caltime.h> |
27 #include <centralrepository.h> |
30 #include <centralrepository.h> |
28 #include <agendaentry.h> |
31 #include <eikenv.h> |
29 |
32 #include <StringLoader.h> |
30 // User includes |
33 #include <sysutil.h> |
31 #include "calendarui_debug.h" |
34 #include <calenglobaldata.h> |
|
35 #include <calrrule.h> |
|
36 #include <calsession.h> |
|
37 #include <calencommands.hrh> // Calendar commands |
|
38 #include <calencontext.h> |
|
39 #include <caleninstanceid.h> // TCalenInstanceId |
|
40 #include <calenactionuiutils.h> |
|
41 #include <calcalendarinfo.h> |
|
42 #include <calentoolbar.h> |
|
43 #include <akntoolbar.h> |
|
44 #include <calenattachmentmodel.h> |
|
45 |
|
46 #include "calendarui_debug.h" // Debug |
32 #include "calendeleteui.h" |
47 #include "calendeleteui.h" |
33 #include "calencontext.h" |
|
34 #include "calencontroller.h" |
48 #include "calencontroller.h" |
35 #include "CleanupResetAndDestroy.h" |
49 #include "CleanupResetAndDestroy.h" |
36 #include "caleninstanceid.h" |
50 #include "CalenInterimUtils2.h" |
37 #include "calenactionuiutils.h" |
51 #include "CalendarPrivateCRKeys.h" // For CalendarInternalCRKeys.h |
38 #include "calendateutils.h" |
52 #include "calenmultipledbmanager.h" |
39 #include "calenagendautils.h" |
|
40 #include "OstTraceDefinitions.h" |
|
41 #ifdef OST_TRACE_COMPILER_IN_USE |
|
42 #include "calendeleteuiTraces.h" |
|
43 #endif |
|
44 |
|
45 |
53 |
46 // Local constants |
54 // Local constants |
47 const TInt KEntriesToDelete = 1; |
55 const TInt KEntriesToDelete = 1; |
48 |
56 |
49 // ---------------------------------------------------------------------------- |
57 // ---------------------------------------------------------------------------- |
50 // CalenDeleteUi::NewL |
58 // CCalenDeleteUi::NewL |
51 // Two phased constructor |
59 // Two phased constructor |
52 // (other items were commented in a header). |
60 // (other items were commented in a header). |
53 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
54 // |
62 // |
55 CalenDeleteUi* CalenDeleteUi::NewL( CCalenController& aController ) |
63 CCalenDeleteUi* CCalenDeleteUi::NewL( CCalenController& aController ) |
56 { |
64 { |
57 OstTraceFunctionEntry0( CALENDELETEUI_NEWL_ENTRY ); |
65 TRACE_ENTRY_POINT; |
58 |
66 |
59 CalenDeleteUi* self = new( ELeave ) CalenDeleteUi( aController, NULL ); |
67 CCalenDeleteUi* self = new( ELeave ) CCalenDeleteUi( aController ); |
60 CleanupStack::PushL( self ); |
68 CleanupStack::PushL( self ); |
61 self->ConstructL(); |
69 self->ConstructL(); |
62 CleanupStack::Pop( self ); |
70 CleanupStack::Pop( self ); |
63 |
71 |
64 OstTraceFunctionExit0( CALENDELETEUI_NEWL_EXIT ); |
72 TRACE_EXIT_POINT; |
65 return self; |
73 return self; |
66 } |
74 } |
67 |
75 |
68 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
69 // CalenDeleteUi::CalenDeleteUi |
77 // CCalenDeleteUi::CCalenDeleteUi |
70 // ?implementation_description |
78 // ?implementation_description |
71 // (other items were commented in a header). |
79 // (other items were commented in a header). |
72 // ---------------------------------------------------------------------------- |
80 // ---------------------------------------------------------------------------- |
73 // |
81 // |
74 CalenDeleteUi::CalenDeleteUi( CCalenController& aController, QObject *parent ) |
82 CCalenDeleteUi::CCalenDeleteUi( CCalenController& aController ) |
75 :QObject(parent), iController( aController ) |
83 : iEikEnv( CEikonEnv::Static() ), iController( aController ) |
76 { |
84 { |
77 OstTraceFunctionEntry0( CALENDELETEUI_CALENDELETEUI_ENTRY ); |
85 TRACE_ENTRY_POINT; |
78 |
86 TRACE_EXIT_POINT; |
79 iIsDeleting = false; |
87 } |
80 |
88 |
81 OstTraceFunctionExit0( CALENDELETEUI_CALENDELETEUI_EXIT ); |
89 // ---------------------------------------------------------------------------- |
82 } |
90 // CCalenDeleteUi::~CCalenDeleteUi |
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // CalenDeleteUi::~CalenDeleteUi |
|
86 // Destructor |
91 // Destructor |
87 // (other items were commented in a header). |
92 // (other items were commented in a header). |
88 // ---------------------------------------------------------------------------- |
93 // ---------------------------------------------------------------------------- |
89 // |
94 // |
90 CalenDeleteUi::~CalenDeleteUi() |
95 CCalenDeleteUi::~CCalenDeleteUi() |
91 { |
96 { |
92 OstTraceFunctionEntry0( DUP1_CALENDELETEUI_CALENDELETEUI_ENTRY ); |
97 TRACE_ENTRY_POINT; |
93 |
98 |
94 OstTraceFunctionExit0( DUP1_CALENDELETEUI_CALENDELETEUI_EXIT ); |
99 if( iWaitDialog ) |
95 } |
100 { |
96 |
101 delete iWaitDialog; |
97 // ---------------------------------------------------------------------------- |
102 iWaitDialog = NULL; |
98 // CalenDeleteUi::ConstructL |
103 } |
|
104 |
|
105 if( iGlobalData ) |
|
106 { |
|
107 iGlobalData->Release(); |
|
108 } |
|
109 |
|
110 if( iDelAllRange ) |
|
111 delete iDelAllRange; |
|
112 |
|
113 iDeleteColIds.Reset(); |
|
114 |
|
115 TRACE_EXIT_POINT; |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------------------------- |
|
119 // CCalenDeleteUi::ConstructL |
99 // Second phase of construction |
120 // Second phase of construction |
100 // (other items were commented in a header). |
121 // (other items were commented in a header). |
101 // ---------------------------------------------------------------------------- |
122 // ---------------------------------------------------------------------------- |
102 // |
123 // |
103 void CalenDeleteUi::ConstructL() |
124 void CCalenDeleteUi::ConstructL() |
104 { |
125 { |
105 OstTraceFunctionEntry0( CALENDELETEUI_CONSTRUCTL_ENTRY ); |
126 TRACE_ENTRY_POINT; |
106 |
127 |
107 RArray<TCalenNotification> notifications; |
128 iGlobalData = CCalenGlobalData::InstanceL(); |
108 notifications.Append(ECalenNotifyCancelDelete); |
129 |
109 notifications.Append(ECalenNotifyCloseDialogs); |
130 // Both the entry view and instance views are needed |
110 notifications.Append(ECalenNotifySystemLocaleChanged); |
131 // by the deleteUi commands, there queue the construction of both |
111 |
132 RArray<TInt> colArray; |
112 iController.RegisterForNotificationsL( this, notifications ); |
133 iController.GetActiveCollectionidsL(colArray); |
113 |
134 |
114 notifications.Close(); |
135 CCalInstanceView* instanceView = iGlobalData->InstanceViewL(colArray); |
115 |
136 colArray.Reset(); |
|
137 if( !instanceView ) |
|
138 { |
|
139 iController.RegisterForNotificationsL( this, ECalenNotifyEntryInstanceViewCreated ); |
|
140 } |
|
141 iController.RegisterForNotificationsL( this, ECalenNotifyCancelDelete ); |
116 iMoreEntriesToDelete = EFalse; |
142 iMoreEntriesToDelete = EFalse; |
117 iDisplayQuery = EFalse; |
143 iDisplayQuery = EFalse; |
118 iEntriesToDelete = KEntriesToDelete; |
144 iEntriesToDelete = KEntriesToDelete; |
119 mDatePicker = 0; |
145 iDelAllRange = NULL; |
120 |
146 TRACE_EXIT_POINT; |
121 OstTraceFunctionExit0( CALENDELETEUI_CONSTRUCTL_EXIT ); |
147 } |
122 } |
148 |
123 |
149 // ---------------------------------------------------------------------------- |
124 // ---------------------------------------------------------------------------- |
150 // CCalenDeleteUi::HandleECalenNotifyViewCreatedL |
125 // CalenDeleteUi::HandleNotification |
151 // Handles ECalenNotifyViewCreated. |
|
152 // (other items were commented in a header). |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 void CCalenDeleteUi::HandleECalenNotifyViewCreatedL() |
|
156 { |
|
157 TRACE_ENTRY_POINT; |
|
158 RArray<TInt> colArray; |
|
159 iController.GetActiveCollectionidsL(colArray); |
|
160 |
|
161 if( iGlobalData->InstanceViewL(colArray) ) |
|
162 { |
|
163 // Handle the outstanding command |
|
164 HandleCommandL( iStoredCommand ); |
|
165 |
|
166 // Cancel the notify as the entry view is now |
|
167 // constructed. |
|
168 iController.CancelNotifications( this ); |
|
169 } |
|
170 colArray.Reset(); |
|
171 TRACE_EXIT_POINT; |
|
172 } |
|
173 |
|
174 // ---------------------------------------------------------------------------- |
|
175 // CCalenDeleteUi::HandleNotification |
126 // Handles notifications. |
176 // Handles notifications. |
127 // (other items were commented in a header). |
177 // (other items were commented in a header). |
128 // ---------------------------------------------------------------------------- |
178 // ---------------------------------------------------------------------------- |
129 // |
179 // |
130 void CalenDeleteUi::HandleNotification(const TCalenNotification aNotification ) |
180 void CCalenDeleteUi::HandleNotification(const TCalenNotification aNotification ) |
131 { |
181 { |
132 OstTraceFunctionEntry0( CALENDELETEUI_HANDLENOTIFICATION_ENTRY ); |
182 TRACE_ENTRY_POINT; |
133 switch(aNotification) { |
183 |
134 case ECalenNotifyCancelDelete: { |
184 if ( aNotification == ECalenNotifyEntryInstanceViewCreated ) |
135 if(iMutlipleContextIdsCount) |
185 { |
136 { |
186 PIM_TRAPD_HANDLE( HandleECalenNotifyViewCreatedL() ); |
137 // get the context |
187 } |
138 MCalenContext& context = iController.context(); |
188 if( aNotification == ECalenNotifyCancelDelete) |
139 // reset the multiple contexts |
189 { |
140 context.resetMultipleContextIds(); |
190 if(iMutlipleContextIdsCount) |
141 } |
191 { |
142 break; |
192 // get the context |
143 } |
193 MCalenContext& context = iGlobalData->Context(); |
144 case ECalenNotifyCloseDialogs: { |
194 // reset the multiple contexts |
145 // Emit the signal to close all the dialogs which are already opened |
195 context.ResetMultipleContextIds(); |
146 emit closeDialogs(); |
196 |
147 break; |
197 // dismiss the waitdialog |
148 } |
198 if(iWaitDialog) |
149 case ECalenNotifySystemLocaleChanged: { |
199 { |
150 //Refresh the date picker of Date query when deleting entries before date |
200 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
151 if(!(mDatePicker.isNull())) { |
201 } |
152 mDatePicker->setDisplayFormat(CalenDateUtils::dateFormatString()); |
202 } |
153 mDatePicker->setDate(QDate::currentDate()); |
203 } |
154 } |
204 TRACE_EXIT_POINT; |
155 break; |
205 } |
156 } |
206 |
157 default: |
207 // ---------------------------------------------------------------------------- |
158 break; |
208 // CCalenDeleteUi::HandleCommandL |
159 } |
|
160 OstTraceFunctionExit0( CALENDELETEUI_HANDLENOTIFICATION_EXIT ); |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CalenDeleteUi::HandleCommandL |
|
165 // Handles action ui commands |
209 // Handles action ui commands |
166 // (other items were commented in a header). |
210 // (other items were commented in a header). |
167 // ---------------------------------------------------------------------------- |
211 // ---------------------------------------------------------------------------- |
168 // |
212 // |
169 TBool CalenDeleteUi::HandleCommandL( const TCalenCommand& aCommand ) |
213 TBool CCalenDeleteUi::HandleCommandL( const TCalenCommand& aCommand ) |
170 { |
214 { |
171 OstTraceFunctionEntry0( CALENDELETEUI_HANDLECOMMANDL_ENTRY ); |
215 TRACE_ENTRY_POINT; |
172 |
|
173 TBool continueCommand(EFalse); |
216 TBool continueCommand(EFalse); |
174 |
217 |
175 switch( aCommand.Command() ) |
218 RArray<TInt> colArray; |
176 { |
219 iController.GetActiveCollectionidsL(colArray); |
177 case ECalenDeleteCurrentEntry: |
220 |
178 mDeleteCommand = ECalenDeleteCurrentEntry; |
221 if( colArray.Count() && !( iGlobalData->InstanceViewL(colArray) ) ) |
179 DeleteCurrentEntryL(); // Entry & instance |
222 { |
180 break; |
223 iStoredCommand = aCommand; |
181 |
224 } |
182 case ECalenDeleteSeries: |
225 else |
183 mDeleteCommand = ECalenDeleteSeries; |
226 { |
184 DeleteThisOrAllL( AgendaUtil::ThisAndAll ); |
227 switch( aCommand.Command() ) |
185 break; |
228 { |
|
229 case ECalenDeleteCurrentEntry: |
|
230 DeleteCurrentEntryL(); // Entry & instance |
|
231 break; |
|
232 |
|
233 case ECalenDeleteSeries: |
|
234 DeleteThisOrAllL( CalCommon::EThisAndAll ); |
|
235 break; |
|
236 |
|
237 case ECalenDeleteCurrentOccurrence: |
|
238 DeleteThisOrAllL( CalCommon::EThisOnly ); |
|
239 break; |
|
240 |
|
241 case ECalenDeleteEntryWithoutQuery: |
|
242 continueCommand = DeleteEntryWithoutQueryL(); |
|
243 break; |
|
244 |
|
245 case ECalenDeleteAllEntries: |
|
246 HandleDeleteAllEntriesL(); |
|
247 break; |
|
248 |
|
249 case ECalenDeleteEntriesBeforeDate: |
|
250 DeleteEntriesBeforeDateL(); // EntryView & instance |
|
251 break; |
|
252 |
|
253 default: |
|
254 // Controller decided this class was the place to handle this |
|
255 // command but it wasn't in our list; something has gone wrong. |
|
256 //ASSERT( EFalse ); |
|
257 break; |
|
258 } |
|
259 } |
|
260 colArray.Reset(); |
|
261 TRACE_EXIT_POINT; |
|
262 return continueCommand; |
|
263 } |
|
264 |
|
265 // ---------------------------------------------------------------------------- |
|
266 // CCalenDeleteUi::CalenCommandHandlerExtensionL |
|
267 // Dummy implementation. |
|
268 // (other items were commented in a header). |
|
269 // ---------------------------------------------------------------------------- |
|
270 // |
|
271 TAny* CCalenDeleteUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
|
272 { |
|
273 TRACE_ENTRY_POINT; |
|
274 TRACE_EXIT_POINT; |
|
275 return NULL; |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 // CCalenDeleteUi::DeleteThisOrAllL |
|
280 // Deletes series repeating entry |
|
281 // (other items were commented in a header). |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 void CCalenDeleteUi::DeleteThisOrAllL( CalCommon::TRecurrenceRange aRepeatType ) |
|
285 { |
|
286 TRACE_ENTRY_POINT; |
|
287 |
|
288 TBool isDeleted( EFalse ); |
|
289 |
|
290 RArray<TInt> colIdArray; |
|
291 colIdArray.AppendL(iGlobalData->Context().InstanceId().iColId); |
|
292 |
|
293 if( iGlobalData->Context().InstanceId().iEntryLocalUid ) |
|
294 { |
|
295 CCalInstance* instance = |
|
296 CalenActionUiUtils::FindPossibleInstanceL( |
|
297 iGlobalData->Context().InstanceId(), |
|
298 *iGlobalData->InstanceViewL(colIdArray) ); |
|
299 if( instance ) |
|
300 { |
|
301 CleanupStack::PushL( instance ); |
|
302 isDeleted = DeleteSingleInstanceL( instance, aRepeatType ); |
186 |
303 |
187 case ECalenDeleteCurrentOccurrence: |
304 if( isDeleted ) |
188 mDeleteCommand = ECalenDeleteCurrentOccurrence; |
305 { |
189 DeleteThisOrAllL( AgendaUtil::ThisOnly ); |
306 CleanupStack::Pop( instance ); |
190 break; |
307 } |
191 |
308 else |
192 case ECalenDeleteEntryWithoutQuery: |
309 { |
193 //TODO: |
310 CleanupStack::PopAndDestroy( instance ); |
194 // This case is not handled currently as no such commands |
311 } |
195 // has been issued. So this has to be handled once we start |
312 } |
196 // issuing the command. |
313 } |
197 /*continueCommand = DeleteEntryWithoutQueryL();*/ |
314 colIdArray.Reset(); |
198 break; |
315 |
199 |
316 iController.BroadcastNotification( isDeleted? ECalenNotifyEntryDeleted : |
200 case ECalenDeleteAllEntries: |
317 ECalenNotifyDeleteFailed ); |
201 mDeleteCommand = ECalenDeleteAllEntries; |
318 |
202 DeleteAllEntriesL(); // EntryView & instance |
319 TRACE_EXIT_POINT; |
203 break; |
320 } |
204 |
321 |
205 case ECalenDeleteEntriesBeforeDate: |
322 // ---------------------------------------------------------------------------- |
206 DeleteEntriesBeforeDateL(); // EntryView & instance |
323 // CCalenDeleteUi::DeleteEntryWithoutQueryL() |
207 break; |
|
208 |
|
209 default: |
|
210 // Controller decided this class was the place to handle this |
|
211 // command but it wasn't in our list; something has gone wrong. |
|
212 //ASSERT( EFalse ); |
|
213 break; |
|
214 } |
|
215 |
|
216 OstTraceFunctionExit0( CALENDELETEUI_HANDLECOMMANDL_EXIT ); |
|
217 return continueCommand; |
|
218 } |
|
219 |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CalenDeleteUi::DeleteThisOrAllL |
|
223 // Deletes series repeating entry |
|
224 // (other items were commented in a header). |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CalenDeleteUi::DeleteThisOrAllL( AgendaUtil::RecurrenceRange aRepeatType ) |
|
228 { |
|
229 OstTraceFunctionEntry0( CALENDELETEUI_DELETETHISORALLL_ENTRY ); |
|
230 |
|
231 if( iController.context().instanceId().mEntryLocalUid ) |
|
232 { |
|
233 AgendaEntry instance = CalenActionUiUtils::findPossibleInstanceL( |
|
234 iController.context().instanceId(), |
|
235 iController.Services().agendaInterface() ); |
|
236 if( !instance.isNull() ) |
|
237 { |
|
238 DeleteSingleInstanceL( instance, aRepeatType ); |
|
239 } |
|
240 } |
|
241 |
|
242 OstTraceFunctionExit0( CALENDELETEUI_DELETETHISORALLL_EXIT ); |
|
243 } |
|
244 |
|
245 // ---------------------------------------------------------------------------- |
|
246 // CalenDeleteUi::DeleteEntryWithoutQueryL() |
|
247 // Deletes the current entry |
324 // Deletes the current entry |
248 // (other items were commented in a header). |
325 // (other items were commented in a header). |
249 // ---------------------------------------------------------------------------- |
326 // ---------------------------------------------------------------------------- |
250 // |
327 // |
251 TBool CalenDeleteUi::DeleteEntryWithoutQueryL() |
328 TBool CCalenDeleteUi::DeleteEntryWithoutQueryL() |
252 { |
329 { |
253 OstTraceFunctionEntry0( CALENDELETEUI_DELETEENTRYWITHOUTQUERYL_ENTRY ); |
330 TRACE_ENTRY_POINT; |
254 |
331 TBool continueCommand(EFalse); |
255 bool continueCommand(EFalse); |
|
256 |
332 |
257 // get the context |
333 // get the context |
258 MCalenContext& context = iController.context(); |
334 MCalenContext& context = iGlobalData->Context(); |
259 |
335 |
260 // get the multliple context ids count |
336 // get the multliple context ids count |
261 iMutlipleContextIdsCount = context.mutlipleContextIdsCount(); |
337 iMutlipleContextIdsCount = context.MutlipleContextIdsCount(); |
262 |
338 |
263 ASSERT( iMutlipleContextIdsCount ); |
339 ASSERT( iMutlipleContextIdsCount ); |
264 |
340 |
265 if(!iMoreEntriesToDelete) |
341 if(!iMoreEntriesToDelete) |
266 { |
342 { |
267 //iDisplayQuery = ShowMultipleEntriesDeleteQueryL(iMutlipleContextIdsCount); |
343 iDisplayQuery = ShowMultipleEntriesDeleteQueryL(iMutlipleContextIdsCount); |
268 } |
344 } |
269 |
345 |
270 if(iDisplayQuery) |
346 if(iDisplayQuery) |
271 { |
347 { |
272 if(!iMoreEntriesToDelete) |
348 if(!iMoreEntriesToDelete) |
273 { |
349 { |
274 DisplayWaitDialogL(); |
350 DisplayWaitDialogL(); |
275 } |
351 } |
276 // get the multiple context instance ids |
352 // get the multiple context instance ids |
277 QList<TCalenInstanceId>& multipleContextIds = context.getMutlipleContextIds(); |
353 RArray<TCalenInstanceId>& multipleContextIds = context.GetMutlipleContextIds(); |
278 |
354 |
279 if(iMutlipleContextIdsCount <= iEntriesToDelete ) |
355 if(iMutlipleContextIdsCount <= iEntriesToDelete ) |
280 { |
356 { |
281 iMoreEntriesToDelete = EFalse; |
357 iMoreEntriesToDelete = EFalse; |
282 iEntriesToDelete = iMutlipleContextIdsCount; |
358 iEntriesToDelete = iMutlipleContextIdsCount; |
290 |
366 |
291 TInt index(0); |
367 TInt index(0); |
292 while(index<iEntriesToDelete) |
368 while(index<iEntriesToDelete) |
293 { |
369 { |
294 // get the local uid of the entry through multiple context list |
370 // get the local uid of the entry through multiple context list |
295 ulong entryLocalUid = multipleContextIds[0].mEntryLocalUid; |
371 TCalLocalUid entryLocalUid = multipleContextIds[0].iEntryLocalUid; |
296 if(entryLocalUid) |
372 if(entryLocalUid) |
297 { |
373 { |
298 DeleteEntryL(entryLocalUid); |
374 DeleteEntryL(entryLocalUid, multipleContextIds[0].iColId); |
299 } |
375 } |
300 // remove mutliple context based on the instanceid |
376 // remove mutliple context based on the instanceid |
301 context.removeMultipleContextId(multipleContextIds[0]); |
377 context.RemoveMultipleContextId(multipleContextIds[0]); |
302 index++; |
378 index++; |
303 } |
379 } |
304 |
380 |
305 if(!iMoreEntriesToDelete) |
381 if(!iMoreEntriesToDelete) |
306 { |
382 { |
307 MarkedEntriesDeletedL(); |
383 MarkedEntriesDeletedL(); |
308 } |
384 } |
|
385 MCalenToolbar* toolbarImpl = iController.Services().ToolbarOrNull(); |
|
386 if (toolbarImpl) |
|
387 { |
|
388 CAknToolbar& toolbar = toolbarImpl->Toolbar(); |
|
389 |
|
390 // dim clear and clear all toolbar buttons |
|
391 toolbar.SetItemDimmed(ECalenNewMeeting, EFalse, ETrue); |
|
392 } |
309 } |
393 } |
310 else |
394 else |
311 { |
395 { |
312 context.resetMultipleContextIds(); |
396 context.ResetMultipleContextIds(); |
313 // notify delete failed |
397 // notify delete failed |
314 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
398 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
315 } |
399 } |
316 |
400 |
317 OstTraceFunctionExit0( CALENDELETEUI_DELETEENTRYWITHOUTQUERYL_EXIT ); |
401 TRACE_EXIT_POINT; |
318 return continueCommand; |
402 return continueCommand; |
319 } |
403 } |
320 |
404 |
321 // ---------------------------------------------------------------------------- |
405 // ---------------------------------------------------------------------------- |
322 // CalenDeleteUi::DeleteCurrentEntryL |
406 // CCalenDeleteUi::DeleteCurrentEntryL |
323 // Deletes the current entry |
407 // Deletes the current entry |
324 // (other items were commented in a header). |
408 // (other items were commented in a header). |
325 // ---------------------------------------------------------------------------- |
409 // ---------------------------------------------------------------------------- |
326 // |
410 // |
327 void CalenDeleteUi::DeleteCurrentEntryL() |
411 void CCalenDeleteUi::DeleteCurrentEntryL() |
328 { |
412 { |
329 OstTraceFunctionEntry0( CALENDELETEUI_DELETECURRENTENTRYL_ENTRY ); |
413 TRACE_ENTRY_POINT; |
330 |
414 |
331 // Make sure we're focused on an entry. |
415 TBool deleted( EFalse ); |
332 if (iController.context().instanceId().mEntryLocalUid) { |
416 TCalenNotification notification = ECalenNotifyDeleteFailed; |
333 // Fetch the entry |
417 |
334 AgendaEntry entry = iController.Services().agendaInterface()->fetchById( |
418 // Make sure we're focused on an entry. |
335 iController.context().instanceId().mEntryLocalUid); |
419 if( iGlobalData->Context().InstanceId().iEntryLocalUid ) |
336 // Check if the entry is a To-Do |
420 { |
337 if (AgendaEntry::TypeTodo == entry.type()) { |
421 //If todo, use the LUid. |
338 showDeleteQuery(EDeleteToDo); |
422 //Todos returns the current time if start or end time has not been saved. |
339 } else { |
423 if( CCalEntry::ETodo == iGlobalData->Context().InstanceId().iType ) |
340 // Show the repeat entry delete query for repeating entries except Anniversary |
424 { |
341 // Even though the anniversary is repeating |
425 CCalEntry* entry = iGlobalData->EntryViewL(iGlobalData->Context().InstanceId().iColId)->FetchL( |
342 // all the instances will be deleted |
426 iGlobalData->Context().InstanceId().iEntryLocalUid ); |
343 if ((entry.isRepeating() || !entry.recurrenceId().isNull()) |
427 |
344 && (AgendaEntry::TypeAnniversary != entry.type())) { |
428 if( entry ) |
345 // Show a confirmation note whether the user |
429 { |
346 // wants to delete the single instance or all of them |
430 CleanupStack::PushL( entry ); |
347 showRepeatingEntryDeleteQuery(); |
431 deleted = DeleteEntryL( iGlobalData->EntryViewL(iGlobalData->Context().InstanceId().iColId), entry ); |
348 } else if (CalenAgendaUtils::isAlldayEvent(entry)) { |
432 |
349 showDeleteQuery(EDeleteEvent); |
433 if( deleted ) |
350 } else { |
434 { |
351 // If the entry is not a repeating entry, |
435 CleanupStack::Pop( entry ); |
352 // delete it directly |
436 notification = ECalenNotifyEntryDeleted; |
353 // Save the entry for later reference in the slot |
437 } |
354 showDeleteQuery(EDeleteEntry); |
438 else |
355 } |
439 { |
|
440 CleanupStack::PopAndDestroy( entry ); |
|
441 } |
|
442 } |
|
443 } |
|
444 else // Not todo |
|
445 { |
|
446 RArray<TInt> colIdArray; |
|
447 colIdArray.AppendL(iGlobalData->Context().InstanceId().iColId); |
|
448 |
|
449 CCalInstance* instance = CalenActionUiUtils::FindPossibleInstanceL( |
|
450 iGlobalData->Context().InstanceId(), |
|
451 *iGlobalData->InstanceViewL(colIdArray) ); |
|
452 // if we have instance we will do delete other wise just return |
|
453 if( instance ) |
|
454 { |
|
455 // Note: ownership handling of instance is dirty in this case, |
|
456 // because DeleteSingleInstanceLtakes ownership, if it's deletes |
|
457 // instance (property of CalInterimApi), otherwise not. |
|
458 CleanupStack::PushL( instance ); |
|
459 deleted = DeleteSingleInstanceL( instance ); |
|
460 |
|
461 if( deleted ) |
|
462 { |
|
463 CleanupStack::Pop( instance ); |
|
464 notification = ECalenNotifyEntryDeleted; |
|
465 } |
|
466 else |
|
467 { |
|
468 CleanupStack::PopAndDestroy( instance ); |
|
469 } |
|
470 } |
|
471 colIdArray.Reset(); |
|
472 } |
|
473 } |
|
474 else |
|
475 { |
|
476 TBool doDelete( ETrue ); |
|
477 |
|
478 doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( |
|
479 iGlobalData->Context().InstanceId().iType == CCalEntry::ETodo ? |
|
480 CalenActionUiUtils::EDeleteToDo : |
|
481 CalenActionUiUtils::EDeleteEntry ); |
|
482 if ( doDelete ) |
|
483 { |
|
484 notification = ECalenNotifyEntryDeleted; |
356 } |
485 } |
357 } |
486 } |
358 OstTraceFunctionExit0( CALENDELETEUI_DELETECURRENTENTRYL_EXIT ); |
487 |
359 } |
488 iController.BroadcastNotification( notification ); |
360 |
489 |
361 // ---------------------------------------------------------------------------- |
490 TRACE_EXIT_POINT; |
362 // CalenDeleteUi::DeleteAllEntriesL |
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // CCalenDeleteUi::DeleteAllEntriesL |
363 // Deletes all entries |
495 // Deletes all entries |
364 // (other items were commented in a header). |
496 // (other items were commented in a header). |
365 // ---------------------------------------------------------------------------- |
497 // ---------------------------------------------------------------------------- |
366 // |
498 // |
367 void CalenDeleteUi::DeleteAllEntriesL() |
499 void CCalenDeleteUi::DeleteAllEntriesL() |
368 { |
500 { |
369 OstTraceFunctionEntry0( CALENDELETEUI_DELETEALLENTRIESL_ENTRY ); |
501 TRACE_ENTRY_POINT; |
370 |
502 |
371 if(iIsDeleting) { |
503 ASSERT( !iIsDeleting ); |
372 OstTraceFunctionExit0( CALENDELETEUI_DELETEALLENTRIESL_EXIT ); |
504 |
373 return; |
505 const TInt buttonId = CalenActionUiUtils::ShowDeleteConfirmationQueryL( |
374 } |
506 CalenActionUiUtils::EDeleteAll ); |
375 |
507 |
376 showDeleteQuery(EDeleteAll ); |
508 if( buttonId ) |
377 OstTraceFunctionExit0( DUP1_CALENDELETEUI_DELETEALLENTRIESL_EXIT ); |
509 { |
378 } |
510 HandleDeleteMultipleEventsL( TCalTime::MinTime(), TCalTime::MaxTime(), |
379 |
511 R_QTN_CALE_CONF_ALL_NOTES_DELETED ); |
380 // ---------------------------------------------------------------------------- |
512 } |
381 // CalenDeleteUi::DeleteEntriesBeforeDateL |
513 else |
|
514 { |
|
515 // notify delete failed |
|
516 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
517 } |
|
518 |
|
519 TRACE_EXIT_POINT; |
|
520 } |
|
521 |
|
522 // ---------------------------------------------------------------------------- |
|
523 // CCalenDeleteUi::DeleteEntriesBeforeDateL |
382 // Deletes all entries before a set date. |
524 // Deletes all entries before a set date. |
383 // (other items were commented in a header). |
525 // (other items were commented in a header). |
384 // ---------------------------------------------------------------------------- |
526 // ---------------------------------------------------------------------------- |
385 // |
527 // |
386 void CalenDeleteUi::DeleteEntriesBeforeDateL() |
528 void CCalenDeleteUi::DeleteEntriesBeforeDateL() |
387 { |
529 { |
388 OstTraceFunctionEntry0( CALENDELETEUI_DELETEENTRIESBEFOREDATEL_ENTRY ); |
530 TRACE_ENTRY_POINT; |
389 |
531 |
390 if(iIsDeleting) { |
532 ASSERT( !iIsDeleting ); |
391 OstTraceFunctionExit0( CALENDELETEUI_DELETEENTRIESBEFOREDATEL_EXIT ); |
533 TTime date; |
392 return; |
534 date.HomeTime(); |
393 } |
535 TTime today = date; |
394 // launch the datepicker |
536 |
395 dateQuery(); |
537 TBool execute( EFalse ); |
396 OstTraceFunctionExit0( DUP1_CALENDELETEUI_DELETEENTRIESBEFOREDATEL_EXIT ); |
538 TBool exit( ETrue ); |
397 } |
539 do{ |
398 |
540 exit = ETrue; |
399 // ---------------------------------------------------------------------------- |
541 execute = EFalse; |
400 // CalenDeleteUi::dateQuery |
542 |
401 // Launches the popup for the date selection |
543 TInt buttonId = CalenActionUiUtils::DateQueryL(date, R_CALEN_DEL_BEFORE_DATE_PROMPT); |
402 // (other items were commented in a header). |
544 |
403 // ---------------------------------------------------------------------------- |
545 if( buttonId == EAknSoftkeyOk || buttonId == EEikBidOk ) |
404 // |
546 { |
405 void CalenDeleteUi::dateQuery() |
547 execute = ETrue; |
406 { |
548 if( today < date ) |
407 OstTraceFunctionEntry0( CALENDELETEUI_DATEQUERY_ENTRY ); |
549 { |
408 |
550 CAknNoteDialog* dialog = new( ELeave ) CAknNoteDialog( |
409 // Create a popup with datepicker to select the date. |
551 CAknNoteDialog::EConfirmationTone, |
410 HbDialog *popUp = new HbDialog(); |
552 CAknNoteDialog::ELongTimeout ); |
411 popUp->setParent(this); |
553 dialog->ExecuteLD( R_CALEN_DELETEERROR_NOTE ); |
412 popUp->setDismissPolicy(HbDialog::NoDismiss); |
554 execute = EFalse; |
413 popUp->setTimeout(HbDialog::NoTimeout ); |
555 exit = EFalse; |
414 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
556 } |
415 popUp->setHeadingWidget(new HbLabel(hbTrId("txt_calendar_title_set_date"))); |
557 } |
416 |
558 }while( !exit ); |
417 QDateTime currentDateTime(CalenDateUtils::today()); |
559 |
418 QDate currentDate(currentDateTime.date()); |
560 // Do delete only if inputted day is after beginning of range |
419 if(mDatePicker) { |
561 if( execute && date > TCalTime::MinTime() ) |
420 mDatePicker = NULL; |
562 { |
421 } |
563 // Two pass delete: |
422 mDatePicker = new HbDateTimePicker(popUp); |
564 // 1. pass |
423 mDatePicker->setMinimumDate(CalenDateUtils::minTime().date()); |
565 // To prevent destroying entries starting and ending midnight |
424 mDatePicker->setMaximumDate(currentDate); |
566 // subtract one microsecond and do delete on that range. |
425 mDatePicker->setDisplayFormat(CalenDateUtils::dateFormatString()); |
567 date -= TTimeIntervalMicroSeconds32( 1 ); |
426 mDatePicker->setDate(currentDate); |
568 date = Max( date, TCalTime::MinTime() ); |
427 |
569 |
428 popUp->setContentWidget(mDatePicker); |
570 HandleDeleteMultipleEventsL( TCalTime::MinTime(), |
429 mDeleteAction = new HbAction( |
571 date, |
430 hbTrId("txt_common_button_delete"), popUp); |
572 R_QTN_CALE_CONF_PAST_NOTE_DELETED ); |
431 popUp->addAction(mDeleteAction); |
573 } |
432 mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"),popUp); |
574 else |
433 popUp->addAction(mCancelAction); |
575 { |
434 // Close the popup once closeDialogs() is received |
576 iController.BroadcastNotification( ECalenNotifyDeleteFailed ); |
435 connect(this, SIGNAL(closeDialogs()), popUp, SLOT(close())); |
577 } |
436 // Show the popup |
578 |
437 popUp->open(this, SLOT(handleDateQuery(HbAction*))); |
579 TRACE_EXIT_POINT; |
438 |
580 } |
439 OstTraceFunctionExit0( CALENDELETEUI_DATEQUERY_EXIT ); |
581 |
440 } |
582 // ---------------------------------------------------------------------------- |
441 |
583 // CCalenDeleteUi::HandleDeleteMultipleEventsL |
442 // ---------------------------------------------------------------------------- |
|
443 // CalenDeleteUi::handleDateQuery |
|
444 // Handles the selection for the date query |
|
445 // (other items were commented in a header). |
|
446 // ---------------------------------------------------------------------------- |
|
447 // |
|
448 void CalenDeleteUi::handleDateQuery(HbAction* action) |
|
449 { |
|
450 OstTraceFunctionEntry0( CALENDELETEUI_HANDLEDATEQUERY_ENTRY ); |
|
451 |
|
452 if(action == mDeleteAction) { |
|
453 // User selected the date before which all the entries has to be deleted |
|
454 QDate selectedDate(mDatePicker->date()); |
|
455 // Check if the date is within the range. |
|
456 if(selectedDate.isValid()) { |
|
457 QTime time(0,0,0,0); |
|
458 QDateTime dateTime; |
|
459 dateTime.setDate(selectedDate); |
|
460 dateTime.setTime(time); |
|
461 // Do delete only if inputted day is after beginning of range |
|
462 if(dateTime > AgendaUtil::minTime()) { |
|
463 // Two pass delete: |
|
464 // 1. pass |
|
465 // To prevent destroying entries starting and ending midnight |
|
466 // subtract one second and do delete on that range. |
|
467 dateTime = dateTime.addSecs(-1); |
|
468 dateTime = ( dateTime > AgendaUtil::minTime()? |
|
469 dateTime : AgendaUtil::minTime()); |
|
470 |
|
471 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), |
|
472 dateTime, 1); |
|
473 }else { |
|
474 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
475 } |
|
476 } |
|
477 }else { |
|
478 // User pressed cancel |
|
479 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
480 } |
|
481 // Reset the member variables |
|
482 mDeleteAction = NULL; |
|
483 mCancelAction = NULL; |
|
484 |
|
485 OstTraceFunctionExit0( CALENDELETEUI_HANDLEDATEQUERY_EXIT ); |
|
486 } |
|
487 // ---------------------------------------------------------------------------- |
|
488 // CalenDeleteUi::showRepeatingEntryDeleteQuery |
|
489 // Launches the popup for deleting the repeating entry |
|
490 // (other items were commented in a header). |
|
491 // ---------------------------------------------------------------------------- |
|
492 // |
|
493 void CalenDeleteUi::showRepeatingEntryDeleteQuery() |
|
494 { |
|
495 OstTraceFunctionEntry0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_ENTRY ); |
|
496 |
|
497 HbDialog *popUp = new HbDialog(); |
|
498 popUp->setParent(this); |
|
499 popUp->setDismissPolicy(HbDialog::NoDismiss); |
|
500 popUp->setTimeout(HbDialog::NoTimeout); |
|
501 popUp->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
502 |
|
503 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
504 HbWidget *editWidget = new HbWidget(); |
|
505 editWidget->setLayout(layout); |
|
506 |
|
507 HbRadioButtonList *editButtonList = new HbRadioButtonList(); |
|
508 |
|
509 QStringList list; |
|
510 list << hbTrId("txt_calendar_info_this_occurrence_only") |
|
511 << hbTrId("txt_calendar_info_all_occurences"); |
|
512 |
|
513 editButtonList->setItems(list); |
|
514 |
|
515 layout->addItem(editButtonList); |
|
516 |
|
517 popUp->setContentWidget(editWidget); |
|
518 popUp->setHeadingWidget(new HbLabel( |
|
519 hbTrId("txt_calendar_title_delete_repeated_entry"))); |
|
520 |
|
521 // Add cancel action |
|
522 mCancelAction = new HbAction( |
|
523 hbTrId("txt_common_button_cancel_singledialog")); |
|
524 popUp->addAction(mCancelAction); |
|
525 connect(editButtonList, SIGNAL(itemSelected(int)), this, |
|
526 SLOT(handleRepeatedEntryDelete(int))); |
|
527 connect(editButtonList, SIGNAL(itemSelected(int)), popUp, SLOT(close())); |
|
528 // Close the popup once closeDialogs() is received |
|
529 connect(this, SIGNAL(closeDialogs()), popUp, SLOT(close())); |
|
530 // Show the popup |
|
531 popUp->open(this, SLOT(handleCancelAndClose(HbAction*))); |
|
532 |
|
533 OstTraceFunctionExit0( CALENDELETEUI_SHOWREPEATINGENTRYDELETEQUERY_EXIT ); |
|
534 } |
|
535 |
|
536 // ---------------------------------------------------------------------------- |
|
537 // CalenDeleteUi::handleCancelAndClose |
|
538 // Handles the cancel action and the close of the popup |
|
539 // (other items were commented in a header). |
|
540 // ---------------------------------------------------------------------------- |
|
541 // |
|
542 void CalenDeleteUi::handleCancelAndClose(HbAction* action) |
|
543 { |
|
544 OstTraceFunctionEntry0( CALENDELETEUI_HANDLECANCELANDCLOSE_ENTRY ); |
|
545 if(action == mCancelAction || !action) { |
|
546 // If the user presses cancel button broadcast ECalenNotifyDeleteFailed |
|
547 // Action will be null if the popup is closed by itself |
|
548 // without pressing any buttons. So in this case also notification |
|
549 // has to be broadcasted as ECalenNotifyDeleteFailed |
|
550 |
|
551 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
552 } |
|
553 mCancelAction = NULL; |
|
554 OstTraceFunctionExit0( CALENDELETEUI_HANDLECANCELANDCLOSE_EXIT ); |
|
555 } |
|
556 |
|
557 void CalenDeleteUi::handleRepeatedEntryDelete(int index) |
|
558 { |
|
559 OstTraceFunctionEntry0( CALENDELETEUI_HANDLEREPEATEDENTRYDELETE_ENTRY ); |
|
560 |
|
561 // Fetch the entry |
|
562 // Find all possible instances |
|
563 AgendaEntry instance = CalenActionUiUtils::findPossibleInstanceL( |
|
564 iController.context().instanceId(), |
|
565 iController.Services().agendaInterface()); |
|
566 |
|
567 if (!instance.isNull()) { |
|
568 connect(iController.Services().agendaInterface(), |
|
569 SIGNAL(entryDeleted(ulong)), |
|
570 this, SLOT(entryDeleted(ulong))); |
|
571 switch(index) { |
|
572 case 0: |
|
573 // User wants to delete only this occurence |
|
574 iController.Services().agendaInterface()->deleteRepeatedEntry( |
|
575 instance, AgendaUtil::ThisOnly); |
|
576 break; |
|
577 case 1: |
|
578 // User wants to delete all the occurences |
|
579 iController.Services().agendaInterface()->deleteRepeatedEntry( |
|
580 instance, AgendaUtil::ThisAndAll); |
|
581 break; |
|
582 } |
|
583 }else { |
|
584 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
585 } |
|
586 OstTraceFunctionExit0( CALENDELETEUI_HANDLEREPEATEDENTRYDELETE_EXIT ); |
|
587 } |
|
588 |
|
589 // ---------------------------------------------------------------------------- |
|
590 // CalenDeleteUi::showDeleteQuery |
|
591 // Launches the popup for deleting the instance/instances |
|
592 // (other items were commented in a header). |
|
593 // ---------------------------------------------------------------------------- |
|
594 // |
|
595 void CalenDeleteUi::showDeleteQuery(const TDeleteConfirmationType type, |
|
596 const int count) |
|
597 { |
|
598 OstTraceFunctionEntry0( CALENDELETEUI_SHOWDELETEQUERY_ENTRY ); |
|
599 |
|
600 HbMessageBox *popup = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
601 popup->setParent(this); |
|
602 popup->setDismissPolicy(HbDialog::NoDismiss); |
|
603 popup->setTimeout(HbDialog::NoTimeout); |
|
604 popup->setAttribute( Qt::WA_DeleteOnClose, true ); |
|
605 |
|
606 QString text = 0; |
|
607 |
|
608 switch(type) |
|
609 { |
|
610 case EDeleteEntry: |
|
611 { |
|
612 text.append(hbTrId("txt_calendar_info_delete_meeting")); |
|
613 break; |
|
614 } |
|
615 case EDeleteToDo: |
|
616 { |
|
617 text.append(hbTrId("txt_calendar_info_delete_todo_note")); |
|
618 break; |
|
619 } |
|
620 case EDeleteToDos: |
|
621 {//"Delete %N to-do notes?" |
|
622 // TODO: Add the text id |
|
623 text.append("Delete %N to-do's?").arg(count); |
|
624 break; |
|
625 } |
|
626 case EDeleteAll: |
|
627 { |
|
628 text.append(hbTrId("txt_calendar_info_delete_all_calendar_entries")); |
|
629 break; |
|
630 } |
|
631 case EDeleteEvent: |
|
632 { |
|
633 text.append(hbTrId("txt_calendar_info_delete_allday_event")); |
|
634 break; |
|
635 } |
|
636 default: |
|
637 break; |
|
638 } |
|
639 |
|
640 popup->setText(text); |
|
641 |
|
642 QList<QAction*> list = popup->actions(); |
|
643 for(int i=0; i < list.count(); i++) |
|
644 { |
|
645 popup->removeAction(list[i]); |
|
646 } |
|
647 mDeleteAction = new HbAction( |
|
648 hbTrId("txt_common_button_delete"), popup); |
|
649 popup->addAction(mDeleteAction); |
|
650 mCancelAction = new HbAction(hbTrId("txt_common_button_cancel"), popup); |
|
651 popup->addAction(mCancelAction); |
|
652 // Close the popup once closeDialogs() is received |
|
653 connect(this, SIGNAL(closeDialogs()), popup, SLOT(close())); |
|
654 // Show the popup |
|
655 popup->open(this, SLOT(handleDeletion(HbAction*))); |
|
656 |
|
657 OstTraceFunctionExit0( CALENDELETEUI_SHOWDELETEQUERY_EXIT ); |
|
658 } |
|
659 |
|
660 // ---------------------------------------------------------------------------- |
|
661 // CalenDeleteUi::handleDeletion |
|
662 // Deletes the entries based on the user selection |
|
663 // (other items were commented in a header). |
|
664 // ---------------------------------------------------------------------------- |
|
665 // |
|
666 void CalenDeleteUi::handleDeletion(HbAction* action) |
|
667 { |
|
668 OstTraceFunctionEntry0( CALENDELETEUI_HANDLEDELETION_ENTRY ); |
|
669 |
|
670 TCalenNotification notification = ECalenNotifyDeleteFailed; |
|
671 |
|
672 if(action == mDeleteAction) { |
|
673 |
|
674 switch (mDeleteCommand) { |
|
675 |
|
676 case ECalenDeleteCurrentEntry: |
|
677 { |
|
678 // Get the entry id |
|
679 ulong id = iController.context().instanceId().mEntryLocalUid; |
|
680 connect(iController.Services().agendaInterface(), |
|
681 SIGNAL(entryDeleted(ulong)), |
|
682 this, SLOT(entryDeleted(ulong))); |
|
683 // Delete the entry if the delete button is been pressed |
|
684 iController.Services().agendaInterface()->deleteEntry(id); |
|
685 } |
|
686 break; |
|
687 |
|
688 case ECalenDeleteSeries: |
|
689 case ECalenDeleteCurrentOccurrence: |
|
690 { |
|
691 AgendaEntry instance = |
|
692 CalenActionUiUtils::findPossibleInstanceL( |
|
693 iController.context().instanceId(), |
|
694 iController.Services().agendaInterface() ); |
|
695 if(!instance.isNull()) { |
|
696 QDateTime recId = instance.recurrenceId().toUTC(); |
|
697 const bool child = recId.isNull(); |
|
698 connect(iController.Services().agendaInterface(), |
|
699 SIGNAL(entryDeleted(ulong)), |
|
700 this, SLOT(entryDeleted(ulong))); |
|
701 if( !child || mRecurrenceRange == AgendaUtil::ThisOnly |
|
702 || mRecurrenceRange == AgendaUtil::ThisAndAll) { |
|
703 iController.Services().agendaInterface()->deleteRepeatedEntry( |
|
704 instance, mRecurrenceRange ); |
|
705 } |
|
706 }else { |
|
707 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
708 } |
|
709 } |
|
710 break; |
|
711 |
|
712 case ECalenDeleteAllEntries: |
|
713 { |
|
714 HandleDeleteMultipleEventsL( AgendaUtil::minTime(), |
|
715 AgendaUtil::maxTime(),1 ); |
|
716 } |
|
717 break; |
|
718 |
|
719 default: |
|
720 break; |
|
721 |
|
722 } |
|
723 } else if(!action || action == mCancelAction ) { |
|
724 // Action will be null if the popup is closed by itself |
|
725 // without pressing any buttons. So in this case also notification |
|
726 // has to be broadcasted as ECalenNotifyDeleteFailed |
|
727 // If the user presses cancel button also the same has to happen |
|
728 // Notify the status |
|
729 iController.BroadcastNotification(notification); |
|
730 } |
|
731 |
|
732 // Reset the member variables |
|
733 mDeleteAction = NULL; |
|
734 mCancelAction = NULL; |
|
735 |
|
736 OstTraceFunctionExit0( CALENDELETEUI_HANDLEDELETION_EXIT ); |
|
737 } |
|
738 |
|
739 void CalenDeleteUi::entryDeleted(ulong id) |
|
740 { |
|
741 OstTraceFunctionEntry0( CALENDELETEUI_ENTRYDELETED_ENTRY ); |
|
742 |
|
743 if (iController.context().instanceId().mEntryLocalUid == id) { |
|
744 iController.BroadcastNotification(ECalenNotifyEntryDeleted); |
|
745 } |
|
746 disconnect(iController.Services().agendaInterface(), SIGNAL(entryDeleted(ulong)), |
|
747 this, SLOT(entryDeleted(ulong))); |
|
748 |
|
749 OstTraceFunctionExit0( CALENDELETEUI_ENTRYDELETED_EXIT ); |
|
750 } |
|
751 |
|
752 // ---------------------------------------------------------------------------- |
|
753 // CalenDeleteUi::HandleDeleteMultipleEventsL |
|
754 // Handles multiple delete events |
584 // Handles multiple delete events |
755 // (other items were commented in a header). |
585 // (other items were commented in a header). |
756 // ---------------------------------------------------------------------------- |
586 // ---------------------------------------------------------------------------- |
757 // |
587 // |
758 void CalenDeleteUi::HandleDeleteMultipleEventsL( const QDateTime& aFirstDay, |
588 void CCalenDeleteUi::HandleDeleteMultipleEventsL( const TTime& aFirstDay, |
759 const QDateTime& aLastDay, |
589 const TTime& aLastDay, |
760 int aConfNoteId ) |
590 TInt /*aConfNoteId */) |
761 { |
591 { |
762 OstTraceFunctionEntry0( CALENDELETEUI_HANDLEDELETEMULTIPLEEVENTSL_ENTRY ); |
592 TRACE_ENTRY_POINT; |
763 |
593 |
764 if(iIsDeleting) { |
594 ASSERT( !iWaitDialog ); |
765 OstTraceFunctionExit0( CALENDELETEUI_HANDLEDELETEMULTIPLEEVENTSL_EXIT ); |
595 ASSERT( !iIsDeleting ); |
766 return; |
596 //iConfirmationNoteId = aConfNoteId; |
767 } |
597 |
768 iConfirmationNoteId = aConfNoteId; |
598 iWaitDialog = new( ELeave ) CAknWaitDialog( REINTERPRET_CAST( CEikDialog**, |
769 |
599 &iWaitDialog ) ); |
|
600 iWaitDialog->ExecuteLD( R_CALEN_DELETE_WAIT_NOTE ); |
|
601 |
770 DeleteDayRangeL( aFirstDay, aLastDay ); |
602 DeleteDayRangeL( aFirstDay, aLastDay ); |
771 |
603 |
772 OstTraceFunctionExit0( DUP1_CALENDELETEUI_HANDLEDELETEMULTIPLEEVENTSL_EXIT ); |
604 TRACE_EXIT_POINT; |
773 } |
605 } |
774 |
606 |
775 // ---------------------------------------------------------------------------- |
607 // ---------------------------------------------------------------------------- |
776 // CalenDeleteUi::DeleteDayRangeL |
608 // CCalenDeleteUi::DeleteDayRangeL |
777 // Deletes all entries in a given range. |
609 // Deletes all entries in a given range. |
778 // (other items were commented in a header). |
610 // (other items were commented in a header). |
779 // ---------------------------------------------------------------------------- |
611 // ---------------------------------------------------------------------------- |
780 // |
612 // |
781 void CalenDeleteUi::DeleteDayRangeL( const QDateTime& aStart, |
613 void CCalenDeleteUi::DeleteDayRangeL( const TTime& aStart, |
782 const QDateTime& aEnd ) |
614 const TTime& aEnd ) |
783 { |
615 { |
784 OstTraceFunctionEntry0( CALENDELETEUI_DELETEDAYRANGEL_ENTRY ); |
616 TRACE_ENTRY_POINT; |
785 |
617 |
786 iStartTime = aStart; |
618 iStartTime = aStart; |
787 iEndTime = aEnd; |
619 iEndTime = aEnd; |
788 |
620 |
789 iIsDeleting = ETrue; |
621 TCalTime start, end; |
790 |
622 start.SetTimeLocalL( iStartTime ); |
791 //AgendaUtil& agendaInterface = iController.agendaInterface(); |
623 end.SetTimeLocalL( iEndTime ); |
792 // Connect to the signal that gets generated when deletion is completed |
624 |
793 connect(iController.agendaInterface(), SIGNAL(entriesDeleted(int)), this, |
625 if( iDelAllRange ) |
794 SLOT(doCompleted(int))); |
626 { |
795 AgendaUtil::FilterFlags filter = |
627 delete iDelAllRange; |
796 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
628 iDelAllRange = NULL; |
797 | AgendaUtil::IncludeAppointments |
629 } |
798 | AgendaUtil::IncludeEvents |
630 |
799 | AgendaUtil::IncludeReminders |
631 iDelAllRange = new(ELeave) CalCommon::TCalTimeRange( start, end ); |
800 | AgendaUtil::IncludeIncompletedTodos |
632 iDeleteColIds.Reset(); |
801 | AgendaUtil::IncludeCompletedTodos |
633 |
802 | AgendaUtil::IncludeAnniversaries); |
634 iIsDeleting = ETrue; |
803 // 1: First pass, delete all entries. |
635 |
804 iController.agendaInterface()->deleteEntries(iStartTime, iEndTime, filter); |
636 iController.GetActiveCollectionidsL(iDeleteColIds); |
805 |
637 |
806 OstTraceFunctionExit0( CALENDELETEUI_DELETEDAYRANGEL_EXIT ); |
638 //remember the calenders, delete entries in each calendar one by one by calling DeleteL(...) after completed() |
807 } |
639 iNumberOfCalendars = iDeleteColIds.Count(); |
808 |
640 iToShowDeleteNote = 0; |
809 // ---------------------------------------------------------------------------- |
641 iGlobalData->EntryViewL(iDeleteColIds[iToShowDeleteNote])->DeleteL( *iDelAllRange, CalCommon::EIncludeAll, *this ); |
810 // CalenDeleteUi::DoCompletedL |
642 |
|
643 TRACE_EXIT_POINT; |
|
644 } |
|
645 |
|
646 // ---------------------------------------------------------------------------- |
|
647 // CCalenDeleteUi::Completed |
|
648 // Completed callback |
|
649 // (other items were commented in a header). |
|
650 // ---------------------------------------------------------------------------- |
|
651 // |
|
652 void CCalenDeleteUi::Completed( TInt aFirstPassError ) |
|
653 { |
|
654 TRACE_ENTRY_POINT; |
|
655 |
|
656 PIM_TRAPD_HANDLE( DoCompletedL( aFirstPassError ) ); |
|
657 |
|
658 TRACE_EXIT_POINT; |
|
659 } |
|
660 |
|
661 // ---------------------------------------------------------------------------- |
|
662 // CCalenDeleteUi::DoCompletedL |
811 // Handles delete callback |
663 // Handles delete callback |
812 // (other items were commented in a header). |
664 // (other items were commented in a header). |
813 // ---------------------------------------------------------------------------- |
665 // ---------------------------------------------------------------------------- |
814 // |
666 // |
815 void CalenDeleteUi::doCompleted( int aFirstPassError ) |
667 void CCalenDeleteUi::DoCompletedL( TInt aFirstPassError ) |
816 { |
668 { |
817 OstTraceFunctionEntry0( CALENDELETEUI_DOCOMPLETED_ENTRY ); |
669 TRACE_ENTRY_POINT; |
818 |
670 iToShowDeleteNote++; |
819 if( aFirstPassError == KErrNone ) |
671 if(iNumberOfCalendars == iToShowDeleteNote) |
820 { |
672 { |
821 // 2: Second pass, delete notes that end 00:00 of next day of iEndTime |
673 if( aFirstPassError == KErrNone ) |
822 // We didn't delete them in first pass |
674 { |
823 QDateTime nextMidnight = CalenDateUtils::beginningOfDay( iEndTime.addDays(1) ); |
675 // 2: Second pass, delete notes that end 00:00 of next day of iEndTime |
824 nextMidnight = ( nextMidnight < AgendaUtil::maxTime()? nextMidnight : AgendaUtil::maxTime() ); |
676 // We didn't delete them in first pass |
825 PIM_TRAPD_HANDLE( deleteEntriesEndingAtMidnight( nextMidnight ) ); |
677 TTime nextMidnight = CalenDateUtils::BeginningOfDay( iEndTime + TTimeIntervalDays( 1 ) ); |
826 } |
678 nextMidnight = Min( nextMidnight, TCalTime::MaxTime() ); |
827 |
679 PIM_TRAPD_HANDLE( DeleteEntriesEndingAtMidnightL( nextMidnight ) ); |
828 // 3. End deleting, close wait dialog, and show confirmation or error note |
680 } |
829 iIsDeleting = EFalse; |
681 |
830 |
682 // 3. End deleting, close wait dialog, and show confirmation or error note |
831 iController.BroadcastNotification( ECalenNotifyMultipleEntriesDeleted ); |
683 iIsDeleting = EFalse; |
832 |
684 iToShowDeleteNote = 0; |
833 OstTraceFunctionExit0( CALENDELETEUI_DOCOMPLETED_EXIT ); |
685 // dismiss the waitdialog |
834 } |
686 if(iWaitDialog) |
835 |
687 { |
836 // ---------------------------------------------------------------------------- |
688 TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); |
837 // CalenDeleteUi::DeleteEntriesEndingAtMidnightL |
689 } |
|
690 |
|
691 if( aFirstPassError == KErrNone ) |
|
692 { |
|
693 // Show confirmation note |
|
694 // HBufC* buf = StringLoader::LoadLC( iConfirmationNoteId, iEikEnv ); |
|
695 // CAknConfirmationNote* dialog = new( ELeave ) CAknConfirmationNote(); |
|
696 // dialog->ExecuteLD(*buf); |
|
697 // CleanupStack::PopAndDestroy( buf ); |
|
698 } |
|
699 else |
|
700 { |
|
701 // Show error note |
|
702 if(iEikEnv) |
|
703 { |
|
704 iEikEnv->ResolveError( aFirstPassError ); |
|
705 } |
|
706 } |
|
707 iDeleteColIds.Reset(); |
|
708 delete iDelAllRange; |
|
709 iDelAllRange = NULL; |
|
710 |
|
711 iController.BroadcastNotification( ECalenNotifyMultipleEntriesDeleted ); |
|
712 } |
|
713 else |
|
714 { |
|
715 //delete entries in next calendar... |
|
716 iGlobalData->EntryViewL(iDeleteColIds[iToShowDeleteNote])->DeleteL( *iDelAllRange, CalCommon::EIncludeAll, *this ); |
|
717 } |
|
718 |
|
719 TRACE_EXIT_POINT; |
|
720 } |
|
721 |
|
722 // ---------------------------------------------------------------------------- |
|
723 // CCalenDeleteUi::NotifyProgress |
|
724 // Delete progress notification |
|
725 // (other items were commented in a header). |
|
726 // ---------------------------------------------------------------------------- |
|
727 // |
|
728 TBool CCalenDeleteUi::NotifyProgress() |
|
729 { |
|
730 TRACE_ENTRY_POINT; |
|
731 // Tell framework that we are not intrested in Progress notifications. |
|
732 TRACE_EXIT_POINT; |
|
733 return EFalse; |
|
734 } |
|
735 |
|
736 // ---------------------------------------------------------------------------- |
|
737 // CCalenDeleteUi::Progress |
|
738 // Delete progress notification |
|
739 // (other items were commented in a header). |
|
740 // ---------------------------------------------------------------------------- |
|
741 // |
|
742 void CCalenDeleteUi::Progress( TInt /*aPercentageCompleted*/ ) |
|
743 { |
|
744 TRACE_ENTRY_POINT; |
|
745 // do nothing, we are not intrested in Progress notifications |
|
746 TRACE_EXIT_POINT; |
|
747 } |
|
748 |
|
749 // ---------------------------------------------------------------------------- |
|
750 // CCalenDeleteUi::DeleteEntriesEndingAtMidnightL |
838 // Deletes entries ending at midnight on the given day |
751 // Deletes entries ending at midnight on the given day |
839 // (other items were commented in a header). |
752 // (other items were commented in a header). |
840 // ---------------------------------------------------------------------------- |
753 // ---------------------------------------------------------------------------- |
841 // |
754 // |
842 void CalenDeleteUi::deleteEntriesEndingAtMidnight( QDateTime aMidnight ) |
755 void CCalenDeleteUi::DeleteEntriesEndingAtMidnightL( TTime aMidnight ) |
843 { |
756 { |
844 OstTraceFunctionEntry0( CALENDELETEUI_DELETEENTRIESENDINGATMIDNIGHT_ENTRY ); |
757 TRACE_ENTRY_POINT; |
845 |
758 |
846 QDateTime start, end; |
759 TCalTime start, end; |
847 QTime startTime(aMidnight.time()); |
760 start.SetTimeLocalL( aMidnight - TTimeIntervalMinutes(1) ); |
848 startTime.setHMS(startTime.hour(), startTime.minute() - 1, |
761 end.SetTimeLocalL( aMidnight ); |
849 startTime.second(), startTime.msec()); |
762 CalCommon::TCalTimeRange midnightRange( start, end ); |
850 start.setDate(aMidnight.date()); |
763 |
851 start.setTime(startTime); |
764 RArray<TInt> colIdArray; |
852 |
765 iController.GetActiveCollectionidsL(colIdArray); |
853 end = aMidnight; |
766 |
854 |
767 // 1: Find instances falling on midnight moment |
855 QList<AgendaEntry> instances = iController.Services().agendaInterface()->fetchEntriesInRange( start, end ); |
768 RPointerArray< CCalInstance > instances; |
|
769 CleanupResetAndDestroyPushL( instances ); |
|
770 iGlobalData->InstanceViewL(colIdArray)->FindInstanceL( instances, |
|
771 CalCommon::EIncludeAll, |
|
772 midnightRange ); |
|
773 |
|
774 colIdArray.Reset(); |
856 |
775 |
857 // 2. loop through them and delete those entries that end at midnight |
776 // 2. loop through them and delete those entries that end at midnight |
858 for( int i=0; i < instances.count(); ++i ) |
777 for( TInt i=0; i < instances.Count(); ++i ) |
859 { |
778 { |
860 AgendaEntry entry = instances[i]; |
779 CCalInstance* item = instances[i]; |
861 |
780 RArray<TInt> colIdArray; |
|
781 colIdArray.AppendL(item->InstanceIdL().iCollectionId); |
|
782 |
862 // Checking that if entry ends at midnight, is quite clumsy, but here goes: |
783 // Checking that if entry ends at midnight, is quite clumsy, but here goes: |
863 // EndsAtStartOfDay takes only CCalInstance, but here we mimic EndsAtStartOfDay |
784 // EndsAtStartOfDay takes only CCalInstance, but here we mimic EndsAtStartOfDay |
864 // for CCalEntry type. |
785 // for CCalEntry type. |
865 |
786 |
866 // First check that if _instance_ ends at midnight, but starts earlier |
787 // First check that if _instance_ ends at midnight, but starts earlier |
867 if( CalenAgendaUtils::endsAtStartOfDay( entry, aMidnight ) ) |
788 if( CalenAgendaUtils::EndsAtStartOfDayL( item, aMidnight ) ) |
868 { |
789 { |
869 // Second, check that _entry's_ endtime is exactly the midnight |
790 // Second, check that _entry's_ endtime is exactly the midnight |
870 // This prevents us from destroying repeating entries, that has one |
791 // This prevents us from destroying repeating entries, that has one |
871 // instance falling on given midnight. |
792 // instance falling on given midnight. |
872 if( entry.endTime() == aMidnight ) |
793 if( item->Entry().EndTimeL().TimeLocalL() == aMidnight ) |
873 { |
794 { |
874 iController.Services().agendaInterface()->deleteRepeatedEntry(entry, AgendaUtil::ThisAndAll); |
795 iGlobalData->InstanceViewL(colIdArray)->DeleteL( item, CalCommon::EThisOnly ); |
875 } |
796 // Ownership was transferred to DeleteL. |
876 } |
797 // Put null to array to prevent double-deletion |
877 } |
798 instances[i] = NULL; |
878 |
799 } |
879 OstTraceFunctionExit0( CALENDELETEUI_DELETEENTRIESENDINGATMIDNIGHT_EXIT ); |
800 } |
880 } |
801 colIdArray.Reset(); |
881 |
802 } |
882 // ----------------------------------------------------------------------------- |
803 CleanupStack::PopAndDestroy( &instances ); |
883 // CalenDeleteUi::DeleteSingleInstanceL |
804 |
|
805 TRACE_EXIT_POINT; |
|
806 } |
|
807 |
|
808 // ----------------------------------------------------------------------------- |
|
809 // CCalenDeleteUi::DeleteSingleInstanceL |
884 // Delete the given instance. Ask the user whether to delete the series or the instance. |
810 // Delete the given instance. Ask the user whether to delete the series or the instance. |
885 // (other items were commented in a header). |
811 // (other items were commented in a header). |
886 // ----------------------------------------------------------------------------- |
812 // ----------------------------------------------------------------------------- |
887 // |
813 // |
888 void CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance ) |
814 TBool CCalenDeleteUi::DeleteSingleInstanceL( CCalInstance* aInstance ) |
889 { |
815 { |
890 OstTraceFunctionEntry0( CALENDELETEUI_DELETESINGLEINSTANCEL_ENTRY ); |
816 TRACE_ENTRY_POINT; |
891 |
817 TRACE_EXIT_POINT; |
892 DoDeleteSingleInstanceL( aInstance, EFalse, AgendaUtil::ThisAndAll ); |
818 return DoDeleteSingleInstanceL( aInstance, EFalse, CalCommon::EThisAndAll ); |
893 |
819 } |
894 OstTraceFunctionExit0( CALENDELETEUI_DELETESINGLEINSTANCEL_EXIT ); |
820 |
895 } |
821 // ----------------------------------------------------------------------------- |
896 |
822 // CCalenDeleteUi::DeleteSingleInstanceL |
897 // ----------------------------------------------------------------------------- |
|
898 // CalenDeleteUi::DeleteSingleInstanceL |
|
899 // Delete the given instance. Delete the entry range given by aRepeatType. |
823 // Delete the given instance. Delete the entry range given by aRepeatType. |
900 // (other items were commented in a header). |
824 // (other items were commented in a header). |
901 // ----------------------------------------------------------------------------- |
825 // ----------------------------------------------------------------------------- |
902 // |
826 // |
903 void CalenDeleteUi::DeleteSingleInstanceL( AgendaEntry& aInstance, |
827 TBool CCalenDeleteUi::DeleteSingleInstanceL( CCalInstance* aInstance, |
904 AgendaUtil::RecurrenceRange aRepeatType ) |
828 CalCommon::TRecurrenceRange aRepeatType ) |
905 { |
829 { |
906 OstTraceFunctionEntry0( DUP1_CALENDELETEUI_DELETESINGLEINSTANCEL_ENTRY ); |
830 TRACE_ENTRY_POINT; |
907 |
831 TRACE_EXIT_POINT; |
908 DoDeleteSingleInstanceL( aInstance, ETrue, aRepeatType ); |
832 return DoDeleteSingleInstanceL( aInstance, ETrue, aRepeatType ); |
909 |
833 } |
910 OstTraceFunctionExit0( DUP1_CALENDELETEUI_DELETESINGLEINSTANCEL_EXIT ); |
834 |
911 } |
835 // ----------------------------------------------------------------------------- |
912 |
836 // CCalenDeleteUi::DoDeleteSingleInstanceL |
913 // ----------------------------------------------------------------------------- |
|
914 // CalenDeleteUi::DoDeleteSingleInstanceL |
|
915 // Performs the deletion of the instance. If aHasRepeatType is EFalse, the user |
837 // Performs the deletion of the instance. If aHasRepeatType is EFalse, the user |
916 // is prompted to delete either the instance or the entire series. In this case, |
838 // is prompted to delete either the instance or the entire series. In this case, |
917 // aRepeatType is ignored. If aHasRepeatType is ETrue, aRepeatType determines |
839 // aRepeatType is ignored. If aHasRepeatType is ETrue, aRepeatType determines |
918 // whether to delete the instance or the entire series. |
840 // whether to delete the instance or the entire series. |
919 // (other items were commented in a header). |
841 // (other items were commented in a header). |
920 // ----------------------------------------------------------------------------- |
842 // ----------------------------------------------------------------------------- |
921 // |
843 // |
922 void CalenDeleteUi::DoDeleteSingleInstanceL( |
844 TBool CCalenDeleteUi::DoDeleteSingleInstanceL( CCalInstance* aInstance, |
923 AgendaEntry& aInstance, |
845 TBool aHasRepeatType, |
924 bool aHasRepeatType, |
846 CalCommon::TRecurrenceRange aRepeatType ) |
925 AgendaUtil::RecurrenceRange aRepeatType ) |
847 { |
926 { |
848 TRACE_ENTRY_POINT; |
927 OstTraceFunctionEntry0( CALENDELETEUI_DODELETESINGLEINSTANCEL_ENTRY ); |
849 |
928 |
850 CCalEntry& entry = aInstance->Entry(); |
929 bool repeating = aInstance.isRepeating(); |
851 const CCalEntry::TType entryType = entry.EntryTypeL(); |
930 |
852 RArray<TInt> colIdArray; |
931 if( !repeating ) { |
853 colIdArray.AppendL(aInstance->InstanceIdL().iCollectionId); |
932 // Even though there is no RRule, the entry might |
854 |
933 // have a list of rdates. |
855 |
934 QList<QDate> rDates = aInstance.rDates(); |
856 TCalRRule rrule; |
935 repeating = ( rDates.count() > 0 ); |
857 |
|
858 TBool repeating = entry.GetRRuleL( rrule ); |
|
859 |
|
860 if( !repeating ) |
|
861 { |
|
862 // Even though there is no RRule, the entry might |
|
863 // have a list of rdates. |
|
864 RArray< TCalTime > rDateArray; |
|
865 CleanupClosePushL( rDateArray ); |
|
866 entry.GetRDatesL( rDateArray ); |
|
867 repeating = ( rDateArray.Count() > 0 ); |
|
868 CleanupStack::PopAndDestroy(); // rDateArray |
|
869 } |
|
870 |
|
871 const TBool child = entry.RecurrenceIdL().TimeUtcL() != Time::NullTTime(); |
|
872 |
|
873 if( !aHasRepeatType ) |
|
874 { |
|
875 aRepeatType = CalCommon::EThisAndAll; |
|
876 } |
|
877 |
|
878 TBool doDelete( ETrue ); |
|
879 |
|
880 if( !aHasRepeatType && ( child || repeating ) && ( entryType != CCalEntry::EAnniv ) ) |
|
881 { |
|
882 doDelete = CalenActionUiUtils::ShowRepeatTypeQueryL( aRepeatType, |
|
883 CalenActionUiUtils::EDelete ); |
|
884 } |
|
885 else |
|
886 { |
|
887 doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( |
|
888 entryType == CCalEntry::ETodo ? |
|
889 CalenActionUiUtils::EDeleteToDo : |
|
890 CalenActionUiUtils::EDeleteEntry ); |
|
891 } |
|
892 |
|
893 if( doDelete ) |
|
894 { |
|
895 //Before deleteing the entry reset the attachment model |
|
896 if(iController.Services().GetAttachmentData()->NumberOfItems()) |
|
897 { |
|
898 iController.Services().GetAttachmentData()->Reset(); |
|
899 } |
|
900 |
|
901 if( !TryDeleteWithMrUtilsL( aInstance, aRepeatType ) ) |
|
902 { |
|
903 if( !child || aRepeatType == CalCommon::EThisOnly ) |
|
904 { |
|
905 iGlobalData->InstanceViewL(colIdArray)->DeleteL( aInstance, aRepeatType ); |
|
906 } |
|
907 else if( aRepeatType == CalCommon::EThisAndAll ) |
|
908 { |
|
909 // Unfortunately we can't pass the existing child instance through to the |
|
910 // InstanceView DeleteL function because even if we pass in EThisAndAll, it |
|
911 // only ever deletes the exception. We'll have to fetch the parent then |
|
912 // delete it via the entry view. |
|
913 RPointerArray<CCalEntry> entries; |
|
914 CleanupResetAndDestroyPushL( entries ); |
|
915 iGlobalData->EntryViewL(aInstance->InstanceIdL().iCollectionId)->FetchL( aInstance->Entry().UidL(), entries ); |
|
916 iGlobalData->EntryViewL(aInstance->InstanceIdL().iCollectionId)->DeleteL( *entries[0] ); |
|
917 CleanupStack::PopAndDestroy( &entries ); |
|
918 if( aInstance ) |
|
919 { |
|
920 delete aInstance; |
|
921 aInstance = NULL; |
|
922 } |
|
923 } |
|
924 else |
|
925 { |
|
926 User::Leave( KErrNotSupported ); |
|
927 } |
|
928 } |
|
929 } |
|
930 |
|
931 colIdArray.Reset(); |
|
932 TRACE_EXIT_POINT; |
|
933 return doDelete; |
|
934 } |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // CCalenDeleteUi::DeleteEntryL |
|
938 // Deletes an entry from the database |
|
939 // (other items were commented in a header). |
|
940 // ----------------------------------------------------------------------------- |
|
941 // |
|
942 TBool CCalenDeleteUi::DeleteEntryL( CCalEntryView* aEntryView, CCalEntry* aEntry ) |
|
943 { |
|
944 TRACE_ENTRY_POINT; |
|
945 const CCalEntry::TType entryType = aEntry->EntryTypeL(); |
|
946 |
|
947 TBool doDelete = CalenActionUiUtils::ShowDeleteConfirmationQueryL( |
|
948 entryType == CCalEntry::ETodo ? |
|
949 CalenActionUiUtils::EDeleteToDo : |
|
950 CalenActionUiUtils::EDeleteEntry ); |
|
951 if( doDelete ) |
|
952 { |
|
953 //Before deleteing the attachment, reset the attachment model |
|
954 if(iController.Services().GetAttachmentData()->NumberOfItems()) |
|
955 { |
|
956 iController.Services().GetAttachmentData()->Reset(); |
|
957 } |
|
958 aEntryView->DeleteL( *aEntry ); |
|
959 |
|
960 if( aEntry ) |
|
961 { |
|
962 delete aEntry; |
|
963 aEntry = NULL; |
|
964 } |
|
965 } |
|
966 |
|
967 TRACE_EXIT_POINT; |
|
968 return doDelete; |
|
969 } |
|
970 |
|
971 // ----------------------------------------------------------------------------- |
|
972 // CCalenDeleteUi::TryDeleteWithMrUtilsL |
|
973 // Attempt to delete the instance using the Meeting Request utilities, |
|
974 // if MR viewers is enabled. |
|
975 // (other items were commented in a header). |
|
976 // ----------------------------------------------------------------------------- |
|
977 // |
|
978 TBool CCalenDeleteUi::TryDeleteWithMrUtilsL( CCalInstance* aInstance, |
|
979 CalCommon::TRecurrenceRange aRepeatType ) |
|
980 { |
|
981 TRACE_ENTRY_POINT; |
|
982 |
|
983 TBool doDelete = ETrue; |
|
984 |
|
985 if( iGlobalData->InterimUtilsL().MRViewersEnabledL() && |
|
986 iGlobalData->InterimUtilsL().IsMeetingRequestL(aInstance->Entry())) |
|
987 |
|
988 { |
|
989 CMRMailboxUtils::TMailboxInfo info; |
|
990 if( iGlobalData->AttemptToRetrieveDefaultMailboxL( info ) ) |
|
991 { |
|
992 if(aRepeatType == CalCommon::EThisAndAll ) |
|
993 { |
|
994 aInstance->Entry().SetStartAndEndTimeL(aInstance->StartTimeL(),aInstance->EndTimeL()); |
|
995 iGlobalData->MeetingRequestUtilsL().DeleteWithUiL( aInstance->Entry(), |
|
996 info.iEntryId ); |
|
997 if( aInstance ) |
|
998 { |
|
999 delete aInstance; |
|
1000 aInstance = NULL; |
|
1001 } |
|
1002 } |
|
1003 else if( aRepeatType == CalCommon::EThisOnly ) |
|
1004 { |
|
1005 iGlobalData->MeetingRequestUtilsL().DeleteWithUiL( aInstance, info.iEntryId ); |
|
1006 } |
|
1007 else |
|
1008 { |
|
1009 User::Leave( KErrNotSupported ); |
|
1010 } |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 doDelete = EFalse; |
|
1015 } |
|
1016 } |
|
1017 else |
|
1018 { |
|
1019 doDelete = EFalse; |
|
1020 } |
|
1021 |
|
1022 TRACE_EXIT_POINT; |
|
1023 return doDelete; |
|
1024 } |
|
1025 |
|
1026 // ----------------------------------------------------------------------------- |
|
1027 // CCalenDeleteUi::ShowMultipleEntriesDeleteQueryL |
|
1028 // For displaying multiple entries deletion confirmation query |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // |
|
1031 TInt CCalenDeleteUi::ShowMultipleEntriesDeleteQueryL(TInt aCount) |
|
1032 { |
|
1033 TRACE_ENTRY_POINT; |
|
1034 |
|
1035 CAknQueryDialog *dialog = CAknQueryDialog::NewL( ); |
|
1036 CleanupStack::PushL( dialog ); |
|
1037 TInt resID; |
|
1038 HBufC* prompt; |
|
1039 if( aCount > 1 ) |
|
1040 { |
|
1041 resID = R_CALEN_QTN_TODO_QUEST_DELETE_MARKED_NOTES; |
|
1042 prompt = StringLoader::LoadLC( resID, aCount ); |
|
1043 } |
|
1044 else if( aCount == 1 ) |
|
1045 { |
|
1046 resID = R_CALEN_QTN_TODO_QUEST_DELETE_MARKED_NOTE; |
|
1047 prompt = StringLoader::LoadLC( resID ); |
|
1048 } |
|
1049 else |
|
1050 { |
|
1051 CleanupStack::PopAndDestroy( dialog ); |
|
1052 TRACE_EXIT_POINT; |
|
1053 return 0; //return 0 for other invalid aCount value ( < 0 ) |
|
1054 } |
|
1055 dialog->SetPromptL( *prompt ); |
|
1056 CleanupStack::PopAndDestroy( prompt ); |
|
1057 |
|
1058 CleanupStack::Pop( dialog ); |
|
1059 |
|
1060 TRACE_EXIT_POINT; |
|
1061 return dialog->ExecuteLD( R_CALEN_ERASEQUERY_NOTE ); |
|
1062 |
936 } |
1063 } |
937 QDateTime recId = aInstance.recurrenceId().toUTC(); |
1064 |
938 const bool child = recId.isNull(); |
1065 // ----------------------------------------------------------------------------- |
939 |
1066 // CCalenDeleteUi::DialogDismissedL |
940 if( !aHasRepeatType ) { |
|
941 aRepeatType = AgendaUtil::ThisAndAll; |
|
942 } |
|
943 // For later reference in handleDeletion() |
|
944 mRecurrenceRange = aRepeatType; |
|
945 |
|
946 if( !aHasRepeatType && ( child || repeating ) && |
|
947 ( aInstance.type() != AgendaEntry::TypeAnniversary ) ) { |
|
948 showRepeatingEntryDeleteQuery(); |
|
949 } |
|
950 else |
|
951 { |
|
952 showDeleteQuery(aInstance.type() == AgendaEntry::TypeTodo ? |
|
953 EDeleteToDo : |
|
954 EDeleteEntry ); |
|
955 } |
|
956 OstTraceFunctionExit0( CALENDELETEUI_DODELETESINGLEINSTANCEL_EXIT ); |
|
957 } |
|
958 |
|
959 |
|
960 // ----------------------------------------------------------------------------- |
|
961 // CalenDeleteUi::DialogDismissedL |
|
962 // From MProgressDialogCallback |
1067 // From MProgressDialogCallback |
963 // Callback method |
1068 // Callback method |
964 // called when a dialog is dismissed. |
1069 // called when a dialog is dismissed. |
965 // ----------------------------------------------------------------------------- |
1070 // ----------------------------------------------------------------------------- |
966 // |
1071 // |
967 void CalenDeleteUi::DialogDismissedL( const TInt /*aButtonId*/ ) |
1072 void CCalenDeleteUi::DialogDismissedL( const TInt /*aButtonId*/ ) |
968 { |
1073 { |
969 OstTraceFunctionEntry0( CALENDELETEUI_DIALOGDISMISSEDL_ENTRY ); |
1074 TRACE_ENTRY_POINT; |
|
1075 // dismiss the wait dialog |
|
1076 if(iWaitDialog) |
|
1077 { |
|
1078 iWaitDialog->ProcessFinishedL(); |
|
1079 } |
970 |
1080 |
971 // no more entries to delete |
1081 // no more entries to delete |
972 iMoreEntriesToDelete = EFalse; |
1082 iMoreEntriesToDelete = EFalse; |
973 iDisplayQuery = EFalse; |
1083 iDisplayQuery = EFalse; |
974 |
1084 |
975 // issue notification cancel delete |
1085 // issue notification cancel delete |
976 iController.BroadcastNotification(ECalenNotifyCancelDelete); |
1086 iController.BroadcastNotification(ECalenNotifyCancelDelete); |
977 |
1087 TRACE_EXIT_POINT; |
978 OstTraceFunctionExit0( CALENDELETEUI_DIALOGDISMISSEDL_EXIT ); |
1088 } |
979 } |
1089 |
980 |
1090 // ----------------------------------------------------------------------------- |
981 // ----------------------------------------------------------------------------- |
1091 // CCalenDeleteUi::DeleteEntryL |
982 // CalenDeleteUi::DeleteEntryL |
|
983 // Delete entry using entry local uid |
1092 // Delete entry using entry local uid |
984 // ----------------------------------------------------------------------------- |
1093 // ----------------------------------------------------------------------------- |
985 // |
1094 // |
986 void CalenDeleteUi::DeleteEntryL(ulong& aEntryLocalUid) |
1095 void CCalenDeleteUi::DeleteEntryL(TCalLocalUid& aEntryLocalUid, TInt aColId) |
987 { |
1096 { |
988 OstTraceFunctionEntry0( CALENDELETEUI_DELETEENTRYL_ENTRY ); |
1097 TRACE_ENTRY_POINT; |
989 |
1098 |
990 iController.Services().agendaInterface()->deleteEntry(aEntryLocalUid); |
1099 // fetch the entry |
991 |
1100 CCalEntry* entry = iGlobalData->EntryViewL(aColId)->FetchL(aEntryLocalUid); |
992 OstTraceFunctionExit0( CALENDELETEUI_DELETEENTRYL_EXIT ); |
1101 if( entry ) |
993 } |
1102 { |
994 |
1103 CleanupStack::PushL( entry ); |
995 // ----------------------------------------------------------------------------- |
1104 iGlobalData->EntryViewL(aColId)->DeleteL( *entry ); |
996 // CalenDeleteUi::DisplayWaitDialogL |
1105 CleanupStack::Pop( entry ); |
|
1106 delete entry; |
|
1107 entry = NULL; |
|
1108 } |
|
1109 |
|
1110 TRACE_EXIT_POINT; |
|
1111 } |
|
1112 |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // CCalenDeleteUi::DisplayWaitDialogL |
997 // Display wait dialog |
1115 // Display wait dialog |
998 // ----------------------------------------------------------------------------- |
1116 // ----------------------------------------------------------------------------- |
999 // |
1117 // |
1000 void CalenDeleteUi::DisplayWaitDialogL() |
1118 void CCalenDeleteUi::DisplayWaitDialogL() |
1001 { |
1119 { |
1002 OstTraceFunctionEntry0( CALENDELETEUI_DISPLAYWAITDIALOGL_ENTRY ); |
1120 TRACE_ENTRY_POINT; |
1003 |
1121 |
1004 OstTraceFunctionExit0( CALENDELETEUI_DISPLAYWAITDIALOGL_EXIT ); |
1122 delete iWaitDialog; |
1005 } |
1123 iWaitDialog = NULL; |
1006 |
1124 iWaitDialog = new( ELeave )CAknWaitDialog( REINTERPRET_CAST( CEikDialog**, &iWaitDialog ), ETrue ); |
1007 // ----------------------------------------------------------------------------- |
1125 iWaitDialog->ExecuteLD( R_TODO_VIEW_DELETE_WAIT_NOTE ); |
1008 // CalenDeleteUi::MarkedEntriesDeletedL |
1126 iWaitDialog->SetCallback(this); |
|
1127 |
|
1128 TRACE_EXIT_POINT; |
|
1129 } |
|
1130 |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // CCalenDeleteUi::MarkedEntriesDeletedL |
1009 // Dismiss wait dialog and show information note |
1133 // Dismiss wait dialog and show information note |
1010 // ----------------------------------------------------------------------------- |
1134 // ----------------------------------------------------------------------------- |
1011 // |
1135 // |
1012 void CalenDeleteUi::MarkedEntriesDeletedL() |
1136 void CCalenDeleteUi::MarkedEntriesDeletedL() |
1013 { |
1137 { |
1014 OstTraceFunctionEntry0( CALENDELETEUI_MARKEDENTRIESDELETEDL_ENTRY ); |
1138 TRACE_ENTRY_POINT; |
1015 |
1139 |
|
1140 // dismiss the waitdialog |
|
1141 if(iWaitDialog) |
|
1142 { |
|
1143 iWaitDialog->ProcessFinishedL(); |
|
1144 } |
|
1145 |
|
1146 // Show confirmation note |
|
1147 //HBufC* buf = StringLoader::LoadLC( R_QTN_CALE_CONF_ALL_NOTES_DELETED, iEikEnv ); |
|
1148 //CAknConfirmationNote* dialog = new( ELeave ) CAknConfirmationNote(); |
|
1149 //dialog->ExecuteLD(*buf); |
|
1150 //CleanupStack::PopAndDestroy( buf ); |
|
1151 |
1016 // notify marked entries deleted |
1152 // notify marked entries deleted |
1017 iController.BroadcastNotification( ECalenNotifyMarkedEntryDeleted ); |
1153 iController.BroadcastNotification( ECalenNotifyMarkedEntryDeleted ); |
1018 |
1154 |
1019 OstTraceFunctionExit0( CALENDELETEUI_MARKEDENTRIESDELETEDL_EXIT ); |
1155 TRACE_EXIT_POINT; |
1020 } |
1156 } |
1021 |
1157 |
|
1158 // ----------------------------------------------------------------------------- |
|
1159 // CCalenDeleteUi::HandleDeleteAllEntriesL |
|
1160 // Handles launching of the delete all entries list query |
|
1161 // ----------------------------------------------------------------------------- |
|
1162 // |
|
1163 void CCalenDeleteUi::HandleDeleteAllEntriesL() |
|
1164 { |
|
1165 TRACE_ENTRY_POINT; |
|
1166 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
1167 CleanupClosePushL(calendarInfoList); |
|
1168 iController.Services().GetAllCalendarInfoL(calendarInfoList); |
|
1169 TInt visibleCalendarsCount(0); |
|
1170 for(TInt index=0;index<calendarInfoList.Count();index++) |
|
1171 { |
|
1172 if(calendarInfoList[index]->Enabled()) |
|
1173 { |
|
1174 visibleCalendarsCount++; |
|
1175 } |
|
1176 if(visibleCalendarsCount>1) |
|
1177 { |
|
1178 break; |
|
1179 } |
|
1180 } |
|
1181 CleanupStack::PopAndDestroy(); |
|
1182 |
|
1183 TInt headingTextResourceId(0); |
|
1184 if(visibleCalendarsCount==1) |
|
1185 { |
|
1186 headingTextResourceId = R_CALE_SINGLE_CALENDAR_DELETE_ENTRIES; |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 headingTextResourceId = R_CALE_MULTI_CALENDAR_DELETE_ENTRIES; |
|
1191 } |
|
1192 |
|
1193 TInt selectedIndex(0); |
|
1194 CAknListQueryDialog* deleteEntriesListDialog = new(ELeave) CAknListQueryDialog(&selectedIndex); |
|
1195 deleteEntriesListDialog->PrepareLC(R_DELETE_ENTRIES_LIST_QUERY); |
|
1196 HBufC* buf = StringLoader::LoadLC( headingTextResourceId, iEikEnv ); |
|
1197 deleteEntriesListDialog->QueryHeading()->SetTextL(buf->Des()); |
|
1198 CleanupStack::PopAndDestroy( buf ); |
|
1199 |
|
1200 if(deleteEntriesListDialog->RunLD()) |
|
1201 { |
|
1202 if(selectedIndex) |
|
1203 { |
|
1204 DeleteAllEntriesL(); |
|
1205 } |
|
1206 else |
|
1207 { |
|
1208 DeleteEntriesBeforeDateL(); |
|
1209 } |
|
1210 } |
|
1211 else |
|
1212 { |
|
1213 iController.BroadcastNotification(ECalenNotifyDeleteFailed); |
|
1214 } |
|
1215 |
|
1216 TRACE_EXIT_POINT |
|
1217 } |
|
1218 |
1022 // End of File |
1219 // End of File |