|
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 <AknGlobalNote.h> |
|
19 |
|
20 #include "TrkSettingsData.h" |
|
21 #include "TrkSettingsList.h" |
|
22 #include "TrkUids.h" |
|
23 #include "TrkApp.hrh" |
|
24 |
|
25 CTrkSettingsList::CTrkSettingsList(CTrkSettingsData* aSettingsData) |
|
26 :iSettingsData(aSettingsData) |
|
27 { |
|
28 } |
|
29 |
|
30 TKeyResponse CTrkSettingsList::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
31 { |
|
32 if (aType != EEventKey) // Is not key event? |
|
33 { |
|
34 return EKeyWasNotConsumed; |
|
35 } |
|
36 |
|
37 switch (aKeyEvent.iCode) // The code of key event is... |
|
38 { |
|
39 default: |
|
40 CAknSettingItemList::OfferKeyEventL(aKeyEvent, aType); |
|
41 break; |
|
42 } |
|
43 |
|
44 return EKeyWasConsumed; |
|
45 } |
|
46 |
|
47 void CTrkSettingsList::SizeChanged() |
|
48 { |
|
49 if (ListBox()) |
|
50 ListBox()->SetRect(Rect()); |
|
51 } |
|
52 |
|
53 void CTrkSettingsList::ChangeSelectedItemL() |
|
54 { |
|
55 if (ListBox()) |
|
56 EditItemL(ListBox()->CurrentItemIndex(), ETrue); |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 CTrkConnSettingsList::CTrkConnSettingsList(CTrkSettingsData* aSettingsData) |
|
63 :CTrkSettingsList(aSettingsData) |
|
64 { |
|
65 } |
|
66 |
|
67 CAknSettingItem* CTrkConnSettingsList::CreateSettingItemL(TInt aIdentifier) |
|
68 { |
|
69 CAknSettingItem* item = NULL; |
|
70 |
|
71 switch (aIdentifier) |
|
72 { |
|
73 case ETrkConnectionType: |
|
74 { |
|
75 item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iConnTypeIndex); |
|
76 break; |
|
77 } |
|
78 case ETrkConnectionPort: |
|
79 { |
|
80 item = new (ELeave) CAknIntegerEdwinSettingItem(aIdentifier, iSettingsData->iPortNumber); |
|
81 break; |
|
82 } |
|
83 case ETrkConnectionBaudRate: |
|
84 { |
|
85 item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iBaudRateIndex); |
|
86 break; |
|
87 } |
|
88 case ETrkPlugAndPlayOption: |
|
89 { |
|
90 item = new (ELeave) CTrkConnIndexPopupSettingItem(aIdentifier, iSettingsData->iPlugAndPlayType); |
|
91 break; |
|
92 } |
|
93 } |
|
94 |
|
95 return item; |
|
96 } |
|
97 |
|
98 void CTrkConnSettingsList::ControlStateChangedAfterL(TInt aIndex) |
|
99 { |
|
100 CAknSettingItemArray* array = SettingItemArray(); |
|
101 |
|
102 CTrkConnIndexPopupSettingItem* connTypePopUp = (CTrkConnIndexPopupSettingItem *)array->At(0); |
|
103 TInt index = connTypePopUp->CurrentIndex(); |
|
104 |
|
105 CAknSettingItem* portEditor = array->At(1); |
|
106 CAknSettingItem* baudRatePopUp = array->At(2); |
|
107 |
|
108 switch(aIndex) |
|
109 { |
|
110 case 0: |
|
111 { |
|
112 switch (index) |
|
113 { |
|
114 // Now port and baud rate are hidden for |
|
115 case 0: // USB (Dbg&Trc) |
|
116 case 1: // BT |
|
117 case 2: // XTI |
|
118 case 3: // DCC |
|
119 { |
|
120 portEditor->SetHidden(ETrue); |
|
121 baudRatePopUp->SetHidden(ETrue); |
|
122 HandleChangeInItemArrayOrVisibilityL(); |
|
123 break; |
|
124 } |
|
125 default: |
|
126 break; |
|
127 } |
|
128 break; |
|
129 } |
|
130 default: |
|
131 break; |
|
132 } |
|
133 } |
|
134 |
|
135 void CTrkConnSettingsList::ControlStateChangedBeforeL(TInt aIndex) |
|
136 { |
|
137 CAknSettingItemArray* array = SettingItemArray(); |
|
138 |
|
139 CTrkConnIndexPopupSettingItem* connTypePopUp = (CTrkConnIndexPopupSettingItem *)array->At(0); |
|
140 TInt index = connTypePopUp->CurrentIndex(); |
|
141 |
|
142 CAknSettingItem* portEditor = array->At(1); |
|
143 CAknSettingItem* baudRatePopUp = array->At(2); |
|
144 |
|
145 switch(aIndex) |
|
146 { |
|
147 case 1: |
|
148 { |
|
149 switch(index) |
|
150 { |
|
151 case 2: |
|
152 { |
|
153 _LIT(KPortNumberInfo, "Recommended port for IR connection is 0."); |
|
154 CAknGlobalNote* globalNote = CAknGlobalNote::NewLC(); |
|
155 globalNote->ShowNoteL(EAknGlobalInformationNote, KPortNumberInfo); |
|
156 CleanupStack::PopAndDestroy(globalNote); |
|
157 break; |
|
158 } |
|
159 default: |
|
160 break; |
|
161 } |
|
162 } |
|
163 default: |
|
164 break; |
|
165 } |
|
166 } |
|
167 |
|
168 void CTrkConnSettingsList::EditItemL(TInt aIndex, TBool aCalledFromMenu) |
|
169 { |
|
170 CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu); |
|
171 ControlStateChangedAfterL(aIndex); |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 CTrkConnIndexPopupSettingItem::CTrkConnIndexPopupSettingItem(TInt aResourceId, TInt& aValue) |
|
177 : CAknEnumeratedTextPopupSettingItem(aResourceId, aValue) |
|
178 { |
|
179 } |