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