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