63 iBgContext = |
63 iBgContext = |
64 CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
64 CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
65 aRect, |
65 aRect, |
66 ETrue ); |
66 ETrue ); |
67 |
67 |
68 iItemArrayShort = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
69 |
|
70 iListboxLandscape = new (ELeave) CAknSingleLargeStyleListBox; |
68 iListboxLandscape = new (ELeave) CAknSingleLargeStyleListBox; |
71 iListboxLandscape->ConstructL(this, aListboxFlags); |
69 iListboxLandscape->ConstructL(this, aListboxFlags); |
72 iListboxLandscape->SetMopParent( this ); |
70 iListboxLandscape->SetMopParent( this ); |
73 iListboxLandscape->SetContainerWindowL(*this); |
71 iListboxLandscape->SetContainerWindowL(*this); |
74 iListboxLandscape->CreateScrollBarFrameL(ETrue); |
72 iListboxLandscape->CreateScrollBarFrameL(ETrue); |
141 if (iListbox != NULL) { |
139 if (iListbox != NULL) { |
142 iListbox->ScrollToMakeItemVisible(iListbox->CurrentItemIndex()); |
140 iListbox->ScrollToMakeItemVisible(iListbox->CurrentItemIndex()); |
143 } |
141 } |
144 } |
142 } |
145 |
143 |
146 TBool CPodcastListContainer::IsLandscape() |
|
147 { |
|
148 return iLandscape; |
|
149 } |
|
150 |
|
151 void CPodcastListContainer::SizeChanged() |
144 void CPodcastListContainer::SizeChanged() |
152 { |
145 { |
153 DP2("CPodcastListContainer::SizeChanged() BEGIN, width=%d, height=%d",Size().iWidth, Size().iHeight); |
146 DP2("CPodcastListContainer::SizeChanged() BEGIN, width=%d, height=%d",Size().iWidth, Size().iHeight); |
154 |
147 |
155 iLandscape = Size().iWidth > Size().iHeight; |
148 iLandscape = Size().iWidth > Size().iHeight; |
160 if (iLandscape) |
153 if (iLandscape) |
161 { |
154 { |
162 iListboxPortrait->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
155 iListboxPortrait->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
163 iListboxPortrait->UpdateScrollBarsL(); |
156 iListboxPortrait->UpdateScrollBarsL(); |
164 iListboxPortrait->MakeVisible(EFalse); |
157 iListboxPortrait->MakeVisible(EFalse); |
|
158 |
|
159 iListboxLandscape->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
165 iListboxLandscape->MakeVisible(ETrue); |
160 iListboxLandscape->MakeVisible(ETrue); |
166 iListboxLandscape->SetFocus(ETrue, EDrawNow); |
161 iListboxLandscape->SetFocus(ETrue, EDrawNow); |
167 iListbox = iListboxLandscape; |
162 iListbox = iListboxLandscape; |
168 iListboxLandscape->SetMopParent( this ); |
|
169 iListboxLandscape->SetContainerWindowL(*this); |
|
170 iListboxLandscape->CreateScrollBarFrameL(ETrue); |
|
171 iListboxLandscape->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
|
172 } |
163 } |
173 else |
164 else |
174 { |
165 { |
175 iListboxLandscape->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
166 iListboxLandscape->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
176 iListboxLandscape->UpdateScrollBarsL(); |
167 iListboxLandscape->UpdateScrollBarsL(); |
|
168 iListboxLandscape->MakeVisible(EFalse); |
|
169 |
|
170 iListboxPortrait->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
177 iListboxPortrait->MakeVisible(ETrue); |
171 iListboxPortrait->MakeVisible(ETrue); |
178 iListboxLandscape->MakeVisible(EFalse); |
|
179 iListboxPortrait->SetFocus(ETrue, EDrawNow); |
172 iListboxPortrait->SetFocus(ETrue, EDrawNow); |
180 iListbox = (CEikColumnListBox*) iListboxPortrait; |
173 iListbox = (CEikColumnListBox*) iListboxPortrait; |
181 iListboxPortrait->SetMopParent( this ); |
|
182 iListboxPortrait->SetContainerWindowL(*this); |
|
183 iListboxPortrait->CreateScrollBarFrameL(ETrue); |
|
184 iListboxPortrait->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
|
185 } |
174 } |
186 |
175 |
187 iListbox->SetSize(Size()); |
176 iListbox->SetSize(Size()); |
188 ActivateL(); |
177 ActivateL(); |
189 DrawNow(); |
178 DrawNow(); |
208 return iListboxLandscape->ItemDrawer()->ColumnData()->IconArray(); |
197 return iListboxLandscape->ItemDrawer()->ColumnData()->IconArray(); |
209 else |
198 else |
210 return iListboxPortrait->ItemDrawer()->FormattedCellData()->IconArray(); |
199 return iListboxPortrait->ItemDrawer()->FormattedCellData()->IconArray(); |
211 } |
200 } |
212 |
201 |
213 void CPodcastListContainer::SetTextArray(CDesCArray* aArray) |
202 void CPodcastListContainer::SetListboxTextArrays(CDesCArray* aPortraitArray, CDesCArray* aLandscapeArray) |
214 { |
203 { |
215 DP1("SetTextArray, aArray.Count=%d", aArray->Count()); |
|
216 iItemArrayShort->Reset(); |
|
217 for (int i=0;i<aArray->Count();i++) |
|
218 { |
|
219 TBuf<1024> line; |
|
220 line.Copy((*aArray)[i]); |
|
221 TInt tpos = line.LocateReverse('\t'); |
|
222 if (tpos != -1) |
|
223 { |
|
224 line = line.Left(tpos); |
|
225 } |
|
226 |
|
227 //DP1("line: %S", line); |
|
228 iItemArrayShort->AppendL(line); |
|
229 } |
|
230 |
|
231 iListboxLandscape->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
204 iListboxLandscape->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
232 iListboxLandscape->Model()->SetItemTextArray(iItemArrayShort); |
205 iListboxLandscape->Model()->SetItemTextArray(aLandscapeArray); |
233 iListboxPortrait->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
206 iListboxPortrait->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
234 iListboxPortrait->Model()->SetItemTextArray(aArray); |
207 iListboxPortrait->Model()->SetItemTextArray(aPortraitArray); |
235 } |
208 } |
236 |
209 |
237 CPodcastListContainer::~CPodcastListContainer() |
210 CPodcastListContainer::~CPodcastListContainer() |
238 { |
211 { |
239 delete iListbox; |
212 delete iListbox; |
240 delete iBgContext; |
213 delete iBgContext; |
241 delete iItemArrayShort; |
214 } |
242 } |
215 |
243 |
216 void CPodcastListContainer::SetEmptyText(const TDesC &aText) |
244 void CPodcastListView::SwitchListbox() |
217 { |
245 { |
218 iListboxPortrait->View()->SetListEmptyTextL(aText); |
246 HandleViewRectChange(); |
219 iListboxLandscape->View()->SetListEmptyTextL(aText); |
247 } |
220 } |
248 |
221 |
249 void CPodcastListContainer::Draw(const TRect& aRect) const |
222 void CPodcastListContainer::Draw(const TRect& aRect) const |
250 { |
223 { |
251 CWindowGc& gc = SystemGc(); |
224 CWindowGc& gc = SystemGc(); |
271 |
244 |
272 void CPodcastListView::ConstructL() |
245 void CPodcastListView::ConstructL() |
273 { |
246 { |
274 DP("CPodcastListView::ConstructL BEGIN"); |
247 DP("CPodcastListView::ConstructL BEGIN"); |
275 |
248 |
276 ResetContainer(); |
249 iListContainer = new (ELeave) CPodcastListContainer; |
|
250 TRect rect = ClientRect(); |
|
251 |
|
252 iListContainer->ConstructL(rect, iListboxFlags); |
|
253 iListContainer->SetMopParent(this); |
|
254 iListContainer->ActivateL(); |
|
255 |
|
256 iItemArray = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
257 iItemArrayShort = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
258 |
|
259 iListContainer->SetListboxTextArrays(iItemArray, iItemArrayShort); |
|
260 iListContainer->SetContainerListener(this); |
277 |
261 |
278 if (Toolbar()) { |
262 if (Toolbar()) { |
279 iToolbar = Toolbar(); |
263 iToolbar = Toolbar(); |
280 iToolbar->SetToolbarObserver(this); |
264 iToolbar->SetToolbarObserver(this); |
281 } |
265 } |
282 |
266 |
283 |
267 |
284 DP("CPodcastListView::ConstructL END"); |
268 DP("CPodcastListView::ConstructL END"); |
285 } |
269 } |
286 |
270 |
287 void CPodcastListView::ResetContainer() |
|
288 { |
|
289 DP("CPodcastListView::ResetContainer BEGIN"); |
|
290 |
|
291 if(iListContainer) |
|
292 { |
|
293 AppUi()->RemoveFromStack(iListContainer); |
|
294 delete iListContainer; |
|
295 } |
|
296 |
|
297 iListContainer = new (ELeave) CPodcastListContainer; |
|
298 TRect rect = ClientRect(); |
|
299 |
|
300 // flipFlop = !flipFlop; |
|
301 // |
|
302 // if (!flipFlop) |
|
303 // { |
|
304 // TUint w = rect.Width(); |
|
305 // rect.SetWidth(rect.Height()); |
|
306 // rect.SetHeight(w); |
|
307 // } |
|
308 |
|
309 iListContainer->ConstructL(rect, iListboxFlags); |
|
310 iListContainer->SetMopParent(this); |
|
311 iListContainer->ActivateL(); |
|
312 iItemArray = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
313 iListContainer->SetTextArray(iItemArray); |
|
314 iListContainer->SetContainerListener(this); |
|
315 |
|
316 DP("CPodcastListView::ResetContainer END"); |
|
317 } |
|
318 |
|
319 void CPodcastListView::HandleViewRectChange() |
271 void CPodcastListView::HandleViewRectChange() |
320 { |
272 { |
321 TBool wasVisible = iListContainer->IsVisible(); |
273 TBool wasVisible = iListContainer->IsVisible(); |
322 |
274 |
323 // if (wasVisible) |
|
324 // { |
|
325 // AppUi()->ActivateLocalViewL(KUidPodcastSearchViewID, TUid::Uid(0), KNullDesC8); |
|
326 // |
|
327 // DoDeactivate(); |
|
328 // } |
|
329 // |
|
330 // ResetContainer(); |
|
331 // |
|
332 // if (wasVisible) |
|
333 // { |
|
334 // AppUi()->ActivateLocalViewL(ViewId().iViewUid, TUid::Uid(0), KNullDesC8); |
|
335 // } |
|
336 |
|
337 if ( iListContainer ) |
275 if ( iListContainer ) |
338 { |
276 { |
339 iListContainer->SetRect( ClientRect() ); |
277 iListContainer->SetRect( ClientRect() ); |
340 } |
278 } |
341 } |
279 } |
439 } |
378 } |
440 |
379 |
441 void CPodcastListView::SetEmptyTextL(TInt aResourceId) |
380 void CPodcastListView::SetEmptyTextL(TInt aResourceId) |
442 { |
381 { |
443 HBufC* emptyText = iEikonEnv->AllocReadResourceLC(aResourceId); |
382 HBufC* emptyText = iEikonEnv->AllocReadResourceLC(aResourceId); |
444 iListContainer->iListboxPortrait->View()->SetListEmptyTextL(*emptyText); |
383 iListContainer->SetEmptyText(*emptyText); |
445 iListContainer->iListboxLandscape->View()->SetListEmptyTextL(*emptyText); |
|
446 CleanupStack::PopAndDestroy(emptyText); |
384 CleanupStack::PopAndDestroy(emptyText); |
447 } |
385 } |
448 |
386 |
449 void CPodcastListView::ShowOkMessageL(TDesC &aText) |
387 void CPodcastListView::ShowOkMessageL(TDesC &aText) |
450 { |
388 { |