|
1 /* |
|
2 * Copyright (c) 2007-2008 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: FreestyleEmailUi folder list visualiser definition |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __FREESTYLEEMAILUI_FOLDERLISTVISUALISER_H__ |
|
21 #define __FREESTYLEEMAILUI_FOLDERLISTVISUALISER_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 //<cmail> |
|
27 #include "fstreelistconstants.h" |
|
28 //</cmail> |
|
29 |
|
30 #include "FreestyleEmailUiConstants.h" |
|
31 #include "FreestyleEmailUiViewBase.h" |
|
32 #include "FreestyleEmailUiControlBarCallback.h" |
|
33 #include "fstreelistobserver.h" |
|
34 #include <alf/alfanchorlayout.h> |
|
35 #include <alf/alfimagebrush.h> |
|
36 // forward declarations |
|
37 class CAlfTextVisual; |
|
38 class CAlfGridLayout; |
|
39 class CAlfImageVisual; |
|
40 class CAlfDeckLayout; |
|
41 class CAlfAnchorLayout; |
|
42 class CFSEmailUiFolderListControl; |
|
43 class CFSEmailUiFolderListModel; |
|
44 class CAlfBorderBrush; |
|
45 class CFSMailMessage; |
|
46 class CScrollerTimer; |
|
47 class CMessageChangerTimer; |
|
48 class CFreestyleEmailUiTextureManager; |
|
49 class CFreestyleEmailUiAppUi; |
|
50 |
|
51 class CFsTreeVisualizerBase; |
|
52 class CFsTreeList; |
|
53 |
|
54 class MFsTreeItemVisualizer; |
|
55 class CFsTreePlainOneLineItemData; |
|
56 class CFsTreePlainOneLineNodeData; |
|
57 class CFsTreePlainOneLineItemVisualizer; |
|
58 class CFsTreePlainOneLineNodeVisualizer; |
|
59 class MFsControlButtonInterface; |
|
60 |
|
61 class TFSMailMsgId; |
|
62 class CFSMailClient; |
|
63 class CFSMailBox; |
|
64 class CFSMailFolder; |
|
65 |
|
66 class CAlfFrameBrush; |
|
67 |
|
68 //REMOVE WHEN DONE TESTING |
|
69 //class CSimpleAOTest; |
|
70 // <cmail> Touch |
|
71 class CFSEmailUiFolderListVisualiser : public CFsEmailUiViewBase, public MFsTreeListObserver |
|
72 // </cmail> |
|
73 { |
|
74 public: // Data types |
|
75 enum TExpandCollapseType |
|
76 { |
|
77 EFolderListExpand, |
|
78 EFolderListCollapse, |
|
79 EFolderListAutomatic |
|
80 }; |
|
81 |
|
82 public: // Construction and destruction |
|
83 /** |
|
84 * Destructor |
|
85 */ |
|
86 ~CFSEmailUiFolderListVisualiser(); |
|
87 |
|
88 /** |
|
89 * Two phase constructors |
|
90 * |
|
91 * @param aEnv Alfred environmet |
|
92 * @param aControlGroup Alfred control group |
|
93 * @param aAppUi Application main UI class |
|
94 * @return Pointer to newly created object |
|
95 */ |
|
96 static CFSEmailUiFolderListVisualiser* NewL( CAlfEnv& aEnv, |
|
97 CAlfControlGroup& aControlGroup, |
|
98 CFreestyleEmailUiAppUi& aAppUi ); |
|
99 static CFSEmailUiFolderListVisualiser* NewLC( CAlfEnv& aEnv, |
|
100 CAlfControlGroup& aControlGroup, |
|
101 CFreestyleEmailUiAppUi& aAppUi ); |
|
102 |
|
103 public: // From base class CAknView |
|
104 void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); |
|
105 void HandleCommandL( TInt aCommand ); |
|
106 TUid Id() const; |
|
107 // <cmail> Toolbar |
|
108 /* |
|
109 void ChildDoActivateL( const TVwsViewId& aPrevViewId, |
|
110 TUid aCustomMessageId, |
|
111 const TDesC8& aCustomMessage );*/ |
|
112 // </cmail> Toolbar |
|
113 void ChildDoDeactivate(); |
|
114 void DoTransitionEffect( TBool aDirectionOut ); |
|
115 void GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const; |
|
116 |
|
117 public: // Own public functions |
|
118 |
|
119 virtual TBool HandleWsEventL( const TWsEvent& aEvent ); |
|
120 |
|
121 // Handle foreground event (called by FreestyleEmailUiMailListVisualiser) |
|
122 void HandleForegroundEventL(); |
|
123 |
|
124 /** |
|
125 * Dynamic switch handling and background updating |
|
126 */ |
|
127 void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType ); |
|
128 |
|
129 /** |
|
130 * Event handling forwarded from control |
|
131 * |
|
132 * @param aEvent Event forwarded from control |
|
133 * @return ETrue if event was consumed, otherwise EFalse |
|
134 */ |
|
135 TBool OfferEventL( const TAlfEvent& aEvent ); |
|
136 |
|
137 // <cmail> Touch |
|
138 /** |
|
139 * Handling pointer events. |
|
140 * |
|
141 * @param aEvent Event forwarded from control |
|
142 * @return ETrue if event was consumed, otherwise EFalse |
|
143 */ |
|
144 TBool HandlePointerEventL(const TAlfEvent& aEvent); |
|
145 // </cmail> |
|
146 |
|
147 /** |
|
148 * Expands or collpases the currently highlighted folder |
|
149 */ |
|
150 void ExpandOrCollapseL( const TExpandCollapseType& aType ); |
|
151 |
|
152 /** |
|
153 * Tells wheter the folder list is shown in full screen or in popup |
|
154 * |
|
155 * @return ETrue if list is shown in fullscreen, otherwise EFalse |
|
156 */ |
|
157 TBool IsFullScreen() const; |
|
158 |
|
159 /** |
|
160 * Show folder list in control bar popup |
|
161 * |
|
162 * @param aFolderId Folder id of the currently visible folder in mail list |
|
163 * @param aCallback Call back to inform the result of the folder query |
|
164 * @param aButton Control bar button from where the popup is opened |
|
165 */ |
|
166 void ShowInPopupL( const TFSMailMsgId aFolderId, |
|
167 MFSEmailUiFolderListCallback* aCallback, |
|
168 MFsControlButtonInterface* aButton = NULL ); |
|
169 |
|
170 /** |
|
171 * Quick and dirty solution to show the sort list with the same list. |
|
172 * Could be changed to some more elegant implementation (e.g. folder list |
|
173 * and sort list derive from some generic control base class that |
|
174 * implements the common operations), if time permits. |
|
175 * |
|
176 * @param aCurrentSortOrder Current sort order in mail list |
|
177 * @param aFolderType Folder type of the currently visible folder in mail list |
|
178 * @param aCallback Call back to inform the result of the sort order query |
|
179 * @param aButton Control bar button from where the popup is opened |
|
180 */ |
|
181 void ShowSortListPopupL( const TFSMailSortField aCurrentSortOrder, |
|
182 const TFSFolderType aFolderType, |
|
183 MFSEmailUiSortListCallback* aCallback, |
|
184 MFsControlButtonInterface* aButton = NULL ); |
|
185 |
|
186 /** |
|
187 * Does a horizontal scroll for the list if needed |
|
188 * |
|
189 * @param aForceRecalculation If ETrue, recalculates the list rect always. |
|
190 * If EFalse, recalculates the list rect only |
|
191 * if list level has changed. |
|
192 */ |
|
193 void DoHorizontalScrollL( TBool aForceRecalculation = EFalse ); |
|
194 |
|
195 /** |
|
196 * Function to check whether folder list is displaying popup |
|
197 */ |
|
198 TBool IsPopupShown(); |
|
199 |
|
200 /** |
|
201 * Function to hide popup |
|
202 */ |
|
203 void HidePopupL(); |
|
204 |
|
205 /** |
|
206 * From MFsTreeListObserver |
|
207 */ |
|
208 // <cmail> Touch |
|
209 void TreeListEventL( const TFsTreeListEvent aEvent, |
|
210 const TFsTreeItemId aId = KFsTreeNoneID ); |
|
211 // </cmail> |
|
212 |
|
213 // <cmail> Receiving online/offline events |
|
214 void HandleMailBoxEventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, |
|
215 TAny* aParam1, TAny* aParam2, TAny* aParam3 ); |
|
216 // </cmail> |
|
217 // <cmail> Toolbar |
|
218 |
|
219 private: // from |
|
220 |
|
221 /** |
|
222 * @see CFsEmailUiViewBase::ChildDoActivateL |
|
223 */ |
|
224 void ChildDoActivateL( const TVwsViewId& aPrevViewId, |
|
225 TUid aCustomMessageId, |
|
226 const TDesC8& aCustomMessage ); |
|
227 |
|
228 /** |
|
229 * @see CFsEmailUiViewBase::OfferToolbarEventL |
|
230 */ |
|
231 void OfferToolbarEventL( TInt aCommand ); |
|
232 |
|
233 /** |
|
234 * @see CFsEmailUiViewBase::ToolbarResourceId |
|
235 */ |
|
236 TInt ToolbarResourceId() const; |
|
237 |
|
238 // </cmail> Toolbar |
|
239 |
|
240 private: // Private functions |
|
241 |
|
242 /** |
|
243 * Comparison function for TLinearOrder |
|
244 * |
|
245 * @param aFirst First folder to compare |
|
246 * @param aSecond Second folder to compare |
|
247 * @return Zero if parameters are equal, |
|
248 * negative if first parameter is less than second, |
|
249 * positive if first parameter is greater than second |
|
250 */ |
|
251 static TInt CompareFolders( const CFSMailFolder& aFirst, const CFSMailFolder& aSecond ); |
|
252 |
|
253 // Construction |
|
254 CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv, CFreestyleEmailUiAppUi &aAppUi, CAlfControlGroup& aControlGroup ); |
|
255 void ConstructL(); |
|
256 void LoadIconsL(); |
|
257 |
|
258 // Internal functions used when showing and hiding the list |
|
259 // <cmail> |
|
260 //void DoShowInPopupL(); |
|
261 void DoShowInPopupL( MFsControlButtonInterface* aButton, |
|
262 MFSEmailUiFolderListCallback* aFolderCallback, |
|
263 MFSEmailUiSortListCallback* aSortCallback ); |
|
264 // </cmail> |
|
265 void PrepareFolderListL(); |
|
266 void PopulateFolderListL(); |
|
267 void PopulateFolderListDeferred(); |
|
268 static TInt DoPopulateFolderList( TAny* aSelfPtr ); |
|
269 |
|
270 // Recreate list content |
|
271 void UpdateFolderListL(); |
|
272 void UpdateSortListL(); |
|
273 |
|
274 // View layout handling and item position calculation |
|
275 void UpdateListSizeAttributes(); |
|
276 void ResizeListIcons(); |
|
277 void ResizeListItemsL(); |
|
278 void AdaptScreenRectToListContent(); |
|
279 // <cmail> |
|
280 void AdjustWidthByContent( TRect& aRect ) const; |
|
281 // </cmail> |
|
282 void SetAnchors(); |
|
283 void SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer ); |
|
284 |
|
285 // Popup list position calcualtion |
|
286 TRect LeftListRectInThisResolution(); |
|
287 TRect RightListRectInThisResolution(); |
|
288 TRect FolderListRectInThisResolution(); |
|
289 TRect SortListRectInThisResolution(); |
|
290 // <cmail> |
|
291 //void PopupListWidthHeightInThisResolution( TInt& aWidth, TInt& aHeight ); |
|
292 // </cmail> |
|
293 |
|
294 // Handle the selection or cancelation of the list |
|
295 void HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection ); |
|
296 TBool HandleCallbackL(); |
|
297 |
|
298 // Set header text |
|
299 void SetHeaderTextByResourceIdL( TInt aResourceId ); |
|
300 |
|
301 // Append folder list data |
|
302 void AppendActiveMailboxFoldersL(); |
|
303 void AppendMoreFoldersL(); |
|
304 void AppendMailboxesL(); |
|
305 void AppendSeparatorLineL(); |
|
306 |
|
307 // Append sort list data |
|
308 void AppendSortListItemsL(); |
|
309 |
|
310 // Helper functions used to append different kind of items to list |
|
311 void AppendSubfoldersL( TFSMailMsgId aFolder, |
|
312 TFsTreeItemId aParentNode, |
|
313 TBool aRefreshLastItem ); |
|
314 TFsTreeItemId AppendNodeFolderL( CFSMailFolder* aFolder, TFsTreeItemId aParentNode ); |
|
315 TFsTreeItemId AppendLeafFolderL( CFSMailFolder* aFolder, TFsTreeItemId aParentNode, TBool aAllowRefresh ); |
|
316 |
|
317 TFsTreeItemId AppendNodeToListFromResourceL( TInt aResourceId, |
|
318 TFsTreeItemId aParentNode, |
|
319 CAlfTexture* aIcon, |
|
320 TUint aUnreadCnt = 0); |
|
321 |
|
322 TFsTreeItemId AppendNodeToListL( TDesC* aItemData, |
|
323 TFsTreeItemId aParentNode, |
|
324 CAlfTexture* aIcon, |
|
325 TUint aUnreadCnt); |
|
326 |
|
327 TFsTreeItemId AppendItemToListFromResourceL( TInt aResourceId, |
|
328 TFsTreeItemId aParentNode, |
|
329 CAlfTexture* aIcon, |
|
330 TBool aAllowRefresh, |
|
331 TUint aUnreadCnt = 0); |
|
332 |
|
333 TFsTreeItemId AppendItemToListL( TDesC* aItemData, |
|
334 TFsTreeItemId aParentNode, |
|
335 CAlfTexture* aIcon, |
|
336 TBool aAllowRefresh, |
|
337 TUint aUnreadCnt = 0); |
|
338 |
|
339 void CreatePlainItemLC2( const TDesC* aItemDataBuff, |
|
340 CFsTreePlainOneLineItemData* &aItemData, |
|
341 CFsTreePlainOneLineItemVisualizer* &aItemVisualizer, |
|
342 CAlfTexture* aIcon ); |
|
343 void CreatePlainNodeLC2( TDesC* aItemDataBuff, |
|
344 CFsTreePlainOneLineNodeData* &aItemData, |
|
345 CFsTreePlainOneLineNodeVisualizer* &aNodeVisualizer, |
|
346 CAlfTexture* aIcon ); |
|
347 |
|
348 TBool GetStandardFolderResouceIdAndIconL( const TInt aFolderType, TInt &aResourceId, CAlfTexture* &aIcon ) const; |
|
349 TBool ShowThisTypeOfFolderL( CFSMailFolder* folder ) const; |
|
350 |
|
351 // Hepler function for folder comparison, return internal folder priority |
|
352 // used when sorting the list |
|
353 static TInt GetFolderPriorityByType( const CFSMailFolder& aFolder ); |
|
354 |
|
355 // Set and clear soft keys when popup list shown |
|
356 void SetPopupSoftkeysL(); |
|
357 void ClearPopupSoftkeys(); |
|
358 |
|
359 // Set initial list focus by current/previous activity |
|
360 void SetFocusToCurrentSortItemL(); |
|
361 void SetFocusToCurrentFolderL(); |
|
362 void SetFocusToLatestMovedFolderL(); |
|
363 |
|
364 // Move list focus to first or to last item |
|
365 void GoToTopL(); |
|
366 void GoToBottomL(); |
|
367 |
|
368 // Set toolbar buttons' dimmed/undimmed statuses. |
|
369 void UpdateToolbarButtons(); |
|
370 |
|
371 // Check wheter all list nodes are expanded or collapsed |
|
372 TBool AllNodesCollapsed() const; |
|
373 TBool AllNodesExpanded( TFsTreeItemId aParentNodeId = KFsTreeRootID ) const; |
|
374 |
|
375 // Recursive function to get item's root level parent |
|
376 TFsTreeItemId GetRootParent( const TFsTreeItemId aItemId ) const; |
|
377 |
|
378 void DoFirstStartL(); |
|
379 //<cmail> |
|
380 void SetHeaderTextAttributesL(); |
|
381 void ConnectToMailboxL(); |
|
382 void DisconnectFromMailboxL(); |
|
383 TBool CbaButtonPressed( TPoint aPosition ); |
|
384 void GetCbaRects( TRect& aLeftCbaRect, TRect& aRightCbaRect ); |
|
385 TBool IsAreaSideRightPaneActive(); |
|
386 //</cmail> |
|
387 |
|
388 private: |
|
389 |
|
390 // Array of list item infos |
|
391 RPointerArray< CFsTreePlainOneLineItemData > iListItemDatas; |
|
392 |
|
393 private: // Typedefs and member variables |
|
394 // Array type for the list icons |
|
395 typedef RPointerArray<CAlfTexture> TFsEmailFolderListIconArray; |
|
396 |
|
397 // ALF environment |
|
398 CAlfEnv& iEnv; |
|
399 |
|
400 // View layouts |
|
401 CAlfDeckLayout* iFaderLayout; |
|
402 CAlfAnchorLayout* iParentLayout; |
|
403 CAlfLayout* iListLayout; |
|
404 CAlfLayout* iHeaderLayout; |
|
405 |
|
406 // ALF visuals etc. for list background and header |
|
407 CAlfImageVisual* iListBgImageVisual; |
|
408 CAlfImageVisual* iHeaderImageVisual; |
|
409 CAlfTextVisual* iHeaderTextVisual; |
|
410 // <cmail> |
|
411 //CAlfImageBrush* iBackgroundBrush; |
|
412 CAlfFrameBrush* iBackgroundBrush; |
|
413 // </cmail> |
|
414 |
|
415 // <cmail> Touch |
|
416 // ALF visual for background |
|
417 CAlfVisual* iFaderVisual; |
|
418 // </cmail> |
|
419 |
|
420 // Pointers to control and model |
|
421 CFSEmailUiFolderListControl* iControl; // not owned (owned by ALF env) |
|
422 CFSEmailUiFolderListModel* iModel; // owned |
|
423 |
|
424 // Callback pointers |
|
425 MFSEmailUiFolderListCallback* iCallback; |
|
426 MFSEmailUiSortListCallback* iSortListCallback; |
|
427 |
|
428 // Type of the currently visible folder in mail list |
|
429 TFSFolderType iCurrentFolderType; |
|
430 |
|
431 // Custom message ID passed in view activation |
|
432 TUid iCustomMessageId; |
|
433 |
|
434 // List/view size attributes |
|
435 TRect iScreenRect; |
|
436 TRect iCtrlButtonRect; |
|
437 TRect iPreviousListRect; |
|
438 TInt iListItemHeight; |
|
439 TInt iListHeaderHeight; |
|
440 TInt iListSeparatorHeight; |
|
441 TSize iListIconSize; |
|
442 TSize iPreviousListIconSize; |
|
443 |
|
444 TPoint iPadding; |
|
445 |
|
446 // ETrue if list shown in fullscreen |
|
447 TBool iFullScreen; |
|
448 |
|
449 // List id of the "More folders" item in folder list |
|
450 TFsTreeItemId iMoreFoldersItemId; |
|
451 |
|
452 // Pointer to the tree list component visualizer. |
|
453 CFsTreeVisualizerBase* iTreeVisualizer; |
|
454 |
|
455 // Pointer to the tree list component, owned |
|
456 CFsTreeList* iTreeList; |
|
457 |
|
458 // Mailbox that is currently active in mail list |
|
459 CFSMailBox* iActiveMailbox; |
|
460 |
|
461 // Folder list icons, items not owned (are owned by texture manager) |
|
462 TFsEmailFolderListIconArray iIconArray; |
|
463 |
|
464 // Previously selected items |
|
465 TFSMailMsgId iLatestSelectedMoveFolderId; |
|
466 TFSMailMsgId iCurrentFolderId; |
|
467 TFSMailSortField iCurrentSortOrder; |
|
468 |
|
469 // Pointers to list items (and nodes) |
|
470 RPointerArray<MFsTreeItemVisualizer> iListItemVisulizers; |
|
471 |
|
472 // Previous level in list, used in horizontal scrolling |
|
473 TInt iPreviousListLevel; |
|
474 |
|
475 TBool iFirstStartCompleted; |
|
476 |
|
477 TBool iPopupListShown; |
|
478 |
|
479 //For header text caption |
|
480 TBool iTitleCaptionVisible; |
|
481 |
|
482 // Flag to see if view opened with move/copy command |
|
483 TBool iMoveOrCopyInitiated; |
|
484 // Flag to see if connection was started |
|
485 TBool iWaitingToGoOnline; |
|
486 // Do we need to connect the mailbox before showing the folder list |
|
487 TBool iNoConnectNeeded; |
|
488 |
|
489 // Should we use expansion animation for the next transition effect |
|
490 TBool iAnimateNextActivation; |
|
491 |
|
492 CAsyncCallBack* iAsyncCallback; |
|
493 |
|
494 TBool iConsumeUntilNextUpEvent; |
|
495 }; |
|
496 |
|
497 |
|
498 #endif //__FREESTYLEEMAILUI_FOLDERLISTVISUALISER_H__ |