author | teknolog |
Thu, 27 May 2010 17:08:58 +0100 | |
changeset 101 | 68b48f53a8ec |
parent 93 | c2f1ea38ec70 |
child 111 | ffa983aa9d7f |
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> |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
32 |
#include <akntitle.h> |
2 | 33 |
|
34 |
const TInt KDefaultGran = 5; |
|
35 |
||
36 |
CPodcastListContainer::CPodcastListContainer() |
|
37 |
{ |
|
38 |
} |
|
39 |
||
40 |
void CPodcastListContainer::SetKeyEventListener(MKeyEventListener *aKeyEventListener) |
|
41 |
{ |
|
42 |
iKeyEventListener = aKeyEventListener; |
|
43 |
} |
|
44 |
||
45 |
TKeyResponse CPodcastListContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
46 |
{ |
|
47 |
TKeyResponse response = iListbox->OfferKeyEventL(aKeyEvent, aType); |
|
48 |
if (iKeyEventListener) |
|
49 |
iKeyEventListener->OfferKeyEventL(aKeyEvent, aType); |
|
50 |
||
51 |
return response; |
|
52 |
} |
|
53 |
||
54 |
void CPodcastListContainer::ConstructL( const TRect& aRect, TInt aListboxFlags ) |
|
55 |
{ |
|
56 |
CreateWindowL(); |
|
57 |
||
58 |
iBgContext = |
|
59 |
CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
60 |
aRect, |
|
61 |
ETrue ); |
|
62 |
||
63 |
// Set the windows size |
|
64 |
SetRect( aRect ); |
|
65 |
iListbox =static_cast<CEikFormattedCellListBox*>( new (ELeave) CAknDoubleLargeStyleListBox); |
|
66 |
iListbox->ConstructL(this, aListboxFlags); |
|
67 |
iListbox->SetMopParent( this ); |
|
68 |
iListbox->SetContainerWindowL(*this); |
|
69 |
iListbox->CreateScrollBarFrameL(ETrue); |
|
70 |
iListbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto ); |
|
71 |
||
72 |
iListbox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
73 |
||
74 |
iListbox->SetSize(aRect.Size()); |
|
75 |
iListbox->MakeVisible(ETrue); |
|
76 |
MakeVisible(EFalse); |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
77 |
|
2 | 78 |
// Activate the window, which makes it ready to be drawn |
79 |
ActivateL(); |
|
80 |
} |
|
81 |
||
82 |
TInt CPodcastListContainer::CountComponentControls() const |
|
83 |
{ |
|
84 |
return 1; // return number of controls inside this container |
|
85 |
} |
|
86 |
||
87 |
CCoeControl* CPodcastListContainer::ComponentControl(TInt aIndex) const |
|
88 |
{ |
|
89 |
switch ( aIndex ) |
|
90 |
{ |
|
91 |
case 0: |
|
92 |
return iListbox; |
|
93 |
default: |
|
94 |
return NULL; |
|
95 |
} |
|
96 |
} |
|
97 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
98 |
void CPodcastListContainer::SetLongTapDetectedL(TBool aLongTapDetected) |
26 | 99 |
{ |
100 |
iLongTapDetected = aLongTapDetected; |
|
27 | 101 |
|
102 |
if (aLongTapDetected == EFalse) |
|
103 |
{ |
|
104 |
TPointerEvent event; |
|
105 |
event.iType = TPointerEvent::EButton1Up; |
|
106 |
CCoeControl::HandlePointerEventL(event); |
|
107 |
} |
|
26 | 108 |
} |
109 |
||
2 | 110 |
void CPodcastListContainer::HandleResourceChange(TInt aType) |
111 |
{ |
|
112 |
switch( aType ) |
|
113 |
{ |
|
114 |
case KEikDynamicLayoutVariantSwitch: |
|
115 |
SetRect(iEikonEnv->EikAppUi()->ClientRect()); |
|
116 |
break; |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
void CPodcastListContainer::ScrollToVisible() { |
|
121 |
if (iListbox != NULL) { |
|
122 |
iListbox->ScrollToMakeItemVisible(iListbox->CurrentItemIndex()); |
|
123 |
} |
|
124 |
} |
|
125 |
void CPodcastListContainer::SizeChanged() |
|
126 |
{ |
|
127 |
DP2("CPodcastListContainer::SizeChanged(), width=%d, height=%d",Size().iWidth, Size().iHeight); |
|
128 |
if(iListbox != NULL) |
|
129 |
{ |
|
130 |
iListbox->SetSize(Size()); |
|
131 |
} |
|
132 |
} |
|
133 |
||
134 |
CEikFormattedCellListBox* CPodcastListContainer::Listbox() |
|
135 |
{ |
|
136 |
return iListbox; |
|
137 |
} |
|
138 |
||
139 |
||
140 |
CPodcastListContainer::~CPodcastListContainer() |
|
141 |
{ |
|
142 |
delete iListbox; |
|
143 |
delete iBgContext; |
|
144 |
} |
|
145 |
||
146 |
||
147 |
void CPodcastListContainer::Draw(const TRect& aRect) const |
|
148 |
{ |
|
149 |
CWindowGc& gc = SystemGc(); |
|
150 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
151 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext(this); |
|
152 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
153 |
AknsDrawUtils::Background(skin, cc, (CCoeControl*) this, gc, aRect); |
|
154 |
} |
|
155 |
||
156 |
||
157 |
TTypeUid::Ptr CPodcastListContainer::MopSupplyObject( TTypeUid aId ) |
|
158 |
{ |
|
159 |
if (iBgContext ) |
|
160 |
{ |
|
161 |
return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
162 |
} |
|
163 |
return CCoeControl::MopSupplyObject(aId); |
|
164 |
} |
|
165 |
||
166 |
void CPodcastListContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
167 |
{ |
|
168 |
if (iPointerListener) |
|
169 |
iPointerListener->PointerEventL(aPointerEvent); |
|
170 |
||
26 | 171 |
// Call base class HandlePointerEventL() if not a long tap |
172 |
if (!iLongTapDetected) |
|
173 |
{ |
|
174 |
CCoeControl::HandlePointerEventL(aPointerEvent); |
|
175 |
} |
|
2 | 176 |
} |
177 |
||
178 |
||
179 |
void CPodcastListContainer::SetPointerListener(MPointerListener *aPointerListener) |
|
180 |
{ |
|
181 |
iPointerListener = aPointerListener; |
|
182 |
} |
|
183 |
||
184 |
||
185 |
CPodcastListView::CPodcastListView() |
|
186 |
{ |
|
187 |
} |
|
188 |
||
189 |
void CPodcastListView::ConstructL() |
|
190 |
{ |
|
191 |
DP("CPodcastListView::ConstructL BEGIN"); |
|
192 |
iListContainer = new (ELeave) CPodcastListContainer; |
|
193 |
iListContainer->ConstructL(ClientRect(), iListboxFlags); |
|
194 |
iListContainer->SetMopParent(this); |
|
195 |
iListContainer->ActivateL(); |
|
196 |
iItemArray = new (ELeave)CDesCArrayFlat(KDefaultGran); |
|
197 |
iListContainer->Listbox()->Model()->SetItemTextArray(iItemArray); |
|
198 |
iListContainer->Listbox()->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
199 |
||
200 |
if (Toolbar()) { |
|
201 |
iToolbar = Toolbar(); |
|
202 |
iToolbar->SetToolbarObserver(this); |
|
203 |
} |
|
204 |
||
205 |
iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
206 |
iListContainer->SetPointerListener(this); |
|
207 |
iListContainer->SetKeyEventListener(this); |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
13
diff
changeset
|
208 |
|
2 | 209 |
DP("CPodcastListView::ConstructL END"); |
210 |
} |
|
211 |
||
212 |
void CPodcastListView::HandleViewRectChange() |
|
213 |
{ |
|
214 |
if ( iListContainer ) |
|
215 |
{ |
|
216 |
iListContainer->SetRect( ClientRect() ); |
|
217 |
} |
|
218 |
} |
|
219 |
||
220 |
void CPodcastListView::HandleStatusPaneSizeChange() |
|
221 |
{ |
|
222 |
DP2("CPodcastListView::HandleStatusPaneSizeChange(), width=%d, height=%d", ClientRect().Width(), ClientRect().Height()); |
|
223 |
||
224 |
if ( iListContainer ) |
|
225 |
{ |
|
226 |
iListContainer->SetRect( ClientRect() ); |
|
227 |
} |
|
228 |
||
229 |
} |
|
230 |
||
231 |
||
232 |
CPodcastListView::~CPodcastListView() |
|
233 |
{ |
|
234 |
if(iListContainer) |
|
235 |
{ |
|
236 |
AppUi()->RemoveFromStack(iListContainer); |
|
237 |
delete iListContainer; |
|
238 |
} |
|
239 |
||
240 |
delete iItemArray; |
|
241 |
delete iLongTapDetector; |
|
242 |
iItemIdArray.Close(); |
|
243 |
} |
|
244 |
||
245 |
||
246 |
void CPodcastListView::DoActivateL(const TVwsViewId& /*aPrevViewId */, |
|
247 |
TUid /*aCustomMessageId */, |
|
248 |
const TDesC8& /* aCustomMessage */) |
|
249 |
{ |
|
250 |
DP("CPodcastListView::DoActivateL() BEGIN"); |
|
251 |
||
252 |
if(iListContainer) |
|
253 |
{ |
|
254 |
iListContainer->SetSize(ClientRect().Size()); |
|
255 |
iListContainer->SetMopParent(this); |
|
256 |
||
257 |
AppUi()->AddToStackL(*this, iListContainer); |
|
258 |
iListContainer->MakeVisible(ETrue); |
|
259 |
} |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
260 |
|
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
261 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
262 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
263 |
titlePane->SetTextToDefaultL(); |
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
264 |
|
2 | 265 |
DP("CPodcastListView::DoActivateL() END"); |
266 |
||
267 |
} |
|
268 |
||
269 |
void CPodcastListView::DoDeactivate() |
|
270 |
{ |
|
271 |
DP("CPodcastListView::DoDeactivate() BEGIN"); |
|
272 |
if ( iListContainer ) |
|
273 |
{ |
|
274 |
AppUi()->RemoveFromViewStack( *this, iListContainer); |
|
275 |
iListContainer->MakeVisible(EFalse); |
|
276 |
} |
|
277 |
DP("CPodcastListView::DoDeactivate() END"); |
|
278 |
} |
|
279 |
||
280 |
/** |
|
281 |
* Command handling function intended for overriding by sub classes. |
|
282 |
* Default implementation is empty. |
|
283 |
* @param aCommand ID of the command to respond to. |
|
284 |
*/ |
|
285 |
void CPodcastListView::HandleCommandL(TInt aCommand) |
|
286 |
{ |
|
287 |
DP1("CPodcastListView::HandleCommandL=%d", aCommand); |
|
288 |
switch(aCommand) |
|
289 |
{ |
|
290 |
case EAknSoftkeyExit: |
|
291 |
case EEikCmdExit: |
|
292 |
{ |
|
293 |
AppUi()->Exit(); |
|
294 |
break; |
|
295 |
} |
|
296 |
case EAknSoftkeyBack: |
|
297 |
{ |
|
298 |
AppUi()->ActivateViewL(iPreviousView); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
299 |
((CPodcastAppUi*)AppUi())->SetActiveTab(KTabIdFeeds); |
2 | 300 |
} |
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
48
diff
changeset
|
301 |
break; |
2 | 302 |
case EPodcastSettings: |
303 |
AppUi()->ActivateLocalViewL(KUidPodcastSettingsViewID); |
|
304 |
break; |
|
305 |
case EPodcastAbout: |
|
306 |
RunAboutDialogL(); |
|
307 |
break; |
|
308 |
default: |
|
309 |
AppUi()->HandleCommandL(aCommand); |
|
310 |
} |
|
311 |
} |
|
312 |
||
48 | 313 |
TBool CPodcastListView::IsVisible() |
314 |
{ |
|
315 |
return iListContainer->IsVisible(); |
|
316 |
} |
|
2 | 317 |
|
318 |
void CPodcastListView::RunAboutDialogL() |
|
319 |
{ |
|
320 |
CAknNoteDialog* dlg = new(ELeave) CAknNoteDialog(); |
|
321 |
dlg->ExecuteLD(R_DLG_ABOUT); |
|
322 |
} |
|
323 |
||
324 |
void CPodcastListView::SetEmptyTextL(TInt aResourceId) |
|
325 |
{ |
|
326 |
HBufC* emptyText = iEikonEnv->AllocReadResourceLC(aResourceId); |
|
327 |
iListContainer->Listbox()->View()->SetListEmptyTextL(*emptyText); |
|
328 |
CleanupStack::PopAndDestroy(emptyText); |
|
329 |
} |
|
330 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
331 |
void CPodcastListView::ShowOkMessageL(TDesC &aText) |
2 | 332 |
{ |
333 |
CAknNoteDialog* dlg= new(ELeave) CAknNoteDialog(); |
|
334 |
CleanupStack::PushL(dlg); |
|
335 |
dlg->SetTextL(aText); |
|
336 |
CleanupStack::Pop(dlg); |
|
337 |
dlg->ExecuteLD(R_MESSAGEDLG_OK); |
|
338 |
} |
|
339 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
340 |
void CPodcastListView::ShowErrorMessageL(TDesC &aText) |
2 | 341 |
{ |
342 |
CAknNoteDialog* dlg= new(ELeave) CAknNoteDialog(); |
|
343 |
CleanupStack::PushL(dlg); |
|
344 |
dlg->SetTextL(aText); |
|
345 |
CleanupStack::Pop(dlg); |
|
346 |
dlg->ExecuteLD(R_ERRORDLG_OK); |
|
347 |
} |
|
348 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
349 |
TInt CPodcastListView::ShowQueryMessageL(TDesC &aText) |
2 | 350 |
{ |
351 |
CAknQueryDialog* dlg= new(ELeave) CAknQueryDialog(); |
|
352 |
||
353 |
CleanupStack::PushL(dlg); |
|
354 |
dlg->SetPromptL(aText); |
|
355 |
CleanupStack::Pop(dlg); |
|
356 |
return dlg->ExecuteLD(R_QUERYDLG); |
|
357 |
} |
|
358 |
||
359 |
void CPodcastListView::CloseToolbarExtension() |
|
360 |
{ |
|
361 |
CAknToolbar* toolbar = Toolbar(); |
|
362 |
if (toolbar) { |
|
363 |
CAknToolbarExtension* toolbarExtension = toolbar->ToolbarExtension(); |
|
364 |
if (toolbarExtension) { |
|
365 |
toolbarExtension->SetShown( EFalse ); |
|
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
||
370 |
void CPodcastListView::PointerEventL(const TPointerEvent& aPointerEvent) |
|
371 |
{ |
|
372 |
//DP1("CPodcastListView::PointerEventL, iType=%d", aPointerEvent.iType); |
|
373 |
// Pass the pointer event to Long tap detector component |
|
374 |
iLongTapDetector->PointerEventL(aPointerEvent); |
|
375 |
} |
|
376 |
||
377 |
||
378 |
void CPodcastListView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */) |
|
379 |
{ |
|
380 |
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
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
|
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
|
385 |
if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight) |
2 | 386 |
{ |
55
31e34b8e2878
Fix for regression in popup menu fix for queue view
teknolog
parents:
50
diff
changeset
|
387 |
iListContainer->SetLongTapDetectedL(ETrue); |
2 | 388 |
iStylusPopupMenu->ShowMenu(); |
389 |
iStylusPopupMenu->SetPosition(aPenEventLocation); |
|
390 |
} |
|
55
31e34b8e2878
Fix for regression in popup menu fix for queue view
teknolog
parents:
50
diff
changeset
|
391 |
|
2 | 392 |
DP("CPodcastListView::HandleLongTapEventL END"); |
393 |
} |
|
394 |
||
395 |
||
396 |
void CPodcastListView::DynInitToolbarL (TInt /*aResourceId*/, CAknToolbar * /*aToolbar*/) |
|
397 |
{ |
|
398 |
} |
|
399 |
||
400 |
||
401 |
void CPodcastListView::OfferToolbarEventL(TInt aCommand) |
|
402 |
{ |
|
403 |
HandleCommandL(aCommand); |
|
404 |
} |
|
405 |
||
406 |
void CPodcastListView::ShowWaitDialogL(TDesC &aWaitText) |
|
407 |
{ |
|
408 |
DP("CPodcastListView::ShowWaitDialogL BEGIN"); |
|
409 |
||
410 |
if (iWaitDialog) { |
|
411 |
User::Leave(KErrInUse); |
|
412 |
} |
|
413 |
||
414 |
iWaitDialog=new(ELeave) CAknWaitDialog(reinterpret_cast<CEikDialog**>(&iWaitDialog), EFalse); |
|
415 |
iWaitDialog->SetCallback(this); |
|
416 |
iWaitDialog->ExecuteLD(R_WAITDLG); |
|
417 |
iWaitDialog->SetTextL(aWaitText); |
|
418 |
DP("CPodcastListView::ShowWaitDialogL END"); |
|
419 |
} |
|
420 |
||
421 |
TKeyResponse CPodcastListView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
422 |
{ |
|
423 |
if (aType==EEventKey) |
|
424 |
{ |
|
425 |
switch (aKeyEvent.iCode) |
|
426 |
{ |
|
427 |
case EKeyRightArrow: |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
428 |
((CPodcastAppUi*)AppUi())->TabRightL(); |
2 | 429 |
return EKeyWasConsumed; |
430 |
case EKeyLeftArrow: |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
27
diff
changeset
|
431 |
((CPodcastAppUi*)AppUi())->TabLeftL(); |
2 | 432 |
return EKeyWasConsumed; |
433 |
} |
|
434 |
} |
|
435 |
return EKeyWasNotConsumed; |
|
436 |
} |
|
437 |