|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Phonebook view navigation implementation. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "CPbkViewNavigator.h" |
|
22 #include <AknTabObserver.h> |
|
23 #include <aknnavi.h> |
|
24 #include <aknnavide.h> |
|
25 #include <akntabgrp.h> |
|
26 #include <CPbkAppUiBase.h> |
|
27 #include <CPbkAppViewBase.h> |
|
28 |
|
29 |
|
30 /// Unnamed namespace for local definitions |
|
31 namespace { |
|
32 |
|
33 // LOCAL FUNCTIONS |
|
34 CAknTabGroup* GetTabGroupOnTop(CAknNavigationControlContainer* aNaviPane) |
|
35 { |
|
36 CAknTabGroup* result = NULL; |
|
37 if (aNaviPane) |
|
38 { |
|
39 CAknNavigationDecorator* topDecorator = aNaviPane->Top(); |
|
40 if (topDecorator && |
|
41 topDecorator->ControlType() == CAknNavigationDecorator::ETabGroup) |
|
42 { |
|
43 result = static_cast<CAknTabGroup*>(topDecorator->DecoratedControl()); |
|
44 } |
|
45 } |
|
46 return result; |
|
47 } |
|
48 |
|
49 } // namespace |
|
50 |
|
51 // CLASS DECLARATION |
|
52 |
|
53 /** |
|
54 * Phonebook view navigation implementation. |
|
55 */ |
|
56 class CPbkViewNavigatorImpl : |
|
57 public CPbkViewNavigator, |
|
58 private MAknTabObserver |
|
59 { |
|
60 public: // Constructors and destructor |
|
61 CPbkViewNavigatorImpl |
|
62 (const CDigViewGraph& aViewGraph, CPbkAppUiBase& aAppUi); |
|
63 void ConstructL(); |
|
64 |
|
65 public: // from CPbkViewNavigator |
|
66 TBool HandleNavigationKeyEventL |
|
67 (const TKeyEvent& aKeyEvent, TEventCode aType); |
|
68 CAknNavigationDecorator* CreateTabGroupL(TResourceReader& aResReader); |
|
69 |
|
70 private: // from MAknTabObserver |
|
71 void TabChangedL(TInt aIndex); |
|
72 }; |
|
73 |
|
74 |
|
75 // ================= MEMBER FUNCTIONS ======================= |
|
76 |
|
77 inline CPbkViewNavigatorImpl::CPbkViewNavigatorImpl |
|
78 (const CDigViewGraph& aViewGraph, CPbkAppUiBase& aAppUi) : |
|
79 CPbkViewNavigator(aViewGraph, aAppUi) |
|
80 { |
|
81 } |
|
82 |
|
83 inline void CPbkViewNavigatorImpl::ConstructL() |
|
84 { |
|
85 BaseConstructL(); |
|
86 } |
|
87 |
|
88 CPbkViewNavigator* CPbkViewNavigator::NewL |
|
89 (const CDigViewGraph& aViewGraph, |
|
90 CPbkAppUiBase& aAppUi) |
|
91 { |
|
92 CPbkViewNavigatorImpl* self = |
|
93 new(ELeave) CPbkViewNavigatorImpl(aViewGraph, aAppUi); |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop(self); |
|
97 return self; |
|
98 } |
|
99 |
|
100 CAknNavigationDecorator* CPbkViewNavigatorImpl::CreateTabGroupL |
|
101 (TResourceReader& aResReader) |
|
102 { |
|
103 // Create tab group and register self as an observer to it |
|
104 return iNaviPane->CreateTabGroupL(aResReader,this); |
|
105 } |
|
106 |
|
107 TBool CPbkViewNavigatorImpl::HandleNavigationKeyEventL |
|
108 (const TKeyEvent& aKeyEvent, TEventCode aType) |
|
109 { |
|
110 TBool result = EFalse; |
|
111 CAknTabGroup* topTabGroup = GetTabGroupOnTop(iNaviPane); |
|
112 if (topTabGroup) |
|
113 { |
|
114 result = topTabGroup->OfferKeyEventL(aKeyEvent, aType)==EKeyWasConsumed; |
|
115 } |
|
116 return result; |
|
117 } |
|
118 |
|
119 void CPbkViewNavigatorImpl::TabChangedL(TInt aIndex) |
|
120 { |
|
121 CAknTabGroup* topTabGroup = GetTabGroupOnTop(iNaviPane); |
|
122 if (topTabGroup) |
|
123 { |
|
124 // View ID is stored in the tab |
|
125 const TInt viewId(topTabGroup->TabIdFromIndex(aIndex)); |
|
126 // Get current view's state and use it as a parameter to the next view |
|
127 CPbkViewState* activeViewState = iAppUi.ActiveView()->GetViewStateLC(); |
|
128 iAppUi.ActivatePhonebookViewL(TUid::Uid(viewId), activeViewState); |
|
129 if (activeViewState) |
|
130 { |
|
131 CleanupStack::PopAndDestroy(activeViewState); |
|
132 } |
|
133 } |
|
134 } |
|
135 |
|
136 // End of File |