author | teknolog |
Sun, 28 Feb 2010 12:06:30 +0000 | |
changeset 23 | cf4b850bbffb |
parent 13 | f58e3c482bd9 |
child 24 | ca50ea154990 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* This component and the accompanying materials are made available |
|
6 |
* under the terms of the License "Eclipse Public License v1.0" |
|
7 |
* which accompanies this distribution, and is available |
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 |
* |
|
10 |
* Initial Contributors: |
|
11 |
* EmbedDev AB - initial contribution. |
|
12 |
* |
|
13 |
* Contributors: |
|
14 |
* |
|
15 |
* Description: |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include "PodcastListView.h" |
|
20 |
#include "Podcast.hrh" |
|
21 |
#include "PodcastAppUi.h" |
|
22 |
#include "constants.h" |
|
23 |
#include <podcast.rsg> |
|
24 |
#include <aknlists.h> |
|
25 |
#include <aknviewappui.h> |
|
26 |
#include <aknnotedialog.h> |
|
27 |
#include <aknsbasicbackgroundcontrolcontext.h> |
|
28 |
#include <akntabgrp.h> |
|
29 |
#include <akntoolbarextension.h> |
|
30 |
#include <aknquerydialog.h> |
|
31 |
#include <barsread.h> |
|
32 |
||
33 |
const TInt KDefaultGran = 5; |
|
34 |
||
35 |
CPodcastListContainer::CPodcastListContainer() |
|
36 |
{ |
|
37 |
} |
|
38 |
||
39 |
void CPodcastListContainer::SetKeyEventListener(MKeyEventListener *aKeyEventListener) |
|
40 |
{ |
|
41 |
iKeyEventListener = aKeyEventListener; |
|
42 |
} |
|
43 |
||
44 |
TKeyResponse CPodcastListContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
45 |
{ |
|
46 |
TKeyResponse response = iListbox->OfferKeyEventL(aKeyEvent, aType); |
|
47 |
if (iKeyEventListener) |
|
48 |
iKeyEventListener->OfferKeyEventL(aKeyEvent, aType); |
|
49 |
||
50 |
return response; |
|
51 |
} |
|
52 |
||
53 |
void CPodcastListContainer::ConstructL( const TRect& aRect, TInt aListboxFlags ) |
|
54 |
{ |
|
55 |
CreateWindowL(); |
|
56 |
||
57 |
iBgContext = |
|
58 |
CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
59 |
aRect, |
|
60 |
ETrue ); |
|
61 |
||
62 |
// Set the windows size |
|
63 |
SetRect( aRect ); |
|
64 |
iListbox =static_cast<CEikFormattedCellListBox*>( new (ELeave) CAknDoubleLargeStyleListBox); |
|
65 |
iListbox->ConstructL(this, aListboxFlags); |
|
66 |
iListbox->SetMopParent( this ); |
|
67 |
iListbox->SetContainerWindowL(*this); |
|
68 |
iListbox->CreateScrollBarFrameL(ETrue); |
|
69 |
iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
|
70 |
||
71 |
iListbox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
72 |
||
73 |
iListbox->SetSize(aRect.Size()); |
|
74 |
iListbox->MakeVisible(ETrue); |
|
75 |
MakeVisible(EFalse); |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
76 |
|
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
77 |
|
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
78 |
//#ifndef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
79 |
// TInt flags = iListbox->View()->ItemDrawer()->Flags(); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
80 |
// flags |= CListItemDrawer::EDisableHighlight; |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
81 |
// iListbox->ItemDrawer()->SetFlags(flags); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
82 |
//#endif |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
83 |
// |
2 | 84 |
|
85 |
// Activate the window, which makes it ready to be drawn |
|
86 |
ActivateL(); |
|
87 |
} |
|
88 |
||
89 |
TInt CPodcastListContainer::CountComponentControls() const |
|
90 |
{ |
|
91 |
return 1; // return number of controls inside this container |
|
92 |
} |
|
93 |
||
94 |
CCoeControl* CPodcastListContainer::ComponentControl(TInt aIndex) const |
|
95 |
{ |
|
96 |
switch ( aIndex ) |
|
97 |
{ |
|
98 |
case 0: |
|
99 |
return iListbox; |
|
100 |
default: |
|
101 |
return NULL; |
|
102 |
} |
|
103 |
} |
|
104 |
||
105 |
void CPodcastListContainer::HandleResourceChange(TInt aType) |
|
106 |
{ |
|
107 |
switch( aType ) |
|
108 |
{ |
|
109 |
case KEikDynamicLayoutVariantSwitch: |
|
110 |
SetRect(iEikonEnv->EikAppUi()->ClientRect()); |
|
111 |
break; |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
void CPodcastListContainer::ScrollToVisible() { |
|
116 |
if (iListbox != NULL) { |
|
117 |
iListbox->ScrollToMakeItemVisible(iListbox->CurrentItemIndex()); |
|
118 |
} |
|
119 |
} |
|
120 |
void CPodcastListContainer::SizeChanged() |
|
121 |
{ |
|
122 |
DP2("CPodcastListContainer::SizeChanged(), width=%d, height=%d",Size().iWidth, Size().iHeight); |
|
123 |
if(iListbox != NULL) |
|
124 |
{ |
|
125 |
iListbox->SetSize(Size()); |
|
126 |
} |
|
127 |
} |
|
128 |
||
129 |
CEikFormattedCellListBox* CPodcastListContainer::Listbox() |
|
130 |
{ |
|
131 |
return iListbox; |
|
132 |
} |
|
133 |
||
134 |
||
135 |
CPodcastListContainer::~CPodcastListContainer() |
|
136 |
{ |
|
137 |
delete iListbox; |
|
138 |
delete iBgContext; |
|
139 |
} |
|
140 |
||
141 |
||
142 |
void CPodcastListContainer::Draw(const TRect& aRect) const |
|
143 |
{ |
|
144 |
CWindowGc& gc = SystemGc(); |
|
145 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
146 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext(this); |
|
147 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
148 |
AknsDrawUtils::Background(skin, cc, (CCoeControl*) this, gc, aRect); |
|
149 |
} |
|
150 |
||
151 |
||
152 |
TTypeUid::Ptr CPodcastListContainer::MopSupplyObject( TTypeUid aId ) |
|
153 |
{ |
|
154 |
if (iBgContext ) |
|
155 |
{ |
|
156 |
return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
157 |
} |
|
158 |
return CCoeControl::MopSupplyObject(aId); |
|
159 |
} |
|
160 |
||
161 |
void CPodcastListContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
162 |
{ |
|
163 |
if (iPointerListener) |
|
164 |
iPointerListener->PointerEventL(aPointerEvent); |
|
165 |
||
166 |
// Call base class HandlePointerEventL() |
|
167 |
CCoeControl::HandlePointerEventL(aPointerEvent); |
|
168 |
} |
|
169 |
||
170 |
||
171 |
void CPodcastListContainer::SetPointerListener(MPointerListener *aPointerListener) |
|
172 |
{ |
|
173 |
iPointerListener = aPointerListener; |
|
174 |
} |
|
175 |
||
176 |
||
177 |
CPodcastListView::CPodcastListView() |
|
178 |
{ |
|
179 |
} |
|
180 |
||
181 |
void CPodcastListView::ConstructL() |
|
182 |
{ |
|
183 |
DP("CPodcastListView::ConstructL BEGIN"); |
|
184 |
iListContainer = new (ELeave) CPodcastListContainer; |
|
185 |
iListContainer->ConstructL(ClientRect(), iListboxFlags); |
|
186 |
iListContainer->SetMopParent(this); |
|
187 |
iListContainer->ActivateL(); |
|
188 |
iItemArray = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
189 |
iListContainer->Listbox()->Model()->SetItemTextArray(iItemArray); |
|
190 |
iListContainer->Listbox()->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
191 |
||
192 |
if (Toolbar()) { |
|
193 |
iToolbar = Toolbar(); |
|
194 |
iToolbar->SetToolbarObserver(this); |
|
195 |
} |
|
196 |
||
197 |
iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
198 |
iListContainer->SetPointerListener(this); |
|
199 |
iListContainer->SetKeyEventListener(this); |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
200 |
|
2 | 201 |
DP("CPodcastListView::ConstructL END"); |
202 |
} |
|
203 |
||
204 |
void CPodcastListView::HandleViewRectChange() |
|
205 |
{ |
|
206 |
if ( iListContainer ) |
|
207 |
{ |
|
208 |
iListContainer->SetRect( ClientRect() ); |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
void CPodcastListView::HandleStatusPaneSizeChange() |
|
213 |
{ |
|
214 |
DP2("CPodcastListView::HandleStatusPaneSizeChange(), width=%d, height=%d", ClientRect().Width(), ClientRect().Height()); |
|
215 |
||
216 |
if ( iListContainer ) |
|
217 |
{ |
|
218 |
iListContainer->SetRect( ClientRect() ); |
|
219 |
} |
|
220 |
||
221 |
} |
|
222 |
||
223 |
||
224 |
CPodcastListView::~CPodcastListView() |
|
225 |
{ |
|
226 |
if(iListContainer) |
|
227 |
{ |
|
228 |
AppUi()->RemoveFromStack(iListContainer); |
|
229 |
delete iListContainer; |
|
230 |
} |
|
231 |
||
232 |
delete iItemArray; |
|
233 |
delete iLongTapDetector; |
|
234 |
iItemIdArray.Close(); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
void CPodcastListView::DoActivateL(const TVwsViewId& /*aPrevViewId */, |
|
239 |
TUid /*aCustomMessageId */, |
|
240 |
const TDesC8& /* aCustomMessage */) |
|
241 |
{ |
|
242 |
DP("CPodcastListView::DoActivateL() BEGIN"); |
|
243 |
||
244 |
if(iListContainer) |
|
245 |
{ |
|
246 |
iListContainer->SetSize(ClientRect().Size()); |
|
247 |
iListContainer->SetMopParent(this); |
|
248 |
||
249 |
AppUi()->AddToStackL(*this, iListContainer); |
|
250 |
iListContainer->MakeVisible(ETrue); |
|
251 |
UpdateListboxItemsL(); |
|
252 |
iListContainer->DrawNow(); |
|
253 |
} |
|
254 |
DP("CPodcastListView::DoActivateL() END"); |
|
255 |
||
256 |
} |
|
257 |
||
258 |
void CPodcastListView::DoDeactivate() |
|
259 |
{ |
|
260 |
DP("CPodcastListView::DoDeactivate() BEGIN"); |
|
261 |
if ( iListContainer ) |
|
262 |
{ |
|
263 |
AppUi()->RemoveFromViewStack( *this, iListContainer); |
|
264 |
iListContainer->MakeVisible(EFalse); |
|
265 |
} |
|
266 |
DP("CPodcastListView::DoDeactivate() END"); |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
* Command handling function intended for overriding by sub classes. |
|
271 |
* Default implementation is empty. |
|
272 |
* @param aCommand ID of the command to respond to. |
|
273 |
*/ |
|
274 |
void CPodcastListView::HandleCommandL(TInt aCommand) |
|
275 |
{ |
|
276 |
DP1("CPodcastListView::HandleCommandL=%d", aCommand); |
|
277 |
switch(aCommand) |
|
278 |
{ |
|
279 |
case EAknSoftkeyExit: |
|
280 |
case EEikCmdExit: |
|
281 |
{ |
|
282 |
AppUi()->Exit(); |
|
283 |
break; |
|
284 |
} |
|
285 |
case EAknSoftkeyBack: |
|
286 |
{ |
|
287 |
AppUi()->ActivateViewL(iPreviousView); |
|
288 |
if (iPreviousView.iViewUid == KUidPodcastFeedViewID) { |
|
289 |
((CPodcastAppUi*)AppUi())->SetActiveTab(KTabIdFeeds); |
|
290 |
} |
|
291 |
}break; |
|
292 |
case EPodcastSettings: |
|
293 |
AppUi()->ActivateLocalViewL(KUidPodcastSettingsViewID); |
|
294 |
break; |
|
295 |
case EPodcastAbout: |
|
296 |
RunAboutDialogL(); |
|
297 |
break; |
|
298 |
default: |
|
299 |
AppUi()->HandleCommandL(aCommand); |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
||
304 |
void CPodcastListView::RunAboutDialogL() |
|
305 |
{ |
|
306 |
CAknNoteDialog* dlg = new(ELeave) CAknNoteDialog(); |
|
307 |
dlg->ExecuteLD(R_DLG_ABOUT); |
|
308 |
} |
|
309 |
||
310 |
void CPodcastListView::SetEmptyTextL(TInt aResourceId) |
|
311 |
{ |
|
312 |
HBufC* emptyText = iEikonEnv->AllocReadResourceLC(aResourceId); |
|
313 |
iListContainer->Listbox()->View()->SetListEmptyTextL(*emptyText); |
|
314 |
CleanupStack::PopAndDestroy(emptyText); |
|
315 |
} |
|
316 |
||
317 |
void CPodcastListView::ShowOkMessage(TDesC &aText) |
|
318 |
{ |
|
319 |
CAknNoteDialog* dlg= new(ELeave) CAknNoteDialog(); |
|
320 |
CleanupStack::PushL(dlg); |
|
321 |
dlg->SetTextL(aText); |
|
322 |
CleanupStack::Pop(dlg); |
|
323 |
dlg->ExecuteLD(R_MESSAGEDLG_OK); |
|
324 |
} |
|
325 |
||
326 |
void CPodcastListView::ShowErrorMessage(TDesC &aText) |
|
327 |
{ |
|
328 |
CAknNoteDialog* dlg= new(ELeave) CAknNoteDialog(); |
|
329 |
CleanupStack::PushL(dlg); |
|
330 |
dlg->SetTextL(aText); |
|
331 |
CleanupStack::Pop(dlg); |
|
332 |
dlg->ExecuteLD(R_ERRORDLG_OK); |
|
333 |
} |
|
334 |
||
335 |
TInt CPodcastListView::ShowQueryMessage(TDesC &aText) |
|
336 |
{ |
|
337 |
CAknQueryDialog* dlg= new(ELeave) CAknQueryDialog(); |
|
338 |
||
339 |
CleanupStack::PushL(dlg); |
|
340 |
dlg->SetPromptL(aText); |
|
341 |
CleanupStack::Pop(dlg); |
|
342 |
return dlg->ExecuteLD(R_QUERYDLG); |
|
343 |
} |
|
344 |
||
345 |
void CPodcastListView::CloseToolbarExtension() |
|
346 |
{ |
|
347 |
CAknToolbar* toolbar = Toolbar(); |
|
348 |
if (toolbar) { |
|
349 |
CAknToolbarExtension* toolbarExtension = toolbar->ToolbarExtension(); |
|
350 |
if (toolbarExtension) { |
|
351 |
toolbarExtension->SetShown( EFalse ); |
|
352 |
} |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
void CPodcastListView::PointerEventL(const TPointerEvent& aPointerEvent) |
|
357 |
{ |
|
358 |
//DP1("CPodcastListView::PointerEventL, iType=%d", aPointerEvent.iType); |
|
359 |
// Pass the pointer event to Long tap detector component |
|
360 |
iLongTapDetector->PointerEventL(aPointerEvent); |
|
361 |
} |
|
362 |
||
363 |
||
364 |
void CPodcastListView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
|
365 |
{ |
|
366 |
DP("CPodcastListView::HandleLongTapEventL BEGIN"); |
|
4
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
367 |
|
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
368 |
const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1 |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
369 |
TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems( |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
370 |
iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight; |
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
371 |
|
be243543a361
Added primitive detection if long tap is on a listbox item or not. Could use a better version of this going forward.
teknolog
parents:
2
diff
changeset
|
372 |
if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight) |
2 | 373 |
{ |
374 |
iStylusPopupMenu->ShowMenu(); |
|
375 |
iStylusPopupMenu->SetPosition(aPenEventLocation); |
|
376 |
} |
|
377 |
DP("CPodcastListView::HandleLongTapEventL END"); |
|
378 |
} |
|
379 |
||
380 |
||
381 |
void CPodcastListView::DynInitToolbarL (TInt /*aResourceId*/, CAknToolbar * /*aToolbar*/) |
|
382 |
{ |
|
383 |
} |
|
384 |
||
385 |
||
386 |
void CPodcastListView::OfferToolbarEventL(TInt aCommand) |
|
387 |
{ |
|
388 |
HandleCommandL(aCommand); |
|
389 |
} |
|
390 |
||
391 |
void CPodcastListView::ShowWaitDialogL(TDesC &aWaitText) |
|
392 |
{ |
|
393 |
DP("CPodcastListView::ShowWaitDialogL BEGIN"); |
|
394 |
||
395 |
if (iWaitDialog) { |
|
396 |
User::Leave(KErrInUse); |
|
397 |
} |
|
398 |
||
399 |
iWaitDialog=new(ELeave) CAknWaitDialog(reinterpret_cast<CEikDialog**>(&iWaitDialog), EFalse); |
|
400 |
iWaitDialog->SetCallback(this); |
|
401 |
iWaitDialog->ExecuteLD(R_WAITDLG); |
|
402 |
iWaitDialog->SetTextL(aWaitText); |
|
403 |
DP("CPodcastListView::ShowWaitDialogL END"); |
|
404 |
} |
|
405 |
||
406 |
TKeyResponse CPodcastListView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
407 |
{ |
|
408 |
if (aType==EEventKey) |
|
409 |
{ |
|
410 |
switch (aKeyEvent.iCode) |
|
411 |
{ |
|
412 |
case EKeyRightArrow: |
|
413 |
((CPodcastAppUi*)AppUi())->TabRight(); |
|
414 |
return EKeyWasConsumed; |
|
415 |
case EKeyLeftArrow: |
|
416 |
((CPodcastAppUi*)AppUi())->TabLeft(); |
|
417 |
return EKeyWasConsumed; |
|
418 |
} |
|
419 |
} |
|
420 |
return EKeyWasNotConsumed; |
|
421 |
} |
|
422 |