1 /* |
|
2 * Copyright (c) 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: Find stations container. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknlists.h> |
|
20 #include <eikfrlbd.h> |
|
21 |
|
22 #include <barsread.h> |
|
23 #include <eikenv.h> |
|
24 #include <eiklabel.h> |
|
25 #include <eikmenub.h> |
|
26 |
|
27 #include <stringloader.h> |
|
28 #include <internetradio.rsg> |
|
29 #include <eikenv.h> |
|
30 #include "irbaseview.h" |
|
31 |
|
32 |
|
33 #include <eikfrlbd.h> |
|
34 |
|
35 |
|
36 #include <internetradio.rsg> |
|
37 #include "irui.h" |
|
38 #include "ir.hrh" |
|
39 #include "ircommon.h" |
|
40 #include "irdebug.h" |
|
41 #include "irfirsttimeview.h" |
|
42 #include "irfirsttimecontainer.h" |
|
43 |
|
44 #include "iraap.hlp.hrh" |
|
45 |
|
46 |
|
47 // The granularity of the scan stations list box. |
|
48 |
|
49 const TInt KMenubufMaxLength = 522; |
|
50 const TInt KStringSize = 20; |
|
51 #define KCONTROLSCOUNT 0 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // C++ default constructor can NOT contain any code, that might leave. |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CIRFirstTimeContainer::CIRFirstTimeContainer(CIRFirstTimeView& aFirstTimeView): |
|
58 iFirstTimeView(aFirstTimeView) |
|
59 { |
|
60 IRLOG_DEBUG( "CIRFirstTimeContainer::CIRFirstTimeContainer" ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CIRFirstTimeContainer::ConstructL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 void CIRFirstTimeContainer::ConstructL( const TRect& aRect ) |
|
68 { |
|
69 IRLOG_DEBUG( "CIRFirstTimeContainer::ConstructL - Entering" ); |
|
70 CreateWindowL(); |
|
71 iListbox = new(ELeave) CAknDoubleStyleListBox; |
|
72 iListbox->SetContainerWindowL(*this); |
|
73 iListbox->ConstructL(this,EAknListBoxSelectionList); |
|
74 |
|
75 iItemArray = static_cast<CDesCArray*>( iListbox->Model()->ItemTextArray()); |
|
76 PopulateFindStationListL(); |
|
77 |
|
78 |
|
79 iListbox->SetCurrentItemIndex(iFirstTimeView.GetCurrentFocus()); |
|
80 iListbox->HandleItemAdditionL( ); |
|
81 |
|
82 |
|
83 SetRect( aRect ); |
|
84 DrawNow(); |
|
85 |
|
86 iListbox->CreateScrollBarFrameL( ETrue ); |
|
87 iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
88 CEikScrollBarFrame::EAuto); |
|
89 |
|
90 iListbox->SetListBoxObserver( this ); |
|
91 IRLOG_DEBUG( "CIRFirstTimeContainer::ConstructL - Exiting" ); |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Destructor |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CIRFirstTimeContainer::~CIRFirstTimeContainer() |
|
99 { |
|
100 IRLOG_DEBUG( "CIRFirstTimeContainer::~CIRFirstTimeContainer - Entering" ); |
|
101 if(iListbox) |
|
102 { |
|
103 delete iListbox; |
|
104 iListbox = NULL; |
|
105 } |
|
106 IRLOG_DEBUG( "CIRFirstTimeContainer::~CIRFirstTimeContainer - Exiting" ); |
|
107 } |
|
108 |
|
109 //---------------------------------------------------------------------------- |
|
110 // CIRFirstTimeContainer::CountComponentControls() const |
|
111 // returns the number of components in the view. |
|
112 //---------------------------------------------------------------------------- |
|
113 // |
|
114 TInt CIRFirstTimeContainer::CountComponentControls() const |
|
115 { |
|
116 IRLOG_DEBUG( "CIRFirstTimeContainer::CountComponentControls - Entering" ); |
|
117 TInt count(KCONTROLSCOUNT); |
|
118 if(iListbox) |
|
119 { |
|
120 count++; |
|
121 } |
|
122 IRLOG_DEBUG( "CIRFirstTimeContainer::CountComponentControls - Exiting" ); |
|
123 return count; |
|
124 } |
|
125 //---------------------------------------------------------------------------- |
|
126 // CIRFirstTimeContainer::ComponentControl() const |
|
127 // returns a pointer to the control under this view depending on the index |
|
128 // passed,to the framework. |
|
129 //---------------------------------------------------------------------------- |
|
130 // |
|
131 CCoeControl* CIRFirstTimeContainer::ComponentControl(TInt aIndex) const |
|
132 { |
|
133 IRLOG_DEBUG( "CIRFirstTimeContainer::ComponentControl - Entering" ); |
|
134 IRLOG_DEBUG( "CIRFirstTimeContainer::ComponentControl - Exiting" ); |
|
135 switch(aIndex) |
|
136 { |
|
137 case 0: |
|
138 { |
|
139 if(iListbox) |
|
140 return iListbox; |
|
141 } |
|
142 default: |
|
143 return NULL; |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // From class CCoeControl. |
|
149 // We need to catch the selection key event in order to do a couple of things |
|
150 // in moving state make the movement, and in normal state open channel |
|
151 // specific popup menu. Up and down buttons are forwarded to the list. |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 TKeyResponse CIRFirstTimeContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
155 { |
|
156 IRLOG_DEBUG( "CIRFirstTimeContainer::OfferKeyEventL" ); |
|
157 return iListbox->OfferKeyEventL(aKeyEvent, aType ); |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // From class CCoeControl. |
|
162 // Opens help by context. |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void CIRFirstTimeContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
166 { |
|
167 IRLOG_DEBUG( "CIRFirstTimeContainer::GetHelpContext - Entering" ); |
|
168 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_RESULTS ); |
|
169 IRLOG_DEBUG( "CIRFirstTimeContainer::GetHelpContext - Exiting" ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // From class MEikListBoxObserver. |
|
174 // List box event handler. |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CIRFirstTimeContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
178 { |
|
179 IRLOG_DEBUG( "CIRFirstTimeContainer::HandleListBoxEventL - Entering" ); |
|
180 CIRUi* appUi = static_cast<CIRUi*>( iCoeEnv->AppUi( ) ); |
|
181 |
|
182 switch ( aEventType ) |
|
183 { |
|
184 case EEventEnterKeyPressed: |
|
185 /** Keypress event. */ |
|
186 case EEventItemDoubleClicked: |
|
187 /** Item single-tap event */ |
|
188 iFirstTimeView.SetCurrentFocus(iListbox->CurrentItemIndex()); |
|
189 switch( iListbox->CurrentItemIndex( ) ) |
|
190 { |
|
191 case 0: |
|
192 { |
|
193 TBuf8<2> dummy; |
|
194 TVwsViewId viewId(TUid::Uid(KUIDIRAPP),KIRStationDirectoryViewId); |
|
195 appUi->ActivateViewL(viewId ,TUid::Uid(1),dummy); |
|
196 } |
|
197 break; |
|
198 case 1: |
|
199 { |
|
200 if( !iFirstTimeView.iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
201 { |
|
202 HBufC *SearchTitle = StringLoader::LoadLC(R_IRAPP_SEARCH_STRING); |
|
203 _LIT(KNullText,""); |
|
204 RBuf string1; |
|
205 string1.Create(KStringSize); |
|
206 string1.Append(KNullText); |
|
207 iFirstTimeView.ShowQueryDialogL(*SearchTitle,string1); |
|
208 CleanupStack::PopAndDestroy(SearchTitle); |
|
209 string1.Close(); |
|
210 } |
|
211 } |
|
212 break; |
|
213 case 2: |
|
214 { |
|
215 if( !iFirstTimeView.iUi->CheckAndNotifyLowDiskSpaceL() ) |
|
216 { |
|
217 appUi->SetEditStation(EFalse); |
|
218 appUi->ActivateLocalViewL(KIRAddManuallyStationViewID); |
|
219 } |
|
220 } |
|
221 break; |
|
222 default: |
|
223 break; |
|
224 } |
|
225 /* fall through */ // pc-lint Warning -e616 |
|
226 default: |
|
227 break; |
|
228 } |
|
229 IRLOG_DEBUG( "CIRFirstTimeContainer::HandleListBoxEventL - Exiting" ); |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CIRSearchResultsViewContainer::Draw() |
|
235 // From class CCoeControl. |
|
236 // Draws the control. |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CIRFirstTimeContainer::Draw( const TRect& /*aRect*/ ) const |
|
240 { |
|
241 IRLOG_DEBUG( "CIRFirstTimeContainer::Draw - Entering" ); |
|
242 CWindowGc& gc = SystemGc(); |
|
243 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
244 gc.SetBrushColor( KRgbBlue ); |
|
245 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
246 IRLOG_DEBUG( "CIRFirstTimeContainer::Draw - Exiting" ); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // Populates listbox |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CIRFirstTimeContainer::PopulateFindStationListL( ) |
|
254 { |
|
255 IRLOG_DEBUG( "CIRFirstTimeContainer::PopulateFindStationListL - Entering" ); |
|
256 //Fetches the data to be displayed in this view from resource. |
|
257 if(!(iItemArray->Count())) |
|
258 { |
|
259 CreateFindStationDataL(R_IRAPP_FINDSTATION_DIRECTORY |
|
260 ,R_IRAPP_MAIN_DISCOVER_EXPAND); |
|
261 CreateFindStationDataL(R_IRAPP_MAIN_MENU_SEARCH |
|
262 ,R_IRAPP_FINDSTATION_SEARCH_EXPAND); |
|
263 CreateFindStationDataL(R_IRAPP_FINDSTATION_ADDSTATIONMANUALLY |
|
264 ,R_IRAPP_FINDSTATION_ADDSTATIONMANUALLY_EXPAND); |
|
265 } |
|
266 IRLOG_DEBUG( "CIRFirstTimeContainer::PopulateFindStationListL - Exiting" ); |
|
267 } |
|
268 |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // CreateDiscoverStationDataL(TInt aTitle,TInt aDescription) |
|
272 // Fetches the data from stringloader that should be displayed |
|
273 // and sets it to the listbox. |
|
274 // --------------------------------------------------------------------------- |
|
275 // |
|
276 void CIRFirstTimeContainer::CreateFindStationDataL(TInt aTitle,TInt aDescription) |
|
277 { |
|
278 IRLOG_DEBUG( "CIRFirstTimeContainer::CreateFindStationDataL - Entering" ); |
|
279 _LIT(KTabSpace,"\t"); |
|
280 |
|
281 HBufC *titleData = StringLoader::LoadLC(aTitle); |
|
282 HBufC *descriptionData = StringLoader::LoadLC(aDescription); |
|
283 TBuf<KMenubufMaxLength> menubuf; |
|
284 menubuf.Append(KTabSpace); |
|
285 menubuf.Append(*titleData); |
|
286 menubuf.Append(KTabSpace); |
|
287 menubuf.Append(*descriptionData); |
|
288 iItemArray->AppendL(menubuf); |
|
289 CleanupStack::PopAndDestroy(descriptionData); |
|
290 CleanupStack::PopAndDestroy(titleData); |
|
291 IRLOG_DEBUG( "CIRFirstTimeContainer::CreateFindStationDataL - Exiting" ); |
|
292 } |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CIRFirstTimeContainer::SizeChanged() |
|
295 // Called by framework when the view size is changed. |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CIRFirstTimeContainer::SizeChanged() |
|
299 { |
|
300 iListbox->SetRect(Rect()); |
|
301 } |
|
302 // --------------------------------------------------------------------------- |
|
303 // CIRFirstTimeContainer::GetCurrentItemIndex() |
|
304 // returns the index of the currently selected item |
|
305 // --------------------------------------------------------------------------- |
|
306 // |
|
307 |
|
308 TInt CIRFirstTimeContainer::GetCurrentItemIndex() const |
|
309 { |
|
310 IRLOG_DEBUG( "CIRStationDirectoryContainer::GetCurrentItemIndex" ); |
|
311 return iListbox->CurrentItemIndex(); |
|
312 } |
|
313 // --------------------------------------------------------------------------- |
|
314 // void CIRFirstTimeContainer::HandleResourceChange(TInt aType) |
|
315 // Handles a change to the control's resources. |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 void CIRFirstTimeContainer::HandleResourceChange(TInt aType) |
|
319 { |
|
320 IRRDEBUG( "CIRFirstTimeContainer::HandleResourceChange - Entering" ); |
|
321 CCoeControl::HandleResourceChange( aType ); |
|
322 iFirstTimeView.RefreshView(); |
|
323 IRRDEBUG( "CIRFirstTimeContainer::HandleResourceChange - Exiting" ); |
|
324 } |
|
325 // End of file |
|
326 |
|
327 |
|