|
1 /* |
|
2 * Copyright (c) 2005-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: Implementation of CGSAccHACView class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <gsaccessoryplugin.rsg> |
|
20 #include <gscommon.hrh> |
|
21 |
|
22 #include "acclocalviewids.h" |
|
23 #include "gsaccessoryplugin.hrh" |
|
24 #include "gsaccessorypluginmodel.h" |
|
25 #include "gsacchaccontainer.h" |
|
26 #include "gsacchacview.h" |
|
27 #include "trace.h" |
|
28 |
|
29 // ========================= MEMBER FUNCTIONS ================================ |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CGSAccHACView::NewLC() |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CGSAccHACView* CGSAccHACView::NewLC( CGSAccessoryPluginModel& aModel ) |
|
36 { |
|
37 CGSAccHACView* self = new ( ELeave ) CGSAccHACView( aModel ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->BaseConstructL( R_ACC_HAC_VIEW ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CGSAccHACView::~CGSAccHACView() |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CGSAccHACView::~CGSAccHACView() |
|
49 { |
|
50 FUNC_LOG; |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // TUid CGSAccHACView::Id() |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 TUid CGSAccHACView::Id() const |
|
59 { |
|
60 return KAccHACViewId; |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CGSAccHACView::HandleCommandL() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CGSAccHACView::HandleCommandL( TInt aCommand ) |
|
69 { |
|
70 FUNC_LOG; |
|
71 |
|
72 if ( aCommand == EGSCmdAppChange ) |
|
73 { |
|
74 const TInt currentFeatureId = iContainer->CurrentFeatureId(); |
|
75 if ( currentFeatureId == KGSSettIdHACMode ) |
|
76 { |
|
77 // Change HAC mode setting through selection dialog |
|
78 ChangeHACModeSettingL( ETrue ); |
|
79 } |
|
80 else |
|
81 { |
|
82 // Act as user had pressed the selection key |
|
83 HandleListBoxSelectionL( currentFeatureId ); |
|
84 } |
|
85 } |
|
86 else |
|
87 { |
|
88 CGSAccBaseView::HandleCommandL( aCommand ); |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CGSAccHACView::NewContainerL() |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CGSAccHACView::NewContainerL() |
|
98 { |
|
99 iContainer = new ( ELeave ) CGSAccHACContainer( iModel ); |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CGSAccHACView::HandleListBoxSelectionL() |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CGSAccHACView::HandleListBoxSelectionL( TInt aSelectedItem ) |
|
108 { |
|
109 FUNC_LOG; |
|
110 |
|
111 // User has pressed selection key. If the selected item has just two |
|
112 // possible values, flip the value to the other option. If the item has |
|
113 // more possible values, show a selection dialog. |
|
114 if ( aSelectedItem == KGSSettIdHACMode ) |
|
115 { |
|
116 // Change HAC mode setting without selection dialog |
|
117 ChangeHACModeSettingL( EFalse ); |
|
118 } |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CGSAccHACView::CGSAccHACView() |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 CGSAccHACView::CGSAccHACView( CGSAccessoryPluginModel& aModel ) |
|
127 : CGSAccBaseView( aModel ) |
|
128 { |
|
129 FUNC_LOG; |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CGSAccHACView::ChangeHACModeSettingL() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CGSAccHACView::ChangeHACModeSettingL( TBool aUseSettingPage ) |
|
138 { |
|
139 FUNC_LOG; |
|
140 |
|
141 TInt currentValue = iModel.HacMode(); |
|
142 TBool updateValue( EFalse ); |
|
143 |
|
144 // Value is updated either by setting page or simply switching to other |
|
145 // value (On<->Off). |
|
146 if ( aUseSettingPage ) |
|
147 { |
|
148 updateValue = ShowRadioButtonSettingsPageL( |
|
149 R_ACC_HAC_MODE_SETTING_PAGE, |
|
150 R_ACC_HAC_MODE_SETTING_PAGE_LBX, |
|
151 currentValue ); |
|
152 } |
|
153 else |
|
154 { |
|
155 // User pressed selection key instead of opening setting page. |
|
156 // Do not ask user input from dialog - just flip the value: |
|
157 // 0 -> 1, 1 -> 0. |
|
158 iModel.FlipValue( currentValue ); |
|
159 updateValue = ETrue; |
|
160 } |
|
161 |
|
162 if ( updateValue ) // If value was changed, store it. |
|
163 { |
|
164 iModel.SetHacModeL( currentValue ); |
|
165 UpdateListBoxL( KGSSettIdHACMode ); |
|
166 } |
|
167 } |