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