|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declaration of Notepad List Dialog class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NPDLISTDIALOG_H |
|
20 #define NPDLISTDIALOG_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <eiklbo.h> |
|
24 #include <coeaui.h> |
|
25 #include <AknProgressDialog.h> |
|
26 #include <basched.h> |
|
27 #include "NpdDialogBase.h" |
|
28 #include "NpdModelObserver.h" |
|
29 #include <AiwServiceHandler.h> //For Application InterWorking |
|
30 #include <AiwCommon.h> |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CAknColumnListBox; |
|
34 class CNotepadModel; |
|
35 class CNotepadEditorDialog; |
|
36 class CSendUi; |
|
37 class CEnvironmentChangeNotifier; |
|
38 class CAknProgressDialog; |
|
39 class CAknAppUi; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 /** |
|
43 * Dialog of list mode. |
|
44 * CNotepadListDialog is a dialog for both list of memos and list of templates. |
|
45 * |
|
46 * @lib NpdLib.lib |
|
47 * @see CNotepadDialogBase |
|
48 */ |
|
49 class CNotepadListDialog : public CNotepadDialogBase, |
|
50 public MEikListBoxObserver, |
|
51 public MCoeViewObserver, |
|
52 public MNotepadModelObserver, |
|
53 public MProgressDialogCallback, |
|
54 public MAiwNotifyCallback |
|
55 { |
|
56 public: // Constructor and destructor |
|
57 enum TNotepadListBoxEvent |
|
58 { |
|
59 EOpenListBoxItem = 1, |
|
60 EOpenListBoxContextMenu |
|
61 }; |
|
62 /** |
|
63 * Constructor. |
|
64 * |
|
65 * @param aResId resource id of type STRUCT NOTEPAD_LIST_DIALOG |
|
66 * @param aSelfPtr pointer to pointer of this |
|
67 * @return Newly constructed CNotepadListDialog object. |
|
68 * @internal |
|
69 */ |
|
70 IMPORT_C static CNotepadListDialog* NewL( |
|
71 TInt aResId, |
|
72 CEikDialog** aSelfPtr ); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 IMPORT_C virtual ~CNotepadListDialog(); |
|
78 |
|
79 public: // New functions |
|
80 |
|
81 /** |
|
82 * Force to switch to editor mode. |
|
83 * |
|
84 * This API function is used when Notepad application is |
|
85 * opened from Pinboard application. |
|
86 * |
|
87 * When this API is called, Notepad status is changed to editor mode |
|
88 * and a memo whose key is aKey is displayed. |
|
89 * |
|
90 * If a memo whose key is equal to aKey doesn't exist or |
|
91 * aKey is equal to KNotepadPseudoKeyIdForNewNote(-1), |
|
92 * an empty Notepad editor for a new memo is displayed. |
|
93 * |
|
94 * @param aKey a unique memo id number. |
|
95 */ |
|
96 IMPORT_C void EditByKeyL(const TInt aKey); |
|
97 |
|
98 /** |
|
99 * If editor is running, save its contents if need. |
|
100 * This is called from CNotepadAppUi on shutdown. |
|
101 * |
|
102 * @internal |
|
103 * @see CNotepadEditorDialog::SaveL |
|
104 */ |
|
105 IMPORT_C void SaveL(); |
|
106 |
|
107 /** |
|
108 * Prepare to switch from editor mode to list mode. |
|
109 * This function is called when the editor has closed by |
|
110 * the right softkey 'Done'. |
|
111 * |
|
112 * @param aStatOfSave status of CNotepadEditorDialog::SaveL. |
|
113 * @param aKey a unique key id of the editing item. |
|
114 * @param aEagerSync if this is ETrue, it is necessary to refresh |
|
115 * CNotepadModel immediately. |
|
116 */ |
|
117 void HandleEditorExitL( |
|
118 TInt aStatOfSave, |
|
119 const TInt aKey, |
|
120 const TBool aEagerSync ); |
|
121 |
|
122 /** |
|
123 * Clear the iEditorDialog. |
|
124 * Called only from destructor of CNotepadEditorDialog. |
|
125 */ |
|
126 void EditorDeleted(); |
|
127 |
|
128 /** |
|
129 * Handle list box events |
|
130 * @param aEvent Listbox event type |
|
131 */ |
|
132 void HandleListBoxPointerEventL(TNotepadListBoxEvent aEvent); |
|
133 |
|
134 /** |
|
135 * From MiddleSoftKeyL |
|
136 * changes middle soft key |
|
137 */ |
|
138 void MiddleSoftKeyL(); |
|
139 /* |
|
140 * |
|
141 */ |
|
142 void ClearSaveOrMarkedListItemsL(TBool aFlag); |
|
143 |
|
144 private: // Constructor |
|
145 |
|
146 /** |
|
147 * Second phase constructor. |
|
148 * |
|
149 * @param aReader resource reader already opened for |
|
150 * "STRUCT NOTEPAD_LIST_DIALOG". |
|
151 */ |
|
152 void ConstructL(TResourceReader& aReader); |
|
153 |
|
154 private: // New functions |
|
155 |
|
156 /** |
|
157 * Start editor dialog. |
|
158 * |
|
159 */ |
|
160 void StartEditorL(); |
|
161 |
|
162 /** |
|
163 * Switch to empty editor mode. |
|
164 */ |
|
165 |
|
166 void OnCmdAddL(); |
|
167 |
|
168 /** |
|
169 * Switch to editor mode. |
|
170 * |
|
171 * @param aIndex ListBox item index to edit. |
|
172 */ |
|
173 void OnCmdOpenL( TInt aIndex ); |
|
174 |
|
175 /** |
|
176 * Show delete confirmation query and return the answer. |
|
177 * |
|
178 * @param aMemos # of items to delete. |
|
179 * @return ETrue if query confirmed Yes, otherwise EFalse. |
|
180 */ |
|
181 TBool ConfirmDeleteL(TInt aMemos); |
|
182 |
|
183 /** |
|
184 * Create key array of selected items. |
|
185 */ |
|
186 void CreateKeyArrayOfSelectionsL(); |
|
187 |
|
188 /** |
|
189 * Delete memos. |
|
190 */ |
|
191 void OnCmdDeleteL(); |
|
192 |
|
193 |
|
194 /** |
|
195 * Process Send Command. |
|
196 * |
|
197 */ |
|
198 void OnCmdSendL(TInt aCommandId); |
|
199 |
|
200 /** |
|
201 * Create iProgressDialog. |
|
202 * |
|
203 * @param aCount number of items to be processed. |
|
204 * @param aLabelResId a label text resource id. |
|
205 */ |
|
206 void CreateProgressDialogL( |
|
207 const TInt aCount, |
|
208 const TInt aLabelResId = 0 ); |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 /** |
|
214 * Main part of EditByKeyL. |
|
215 * |
|
216 * @param aKey a unique memo id number. |
|
217 */ |
|
218 void DoEditByKeyL(const TInt aKey); |
|
219 |
|
220 /** |
|
221 * Resource id of prompt text when deleting a single item. |
|
222 * |
|
223 * @return TBUF resource id. |
|
224 */ |
|
225 inline TInt QueryDeleteSingleResId() const; |
|
226 |
|
227 /** |
|
228 * Resource id of prompt text when deleting a single item. |
|
229 * |
|
230 * @return TBUF resource id. |
|
231 */ |
|
232 inline TInt QueryDeleteMultipleResId() const; |
|
233 |
|
234 /** |
|
235 * Environment change callback entry function. |
|
236 * |
|
237 * @param aThisPtr pointer to this. |
|
238 * @return always TRUE (callback should be called again). |
|
239 */ |
|
240 static TInt HandleEnvironmentChangedL(TAny* aThisPtr); |
|
241 |
|
242 /** |
|
243 * Environment change callback entry function. |
|
244 * |
|
245 * @return always TRUE (callback should be called again). |
|
246 */ |
|
247 TInt DoHandleEnvironmentChangedL(); |
|
248 |
|
249 /** |
|
250 */ |
|
251 void SaveCurrentAndSelectionsL(); |
|
252 |
|
253 /** |
|
254 */ |
|
255 void RestoreCurrentAndSelectionsL(); |
|
256 |
|
257 /** |
|
258 */ |
|
259 void RestoreCurrent(); |
|
260 |
|
261 /** |
|
262 */ |
|
263 void RestoreSelectionsL(); |
|
264 |
|
265 /** |
|
266 */ |
|
267 void ClearSavedCurrentAndSelections(); |
|
268 |
|
269 /** |
|
270 */ |
|
271 void AdjustTopItemIfNeed(); |
|
272 |
|
273 /** |
|
274 */ |
|
275 TBool AvoidSyncing() const; |
|
276 |
|
277 /** |
|
278 */ |
|
279 inline static TInt LevelOfActiveScheduler(); |
|
280 |
|
281 /** |
|
282 * Implementation of HandleViewEventL. |
|
283 * |
|
284 * @param aEvent view event type. |
|
285 */ |
|
286 void DoHandleViewEventL(const TVwsViewEvent& aEvent); |
|
287 |
|
288 /** |
|
289 * handle the mark/unmark/markall/unmarkall command |
|
290 * @param aResourceId the resouce id |
|
291 * @param aMenu the pane to be processed. |
|
292 * @param aListBox the refered list box for the pane. |
|
293 */ |
|
294 void HandleMarkListDynInitMenuPane( TInt aResourceId, CEikMenuPane *aMenu, CEikListBox *aListBox ); |
|
295 |
|
296 private: // Functions from base classes |
|
297 |
|
298 /** |
|
299 * From MNotepadModelObserver. |
|
300 */ |
|
301 void HandleNotepadModelEventL(TEvent aEvent, TInt aParam = 0); |
|
302 |
|
303 /** |
|
304 * From MEikMenuObserver. |
|
305 * |
|
306 * @param aResourceId resource id. |
|
307 * @param menu pane object. |
|
308 */ |
|
309 void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); |
|
310 |
|
311 |
|
312 /** |
|
313 * From MEikMenuObserver. |
|
314 * |
|
315 * @param aResourceId resource id. |
|
316 * @param menu Bar object. |
|
317 */ |
|
318 void DynInitMenuBarL(TInt aResourceId,CEikMenuBar* aMenuBar); |
|
319 |
|
320 |
|
321 /** |
|
322 * From MEikCommandObserver |
|
323 * |
|
324 * @param aCommandId command. |
|
325 */ |
|
326 void ProcessCommandL(TInt aCommandId); |
|
327 |
|
328 /** |
|
329 * From MCoeViewObserver |
|
330 * |
|
331 * @param aEvent view event type. |
|
332 */ |
|
333 void HandleViewEventL(const TVwsViewEvent& aEvent); |
|
334 |
|
335 /** |
|
336 * From MProgressDialogCallback. |
|
337 * |
|
338 * @param aButtonId button id which is derived from OkToExitL. |
|
339 */ |
|
340 void DialogDismissedL( TInt aButtonId ); |
|
341 |
|
342 /** |
|
343 * From CEikDialog. |
|
344 */ |
|
345 void PreLayoutDynInitL(); |
|
346 |
|
347 /** |
|
348 * From CEikDialog. |
|
349 */ |
|
350 void PostLayoutDynInitL(); |
|
351 |
|
352 /** |
|
353 * From CEikDialog. |
|
354 */ |
|
355 TBool OkToExitL( TInt aButtonId ); |
|
356 |
|
357 /** |
|
358 * From MEikListBoxObserver. |
|
359 * |
|
360 * @param aListBox List box object. |
|
361 * @param aEventType event type. |
|
362 */ |
|
363 void HandleListBoxEventL( |
|
364 CEikListBox* aListBox, |
|
365 TListBoxEvent aEventType ); |
|
366 |
|
367 /** |
|
368 * From CCoeControl. |
|
369 * |
|
370 * @param aContext TCoeHelpContext. |
|
371 */ |
|
372 void GetHelpContext(TCoeHelpContext& aContext) const; |
|
373 |
|
374 /** |
|
375 * From CCoeControl |
|
376 * |
|
377 * @param aKeyEvent key event which includes ScanCode etc. |
|
378 * @param aType event type ( up, in, down...). |
|
379 */ |
|
380 TKeyResponse OfferKeyEventL( |
|
381 const TKeyEvent& aKeyEvent, |
|
382 TEventCode aType); |
|
383 |
|
384 private: // From MAiwNotifyCallback |
|
385 /** |
|
386 * Handles any notification caused by asynchronous ExecuteCommandL |
|
387 * or event. |
|
388 * @param aCmdId Service command associated to the event. |
|
389 * @param aEventId Occured event |
|
390 * @param aEventParamList Event parameters, if any, as defined per |
|
391 * each event. |
|
392 * @param aInParamList Input parameters, if any, given in the |
|
393 * related HandleCommmandL |
|
394 * @return error code for the callback |
|
395 */ |
|
396 TInt HandleNotifyL( TInt aCmdId, |
|
397 TInt aEventId, |
|
398 CAiwGenericParamList& aEventParamList, |
|
399 const CAiwGenericParamList& aInParamList |
|
400 ); |
|
401 |
|
402 /** |
|
403 * From CEikColumnListBox/CCoeControl |
|
404 * |
|
405 * @param aType event type. |
|
406 */ |
|
407 void HandleResourceChange(TInt aType); |
|
408 |
|
409 private: // Reserved |
|
410 |
|
411 /** |
|
412 * Reserved API entry. |
|
413 * |
|
414 * @internal |
|
415 */ |
|
416 IMPORT_C void CNotepadListDialog_Reserved(); |
|
417 |
|
418 CAiwGenericParamList* AiwSyncParamListLC(TInt /*aApplicationId*/); |
|
419 |
|
420 private: // Inner class |
|
421 |
|
422 /** |
|
423 * CNotepadIdle override CIdle to add Restart function and |
|
424 * internal state. |
|
425 */ |
|
426 class CNotepadIdle : public CIdle |
|
427 { |
|
428 public: // Constructor and destructor |
|
429 static CNotepadIdle* NewLC(const TInt aMarkCount); |
|
430 ~CNotepadIdle(); |
|
431 public: // New functions |
|
432 inline TInt MarkCountWhenStarted() const; |
|
433 private: // Constructors |
|
434 inline CNotepadIdle(const TInt aMarkCount); |
|
435 void ConstructL(); |
|
436 private: // Data |
|
437 TInt iMarkCount; |
|
438 }; |
|
439 |
|
440 class CKludgeScheduler : public CBaActiveScheduler |
|
441 { |
|
442 public: |
|
443 inline TInt PublicLevel() const; |
|
444 }; |
|
445 |
|
446 class CNotepadProgressDialog : public CAknProgressDialog |
|
447 { |
|
448 public: // Constructor and destructor |
|
449 CNotepadProgressDialog( |
|
450 CEikDialog** aSelfPtr, |
|
451 TBool aVisibilityDelayOff ); |
|
452 ~CNotepadProgressDialog(); |
|
453 public: // New functions |
|
454 void PrepareL( const TInt aCount, const TInt aLabelResId ); |
|
455 void IncrementL( const TInt aIncrement ); |
|
456 inline CEikProgressInfo* ProgressInfo() const; |
|
457 public: // From CAknProgressDialog |
|
458 void ProcessFinishedL(); |
|
459 private: // Data |
|
460 CEikProgressInfo* iProgressInfo; // not own, set in PrepareL |
|
461 CArrayFix<TInt>* iInts; // own |
|
462 }; |
|
463 |
|
464 private: // Data |
|
465 |
|
466 /** |
|
467 * Flags set to iFlags. |
|
468 */ |
|
469 enum TNotepadListFlags |
|
470 { |
|
471 ENotepadObserveView = 0x01, |
|
472 ENotepadItemAdded = 0x02, |
|
473 ENotepadMenuByOkKey = 0x04, |
|
474 ENotepadEverEnvironmentChanged = 0x08, |
|
475 ENotepadEverViewDeactivated = 0x10, |
|
476 ENotepadIsBackground = 0x20 |
|
477 }; |
|
478 |
|
479 CNotepadModel* iModel; // own |
|
480 CAknColumnListBox* iListBox; // not own (dialog own) |
|
481 TInt iEditorResId; |
|
482 CNotepadEditorDialog* iEditorDialog; // own |
|
483 CSendUi* iSendUi; // own |
|
484 TInt iSavedKey; |
|
485 TUint iFlags; |
|
486 CAknAppUi* iBaseAppUi; // not own. to know whether SendUi is running |
|
487 CNotepadIdle* iIdle; // own |
|
488 CNotepadProgressDialog* iProgressDialog; // own |
|
489 RArray<TInt> iSavedSelectedKeys; // save keys to delete |
|
490 RArray<TInt> iSavedKeysAboveCurrent; |
|
491 CEnvironmentChangeNotifier* iEnvironmentChangeNotifier; // own |
|
492 TInt iBaseLevelOfActiveScheduler; |
|
493 CAiwServiceHandler* iServiceHandler; /// Own: AIW |
|
494 TBool iSendingEmail; |
|
495 TBool iClockValueChange; |
|
496 TBool shiftflag; |
|
497 TBool iEditorFlag; |
|
498 TBool iNeedSave; |
|
499 TTimeFormat iPreTimeFormat; |
|
500 TTimeFormat iCurrentTimeFormat; |
|
501 }; |
|
502 |
|
503 #include "NpdListDialog.inl" |
|
504 #endif // NPDLISTDIALOG_H |
|
505 |
|
506 // End of File |