9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Controller class for deleting related UI behavior |
14 * Description: Controller class for deleting related UI behavior |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
|
20 #ifndef CALENDELETEUI_H |
19 #ifndef CALENDELETEUI_H |
21 #define CALENDELETEUI_H |
20 #define CALENDELETEUI_H |
22 |
21 |
23 // INCLUDES |
22 // System Includes |
|
23 #include <QObject> |
24 #include <e32base.h> |
24 #include <e32base.h> |
25 #include <calcommon.h> |
25 #include <hbdatetimepicker.h> |
26 #include <eikenv.h> |
26 #include <agendautil.h> |
27 #include <AknWaitDialog.h> |
27 |
28 #include <calprogresscallback.h> |
28 //User Includes |
29 #include <calencommandhandler.h> |
29 #include "calenactionuiutils.h" |
30 #include <calennotificationhandler.h> |
30 #include "calennotificationhandler.h" |
31 #include <calenactionuiutils.h> |
31 #include "calencommandhandler.h" |
|
32 #include "hb_calencommands.hrh" |
32 |
33 |
33 // FORWARD DECLARATIONS |
34 // FORWARD DECLARATIONS |
34 class CAknWaitDialog; |
|
35 class CCalenGlobalData; |
|
36 class CCalenController; |
35 class CCalenController; |
37 class CCalInstanceView; |
36 class HbAction; |
38 class CCalInstance; |
37 |
39 class CCalEntry; |
38 enum TDeleteConfirmationType |
40 class CCalEntryView; |
39 { |
|
40 EDeleteEntry = 1, |
|
41 EDeleteToDo, |
|
42 EDeleteToDos, |
|
43 EDeleteAll, |
|
44 EDeleteEvent |
|
45 }; |
41 |
46 |
42 // CLASS DECLARATION |
47 // CLASS DECLARATION |
43 /** |
48 /** |
44 * CCalenDeleteUi encapsulates deleting related behavior |
49 * CalenDeleteUi encapsulates deleting related behavior |
45 * in Calendar application. |
50 * in Calendar application. |
46 */ |
51 */ |
47 NONSHARABLE_CLASS( CCalenDeleteUi ) : public CBase, |
52 class CalenDeleteUi : public QObject, |
48 public MCalProgressCallBack, |
53 public MCalenNotificationHandler, |
49 public MCalenNotificationHandler, |
54 public MCalenCommandHandler |
50 public MCalenCommandHandler, |
55 |
51 public MProgressDialogCallback |
|
52 { |
56 { |
53 |
57 Q_OBJECT |
54 public: // public API |
58 |
55 |
59 public: // public API |
56 /** |
60 /** |
57 * Symbian 1st phase constructor |
61 * Symbian 1st phase constructor |
58 * @param aController Reference to CCalenController |
62 * @param aController Reference to CCCalenController |
59 */ |
63 */ |
60 static CCalenDeleteUi* NewL( CCalenController& aController ); |
64 static CalenDeleteUi* NewL(CCalenController& aController ); |
61 |
65 |
62 /** |
66 /** |
63 * Destructor |
67 * Destructor |
64 */ |
68 */ |
65 virtual ~CCalenDeleteUi(); |
69 virtual ~CalenDeleteUi(); |
66 |
70 |
67 public: // From MCalenCommandHandler |
71 public: // MCalenCommandHandler |
68 |
72 /** |
69 /** |
73 * Handles action ui commands |
70 * Handles key presses. |
74 * @param aCommand Command to be handled |
71 * |
75 */ |
72 * @param aCommand The command Id of the key. |
76 TBool HandleCommandL( const TCalenCommand& aCommand ); |
73 */ |
77 |
74 TBool HandleCommandL( const TCalenCommand& aCommand ); |
78 public: // New functions |
75 |
79 /** |
76 /** |
80 * UI sequence for deleting single entry. Shows UI queries and notes and |
77 * Allows extending this API without breaking BC. |
81 * performs delete. Current entry is taken from Calendar Context |
78 * |
82 */ |
79 * @param aExtensionUid specifies |
83 void DeleteCurrentEntryL(); |
80 * @return extension of the requested type |
84 |
81 */ |
85 /** |
82 TAny* CalenCommandHandlerExtensionL( TUid aExtensionUid ); |
86 * UI sequence for deleting all entries. Shows UI queries and notes and |
83 |
87 * performs delete asynchronosuly. |
84 public: // New functions |
88 */ |
85 /** |
89 void DeleteAllEntriesL(); |
86 * UI sequence for deleting single entry. Shows UI queries and notes and |
90 |
87 * performs delete. Current entry is taken from Calendar Context |
91 /** |
88 */ |
92 * UI sequence for deleting entries before given date. |
89 void DeleteCurrentEntryL(); |
93 * Shows UI queries and notes and performs delete asynchronosuly. |
90 |
94 */ |
91 /** |
95 void DeleteEntriesBeforeDateL(); |
92 * UI sequence for deleting all entries. Shows UI queries and notes and |
96 |
93 * performs delete asynchronosuly. |
97 /** |
94 */ |
98 * UI sequence for deleting series repeating entry |
95 void DeleteAllEntriesL(); |
99 * Becasue a ThisAndAll repeat type has already been chosen by user, |
96 |
100 * no repeat query is required. Performs delete asynchronosuly. |
97 /** |
101 */ |
98 * UI sequence for deleting entries before given date. |
102 void DeleteThisOrAllL( AgendaUtil::RecurrenceRange aRepeatType ); |
99 * Shows UI queries and notes and performs delete asynchronosuly. |
103 |
100 */ |
104 public: // from MCalenNotificationHandler |
101 void DeleteEntriesBeforeDateL(); |
105 /** |
102 |
106 * Handle notifications |
103 /** |
107 * @param aNotification Notification to be handled |
104 * UI sequence for deleting series repeating entry |
108 */ |
105 * Becasue a ThisAndAll repeat type has already been chosen by user, |
109 void HandleNotification(const TCalenNotification aNotification ); |
106 * no repeat query is required. Performs delete asynchronosuly. |
110 |
107 */ |
111 private: // own methods |
108 void DeleteThisOrAllL( CalCommon::TRecurrenceRange aRepeatType ); |
112 /** |
109 |
113 * Handles deleting all entries in time range from aFirstDay to aLastDay. |
110 public: // from MCalenNotificationHandler |
114 * Shows wait notification and given confirmation notifications. |
111 /** |
115 */ |
112 * Handle notifications |
116 void HandleDeleteMultipleEventsL( const QDateTime& aFirstDay, |
113 * @param aNotification Notification to be handled |
117 const QDateTime& aLastDay, |
114 */ |
118 int aConfNoteId ); |
115 void HandleNotification(const TCalenNotification aNotification ); |
119 |
116 |
120 /** |
117 private: // From MCalProgressCallBack |
121 * Delete entries from given range |
118 /** |
122 */ |
119 * From MCalProgressCallBack |
123 void DeleteDayRangeL( const QDateTime& aStart, const QDateTime& aEnd ); |
120 */ |
124 |
121 void Completed( TInt aError ); |
125 /** |
122 |
126 * Delete entries than end at given midnight. |
123 /** |
127 * This is needed when deleting multiple entries, to handle |
124 * From MCalProgressCallBack |
128 * e.g all-day notes that extends to next day's midnight. |
125 */ |
129 */ |
126 TBool NotifyProgress(); |
130 void deleteEntriesEndingAtMidnight( QDateTime aMidnight ); |
127 |
131 |
128 /** |
132 /** |
129 * From MCalProgreeCallBack |
133 * Delete entry without querying the user |
130 */ |
134 */ |
131 void Progress( TInt aPercentageCompleted ); |
135 TBool DeleteEntryWithoutQueryL(); |
132 |
136 |
133 private: // own methods |
137 /** |
134 /** |
138 * Delete the given entry. Ask the user whether to delete the |
135 * Handles deleting all entries in time range from aFirstDay to aLastDay. |
139 * instance or the entire series. |
136 * Shows wait notification and given confirmation notifications. |
140 */ |
137 */ |
141 void DeleteSingleInstanceL( AgendaEntry& aInstance ); |
138 void HandleDeleteMultipleEventsL( const TTime& aFirstDay, |
142 |
139 const TTime& aLastDay, |
143 /** |
140 TInt aConfNoteId ); |
144 * Delete the given entry, using aRepeatType to determine |
141 |
145 * whether to delete the instance or the entire series. |
142 /** |
146 */ |
143 * Delete entries from given range |
147 void DeleteSingleInstanceL( AgendaEntry& aInstance, |
144 */ |
148 AgendaUtil::RecurrenceRange aRepeatType ); |
145 void DeleteDayRangeL( const TTime& aStart, const TTime& aEnd ); |
149 |
146 |
150 /** |
147 /** |
151 * Delete single instance. |
148 * Delete entries than end at given midnight. |
152 * @param aInstance Pointer to the instance to be deleted |
149 * This is needed when deleting multiple entries, to handle |
153 * @param aHasRepeatType Whether or not the instance is repeating |
150 * e.g all-day notes that extends to next day's midnight. |
154 * @param aRepeatType Repeat type choosen to apply on delete |
151 */ |
155 * @return ETrue is user confirms to delete, EFalse otherwise |
152 void DeleteEntriesEndingAtMidnightL( TTime aMidnight ); |
156 */ |
153 |
157 void DoDeleteSingleInstanceL( AgendaEntry& aInstance, |
154 /** |
158 bool aHasRepeatType, |
155 * just a wrapper for leave |
159 AgendaUtil::RecurrenceRange aRepeatType ); |
156 */ |
160 |
157 void DoCompletedL( TInt aFirstPassError ); |
161 /** |
158 |
162 * Leaving function, handle ECalenNotifyViewCreated |
159 /** |
163 */ |
160 * Delete entry by passing CCalEntryView and CCalEntry |
164 void HandleECalenNotifyViewCreatedL(); |
161 * Will query user for confirmation before deletion |
165 |
162 * @return ETrue user confirms to delete EFalse otherwise |
166 /** |
163 */ |
167 * Get the date from user. |
164 TBool DeleteEntryL( CCalEntryView* aEntryView, CCalEntry* aEntry ); |
168 */ |
165 |
169 void dateQuery(); |
166 /** |
170 |
167 * Delete entry without querying the user |
171 /** |
168 */ |
172 * Shows a confirmation query to the user if |
169 TBool DeleteEntryWithoutQueryL(); |
173 * he/she wants to delete the particular instance |
170 |
174 * or the entire series of a repeating entry |
171 /** |
175 */ |
172 * Delete the given entry. Ask the user whether to delete the |
176 void showRepeatingEntryDeleteQuery(); |
173 * instance or the entire series. |
177 |
174 */ |
178 /** |
175 TBool DeleteSingleInstanceL( CCalInstance* aInstance ); |
179 * Shows a confirmation query to the user if |
176 |
180 * he/she wants to delete instance/instances |
177 /** |
181 */ |
178 * Delete the given entry, using aRepeatType to determine |
182 void showDeleteQuery(const TDeleteConfirmationType type, |
179 * whether to delete the instance or the entire series. |
183 const int count = 0); |
180 */ |
184 |
181 TBool DeleteSingleInstanceL( CCalInstance* aInstance, |
185 private: // own methods |
182 CalCommon::TRecurrenceRange aRepeatType ); |
186 /** |
183 |
187 * C++ constructor |
184 /** |
188 */ |
185 * Show the confirmation query with confirmation type and number of entries this query is for |
189 CalenDeleteUi( CCalenController& aController, QObject *parent = 0 ); |
186 * @param aType Type of query: EDeleteEntry/ EDeleteTodo/ EDeleteTodos/ EDeleteAll |
190 |
187 */ |
191 /** |
188 TInt ShowDeleteConfirmationQueryL( const CalenActionUiUtils::TDeleteConfirmationType aType, |
192 * Symbian 2nd phase constructor |
189 const TInt aCount=0 ); |
193 */ |
190 |
194 void ConstructL(); |
191 /** |
195 |
192 * Delete single instance. |
196 protected: // Methods derived from MProgressDialogCallback |
193 * @param aInstance Pointer to the instance to be deleted |
197 /** |
194 * @param aHasRepeatType Whether or not the instance is repeating |
198 * From MProgressDialogCallback |
195 * @param aRepeatType Repeat type choosen to apply on delete |
199 * Callback method |
196 * @return ETrue is user confirms to delete, EFalse otherwise |
200 * called when a dialog is dismissed |
197 */ |
201 */ |
198 TBool DoDeleteSingleInstanceL( CCalInstance* aInstance, |
202 void DialogDismissedL( const int aButtonId ); |
199 TBool aHasRepeatType, |
203 |
200 CalCommon::TRecurrenceRange aRepeatType ); |
204 public slots: |
201 |
205 |
202 /** |
206 void doCompleted( int aFirstPassError ); |
203 * Attempt to delete the instance using the Meeting Request utilities, |
207 void handleDateQuery(HbAction* action); |
204 * if MR viewers is enabled. |
208 void handleDeletion(HbAction* action); |
205 * @param aInstance Pointer to the instance to be delete |
209 void handleDeleteCancel(); |
206 * @param aRepeatType Repeat Type choosen to apply on delete |
210 |
207 * @return ETrue if user confirms to delete, EFalse otherwise |
211 private slots: |
208 */ |
212 void handleRepeatedEntryDelete(int index); |
209 TBool TryDeleteWithMrUtilsL( CCalInstance* aInstance, |
213 void entryDeleted(ulong id); |
210 CalCommon::TRecurrenceRange aRepeatType ); |
214 |
211 |
215 private: |
212 /** |
216 |
213 * Leaving function, handle ECalenNotifyViewCreated |
217 /** |
214 */ |
218 * Delete entry using entry local uid |
215 void HandleECalenNotifyViewCreatedL(); |
219 */ |
216 |
220 void DeleteEntryL(ulong& aEntryLocalUid); |
217 /** |
221 |
218 * Multiple entries delete query |
222 /** |
219 */ |
223 * Displays wait dialog while deleting marked entries |
220 TInt ShowMultipleEntriesDeleteQueryL(TInt aCount); |
224 */ |
221 |
225 void DisplayWaitDialogL(); |
222 private: // own methods |
226 |
223 /** |
227 /** |
224 * C++ constructor |
228 * Dismiss wait dialog and show information note |
225 */ |
229 */ |
226 CCalenDeleteUi( CCalenController& aController ); |
230 void MarkedEntriesDeletedL(); |
227 |
231 |
228 /** |
232 private: // data |
229 * Symbian 2nd phase constructor |
233 |
230 */ |
234 bool iIsDeleting; // True, if asynchronous delete is running |
231 void ConstructL(); |
235 QDateTime iStartTime; |
232 |
236 QDateTime iEndTime; |
233 protected: // Methods derived from MProgressDialogCallback |
237 HbDateTimePicker *mDatePicker; |
234 /** |
238 HbAction *mDeleteAction; |
235 * From MProgressDialogCallback |
239 HbAction *mCancelAction; |
236 * Callback method |
240 // Confirmation note id is stored here. Note is shown when asynchronous |
237 * called when a dialog is dismissed |
241 // delete completes. |
238 */ |
242 int iConfirmationNoteId; |
239 void DialogDismissedL( const TInt aButtonId ); |
243 CCalenController& iController; |
240 |
244 TCalenCommandId mDeleteCommand; |
241 private: |
245 AgendaUtil::RecurrenceRange mRecurrenceRange; |
242 |
246 |
243 /** |
247 // Stored command if the entry view |
244 * Delete entry using entry local uid |
248 // needs to constructed asyncronously |
245 */ |
249 TCalenCommand iStoredCommand; |
246 void DeleteEntryL(TCalLocalUid& aEntryLocalUid, TInt aColId ); |
250 int iMutlipleContextIdsCount; |
247 |
251 bool iMoreEntriesToDelete; |
248 /** |
252 bool iDisplayQuery; |
249 * Displays wait dialog while deleting marked entries |
253 int iEntriesToDelete; |
250 */ |
|
251 void DisplayWaitDialogL(); |
|
252 |
|
253 /** |
|
254 * Dismiss wait dialog and show information note |
|
255 */ |
|
256 void MarkedEntriesDeletedL(); |
|
257 |
|
258 /** |
|
259 * Handles launching of the delete entries list query |
|
260 */ |
|
261 void HandleDeleteAllEntriesL(); |
|
262 |
|
263 private: // data |
|
264 |
|
265 CEikonEnv* iEikEnv; |
|
266 CAknWaitDialog* iWaitDialog; |
|
267 |
|
268 TBool iIsDeleting; // True, if asynchronous delete is running |
|
269 TTime iStartTime; |
|
270 TTime iEndTime; |
|
271 // Confirmation note id is stored here. Note is shown when asynchronous |
|
272 // delete completes. |
|
273 TInt iConfirmationNoteId; |
|
274 CCalenGlobalData* iGlobalData; |
|
275 CCalenController& iController; |
|
276 |
|
277 // Stored command if the entry view |
|
278 // needs to constructed asyncronously |
|
279 TCalenCommand iStoredCommand; |
|
280 TInt iMutlipleContextIdsCount; |
|
281 TBool iMoreEntriesToDelete; |
|
282 TBool iDisplayQuery; |
|
283 TInt iEntriesToDelete; |
|
284 TInt iToShowDeleteNote; |
|
285 TInt iNumberOfCalendars; |
|
286 |
|
287 RArray<TInt> iDeleteColIds; |
|
288 CalCommon::TCalTimeRange *iDelAllRange; |
|
289 |
|
290 }; |
254 }; |
291 |
255 |
292 #endif // CALENDELETEUI_H |
256 #endif // CALENDELETEUI_H |
293 |
257 |
294 // End of File |
258 // End of File |