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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <avkon.rsg> |
|
20 #include <eikmenup.h> |
|
21 #include <aknappui.h> |
|
22 #include <eikcmobs.h> |
|
23 #include <eikappui.h> |
|
24 #include <barsread.h> |
|
25 #include <stringloader.h> |
|
26 #include <aknnumedwin.h> |
|
27 #include <eikenv.h> |
|
28 #include <aknpopupfieldtext.h> |
|
29 #include <SyncStatusSpy.rsg> |
|
30 #include <centralrepository.h> |
|
31 #include <NsmlOperatorErrorCRKeys.h> |
|
32 |
|
33 #include "SyncStatusSpySettingItemList.h" |
|
34 #include "SyncStatusSpySettingItemListSettings.h" |
|
35 #include "SyncStatusSpySettingItemList.hrh" |
|
36 #include "SyncStatusSpyAppUi.h" |
|
37 |
|
38 /** |
|
39 * Construct the CSyncStatusSpySettingItemList instance |
|
40 * @param aCommandObserver command observer |
|
41 */ |
|
42 CSyncStatusSpySettingItemList::CSyncStatusSpySettingItemList( |
|
43 CSyncStatusSpySettingItemListSettings& aSettings, |
|
44 MEikCommandObserver* aCommandObserver ) |
|
45 : iSettings( aSettings ), iCommandObserver( aCommandObserver ) |
|
46 { |
|
47 |
|
48 } |
|
49 /** |
|
50 * Destroy any instance variables |
|
51 */ |
|
52 CSyncStatusSpySettingItemList::~CSyncStatusSpySettingItemList() |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 /** |
|
58 * Handle system notification that the container's size has changed. |
|
59 */ |
|
60 void CSyncStatusSpySettingItemList::SizeChanged() |
|
61 { |
|
62 if ( ListBox() ) |
|
63 { |
|
64 ListBox()->SetRect( Rect() ); |
|
65 } |
|
66 } |
|
67 |
|
68 /** |
|
69 * Create one setting item at a time, identified by id. |
|
70 * CAknSettingItemList calls this method and takes ownership |
|
71 * of the returned value. The CAknSettingItem object owns |
|
72 * a reference to the underlying data, which EditItemL() uses |
|
73 * to edit and store the value. |
|
74 */ |
|
75 CAknSettingItem* CSyncStatusSpySettingItemList::CreateSettingItemL( TInt aId ) |
|
76 { |
|
77 switch ( aId ) |
|
78 { |
|
79 case ESyncStatusSpyAppUiIntegerEditor1: |
|
80 { |
|
81 CAknIntegerEdwinSettingItem* item = new ( ELeave ) |
|
82 CAknIntegerEdwinSettingItem( |
|
83 aId, |
|
84 iSettings.IntegerEditor1() ); |
|
85 return item; |
|
86 } |
|
87 case ESyncStatusSpyAppUiIntegerEditor2: |
|
88 { |
|
89 CAknIntegerEdwinSettingItem* item = new ( ELeave ) |
|
90 CAknIntegerEdwinSettingItem( |
|
91 aId, |
|
92 iSettings.IntegerEditor2() ); |
|
93 return item; |
|
94 } |
|
95 case ESyncStatusSpyAppUiEnumeratedTextPopup2: |
|
96 { |
|
97 CAknEnumeratedTextPopupSettingItem* item = new ( ELeave ) |
|
98 CAknEnumeratedTextPopupSettingItem( |
|
99 aId, |
|
100 iSettings.EnumeratedTextPopup2() ); |
|
101 return item; |
|
102 } |
|
103 case ESyncStatusSpyAppUiEnumeratedTextPopup1: |
|
104 { |
|
105 CAknEnumeratedTextPopupSettingItem* item = new ( ELeave ) |
|
106 CAknEnumeratedTextPopupSettingItem( |
|
107 aId, |
|
108 iSettings.EnumeratedTextPopup1() ); |
|
109 return item; |
|
110 } |
|
111 |
|
112 } |
|
113 |
|
114 return NULL; |
|
115 } |
|
116 |
|
117 /** |
|
118 * Edit the setting item identified by the given id and store |
|
119 * the changes into the store. |
|
120 * @param aIndex the index of the setting item in SettingItemArray() |
|
121 * @param aCalledFromMenu true: a menu item invoked editing, thus |
|
122 * always show the edit page and interactively edit the item; |
|
123 * false: change the item in place if possible, else show the edit page |
|
124 */ |
|
125 void CSyncStatusSpySettingItemList::EditItemL ( TInt aIndex, TBool aCalledFromMenu ) |
|
126 { |
|
127 CAknSettingItem* item = ( *SettingItemArray() )[aIndex]; |
|
128 switch ( item->Identifier() ) |
|
129 { |
|
130 |
|
131 |
|
132 } |
|
133 |
|
134 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
135 |
|
136 TBool storeValue = ETrue; |
|
137 switch ( item->Identifier() ) |
|
138 { |
|
139 |
|
140 } |
|
141 |
|
142 if ( storeValue ) |
|
143 { |
|
144 item->StoreL(); |
|
145 SaveSettingValuesL(); |
|
146 } |
|
147 } |
|
148 /** |
|
149 * Handle the "Change" option on the Options menu. This is an |
|
150 * alternative to the Selection key that forces the settings page |
|
151 * to come up rather than changing the value in place (if possible). |
|
152 */ |
|
153 void CSyncStatusSpySettingItemList::ChangeSelectedItemL() |
|
154 { |
|
155 if ( ListBox()->CurrentItemIndex() >= 0 ) |
|
156 { |
|
157 EditItemL( ListBox()->CurrentItemIndex(), ETrue ); |
|
158 } |
|
159 } |
|
160 |
|
161 /** |
|
162 * Load the initial contents of the setting items. By default, |
|
163 * the setting items are populated with the default values from |
|
164 * the design. You can override those values here. |
|
165 * <p> |
|
166 * Note: this call alone does not update the UI. |
|
167 * LoadSettingsL() must be called afterwards. |
|
168 */ |
|
169 void CSyncStatusSpySettingItemList::LoadSettingValuesL() |
|
170 { |
|
171 // load values into iSettings |
|
172 TInt value; |
|
173 CRepository* rep = NULL; |
|
174 TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) ); |
|
175 if ( err == KErrNone ) |
|
176 { |
|
177 rep->Get( KNsmlOpDsErrorCode, value ); |
|
178 iSettings.SetIntegerEditor1( value ); |
|
179 |
|
180 rep->Get( KNsmlOpDsSyncProfUid, value ); |
|
181 iSettings.SetIntegerEditor2( value ); |
|
182 |
|
183 rep->Get( KNsmlOpDsSyncType, value ); |
|
184 iSettings.SetEnumeratedTextPopup2( value ); |
|
185 |
|
186 rep->Get( KNsmlOpDsSyncInitiation, value ); |
|
187 iSettings.SetEnumeratedTextPopup1( value ); |
|
188 |
|
189 delete rep; |
|
190 } |
|
191 } |
|
192 |
|
193 /** |
|
194 * Save the contents of the setting items. Note, this is called |
|
195 * whenever an item is changed and stored to the model, so it |
|
196 * may be called multiple times or not at all. |
|
197 */ |
|
198 void CSyncStatusSpySettingItemList::SaveSettingValuesL() |
|
199 { |
|
200 // store values from iSettings |
|
201 CRepository* rep = NULL; |
|
202 TRAPD ( err, rep = CRepository::NewL( KCRUidOperatorDatasyncErrorKeys ) ); |
|
203 if ( err == KErrNone ) |
|
204 { |
|
205 rep->Set( KNsmlOpDsErrorCode, iSettings.IntegerEditor1() ); |
|
206 rep->Set( KNsmlOpDsSyncProfUid, iSettings.IntegerEditor2() ); |
|
207 rep->Set( KNsmlOpDsSyncType, iSettings.EnumeratedTextPopup2() ); |
|
208 rep->Set( KNsmlOpDsSyncInitiation, iSettings.EnumeratedTextPopup1() ); |
|
209 |
|
210 delete rep; |
|
211 } |
|
212 } |
|
213 |
|
214 |
|
215 /** |
|
216 * Handle global resource changes, such as scalable UI or skin events (override) |
|
217 */ |
|
218 void CSyncStatusSpySettingItemList::HandleResourceChange( TInt aType ) |
|
219 { |
|
220 CAknSettingItemList::HandleResourceChange( aType ); |
|
221 SetRect( static_cast< CEikAppUi* >( iCoeEnv->AppUi() )->ClientRect() ); |
|
222 } |
|
223 |
|
224 /** |
|
225 * Handle key event (override) |
|
226 * @param aKeyEvent key event |
|
227 * @param aType event code |
|
228 * @return EKeyWasConsumed if the event was handled, else EKeyWasNotConsumed |
|
229 */ |
|
230 TKeyResponse CSyncStatusSpySettingItemList::OfferKeyEventL( |
|
231 const TKeyEvent& aKeyEvent, |
|
232 TEventCode aType ) |
|
233 { |
|
234 return CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType ); |
|
235 } |
|
236 |
|