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