|
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 visualiser for the attachment list view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // SYSTEM INCLUDES |
|
21 #include "emailtrace.h" |
|
22 #include <freestyleemailui.mbg> |
|
23 #include <AknUtils.h> |
|
24 #include <gulicon.h> |
|
25 #include <StringLoader.h> |
|
26 #include <FreestyleEmailUi.rsg> |
|
27 #include <aknlistquerydialog.h> |
|
28 #include <e32cmn.h> |
|
29 #include <featmgr.h> // For FeatureManager |
|
30 #include <alf/alfcontrolgroup.h> |
|
31 |
|
32 #include <csxhelp/cmail.hlp.hrh> |
|
33 |
|
34 // INTERNAL INCLUDES |
|
35 #include "FreestyleEmailUiUtilities.h" |
|
36 #include "FreestyleEmailUiLayoutHandler.h" |
|
37 #include "FreestyleEmailUiSendAttachmentsListVisualiser.h" |
|
38 #include "FreestyleEmailUiSendAttachmentsListControl.h" |
|
39 #include "FreestyleEmailUiSendAttachmentsListModel.h" |
|
40 #include "FreestyleEmailUiFileSystemInfo.h" |
|
41 #include "FreestyleEmailUi.hrh" |
|
42 #include "FreestyleEmailUiTextureManager.h" |
|
43 #include "FreestyleEmailUiShortcutBinding.h" |
|
44 |
|
45 |
|
46 // CLASS IMPLEMENTATION |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // Two-phased constructor. |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CFSEmailUiSendAttachmentsListVisualiser* CFSEmailUiSendAttachmentsListVisualiser::NewL( |
|
53 CAlfEnv& aEnv, |
|
54 CFreestyleEmailUiAppUi* aAppUi, |
|
55 CAlfControlGroup& aMailListControlGroup ) |
|
56 { |
|
57 FUNC_LOG; |
|
58 CFSEmailUiSendAttachmentsListVisualiser* self = CFSEmailUiSendAttachmentsListVisualiser::NewLC(aEnv, aAppUi, aMailListControlGroup ); |
|
59 CleanupStack::Pop(self); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // Two-phased constructor. |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CFSEmailUiSendAttachmentsListVisualiser* CFSEmailUiSendAttachmentsListVisualiser::NewLC( |
|
68 CAlfEnv& aEnv, |
|
69 CFreestyleEmailUiAppUi* aAppUi, |
|
70 CAlfControlGroup& aMailListControlGroup ) |
|
71 { |
|
72 FUNC_LOG; |
|
73 CFSEmailUiSendAttachmentsListVisualiser* self = new (ELeave) CFSEmailUiSendAttachmentsListVisualiser(aAppUi, aEnv, aMailListControlGroup); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Two-phased constructor. |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CFSEmailUiSendAttachmentsListVisualiser::ConstructL() |
|
84 { |
|
85 FUNC_LOG; |
|
86 |
|
87 BaseConstructL( R_FSEMAILUI_SENDATTACHMENTS_VIEW ); |
|
88 |
|
89 // Create list screen (list) control and screen anchor layout |
|
90 iScreenControl = CFreestyleEmailUiSendAttachmentsListControl::NewL( *iEnv, this, &iAppUi ); |
|
91 // insert control to control group given from AppUi |
|
92 // owner transferred |
|
93 //<cmail> Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in |
|
94 // opposite order. |
|
95 ControlGroup().AppendL( iScreenControl ); |
|
96 ControlGroup().AppendL( iScreenControl->Model()->AttachmentList()->TreeControl() ); |
|
97 //</cmail> |
|
98 |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // c++ constructor. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CFSEmailUiSendAttachmentsListVisualiser::CFSEmailUiSendAttachmentsListVisualiser( |
|
107 CFreestyleEmailUiAppUi* aAppUi, |
|
108 CAlfEnv& aEnv, |
|
109 CAlfControlGroup& aAttachmentsListControlGroup ) |
|
110 : CFsEmailUiViewBase( aAttachmentsListControlGroup, *aAppUi ), |
|
111 iEnv( &aEnv ) |
|
112 { |
|
113 FUNC_LOG; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // c++ destructor. |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CFSEmailUiSendAttachmentsListVisualiser::~CFSEmailUiSendAttachmentsListVisualiser() |
|
121 { |
|
122 FUNC_LOG; |
|
123 if ( iScreenControl->Model() ) |
|
124 { |
|
125 iScreenControl->DeleteModel(); |
|
126 } |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------------------------- |
|
131 // Id |
|
132 // from aknview |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 TUid CFSEmailUiSendAttachmentsListVisualiser::Id() const |
|
136 { |
|
137 FUNC_LOG; |
|
138 return SendAttachmentMngrViewId; |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // DoActivateL |
|
143 // From aknview |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 // <cmail> Toolbar |
|
147 /*void CFSEmailUiSendAttachmentsListVisualiser::DoActivateL( |
|
148 const TVwsViewId& aPrevViewId, |
|
149 TUid aCustomMessageId, |
|
150 const TDesC8& aCustomMessage )*/ |
|
151 void CFSEmailUiSendAttachmentsListVisualiser::ChildDoActivateL( |
|
152 const TVwsViewId& aPrevViewId, |
|
153 TUid aCustomMessageId, |
|
154 const TDesC8& aCustomMessage ) |
|
155 // </cmail> Toolbar |
|
156 { |
|
157 FUNC_LOG; |
|
158 |
|
159 if ( aCustomMessageId == TUid::Uid( KEditorCmdOpenAttachmentsList ) ) |
|
160 { |
|
161 TPckgBuf<TEditorLaunchParams> buf( iEditorParams ); |
|
162 buf.Copy( aCustomMessage ); |
|
163 iEditorParams = buf(); |
|
164 |
|
165 iPrevViewId = aPrevViewId; |
|
166 |
|
167 RefreshL(); |
|
168 } |
|
169 SetMskL(); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // ChildDoDeactivate |
|
174 // From CFsEmailUiViewBase |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CFSEmailUiSendAttachmentsListVisualiser::ChildDoDeactivate() |
|
178 { |
|
179 FUNC_LOG; |
|
180 if ( !iAppUi.AppUiExitOngoing() ) |
|
181 { |
|
182 iScreenControl->Model()->GetVisualizer()->NotifyControlVisibilityChange( EFalse ); |
|
183 } |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // DynInitMenuPaneL |
|
188 // From aknview |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CFSEmailUiSendAttachmentsListVisualiser::DynInitMenuPaneL( |
|
192 TInt aResourceId, |
|
193 CEikMenuPane* aMenuPane ) |
|
194 { |
|
195 FUNC_LOG; |
|
196 if ( aResourceId == R_FS_EMAILUI_SENDATTACHMENTS_MENU_PANE ) |
|
197 { |
|
198 // if there are read-only attachments or there's no multiple attachments, |
|
199 // remove all functionality is disabled |
|
200 if ( iScreenControl->Model()->Count() <= 1 || |
|
201 iScreenControl->Model()->HasReadOnlyAttachments() ) |
|
202 { |
|
203 aMenuPane->SetItemDimmed( ESendAttachmentMenuRemoveAllAttachments, ETrue ); |
|
204 } |
|
205 |
|
206 // if no attachment is focused then disable open and remove |
|
207 CFSEmailUiSendAttachmentsListModelItem* item = iScreenControl->Model()->GetSelectedItem(); |
|
208 if ( !item || item->IsRemote() ) |
|
209 { |
|
210 aMenuPane->SetItemDimmed( ESendAttachmentMenuOpen, ETrue ); |
|
211 } |
|
212 |
|
213 if ( !item || item->IsReadOnly() ) |
|
214 { |
|
215 aMenuPane->SetItemDimmed( ESendAttachmentMenuRemoveAttachment, ETrue ); |
|
216 } |
|
217 |
|
218 // remove help support in pf5250 |
|
219 if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) ) |
|
220 { |
|
221 aMenuPane->SetItemDimmed( ESendAttachmentMenuHelp, ETrue); |
|
222 } |
|
223 } |
|
224 |
|
225 // Add shortcut hints |
|
226 iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, |
|
227 CFSEmailUiShortcutBinding::EContextSendAttachmentList ); |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // RefreshL |
|
232 // Refreshes list items |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CFSEmailUiSendAttachmentsListVisualiser::RefreshL() |
|
236 { |
|
237 FUNC_LOG; |
|
238 iScreenControl->Model()->ReFreshListL(); |
|
239 } |
|
240 |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // HandleDynamicVariantSwitchL |
|
244 // from aknview |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CFSEmailUiSendAttachmentsListVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ ) |
|
248 { |
|
249 FUNC_LOG; |
|
250 ReScaleUiL(); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // GetParentLayoutsL |
|
255 // From CFsEmailUiViewBase |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CFSEmailUiSendAttachmentsListVisualiser::GetParentLayoutsL( |
|
259 RPointerArray<CAlfVisual>& aLayoutArray ) const |
|
260 { |
|
261 aLayoutArray.AppendL( iScreenControl->Model()->GetParentLayout() ); |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // HandleCommandL |
|
266 // from aknview |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CFSEmailUiSendAttachmentsListVisualiser::HandleCommandL( TInt aCommand ) |
|
270 { |
|
271 FUNC_LOG; |
|
272 switch ( aCommand ) |
|
273 { |
|
274 case EAknSoftkeyOpen: |
|
275 case ESendAttachmentMenuOpen: |
|
276 // open file in suitable program |
|
277 iScreenControl->OpenHighlightedFileL(); |
|
278 break; |
|
279 case EFsEmailUiCmdCollapse: |
|
280 iScreenControl->HandleCommandL(EFsEmailUiCmdCollapse); |
|
281 break; |
|
282 case EFsEmailUiCmdExpand: |
|
283 iScreenControl->HandleCommandL(EFsEmailUiCmdExpand); |
|
284 break; |
|
285 case ESendAttachmentMenuAddAttachment: |
|
286 iScreenControl->AppendAttachmentToListL(); |
|
287 break; |
|
288 case ESendAttachmentMenuRemoveAttachment: |
|
289 iScreenControl->RemoveAttachmentFromListL(); |
|
290 break; |
|
291 case ESendAttachmentMenuRemoveAllAttachments: |
|
292 iScreenControl->RemoveAllAttachmentsL(); |
|
293 break; |
|
294 case ESendAttachmentMenuExit: |
|
295 iAppUi.Exit(); |
|
296 break; |
|
297 case ESendAttachmentMenuHelp: |
|
298 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID ); |
|
299 break; |
|
300 case EAknSoftkeyBack: |
|
301 { |
|
302 TPckgBuf<TEditorLaunchParams> buf( iEditorParams ); |
|
303 iAppUi.ReturnToPreviousViewL( buf ); |
|
304 break; |
|
305 } |
|
306 case EFsEmailUiCmdPageUp: |
|
307 { |
|
308 TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 }; |
|
309 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
310 } |
|
311 break; |
|
312 case EFsEmailUiCmdPageDown: |
|
313 { |
|
314 TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 }; |
|
315 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey ); |
|
316 } |
|
317 break; |
|
318 default: |
|
319 break; |
|
320 } |
|
321 |
|
322 // Handling the command may have changed the focused item |
|
323 SetMskL(); |
|
324 } |
|
325 |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // SetViewSoftkeysL |
|
329 // |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CFSEmailUiSendAttachmentsListVisualiser::SetViewSoftkeysL( TInt aResourceId ) |
|
333 { |
|
334 FUNC_LOG; |
|
335 Cba()->SetCommandSetL( aResourceId ); |
|
336 Cba()->DrawDeferred(); |
|
337 } |
|
338 |
|
339 void CFSEmailUiSendAttachmentsListVisualiser::SetMskL() |
|
340 { |
|
341 FUNC_LOG; |
|
342 TFsTreeItemId curId = iScreenControl->Model()->AttachmentList()->FocusedItem(); |
|
343 |
|
344 if ( curId != KFsTreeNoneID ) |
|
345 { |
|
346 if ( (iScreenControl->Model()->AttachmentList()->IsNode( curId )) ) |
|
347 { |
|
348 if ( iScreenControl->Model()->AttachmentList()->IsExpanded( curId ) ) |
|
349 { |
|
350 ChangeMskCommandL( R_FSE_QTN_MSK_COLLAPSE ); |
|
351 } |
|
352 else |
|
353 { |
|
354 ChangeMskCommandL( R_FSE_QTN_MSK_EXPAND ); |
|
355 } |
|
356 } |
|
357 else // non-node item |
|
358 { |
|
359 CFSEmailUiSendAttachmentsListModelItem* item = |
|
360 iScreenControl->Model()->GetSelectedItem(); |
|
361 if ( item && !item->IsRemote() ) |
|
362 { |
|
363 ChangeMskCommandL( R_FSE_QTN_MSK_OPEN ); |
|
364 } |
|
365 else |
|
366 { // Open command is inavailable for remote attachments |
|
367 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
368 } |
|
369 } |
|
370 } |
|
371 else |
|
372 { |
|
373 // No item in focus |
|
374 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
375 } |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // OfferEventL |
|
380 // |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 TBool CFSEmailUiSendAttachmentsListVisualiser::OfferEventL( const TAlfEvent& /*aEvent*/ ) |
|
384 { |
|
385 FUNC_LOG; |
|
386 return EFalse; |
|
387 } |
|
388 |
|
389 void CFSEmailUiSendAttachmentsListVisualiser::ReScaleUiL() |
|
390 { |
|
391 FUNC_LOG; |
|
392 iScreenControl->Model()->ReScaleUiL(); |
|
393 } |
|
394 |
|
395 CAlfControl* CFSEmailUiSendAttachmentsListVisualiser::ViewerControl() |
|
396 { |
|
397 FUNC_LOG; |
|
398 return iScreenControl; |
|
399 } |
|
400 |
|
401 TEditorLaunchParams CFSEmailUiSendAttachmentsListVisualiser::EditorParams() |
|
402 { |
|
403 FUNC_LOG; |
|
404 return iEditorParams; |
|
405 } |
|
406 |