|
1 /* |
|
2 * Copyright (c) 2009 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: Container for the Power saving query view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSPowerSavingQueryPluginContainer.h" |
|
21 #include "GSPowerSavingQueryPluginModel.h" |
|
22 #include "GSPowerSavingQueryPlugin.hrh" |
|
23 #include "GsLogger.h" |
|
24 #include <GSPowerSavingQueryPluginRsc.rsg> |
|
25 #include <aknlists.h> |
|
26 #include <StringLoader.h> |
|
27 #include <AknUtils.h> |
|
28 #include <gsfwviewuids.h> |
|
29 #include <gslistbox.h> |
|
30 |
|
31 // ========================= MEMBER FUNCTIONS ================================ |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CGSPowerSavingQueryPluginContainer::ConstructL() |
|
35 // |
|
36 // Symbian OS two phased constructor |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 void CGSPowerSavingQueryPluginContainer::ConstructL( const TRect& aRect ) |
|
40 { |
|
41 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]-->CGSPowerSavingQueryPluginContainer::ConstructL"); |
|
42 |
|
43 iListBox = new( ELeave ) CAknSettingStyleListBox; |
|
44 iModel = CGSPowerSavingQueryPluginModel::NewL(); |
|
45 |
|
46 BaseConstructL( aRect, R_GS_POWER_SAVING_QUERY_VIEW_TITLE, |
|
47 R_POWER_SAVING_QUERY_LBX ); |
|
48 |
|
49 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]<--CGSPowerSavingQueryPluginContainer::ConstructL"); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CGSPowerSavingQueryPluginContainer::~CGSPowerSavingQueryPluginContainer() |
|
54 // |
|
55 // Destructor |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CGSPowerSavingQueryPluginContainer::~CGSPowerSavingQueryPluginContainer() |
|
59 { |
|
60 delete iListboxItemArray; |
|
61 delete iModel; |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CGSPowerSavingQueryPluginContainer::ConstructListBoxL() |
|
67 // |
|
68 // Construct the listbox from resource array. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CGSPowerSavingQueryPluginContainer::ConstructListBoxL( TInt aResLbxId ) |
|
72 { |
|
73 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]-->CGSPowerSavingQueryPluginContainer::ConstructListBoxL"); |
|
74 |
|
75 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
76 |
|
77 iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, |
|
78 *iListBox, *iCoeEnv ); |
|
79 iListBox->Model()->SetItemTextArray( iListboxItemArray ); |
|
80 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
81 |
|
82 CreateListBoxItemsL(); |
|
83 |
|
84 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]<--CGSPowerSavingQueryPluginContainer::ConstructListBoxL"); |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CGSPowerSavingQueryPluginContainer::CreateListBoxItemsL() |
|
90 // |
|
91 // Create listbox items. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CGSPowerSavingQueryPluginContainer::CreateListBoxItemsL() |
|
95 { |
|
96 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]-->CGSPowerSavingQueryPluginContainer::CreateListBoxItemsL"); |
|
97 |
|
98 MakePowerSavingQueryItemL(); |
|
99 |
|
100 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]<--CGSPowerSavingQueryPluginContainer::CreateListBoxItemsL"); |
|
101 } |
|
102 |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CGSPowerSavingQueryPluginContainer::UpdateListBoxL() |
|
106 // |
|
107 // Update listbox item. |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CGSPowerSavingQueryPluginContainer::UpdateListBoxL( TInt aFeatureId ) |
|
111 { |
|
112 switch( aFeatureId ) |
|
113 { |
|
114 case KGSSettIdPowerSavingQuery: |
|
115 MakePowerSavingQueryItemL(); |
|
116 break; |
|
117 default: |
|
118 break; |
|
119 } |
|
120 |
|
121 iListBox->HandleItemAdditionL(); |
|
122 } |
|
123 |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CGSPowerSavingQueryPluginContainer::MakePowerSavingQueryItemL() |
|
127 // |
|
128 // Create Power saving query list item |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CGSPowerSavingQueryPluginContainer::MakePowerSavingQueryItemL() |
|
132 { |
|
133 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]-->CGSPowerSavingQueryPluginContainer::MakePowerSavingQueryItemL"); |
|
134 |
|
135 TInt queryValue = iModel->PowerSavingQueryEnabled(); |
|
136 |
|
137 TInt resId( R_POWER_SAVING_QUERY_OFF ); |
|
138 if ( EGSPowerSavingQueryOn == queryValue ) |
|
139 { |
|
140 resId = R_POWER_SAVING_QUERY_ON; |
|
141 } |
|
142 |
|
143 HBufC* buf = iEikonEnv->AllocReadResourceL( resId ); |
|
144 |
|
145 TPtr bufPtr( buf->Des() ); |
|
146 iListboxItemArray->SetDynamicTextL( KGSSettIdPowerSavingQuery, bufPtr ); |
|
147 |
|
148 // And add to listbox |
|
149 iListboxItemArray->SetItemVisibilityL( KGSSettIdPowerSavingQuery, |
|
150 CGSListBoxItemTextArray::EVisible ); |
|
151 |
|
152 delete buf; |
|
153 |
|
154 __GSLOGSTRING("[CGSPowerSavingQueryPluginContainer]<--CGSPowerSavingQueryPluginContainer::MakePowerSavingQueryItemL"); |
|
155 |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CGSPowerSavingQueryPluginContainer::GetHelpContext() const |
|
160 // |
|
161 // Gets Help |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CGSPowerSavingQueryPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
165 { |
|
166 aContext.iMajor = KUidGS; |
|
167 // aContext.iContext = 0; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CGSPowerSavingQueryPluginContainer::CurrentFeatureId() |
|
172 // |
|
173 // Return the feature id of selected listitem |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CGSPowerSavingQueryPluginContainer::CurrentFeatureId() const |
|
177 { |
|
178 return iListboxItemArray->CurrentFeature(); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CGSPowerSavingQueryPluginContainer::Model() |
|
183 // |
|
184 // Return the power saving query plugin data model |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 CGSPowerSavingQueryPluginModel* CGSPowerSavingQueryPluginContainer::Model() |
|
188 { |
|
189 return iModel; |
|
190 } |
|
191 |
|
192 // End of File |