|
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: Calendar action ui |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <aknViewAppUi.h> |
|
21 #include <avkon.hrh> |
|
22 #include <aknnavi.h> |
|
23 #include <akntitle.h> |
|
24 #include <eikspane.h> |
|
25 #include <Calendar.rsg> |
|
26 #include <calencommonui.rsg> |
|
27 #include <calenservices.h> |
|
28 #include <calentoolbar.h> |
|
29 |
|
30 #include "calendarui_debug.h" |
|
31 #include "calenactionui.h" |
|
32 #include "calencontroller.h" |
|
33 #include "calendeleteui.h" |
|
34 #include "caleneditui.h" |
|
35 #include "calenlocationui.h" |
|
36 #include "calensettingsui.h" |
|
37 #include "calennotifier.h" |
|
38 #include "calenmultipledbui.h" |
|
39 #include "calenattachmentui.h" |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CCalenActionUi::NewL |
|
43 // 1st phase of construction |
|
44 // (other items were commented in a header). |
|
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 CCalenActionUi* CCalenActionUi::NewL( CCalenController& aController ) |
|
48 { |
|
49 TRACE_ENTRY_POINT; |
|
50 |
|
51 CCalenActionUi* self = new( ELeave ) CCalenActionUi( aController ); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop( self ); |
|
55 |
|
56 TRACE_EXIT_POINT; |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CCalenActionUi::CCalenActionUi |
|
62 // C++ default constructor. |
|
63 // (other items were commented in a header). |
|
64 // ---------------------------------------------------------------------------- |
|
65 // |
|
66 CCalenActionUi::CCalenActionUi( CCalenController& aController ) |
|
67 : iController( aController ) |
|
68 { |
|
69 TRACE_ENTRY_POINT; |
|
70 TRACE_EXIT_POINT; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CCalenActionUi::ConstructL |
|
75 // 2nd phase of construction. |
|
76 // (other items were commented in a header). |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 void CCalenActionUi::ConstructL() |
|
80 { |
|
81 TRACE_ENTRY_POINT; |
|
82 TRACE_EXIT_POINT; |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // CCalenActionUi::~CCalenActionUi |
|
87 // Destructor. |
|
88 // (other items were commented in a header). |
|
89 // ---------------------------------------------------------------------------- |
|
90 // |
|
91 CCalenActionUi::~CCalenActionUi() |
|
92 { |
|
93 TRACE_ENTRY_POINT; |
|
94 |
|
95 delete iDeleteUi; |
|
96 delete iEditUi; |
|
97 delete iLocationUi; |
|
98 delete iAttachmentUi; |
|
99 |
|
100 TRACE_EXIT_POINT; |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CCalenActionUi::GetCommandHandlerL |
|
105 // Gets a command handler |
|
106 // ---------------------------------------------------------------------------- |
|
107 // |
|
108 MCalenCommandHandler* CCalenActionUi::GetCommandHandlerL( TInt aCommand ) |
|
109 { |
|
110 MCalenCommandHandler* handler = NULL; |
|
111 |
|
112 if( aCommand >= ECalenEditCommandBase && |
|
113 aCommand < ECalenDeleteCommandBase ) |
|
114 { |
|
115 if(!iEditUi) |
|
116 { |
|
117 iEditUi = CCalenEditUi::NewL(iController); |
|
118 } |
|
119 handler = iEditUi; |
|
120 } |
|
121 else if( aCommand >= ECalenDeleteCommandBase && |
|
122 aCommand < ECalenSettingsCommandBase ) |
|
123 { |
|
124 if(!iDeleteUi) |
|
125 { |
|
126 iDeleteUi = CCalenDeleteUi::NewL( iController ); |
|
127 } |
|
128 handler = iDeleteUi; |
|
129 } |
|
130 else if( aCommand >= ECalenSettingsCommandBase && |
|
131 aCommand < ECalenMapCommandBase ) |
|
132 { |
|
133 handler = this; |
|
134 } |
|
135 else if( aCommand >= ECalenMapCommandBase && |
|
136 aCommand < ECalenAttachmentCommandBase ) |
|
137 { |
|
138 if(!iLocationUi) |
|
139 { |
|
140 iLocationUi = CCalenLocationUi::NewL( iController ); |
|
141 } |
|
142 handler = iLocationUi; |
|
143 } |
|
144 else if( aCommand >= ECalenAttachmentCommandBase && |
|
145 aCommand < ECalenLastCommand ) |
|
146 { |
|
147 if(!iAttachmentUi) |
|
148 { |
|
149 iAttachmentUi = CCalenAttachmentUi::NewL(iController); |
|
150 } |
|
151 handler = iAttachmentUi; |
|
152 } |
|
153 |
|
154 TRACE_EXIT_POINT; |
|
155 return handler; |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------------------------------- |
|
159 // CCalenActionUi::HandleCommmandL |
|
160 // Handles Calendar commands. Delegates to appropriate action ui. |
|
161 // (other items were commented in a header). |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 /*TBool CCalenActionUi::HandleActionUiCommandL( TInt aCommand ) |
|
165 { |
|
166 TRACE_ENTRY_POINT; |
|
167 |
|
168 // Lazy initialisation for action uis. |
|
169 TBool handled( EFalse ); |
|
170 |
|
171 if( aCommand >= ECalenEditCommandBase && aCommand < ECalenLastCommand ) |
|
172 { |
|
173 if( !iEditUi ) |
|
174 { |
|
175 iEditUi = CCalenEditUi::NewL( iController ); |
|
176 } |
|
177 handled = iEditUi->HandleActionUiCommandL( aCommand ); |
|
178 |
|
179 if( !handled ) |
|
180 { |
|
181 if( !iDeleteUi ) |
|
182 { |
|
183 iDeleteUi = CCalenDeleteUi::NewL( iController ); |
|
184 } |
|
185 handled = iDeleteUi->HandleActionUiCommandL( aCommand ); |
|
186 } |
|
187 |
|
188 if( !handled && aCommand == ECalenShowSettings ) |
|
189 { |
|
190 handled = ETrue; |
|
191 |
|
192 ShowSettingsL(); |
|
193 } |
|
194 } |
|
195 |
|
196 TRACE_EXIT_POINT; |
|
197 return handled; |
|
198 }*/ |
|
199 |
|
200 |
|
201 // ---------------------------------------------------------------------------- |
|
202 // CCalenActionUi::HandleCommandL |
|
203 // Handles key presses. |
|
204 // (other items were commented in a header). |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CCalenActionUi::HandleCommandL( const TCalenCommand& aCommand ) |
|
208 { |
|
209 TRACE_ENTRY_POINT; |
|
210 TBool continueCommand(EFalse); |
|
211 |
|
212 switch(aCommand.Command()) |
|
213 { |
|
214 case ECalenShowSettings: |
|
215 { |
|
216 ShowSettingsL(); |
|
217 } |
|
218 break; |
|
219 case ECalenShowCalendars: |
|
220 { |
|
221 ShowCalendarsL(); |
|
222 } |
|
223 break; |
|
224 default: |
|
225 break; |
|
226 } |
|
227 |
|
228 TRACE_EXIT_POINT; |
|
229 return continueCommand; |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CCalenActionUi::CalenCommandHandlerExtensionL |
|
234 // Dummy implementation. |
|
235 // (other items were commented in a header). |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 TAny* CCalenActionUi::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
|
239 { |
|
240 TRACE_ENTRY_POINT; |
|
241 TRACE_EXIT_POINT; |
|
242 return NULL; |
|
243 } |
|
244 |
|
245 // ---------------------------------------------------------------------------- |
|
246 // CCalenActionUi::ShowCalendarsL |
|
247 // Shows the multiple db calendar's dialog |
|
248 // (other items were commented in a header). |
|
249 // ---------------------------------------------------------------------------- |
|
250 // |
|
251 void CCalenActionUi::ShowCalendarsL() |
|
252 { |
|
253 TRACE_ENTRY_POINT; |
|
254 // Create settings own titlepane and navipane, and swap with existing ones |
|
255 CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
256 |
|
257 // Titlepane |
|
258 CAknTitlePane* newtp = new( ELeave ) CAknTitlePane(); |
|
259 CleanupStack::PushL( newtp ); |
|
260 CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp ); |
|
261 CleanupStack::Pop( newtp ); // ownership is passed to statuspane |
|
262 TRect oldRect( 0, 0, 0, 0 ); |
|
263 if( oldtp ) |
|
264 { |
|
265 CleanupStack::PushL( oldtp ); |
|
266 oldRect = oldtp->Rect(); |
|
267 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle )); |
|
268 newtp->SetContainerWindowL( *ctrl ); |
|
269 newtp->ConstructL(); |
|
270 newtp->SetRect(oldRect); |
|
271 newtp->ActivateL(); |
|
272 } |
|
273 // NaviPane |
|
274 CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer(); |
|
275 CleanupStack::PushL( newnp ); |
|
276 CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp ); |
|
277 CleanupStack::Pop( newnp ); // ownership is passed to statuspane |
|
278 if( oldnp ) |
|
279 { |
|
280 CleanupStack::PushL( oldnp ); |
|
281 oldRect = oldnp->Rect(); |
|
282 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
283 newnp->SetContainerWindowL( *ctrl ); |
|
284 newnp->ConstructL(); |
|
285 newnp->SetRect( oldRect ); |
|
286 newnp->PushDefaultL(); |
|
287 newnp->ActivateL(); |
|
288 } |
|
289 |
|
290 // Hide the toolbar before we display settings menu |
|
291 MCalenToolbar* toolbar = iController.Services().ToolbarOrNull(); |
|
292 if(toolbar) |
|
293 { |
|
294 toolbar->SetToolbarVisibilityL(EFalse); |
|
295 } |
|
296 |
|
297 // defer settings notifications before launching the settings |
|
298 CCalenNotifier& notifier = iController.Notifier(); |
|
299 notifier.DeferSettingsNotifications(); |
|
300 |
|
301 CCalenMultipleDbUi* dlg = CCalenMultipleDbUi::NewL(iController); |
|
302 TInt retValue = KErrNone; |
|
303 // Trap showing settings so settings watcher is always resumed. |
|
304 PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_MULTIPLEDB_DIALOG ) ); |
|
305 notifier.ResumeSettingsNotifications(); |
|
306 |
|
307 // Unhide the toolbar when settings is closed |
|
308 if(toolbar) |
|
309 { |
|
310 toolbar->SetToolbarVisibilityL(ETrue); |
|
311 } |
|
312 |
|
313 // When setting is closed, swap back old titlepane and navipane |
|
314 if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) ) |
|
315 { |
|
316 CleanupStack::Pop( oldnp ); |
|
317 delete newnp; |
|
318 oldnp->ActivateL(); |
|
319 } |
|
320 if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) ) |
|
321 { |
|
322 CleanupStack::Pop( oldtp ); |
|
323 delete newtp; |
|
324 oldtp->ActivateL(); |
|
325 } |
|
326 |
|
327 iController.BroadcastNotification( ECalenNotifyCalendarFieldChanged ); |
|
328 |
|
329 if( retValue == EAknCmdExit || |
|
330 retValue == EKeyEscape ) |
|
331 { |
|
332 // iController.IssueCommandL( EAknCmdExit ); |
|
333 // FIX ME :: |
|
334 // Issuing the command from here will not exit the application properly |
|
335 // because aknviewappui is not exited |
|
336 // Calling ProcessCommandL of aknviewappui will exits the application |
|
337 iController.AppUi().ProcessCommandL(EAknCmdExit); |
|
338 } |
|
339 else if(retValue == EAknSoftkeyExit) |
|
340 { |
|
341 // iController.IssueCommandL( EAknCmdExit ); |
|
342 // FIX ME :: |
|
343 // Issuing the command from here will not exit the application properly |
|
344 // because aknviewappui is not exited |
|
345 // Calling ProcessCommandL of aknviewappui will exits the application |
|
346 iController.AppUi().ProcessCommandL(EAknSoftkeyExit); |
|
347 } |
|
348 |
|
349 TRACE_EXIT_POINT; |
|
350 } |
|
351 |
|
352 // ---------------------------------------------------------------------------- |
|
353 // CCalenActionUi::ShowSettingsL |
|
354 // Shows the settings dialog |
|
355 // (other items were commented in a header). |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 void CCalenActionUi::ShowSettingsL() |
|
359 { |
|
360 TRACE_ENTRY_POINT; |
|
361 |
|
362 // Create settings own titlepane and navipane, and swap with existing ones |
|
363 CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
364 |
|
365 // Titlepane |
|
366 CAknTitlePane* newtp = new( ELeave ) CAknTitlePane(); |
|
367 CleanupStack::PushL( newtp ); |
|
368 CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp ); |
|
369 CleanupStack::Pop( newtp ); // ownership is passed to statuspane |
|
370 TRect oldRect( 0, 0, 0, 0 ); |
|
371 if( oldtp ) |
|
372 { |
|
373 CleanupStack::PushL( oldtp ); |
|
374 oldRect = oldtp->Rect(); |
|
375 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle )); |
|
376 newtp->SetContainerWindowL( *ctrl ); |
|
377 newtp->ConstructL(); |
|
378 newtp->SetRect(oldRect); |
|
379 newtp->ActivateL(); |
|
380 } |
|
381 |
|
382 // NaviPane |
|
383 CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer(); |
|
384 CleanupStack::PushL( newnp ); |
|
385 CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp ); |
|
386 CleanupStack::Pop( newnp ); // ownership is passed to statuspane |
|
387 if( oldnp ) |
|
388 { |
|
389 CleanupStack::PushL( oldnp ); |
|
390 oldRect = oldnp->Rect(); |
|
391 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
392 newnp->SetContainerWindowL( *ctrl ); |
|
393 newnp->ConstructL(); |
|
394 newnp->SetRect( oldRect ); |
|
395 newnp->PushDefaultL(); |
|
396 newnp->ActivateL(); |
|
397 } |
|
398 |
|
399 // Hide the toolbar before we display settings menu |
|
400 MCalenToolbar* toolbar = iController.Services().ToolbarOrNull(); |
|
401 if(toolbar) |
|
402 { |
|
403 toolbar->SetToolbarVisibilityL(EFalse); |
|
404 } |
|
405 |
|
406 // defer settings notifications before launching the settings |
|
407 CCalenNotifier& notifier = iController.Notifier(); |
|
408 notifier.DeferSettingsNotifications(); |
|
409 |
|
410 CCalenSettingsUi* dlg = CCalenSettingsUi::NewL(iController.CustomisationManager()); |
|
411 TInt retValue = KErrNone; |
|
412 // Trap showing settings so settings watcher is always resumed. |
|
413 PIM_TRAPD_HANDLE( retValue = dlg->ExecuteLD( R_CALEN_SETTING_DIALOG ) ); |
|
414 notifier.ResumeSettingsNotifications(); |
|
415 |
|
416 // Unhide the toolbar when settings is closed |
|
417 if(toolbar) |
|
418 { |
|
419 toolbar->SetToolbarVisibilityL(ETrue); |
|
420 } |
|
421 |
|
422 // When setting is closed, swap back old titlepane and navipane |
|
423 if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) ) |
|
424 { |
|
425 CleanupStack::Pop( oldnp ); |
|
426 delete newnp; |
|
427 oldnp->ActivateL(); |
|
428 } |
|
429 if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) ) |
|
430 { |
|
431 CleanupStack::Pop( oldtp ); |
|
432 delete newtp; |
|
433 oldtp->ActivateL(); |
|
434 } |
|
435 |
|
436 iController.BroadcastNotification( ECalenNotifySettingsClosed ); |
|
437 |
|
438 if( retValue == EAknCmdExit || |
|
439 retValue == EKeyEscape ) |
|
440 { |
|
441 // iController.IssueCommandL( EAknCmdExit ); |
|
442 // FIX ME :: |
|
443 // Issuing the command from here will not exit the application properly |
|
444 // because aknviewappui is not exited |
|
445 // Calling ProcessCommandL of aknviewappui will exits the application |
|
446 iController.AppUi().ProcessCommandL(EAknCmdExit); |
|
447 } |
|
448 else if(retValue == EAknSoftkeyExit) |
|
449 { |
|
450 // iController.IssueCommandL( EAknCmdExit ); |
|
451 // FIX ME :: |
|
452 // Issuing the command from here will not exit the application properly |
|
453 // because aknviewappui is not exited |
|
454 // Calling ProcessCommandL of aknviewappui will exits the application |
|
455 iController.AppUi().ProcessCommandL(EAknSoftkeyExit); |
|
456 } |
|
457 |
|
458 TRACE_EXIT_POINT; |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CCalenActionUi::IsEditorActive |
|
463 // Tells framework whether editor is active or not |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 TBool CCalenActionUi::IsEditorActive() |
|
467 { |
|
468 if(iEditUi) |
|
469 { |
|
470 return(iEditUi->IsEditorActive()); |
|
471 } |
|
472 else |
|
473 return EFalse; |
|
474 } |
|
475 |
|
476 // End of file |