|
1 /* |
|
2 * Copyright (c) 2007 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: Implements model for the attachment list view |
|
15 * |
|
16 */ |
|
17 |
|
18 // SYSTEM INCLUDES |
|
19 //<cmail> |
|
20 #include "emailtrace.h" |
|
21 #include "fstreelist.h" |
|
22 #include <AknUtils.h> |
|
23 #include <StringLoader.h> |
|
24 #include <FreestyleEmailUi.rsg> |
|
25 #include "cfsmailclient.h" |
|
26 // <cmail> SF |
|
27 #include <alf/alfdecklayout.h> |
|
28 // </cmail> |
|
29 #include "fstreelist.h" |
|
30 #include "fstreevisualizerbase.h" |
|
31 #include "fstreeplainonelineitemdata.h" |
|
32 #include "fstreeplainonelineitemvisualizer.h" |
|
33 #include "fstreeplainonelinenodedata.h" |
|
34 #include "fstreeplainonelinenodevisualizer.h" |
|
35 #include "fstreeplaintwolineitemdata.h" |
|
36 #include "fstreeplaintwolineitemvisualizer.h" |
|
37 //</cmail> |
|
38 |
|
39 // <cmail> Use layout data instead of hard-coded values |
|
40 #include <aknlayoutscalable_apps.cdl.h> |
|
41 #include <layoutmetadata.cdl.h> |
|
42 // </cmail> |
|
43 |
|
44 |
|
45 // INTERNAL INCLUDES |
|
46 #include "FreestyleEmailUiAppui.h" |
|
47 #include "FreestyleEmailUi.hrh" |
|
48 #include "FreestyleEmailUiLayoutHandler.h" |
|
49 #include "FreestyleEmailUiTextureManager.h" |
|
50 #include "FreestyleEmailUiSendAttachmentsListModel.h" |
|
51 #include "FreestyleEmailUiSendAttachmentsListControl.h" |
|
52 #include "FreestyleEmailUiSendAttachmentsListVisualiser.h" |
|
53 #include "FreestyleEmailUiShortcutBinding.h" |
|
54 #include "FreestyleEmailUiUtilities.h" |
|
55 #include "ncscomposeview.h" |
|
56 #include "ncsconstants.h" |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Two-phased constructor. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModelItem::NewL( |
|
63 const TDesC& aFileName, |
|
64 TInt aFileSize, |
|
65 TFileType aFileType, |
|
66 TBool aRemote, |
|
67 TBool aReadOnly ) |
|
68 { |
|
69 FUNC_LOG; |
|
70 CFSEmailUiSendAttachmentsListModelItem* self = |
|
71 CFSEmailUiSendAttachmentsListModelItem::NewLC( |
|
72 aFileName, |
|
73 aFileSize, |
|
74 aFileType, |
|
75 aRemote, |
|
76 aReadOnly ); |
|
77 CleanupStack::Pop( self ); |
|
78 return self; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Two-phased constructor. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModelItem::NewLC( |
|
86 const TDesC& aFileName, |
|
87 TInt aFileSize, |
|
88 TFileType aFileType, |
|
89 TBool aRemote, |
|
90 TBool aReadOnly ) |
|
91 { |
|
92 FUNC_LOG; |
|
93 CFSEmailUiSendAttachmentsListModelItem* self = |
|
94 new (ELeave) CFSEmailUiSendAttachmentsListModelItem( |
|
95 aFileName, |
|
96 aFileSize, |
|
97 aFileType, |
|
98 aRemote, |
|
99 aReadOnly ); |
|
100 CleanupStack::PushL( self ); |
|
101 return self; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // c++ constructor. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CFSEmailUiSendAttachmentsListModelItem::CFSEmailUiSendAttachmentsListModelItem( |
|
109 const TDesC& aFileName, |
|
110 TInt aFileSize, |
|
111 TFileType aFileType, |
|
112 TBool aRemote, |
|
113 TBool aReadOnly ) |
|
114 :iFileName( aFileName ), |
|
115 iFileSize( aFileSize ), |
|
116 iRemote( aRemote ), |
|
117 iReadOnly( aReadOnly ), |
|
118 iFileType( aFileType ) |
|
119 { |
|
120 FUNC_LOG; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // c++ destructor. |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 CFSEmailUiSendAttachmentsListModelItem::~CFSEmailUiSendAttachmentsListModelItem() |
|
128 { |
|
129 FUNC_LOG; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // FileName |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 const TDesC& CFSEmailUiSendAttachmentsListModelItem::FileName() const |
|
137 { |
|
138 FUNC_LOG; |
|
139 return iFileName; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // FileExtension |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 TPtrC CFSEmailUiSendAttachmentsListModelItem::FileExtension() const |
|
147 { |
|
148 FUNC_LOG; |
|
149 return TParsePtrC( iFileName ).Ext(); |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // MailMsgPartId |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 TFSMailMsgId CFSEmailUiSendAttachmentsListModelItem::MailMsgPartId() const |
|
158 { |
|
159 FUNC_LOG; |
|
160 return iMailMsgPartId; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // MailMsgPartId |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CFSEmailUiSendAttachmentsListModelItem::SetMailMsgPartId( |
|
168 const TFSMailMsgId aPartId ) |
|
169 { |
|
170 FUNC_LOG; |
|
171 iMailMsgPartId = aPartId; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // GetFileSize |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CFSEmailUiSendAttachmentsListModelItem::FileSize() const |
|
179 { |
|
180 FUNC_LOG; |
|
181 return iFileSize; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // GetFileSize |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 TInt CFSEmailUiSendAttachmentsListModelItem::ItemId() const |
|
189 { |
|
190 FUNC_LOG; |
|
191 return iItemId; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // SetItemId |
|
196 // Sets Id to item for identification |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CFSEmailUiSendAttachmentsListModelItem::SetItemId( TFsTreeItemId aItemId ) |
|
200 { |
|
201 FUNC_LOG; |
|
202 iItemId = aItemId; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // IsRemote |
|
207 // |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 TBool CFSEmailUiSendAttachmentsListModelItem::IsRemote() |
|
211 { |
|
212 FUNC_LOG; |
|
213 return iRemote; |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // IsReadOnly |
|
218 // |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 TBool CFSEmailUiSendAttachmentsListModelItem::IsReadOnly() |
|
222 { |
|
223 FUNC_LOG; |
|
224 // As a temporary solution, all remote attachments are made non-removable. |
|
225 // Intellisync protocol should support removing also remote attachments |
|
226 // but this doesn't seem to work currently in the Intellisync plugin. |
|
227 return iReadOnly || iRemote; |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // FileType |
|
232 // |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 TFileType CFSEmailUiSendAttachmentsListModelItem::FileType() |
|
236 { |
|
237 FUNC_LOG; |
|
238 return iFileType; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // SetRemote |
|
243 // |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CFSEmailUiSendAttachmentsListModelItem::SetRemote( TBool aIsRemote ) |
|
247 { |
|
248 FUNC_LOG; |
|
249 iRemote = aIsRemote; |
|
250 } |
|
251 |
|
252 |
|
253 //MODEL CLASS CONSTRUCTION |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // Two-phased constructor. |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 CFSEmailUiSendAttachmentsListModel* CFSEmailUiSendAttachmentsListModel::NewL( |
|
260 CFreestyleEmailUiAppUi* aAppUi, |
|
261 CAlfEnv& aEnv, |
|
262 CFreestyleEmailUiSendAttachmentsListControl* aControl ) |
|
263 { |
|
264 FUNC_LOG; |
|
265 CFSEmailUiSendAttachmentsListModel* self = |
|
266 CFSEmailUiSendAttachmentsListModel::NewLC( |
|
267 aAppUi, |
|
268 aEnv, |
|
269 aControl ); |
|
270 CleanupStack::Pop( self ); |
|
271 return self; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Two-phased constructor. |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 CFSEmailUiSendAttachmentsListModel* CFSEmailUiSendAttachmentsListModel::NewLC( |
|
279 CFreestyleEmailUiAppUi* aAppUi, |
|
280 CAlfEnv& aEnv, |
|
281 CFreestyleEmailUiSendAttachmentsListControl* aControl ) |
|
282 { |
|
283 FUNC_LOG; |
|
284 CFSEmailUiSendAttachmentsListModel* self = |
|
285 new (ELeave) CFSEmailUiSendAttachmentsListModel( aAppUi ); |
|
286 CleanupStack::PushL( self ); |
|
287 self->ConstructL( aEnv, aControl ); |
|
288 return self; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // Two-phased constructor. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CFSEmailUiSendAttachmentsListModel::ConstructL( |
|
296 CAlfEnv& aEnv, |
|
297 CFreestyleEmailUiSendAttachmentsListControl* aControl ) |
|
298 { |
|
299 FUNC_LOG; |
|
300 iEnv = &aEnv; |
|
301 iControl = aControl; |
|
302 iAttachmentsList = NULL; |
|
303 InitAttachmentListL(); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // c++ constructor. |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 CFSEmailUiSendAttachmentsListModel::CFSEmailUiSendAttachmentsListModel( |
|
311 CFreestyleEmailUiAppUi* aAppUi ) |
|
312 : iAppUi( aAppUi ) |
|
313 { |
|
314 FUNC_LOG; |
|
315 } |
|
316 |
|
317 // --------------------------------------------------------------------------- |
|
318 // c++ destructor. |
|
319 // --------------------------------------------------------------------------- |
|
320 // |
|
321 CFSEmailUiSendAttachmentsListModel::~CFSEmailUiSendAttachmentsListModel() |
|
322 { |
|
323 FUNC_LOG; |
|
324 while ( Count() > 0 ) |
|
325 { |
|
326 RemoveAndDestroy( 0 ); |
|
327 } |
|
328 // Close list resource. |
|
329 iItems.Close(); |
|
330 delete iAttachmentsList; |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // AppendL |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 void CFSEmailUiSendAttachmentsListModel::AppendL( MFSListModelItem* aItem ) |
|
338 { |
|
339 FUNC_LOG; |
|
340 TInt err; |
|
341 CFSEmailUiSendAttachmentsListModelItem* item = |
|
342 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( aItem ); |
|
343 |
|
344 err = iItems.Append( item ); |
|
345 User::LeaveIfError( err ); |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // InsertL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CFSEmailUiSendAttachmentsListModel::InsertL( MFSListModelItem* aItem, TInt aIndex) |
|
353 { |
|
354 FUNC_LOG; |
|
355 TInt err; |
|
356 CFSEmailUiSendAttachmentsListModelItem* item = |
|
357 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( aItem ); |
|
358 |
|
359 err = iItems.Insert( item, aIndex ); |
|
360 User::LeaveIfError( err ); |
|
361 } |
|
362 |
|
363 // --------------------------------------------------------------------------- |
|
364 // RemoveAndDestroy |
|
365 // --------------------------------------------------------------------------- |
|
366 // |
|
367 void CFSEmailUiSendAttachmentsListModel::RemoveAndDestroy( TInt aIndex ) |
|
368 { |
|
369 FUNC_LOG; |
|
370 delete Item( aIndex ); |
|
371 iItems.Remove( aIndex ); |
|
372 } |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // Item |
|
376 // Retuns valid item in model by index |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 MFSListModelItem* CFSEmailUiSendAttachmentsListModel::Item( TInt aIndex ) |
|
380 { |
|
381 FUNC_LOG; |
|
382 TInt numInList = iItems.Count(); |
|
383 if ( aIndex < 0 || aIndex >= numInList ) |
|
384 { |
|
385 return NULL; |
|
386 } |
|
387 |
|
388 return iItems[aIndex]; |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------------------------- |
|
392 // Count |
|
393 // --------------------------------------------------------------------------- |
|
394 // |
|
395 TInt CFSEmailUiSendAttachmentsListModel::Count() const |
|
396 { |
|
397 FUNC_LOG; |
|
398 return iItems.Count(); |
|
399 } |
|
400 |
|
401 // --------------------------------------------------------------------------- |
|
402 // AppUi |
|
403 // return appui pointer |
|
404 // --------------------------------------------------------------------------- |
|
405 // |
|
406 CFreestyleEmailUiAppUi* CFSEmailUiSendAttachmentsListModel::AppUi() |
|
407 { |
|
408 FUNC_LOG; |
|
409 return iAppUi; |
|
410 } |
|
411 |
|
412 // --------------------------------------------------------------------------- |
|
413 // ReFreshList |
|
414 // Refresh attachment list eg. after item removal |
|
415 // --------------------------------------------------------------------------- |
|
416 // |
|
417 void CFSEmailUiSendAttachmentsListModel::ReFreshListL() |
|
418 { |
|
419 FUNC_LOG; |
|
420 // empty the list |
|
421 if ( !iAttachmentsList ) |
|
422 { |
|
423 // Coverity error fix. iAttachmentsList was used also later without null checks |
|
424 return; |
|
425 } |
|
426 |
|
427 iAttachmentsList->RemoveAllL(); |
|
428 iAttachmentsList->SetFocusedL(ETrue); |
|
429 iAttachmentsList->HideListL(); |
|
430 TRect screenRect; |
|
431 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect ); |
|
432 iListLayout->SetSize( screenRect.Size() ); |
|
433 iListLayout->UpdateChildrenLayout(); |
|
434 |
|
435 // header and dividers |
|
436 CreateListSkeletonL(); |
|
437 // list model items |
|
438 CreateListItemsL(); |
|
439 |
|
440 if ( iAttachmentsList->IsEmpty(iLocalNode) && |
|
441 !iAttachmentsList->ItemVisualizer(iLocalNode).IsHidden() ) |
|
442 { |
|
443 iAttachmentsTreeListVisualizer->HideItemL( iLocalNode ); |
|
444 } |
|
445 if ( iAttachmentsList->IsEmpty(iRemoteNode) && |
|
446 !iAttachmentsList->ItemVisualizer(iRemoteNode).IsHidden() ) |
|
447 { |
|
448 iAttachmentsTreeListVisualizer->HideItemL( iRemoteNode ); |
|
449 } |
|
450 |
|
451 iAttachmentsList->ShowListL(); |
|
452 |
|
453 // Set the focus on the topmost visible focusable item |
|
454 GoToTopL(); |
|
455 } |
|
456 |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // ReScaleUiL |
|
460 // |
|
461 // |
|
462 // --------------------------------------------------------------------------- |
|
463 // |
|
464 void CFSEmailUiSendAttachmentsListModel::ReScaleUiL() |
|
465 { |
|
466 FUNC_LOG; |
|
467 |
|
468 // No rescaling to do if the list is empty |
|
469 if ( iAttachmentsList->IsEmpty(iLocalNode) && iAttachmentsList->IsEmpty(iRemoteNode) ) |
|
470 return; |
|
471 |
|
472 iAttachmentsList->HideListL(); |
|
473 |
|
474 // Reset font heights |
|
475 // ------------------ |
|
476 TInt fontHeight = iAppUi->LayoutHandler()->ListItemFontHeightInTwips(); |
|
477 |
|
478 // <cmail/> Header item not used - UI update. |
|
479 //</cmail> |
|
480 |
|
481 // Dividers |
|
482 iLocalNodeVisualiser->SetFontHeight( fontHeight ); |
|
483 iRemoteNodeVisualiser->SetFontHeight( fontHeight ); |
|
484 |
|
485 // Attachment items |
|
486 for ( TInt i=0; i<iItems.Count(); i++ ) |
|
487 { |
|
488 MFsTreeItemVisualizer& attachmentVis = iAttachmentsList->ItemVisualizer( iItems[i]->ItemId() ); |
|
489 attachmentVis.SetFontHeight( fontHeight ); |
|
490 } |
|
491 |
|
492 iAttachmentsList->ShowListL(); |
|
493 } |
|
494 |
|
495 // --------------------------------------------------------------------------- |
|
496 // CreateListSkeletonL |
|
497 // |
|
498 // |
|
499 // --------------------------------------------------------------------------- |
|
500 // |
|
501 void CFSEmailUiSendAttachmentsListModel::CreateListSkeletonL() |
|
502 { |
|
503 FUNC_LOG; |
|
504 // <cmail> Removed listbox header lines because of modified UI specification. |
|
505 |
|
506 //</cmail> |
|
507 |
|
508 CreateListSeparatorL( |
|
509 R_FSE_EDITOR_LOCAL_ATTACHMENTS, |
|
510 KFsTreeRootID, |
|
511 iLocalNodeVisualiser, |
|
512 iLocalNode ); |
|
513 |
|
514 CreateListSeparatorL( |
|
515 R_FSE_EDITOR_REMOTE_ATTACHMENTS, |
|
516 KFsTreeRootID, |
|
517 iRemoteNodeVisualiser, |
|
518 iRemoteNode ); |
|
519 |
|
520 iAttachmentsList->SetItemsAlwaysExtendedL(ETrue); |
|
521 |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // CreateListItemsL |
|
526 // |
|
527 // --------------------------------------------------------------------------- |
|
528 // |
|
529 void CFSEmailUiSendAttachmentsListModel::CreateListItemsL() |
|
530 { |
|
531 FUNC_LOG; |
|
532 CFSEmailUiSendAttachmentsListModelItem* item; |
|
533 TInt count = Count(); |
|
534 |
|
535 for ( TInt i=0; i < count; ++i ) |
|
536 { |
|
537 item = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item( i ) ); |
|
538 // append item content to Freestyle tree list |
|
539 AppendItemToAttachmentListL( item ); |
|
540 } |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // CreateListSeparatorL |
|
545 // |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 void CFSEmailUiSendAttachmentsListModel::CreateListSeparatorL( |
|
549 TInt aResourceId, |
|
550 TFsTreeItemId aParentNodeId, |
|
551 CFsTreePlainOneLineNodeVisualizer*& aVisualizer, |
|
552 TFsTreeItemId& aSeparatorNodeId ) |
|
553 { |
|
554 FUNC_LOG; |
|
555 // get screen rectangle |
|
556 TRect screenRect; |
|
557 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
558 |
|
559 // create data and visualizer objects |
|
560 CFsTreePlainOneLineNodeData* separatorData = CFsTreePlainOneLineNodeData::NewL(); |
|
561 CleanupStack::PushL( separatorData ); |
|
562 CFsTreePlainOneLineNodeVisualizer* separatorVisualiser = CFsTreePlainOneLineNodeVisualizer::NewL(*iAttachmentsList->TreeControl()); |
|
563 CleanupStack::PushL( separatorVisualiser ); |
|
564 |
|
565 // load resource string and set to separator object |
|
566 HBufC* resourceString = StringLoader::LoadLC( aResourceId ); |
|
567 separatorData->SetDataL( *resourceString ); |
|
568 CleanupStack::PopAndDestroy( resourceString ); |
|
569 |
|
570 // set properties of visualizer |
|
571 separatorVisualiser->SetSize( TSize( screenRect.Width(), iAppUi->LayoutHandler()->OneLineListNodeHeight() ) ); |
|
572 separatorVisualiser->SetExtendable( EFalse ); |
|
573 |
|
574 //<cmail> |
|
575 //separatorVisualiser->SetFontHeight( iAppUi->LayoutHandler()->ListItemFontHeightInTwips() ); |
|
576 //</cmail> |
|
577 separatorVisualiser->SetTextBold( ETrue ); |
|
578 separatorData->SetIconExpanded( iAppUi->FsTextureManager()->TextureByIndex( EListTextureNodeExpanded ) ); |
|
579 separatorData->SetIconCollapsed( iAppUi->FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed ) ); |
|
580 |
|
581 TRgb nodeTextColor = iAppUi->LayoutHandler()->ListNodeTextColor(); |
|
582 TRgb focusedTextColor = iAppUi->LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
583 //<cmail> |
|
584 //TRgb nodeBgColor = iAppUi->LayoutHandler()->ListNodeBackgroundColor(); |
|
585 //</cmail> |
|
586 separatorVisualiser->SetNormalStateTextColor( nodeTextColor ); |
|
587 separatorVisualiser->SetFocusedStateTextColor( focusedTextColor ); |
|
588 //<cmail> |
|
589 //separatorVisualiser->SetBackgroundColor( nodeBgColor ); |
|
590 //</cmail> |
|
591 |
|
592 aVisualizer = separatorVisualiser; |
|
593 CleanupStack::Pop( separatorVisualiser ); |
|
594 CleanupStack::Pop( separatorData ); |
|
595 aSeparatorNodeId = iAttachmentsList->InsertNodeL( *separatorData, *separatorVisualiser, aParentNodeId ); |
|
596 } |
|
597 |
|
598 // --------------------------------------------------------------------------- |
|
599 // UpdateHeaderItemTextL |
|
600 // Update the attachment count and total size information shown in header |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 void CFSEmailUiSendAttachmentsListModel::UpdateHeaderItemTextL() |
|
604 { |
|
605 FUNC_LOG; |
|
606 // Currently send attachment list headers doesn't contain any data that |
|
607 // need to be updated |
|
608 } |
|
609 |
|
610 // --------------------------------------------------------------------------- |
|
611 // AppendItemToAttachmentList |
|
612 // Appends item to graphical list from model list |
|
613 // --------------------------------------------------------------------------- |
|
614 // |
|
615 TFsTreeItemId CFSEmailUiSendAttachmentsListModel::AppendItemToAttachmentListL( |
|
616 CFSEmailUiSendAttachmentsListModelItem* aItem ) |
|
617 { |
|
618 FUNC_LOG; |
|
619 TFsTreeItemId itemId; |
|
620 CFsTreePlainTwoLineItemData* twoLineItemData; |
|
621 CFsTreePlainTwoLineItemVisualizer* twoLineItemVisualizer; |
|
622 |
|
623 twoLineItemData = CFsTreePlainTwoLineItemData::NewL(); |
|
624 twoLineItemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL( *iAttachmentsList->TreeControl() ); |
|
625 |
|
626 // load localization strings for file size |
|
627 HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( aItem->FileSize() ); |
|
628 HBufC* decoratedSize = StringLoader::LoadLC( R_FS_EMAILUI_SENDATTACHMENTS_ITEMSIZE_TXT, |
|
629 *sizeDesc ); |
|
630 |
|
631 // construct item 2nd row text |
|
632 HBufC* row2Buffer = HBufC::NewLC( aItem->FileExtension().Length() + KSpace().Length() + decoratedSize->Length() ); |
|
633 TPtr row2Des = row2Buffer->Des(); |
|
634 row2Des.Copy( aItem->FileExtension() ); |
|
635 row2Des.Append( KSpace ); |
|
636 row2Des.Append( *decoratedSize ); |
|
637 |
|
638 // set data to item |
|
639 twoLineItemData->SetDataL( aItem->FileName() ); |
|
640 twoLineItemData->SetSecondaryDataL( *row2Buffer ); |
|
641 |
|
642 // free resources |
|
643 CleanupStack::PopAndDestroy( row2Buffer ); |
|
644 CleanupStack::PopAndDestroy( decoratedSize ); |
|
645 CleanupStack::PopAndDestroy( sizeDesc ); |
|
646 |
|
647 // set icon |
|
648 CAlfTexture& itemTexture = TFsEmailUiUtility::GetAttachmentIcon( |
|
649 aItem->FileType(), |
|
650 *iAppUi->FsTextureManager() ); |
|
651 twoLineItemData->SetIcon( itemTexture ); |
|
652 |
|
653 // set item size and properties |
|
654 TRect screenRect; |
|
655 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
656 |
|
657 twoLineItemVisualizer->SetSize( TSize(screenRect.Width(), iAppUi->LayoutHandler()->OneLineListItemHeight()) ); |
|
658 twoLineItemVisualizer->SetExtendedSize( TSize(screenRect.Width(), 2 * iAppUi->LayoutHandler()->OneLineListItemHeight()) ); |
|
659 twoLineItemVisualizer->SetFlags( twoLineItemVisualizer->Flags()|KFsTreeListItemHasMenu ); |
|
660 |
|
661 twoLineItemVisualizer->SetExtendable( ETrue ); |
|
662 twoLineItemVisualizer->SetFocusable( ETrue ); |
|
663 |
|
664 twoLineItemVisualizer->SetTextBold( EFalse ); |
|
665 |
|
666 TRgb normalTextColor = iAppUi->LayoutHandler()->ListNormalStateTextSkinColor(); |
|
667 if ( aItem->IsReadOnly() ) |
|
668 { |
|
669 normalTextColor = iAppUi->LayoutHandler()->ComposerDimmedTextColor(); |
|
670 } |
|
671 TRgb focusedTextColor = iAppUi->LayoutHandler()->ListFocusedStateTextSkinColor(); |
|
672 twoLineItemVisualizer->SetNormalStateTextColor( normalTextColor ); |
|
673 twoLineItemVisualizer->SetFocusedStateTextColor( focusedTextColor ); |
|
674 |
|
675 // Ensure the parent node of the item to be added is visible and expanded. |
|
676 TFsTreeItemId parentNodeId = aItem->IsRemote() ? iRemoteNode : iLocalNode; |
|
677 if ( iAttachmentsList->ItemVisualizer(parentNodeId).IsHidden() ) |
|
678 { |
|
679 // Unhiding a node is a relatively heavy-weight operation. Thus, |
|
680 // we need to ensure it's not called in vain. |
|
681 iAttachmentsTreeListVisualizer->UnhideItemL( parentNodeId ); |
|
682 } |
|
683 iAttachmentsList->ExpandNodeL( parentNodeId ); |
|
684 |
|
685 // insert item and catch id returned |
|
686 itemId = iAttachmentsList->InsertItemL( |
|
687 *twoLineItemData, |
|
688 *twoLineItemVisualizer, |
|
689 parentNodeId ); |
|
690 |
|
691 // set list item id to model item |
|
692 aItem->SetItemId( itemId ); |
|
693 return itemId; |
|
694 } |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // RemoveItemByIndexL |
|
698 // Removes item by given index from list |
|
699 // --------------------------------------------------------------------------- |
|
700 // |
|
701 void CFSEmailUiSendAttachmentsListModel::RemoveItemByIndexL( const TInt aIndex ) |
|
702 { |
|
703 FUNC_LOG; |
|
704 if ( aIndex >= 0 && aIndex < Count() ) |
|
705 { |
|
706 CFSEmailUiSendAttachmentsListModelItem* item = |
|
707 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item(aIndex) ); |
|
708 TFsTreeItemId deletedItemId = item->ItemId(); |
|
709 |
|
710 // remove attachment from mail message |
|
711 CNcsComposeView* composeView = |
|
712 static_cast<CNcsComposeView*>( iAppUi->View( MailEditorId ) ); |
|
713 |
|
714 if ( composeView->NewMessage() ) |
|
715 { |
|
716 // compose view is open, so remove attachment there |
|
717 composeView->NewMessage()->RemoveChildPartL( |
|
718 item->MailMsgPartId() ); |
|
719 if ( iItems.Count() == 1 ) |
|
720 { |
|
721 composeView->NewMessage()->ResetFlag( EFSMsgFlag_Attachments ); |
|
722 } |
|
723 } |
|
724 else |
|
725 { |
|
726 CFSEmailUiSendAttachmentsListVisualiser* parentView = |
|
727 static_cast<CFSEmailUiSendAttachmentsListVisualiser*>( |
|
728 iAppUi->View( SendAttachmentMngrViewId ) ); |
|
729 |
|
730 // Open message from framework and delete attachment |
|
731 CFSMailClient* mailClient = iAppUi->GetMailClient(); // not owned |
|
732 CFSMailMessage* msg = mailClient->GetMessageByUidL( |
|
733 parentView->EditorParams().iMailboxId, |
|
734 parentView->EditorParams().iFolderId, |
|
735 parentView->EditorParams().iMsgId, |
|
736 EFSMsgDataStructure ); |
|
737 CleanupStack::PushL( msg ); |
|
738 msg->RemoveChildPartL( item->MailMsgPartId() ); |
|
739 msg->ResetFlag( EFSMsgFlag_Attachments ); |
|
740 msg->SaveMessageL(); |
|
741 CleanupStack::PopAndDestroy( msg ); |
|
742 } |
|
743 |
|
744 // Remove attachment item from model |
|
745 RemoveAndDestroy( aIndex ); |
|
746 |
|
747 // Remove attachment item from tree list if present |
|
748 if ( deletedItemId != KFsTreeNoneID ) |
|
749 { |
|
750 iAttachmentsList->RemoveL( deletedItemId ); |
|
751 |
|
752 // Hide parent node of the removed item if it just became empty |
|
753 if ( iAttachmentsList->IsEmpty(iLocalNode) && |
|
754 !iAttachmentsList->ItemVisualizer(iLocalNode).IsHidden() ) |
|
755 { |
|
756 iAttachmentsTreeListVisualizer->HideItemL( iLocalNode ); |
|
757 } |
|
758 if ( iAttachmentsList->IsEmpty(iRemoteNode) && |
|
759 !iAttachmentsList->ItemVisualizer(iRemoteNode).IsHidden() ) |
|
760 { |
|
761 iAttachmentsTreeListVisualizer->HideItemL( iRemoteNode ); |
|
762 } |
|
763 } |
|
764 } |
|
765 } |
|
766 |
|
767 // --------------------------------------------------------------------------- |
|
768 // RemoveAllAttachmentsL |
|
769 // Removes all attachment items from the model, list, and message |
|
770 // --------------------------------------------------------------------------- |
|
771 // |
|
772 void CFSEmailUiSendAttachmentsListModel::RemoveAllAttachmentsL() |
|
773 { |
|
774 FUNC_LOG; |
|
775 CNcsComposeView* composeView = |
|
776 static_cast<CNcsComposeView*>( iAppUi->View(MailEditorId) ); |
|
777 CFSMailMessage* msg = composeView->NewMessage(); |
|
778 |
|
779 if ( !msg ) |
|
780 { |
|
781 // Open message from framework |
|
782 CFSEmailUiSendAttachmentsListVisualiser* attListView = |
|
783 static_cast<CFSEmailUiSendAttachmentsListVisualiser*>( |
|
784 iAppUi->View( SendAttachmentMngrViewId ) ); |
|
785 CFSMailClient* mailClient = iAppUi->GetMailClient(); // not owned |
|
786 msg = mailClient->GetMessageByUidL( |
|
787 attListView->EditorParams().iMailboxId, |
|
788 attListView->EditorParams().iFolderId, |
|
789 attListView->EditorParams().iMsgId, |
|
790 EFSMsgDataStructure ); |
|
791 CleanupStack::PushL( msg ); |
|
792 } |
|
793 |
|
794 // remove attachments from mail message |
|
795 for ( TInt i = Count()-1 ; i >= 0 ; --i ) |
|
796 { |
|
797 CFSEmailUiSendAttachmentsListModelItem* item = |
|
798 static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item(i) ); |
|
799 |
|
800 TRAPD( err, msg->RemoveChildPartL( item->MailMsgPartId() ) ); |
|
801 // Remove attachment item from model if message part was succesfully removed |
|
802 if ( !err ) |
|
803 { |
|
804 RemoveAndDestroy( i ); |
|
805 } |
|
806 } |
|
807 msg->ResetFlag( EFSMsgFlag_Attachments ); |
|
808 msg->SaveMessageL(); |
|
809 |
|
810 // Delete msg if we own it |
|
811 if ( !composeView->NewMessage() ) |
|
812 { |
|
813 CleanupStack::PopAndDestroy( msg ); |
|
814 } |
|
815 |
|
816 // Update the tree list to match the model. |
|
817 ReFreshListL(); |
|
818 } |
|
819 |
|
820 // --------------------------------------------------------------------------- |
|
821 // HighlightedIndex |
|
822 // Returns currenlty higlighted index from list |
|
823 // --------------------------------------------------------------------------- |
|
824 // |
|
825 TInt CFSEmailUiSendAttachmentsListModel::HighlightedIndex() |
|
826 { |
|
827 FUNC_LOG; |
|
828 TInt ret( KErrNotFound ); |
|
829 |
|
830 TFsTreeItemId focusedId = iAttachmentsList->FocusedItem(); |
|
831 // Map id to the index in model |
|
832 |
|
833 for ( TInt i=0; i < iItems.Count(); ++i ) |
|
834 { |
|
835 if ( focusedId == iItems[i]->ItemId() ) |
|
836 { |
|
837 ret = i; |
|
838 break; |
|
839 } |
|
840 } |
|
841 return ret; |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // AttachmentList |
|
846 // Returns pointer to attachment list |
|
847 // --------------------------------------------------------------------------- |
|
848 // |
|
849 CFsTreeList* CFSEmailUiSendAttachmentsListModel::AttachmentList() |
|
850 { |
|
851 FUNC_LOG; |
|
852 return iAttachmentsList; |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------------------------- |
|
856 // TotalAttachmentSize |
|
857 // |
|
858 // Retuns sum of all attachments sizes in kB from the model |
|
859 // --------------------------------------------------------------------------- |
|
860 // |
|
861 TInt CFSEmailUiSendAttachmentsListModel::TotalAttachmentSize() |
|
862 { |
|
863 FUNC_LOG; |
|
864 CFSEmailUiSendAttachmentsListModelItem* fileItem; |
|
865 TInt totalSize = 0; |
|
866 TInt count = Count(); |
|
867 |
|
868 for ( TInt i=0; i < count; ++i ) |
|
869 { |
|
870 fileItem = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item( i ) ); |
|
871 totalSize += fileItem->FileSize(); |
|
872 } |
|
873 return totalSize; |
|
874 } |
|
875 |
|
876 // --------------------------------------------------------------------------- |
|
877 // InitAttachmentListL |
|
878 // |
|
879 // Creates new instance of attachment tree list |
|
880 // --------------------------------------------------------------------------- |
|
881 // |
|
882 void CFSEmailUiSendAttachmentsListModel::InitAttachmentListL() |
|
883 { |
|
884 FUNC_LOG; |
|
885 |
|
886 if ( iAttachmentsList == NULL ) |
|
887 { |
|
888 |
|
889 /*TRect screenRect; |
|
890 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
891 iListLayout = CAlfDeckLayout::AddNewL( *iControl ); |
|
892 iListLayout->SetSize( TSize( screenRect.Width(), screenRect.Height()) );*/ |
|
893 |
|
894 TRect screenRect; |
|
895 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect ); |
|
896 iListLayout = CAlfDeckLayout::AddNewL( *iControl ); |
|
897 iListLayout->SetSize( screenRect.Size() ); |
|
898 |
|
899 // Create attachments list tree list component |
|
900 iAttachmentsTreeListVisualizer = CFsTreeVisualizerBase::NewL( |
|
901 iControl, |
|
902 *iListLayout ); |
|
903 iAttachmentsTreeListVisualizer->SetItemExpansionDelay( KListItemExpansionDelay ); |
|
904 //<cmail> S60 skin support |
|
905 //iAttachmentsTreeListVisualizer->SetBackgroundTextureL( |
|
906 // iAppUi->FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) ); |
|
907 //</cmail> |
|
908 iAttachmentsTreeListVisualizer->SetMenuIcon( |
|
909 iAppUi->FsTextureManager()->TextureByIndex( EListControlMenuIcon ) ); |
|
910 // Set page up and page down keys |
|
911 iAttachmentsTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp ); |
|
912 iAttachmentsTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown ); |
|
913 |
|
914 // create list |
|
915 iAttachmentsList = CFsTreeList::NewL( *iAttachmentsTreeListVisualizer, *iEnv ); |
|
916 iAttachmentsList->SetScrollbarVisibilityL( EFsScrollbarAuto ); |
|
917 iAttachmentsList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable ); |
|
918 iAttachmentsList->SetLoopingType( EFsTreeListLoopingDisabled ); |
|
919 iAttachmentsList->SetIndentationL( 0 ); |
|
920 iAttachmentsList->AddObserverL( *this ); |
|
921 iAppUi->LayoutHandler()->SetListMarqueeBehaviour( iAttachmentsList ); |
|
922 |
|
923 CreateListSkeletonL(); |
|
924 } |
|
925 |
|
926 } |
|
927 |
|
928 //<cmail> touch |
|
929 |
|
930 // --------------------------------------------------------------------------- |
|
931 // TreeListEventL |
|
932 // |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 |
|
936 void CFSEmailUiSendAttachmentsListModel::TreeListEventL( |
|
937 const TFsTreeListEvent aEvent, |
|
938 const TFsTreeItemId /*aId*/, |
|
939 const TPoint& /*aPoint*/ ) |
|
940 { |
|
941 FUNC_LOG; |
|
942 |
|
943 CFSEmailUiSendAttachmentsListModelItem* item = 0; |
|
944 |
|
945 switch(aEvent) |
|
946 { |
|
947 case MFsTreeListObserver::EFsTreeListItemTouchAction: |
|
948 DoHandleActionL(); |
|
949 break; |
|
950 case MFsTreeListObserver::EFsTreeListItemTouchLongTap: |
|
951 item = GetSelectedItem(); |
|
952 if(NULL != item) |
|
953 iControl->ShowActionMenuL( item ); |
|
954 break; |
|
955 case MFsTreeListObserver::EFsTreeListItemTouchFocused: |
|
956 iControl->SetMskL(); |
|
957 break; |
|
958 default: |
|
959 //Just ignore rest of events |
|
960 break; |
|
961 } |
|
962 |
|
963 } |
|
964 |
|
965 // --------------------------------------------------------------------------- |
|
966 // Handles action for focused item. |
|
967 // --------------------------------------------------------------------------- |
|
968 // |
|
969 void CFSEmailUiSendAttachmentsListModel::HandleActionL() |
|
970 { |
|
971 FUNC_LOG; |
|
972 DoHandleActionL(); |
|
973 } |
|
974 |
|
975 // --------------------------------------------------------------------------- |
|
976 // CFSEmailUiSendAttachmentsListModel::DoHandleActionL |
|
977 // --------------------------------------------------------------------------- |
|
978 // |
|
979 void CFSEmailUiSendAttachmentsListModel::DoHandleActionL( ) |
|
980 { |
|
981 FUNC_LOG; |
|
982 |
|
983 TFsTreeItemId id = iAttachmentsList->FocusedItem(); |
|
984 |
|
985 //Expand / Collapse |
|
986 if ( iAttachmentsList->IsNode(id) ) |
|
987 { |
|
988 if ( iAttachmentsList->IsExpanded(id) ) |
|
989 { |
|
990 CollapseL(); |
|
991 } |
|
992 else |
|
993 { |
|
994 ExpandL(); |
|
995 } |
|
996 } |
|
997 else //Open |
|
998 { |
|
999 iControl->OpenHighlightedFileL(); |
|
1000 } |
|
1001 |
|
1002 iControl->SetMskL(); |
|
1003 } |
|
1004 |
|
1005 //</cmail> |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // HasRemoteAttachments |
|
1012 // --------------------------------------------------------------------------- |
|
1013 // |
|
1014 TBool CFSEmailUiSendAttachmentsListModel::HasRemoteAttachments() |
|
1015 { |
|
1016 FUNC_LOG; |
|
1017 // remote files have no file path within local system |
|
1018 for ( TInt i=0; i<iItems.Count(); i++ ) |
|
1019 { |
|
1020 if ( iItems[i]->IsRemote() ) |
|
1021 { |
|
1022 return ETrue; |
|
1023 } |
|
1024 } |
|
1025 return EFalse; |
|
1026 } |
|
1027 |
|
1028 // --------------------------------------------------------------------------- |
|
1029 // HasReadOnlyAttachments |
|
1030 // --------------------------------------------------------------------------- |
|
1031 // |
|
1032 TBool CFSEmailUiSendAttachmentsListModel::HasReadOnlyAttachments() |
|
1033 { |
|
1034 FUNC_LOG; |
|
1035 // remote files have no file path within local system |
|
1036 for ( TInt i=0; i<iItems.Count(); i++ ) |
|
1037 { |
|
1038 if ( iItems[i]->IsReadOnly() ) |
|
1039 { |
|
1040 return ETrue; |
|
1041 } |
|
1042 } |
|
1043 return EFalse; |
|
1044 } |
|
1045 |
|
1046 // --------------------------------------------------------------------------- |
|
1047 // GetSelectedItem |
|
1048 // --------------------------------------------------------------------------- |
|
1049 // |
|
1050 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModel::GetSelectedItem() |
|
1051 { |
|
1052 FUNC_LOG; |
|
1053 TFsTreeItemId nodeId = iAttachmentsList->FocusedItem(); |
|
1054 //<cmail> |
|
1055 if ( nodeId == iLocalNode || |
|
1056 nodeId == iRemoteNode || |
|
1057 nodeId == KFsTreeNoneID ) |
|
1058 //</cmail> |
|
1059 { |
|
1060 return NULL; |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 return GetItemByNodeId( nodeId ); |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // GetItemByNodeId |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModel::GetItemByNodeId( TFsTreeItemId aNodeId ) |
|
1073 { |
|
1074 FUNC_LOG; |
|
1075 for ( TInt i=0; i<iItems.Count(); i++ ) |
|
1076 { |
|
1077 if ( iItems[i]->ItemId() == aNodeId ) |
|
1078 { |
|
1079 return iItems[i]; |
|
1080 } |
|
1081 } |
|
1082 return NULL; |
|
1083 } |
|
1084 |
|
1085 TBool CFSEmailUiSendAttachmentsListModel::CanSelectPreviousItem() |
|
1086 { |
|
1087 FUNC_LOG; |
|
1088 return iAttachmentsList->FocusedItem() != iLocalNode; |
|
1089 } |
|
1090 |
|
1091 // --------------------------------------------------------------------------- |
|
1092 // Moves the focus to the topmost item |
|
1093 // --------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CFSEmailUiSendAttachmentsListModel::GoToTopL() |
|
1096 { |
|
1097 FUNC_LOG; |
|
1098 // Focus first visible focusable item. |
|
1099 TFsTreeItemId topId = KErrNotFound; |
|
1100 |
|
1101 const TInt count = iAttachmentsList->CountChildren( KFsTreeRootID ); |
|
1102 for ( TInt index = 0; index < count && topId == KErrNotFound; ++index ) |
|
1103 { |
|
1104 TFsTreeItemId id =iAttachmentsList->Child( KFsTreeRootID, index ); |
|
1105 if ( !iAttachmentsList->ItemVisualizer( id ).IsHidden() ) |
|
1106 { |
|
1107 topId = id; |
|
1108 } |
|
1109 } |
|
1110 |
|
1111 if ( topId != KErrNotFound ) |
|
1112 { |
|
1113 iAttachmentsTreeListVisualizer->SetFocusedItemL( topId ); |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // Moves the focus to the bottommost item |
|
1119 // --------------------------------------------------------------------------- |
|
1120 // |
|
1121 void CFSEmailUiSendAttachmentsListModel::GoToBottomL() |
|
1122 { |
|
1123 FUNC_LOG; |
|
1124 if ( Count() ) |
|
1125 { |
|
1126 TInt topLevelCount = iAttachmentsList->CountChildren( KFsTreeRootID ); |
|
1127 if ( topLevelCount ) |
|
1128 { |
|
1129 // Get last visible top level item |
|
1130 TFsTreeItemId bottomId = KErrNotFound; |
|
1131 TInt index = topLevelCount - 1; |
|
1132 do |
|
1133 { |
|
1134 bottomId = iAttachmentsList->Child( KFsTreeRootID, index ); |
|
1135 index--; |
|
1136 } |
|
1137 while ( iAttachmentsList->ItemVisualizer(bottomId).IsHidden() && |
|
1138 index >= 0 ); |
|
1139 |
|
1140 if ( iAttachmentsList->IsNode(bottomId) ) |
|
1141 { |
|
1142 TInt childCount = iAttachmentsList->CountChildren(bottomId); |
|
1143 if ( childCount && iAttachmentsList->IsExpanded(bottomId) ) |
|
1144 { |
|
1145 // Focus the last child of the bottom node if the node is expanded. |
|
1146 bottomId = iAttachmentsList->Child( bottomId, childCount-1 ); |
|
1147 } |
|
1148 } |
|
1149 iAttachmentsTreeListVisualizer->SetFocusedItemL( bottomId ); |
|
1150 } |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 // --------------------------------------------------------------------------- |
|
1155 // Collapse nodes |
|
1156 // --------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CFSEmailUiSendAttachmentsListModel::CollapseL() |
|
1159 { |
|
1160 FUNC_LOG; |
|
1161 TFsTreeItemId focId1 = iAttachmentsList->FocusedItem(); |
|
1162 iAttachmentsList->CollapseNodeL(focId1); |
|
1163 } |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // Expands nodes |
|
1166 // --------------------------------------------------------------------------- |
|
1167 // |
|
1168 void CFSEmailUiSendAttachmentsListModel::ExpandL() |
|
1169 { |
|
1170 FUNC_LOG; |
|
1171 TFsTreeItemId focId = iAttachmentsList->FocusedItem(); |
|
1172 iAttachmentsList->ExpandNodeL( focId ); |
|
1173 } |
|
1174 // --------------------------------------------------------------------------- |
|
1175 // Collapses or expands all nodes |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // |
|
1178 void CFSEmailUiSendAttachmentsListModel::CollapseExpandAllToggleL() |
|
1179 { |
|
1180 FUNC_LOG; |
|
1181 TBool collapseAllNodes( EFalse ); |
|
1182 TInt count = iAttachmentsList->CountChildren( KFsTreeRootID ); |
|
1183 for ( TInt i=0 ; i<count ; i++ ) |
|
1184 { |
|
1185 TFsTreeItemId curId = iAttachmentsList->Child(KFsTreeRootID, i); |
|
1186 if ( iAttachmentsList->IsNode( curId ) && |
|
1187 iAttachmentsList->IsExpanded( curId ) ) |
|
1188 { |
|
1189 collapseAllNodes = ETrue; |
|
1190 break; |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 if ( collapseAllNodes ) |
|
1195 { |
|
1196 iAttachmentsTreeListVisualizer->CollapseAllL(); |
|
1197 } |
|
1198 else |
|
1199 { |
|
1200 TFsTreeItemId prevId = iAttachmentsList->FocusedItem(); // the focus may fall out of the screen unless manually reset |
|
1201 iAttachmentsTreeListVisualizer->ExpandAllL(); |
|
1202 iAttachmentsTreeListVisualizer->SetFocusedItemL( prevId ); |
|
1203 } |
|
1204 } |
|
1205 |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // |
|
1208 // --------------------------------------------------------------------------- |
|
1209 // |
|
1210 void CFSEmailUiSendAttachmentsListModel::Clear() |
|
1211 { |
|
1212 FUNC_LOG; |
|
1213 // <cmail> Remove all children of nodes on the list |
|
1214 if ( iAttachmentsList ) |
|
1215 { |
|
1216 TRAP_IGNORE( iAttachmentsList->RemoveChildrenL( iRemoteNode ) ); |
|
1217 TRAP_IGNORE( iAttachmentsList->RemoveChildrenL( iLocalNode ) ); |
|
1218 } |
|
1219 // </cmail> |
|
1220 iItems.ResetAndDestroy(); |
|
1221 } |
|
1222 |
|
1223 //<cmail> |
|
1224 // --------------------------------------------------------------------------- |
|
1225 // CFSEmailUiSendAttachmentsListModel::GetVisualizer |
|
1226 // --------------------------------------------------------------------------- |
|
1227 // |
|
1228 CFsTreeVisualizerBase* CFSEmailUiSendAttachmentsListModel::GetVisualizer() |
|
1229 { |
|
1230 FUNC_LOG; |
|
1231 return iAttachmentsTreeListVisualizer; |
|
1232 } |
|
1233 //</cmail> |
|
1234 |
|
1235 // --------------------------------------------------------------------------- |
|
1236 // |
|
1237 // --------------------------------------------------------------------------- |
|
1238 // |
|
1239 CAlfLayout* CFSEmailUiSendAttachmentsListModel::GetParentLayout() const |
|
1240 { |
|
1241 return iListLayout; |
|
1242 } |
|
1243 |
|
1244 |
|
1245 // --------------------------------------------------------------------------- |
|
1246 // Sets up the title pane |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // |
|
1249 void CFSEmailUiSendAttachmentsListModel::SetupTitlePaneTextL() |
|
1250 { |
|
1251 FUNC_LOG; |
|
1252 HBufC* titleText = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_VIEW_TITLE ); |
|
1253 AppUi()->SetTitlePaneTextL( *titleText ); |
|
1254 CleanupStack::PopAndDestroy( titleText ); |
|
1255 } |
|
1256 |
|
1257 //</cmail> |
|
1258 |