author | teknolog |
Wed, 10 Mar 2010 23:26:17 +0000 | |
branch | symbian1 |
changeset 44 | f6f9647922ba |
parent 36 | e010fc411ddc |
child 45 | 56d4e0784e5d |
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 "PodcastQueueView.h" |
|
20 |
#include "PodcastAppUi.h" |
|
21 |
#include "ShowEngine.h" |
|
22 |
#include "SettingsEngine.h" |
|
23 |
#include "PodcastApp.h" |
|
24 |
#include "Constants.h" |
|
25 |
#include "imagehandler.h" |
|
26 |
#include "PodcastShowsView.h" |
|
27 |
||
28 |
#include <akntitle.h> |
|
29 |
#include <podcast.rsg> |
|
30 |
#include <podcast.mbg> |
|
31 |
#include <gulicon.h> |
|
32 |
#include <barsread.h> |
|
33 |
#include <aknnotedialog.h> |
|
34 |
#include <aknmessagequerydialog.h> |
|
35 |
#include "Podcast.hrh" |
|
36 |
||
37 |
#define KMaxMessageLength 200 |
|
38 |
||
39 |
#define KPodcastImageWidth 160 |
|
40 |
#define KPodcastImageHeight 120 |
|
41 |
#define KPodcastDialogOffset 2 |
|
42 |
||
43 |
#define KOneHundredPercent 100 |
|
44 |
||
45 |
const TInt KSizeBufLen = 64; |
|
46 |
const TInt KDefaultGran = 5; |
|
47 |
_LIT(KSizeDownloadingOf, "%.1f/%.1f MB"); |
|
48 |
_LIT(KShowsSizeFormatS60, "%.1f MB"); |
|
49 |
||
50 |
_LIT(KShowFormat, "%d\t%S\t%S %S\t"); |
|
51 |
_LIT(KShowErrorFormat, "%d\t%S\t%S\t"); |
|
52 |
_LIT(KShowQueueFormat, "%d\t%S\t%S%S\t"); |
|
53 |
||
54 |
||
55 |
// these must correspond with TShowsIconIndex |
|
56 |
||
57 |
const TUint KShowIconArrayIds[] = |
|
58 |
{ |
|
59 |
EMbmPodcastAudio, |
|
60 |
EMbmPodcastAudio_mask, |
|
61 |
EMbmPodcastAudio_new, |
|
62 |
EMbmPodcastAudio_new_mask, |
|
63 |
EMbmPodcastAudio_queued, |
|
64 |
EMbmPodcastAudio_queued_mask, |
|
65 |
EMbmPodcastAudio_downloading, |
|
66 |
EMbmPodcastAudio_downloading_mask, |
|
67 |
EMbmPodcastAudio_downloaded, |
|
68 |
EMbmPodcastAudio_downloaded_mask, |
|
69 |
EMbmPodcastAudio_downloaded_new, |
|
70 |
EMbmPodcastAudio_downloaded_new_mask, |
|
71 |
EMbmPodcastAudio_failed, |
|
72 |
EMbmPodcastAudio_failed_mask, |
|
73 |
EMbmPodcastAudio_suspended, |
|
74 |
EMbmPodcastAudio_suspended_mask, |
|
75 |
0, |
|
76 |
0 |
|
77 |
}; |
|
78 |
||
79 |
CPodcastQueueView* CPodcastQueueView::NewL(CPodcastModel& aPodcastModel) |
|
80 |
{ |
|
81 |
CPodcastQueueView* self = CPodcastQueueView::NewLC(aPodcastModel); |
|
82 |
CleanupStack::Pop(self); |
|
83 |
return self; |
|
84 |
} |
|
85 |
||
86 |
CPodcastQueueView* CPodcastQueueView::NewLC(CPodcastModel& aPodcastModel) |
|
87 |
{ |
|
88 |
CPodcastQueueView* self = new ( ELeave ) CPodcastQueueView(aPodcastModel); |
|
89 |
CleanupStack::PushL(self); |
|
90 |
self->ConstructL(); |
|
91 |
return self; |
|
92 |
} |
|
93 |
||
94 |
CPodcastQueueView::CPodcastQueueView(CPodcastModel& aPodcastModel) : |
|
95 |
iPodcastModel(aPodcastModel) |
|
96 |
{ |
|
97 |
} |
|
98 |
||
99 |
void CPodcastQueueView::ConstructL() |
|
100 |
{ |
|
101 |
BaseConstructL(R_PODCAST_QUEUEVIEW); |
|
102 |
CPodcastListView::ConstructL(); |
|
103 |
CArrayPtr< CGulIcon>* icons = new(ELeave) CArrayPtrFlat< CGulIcon>(1); |
|
104 |
CleanupStack::PushL(icons); |
|
105 |
TInt pos = 0; |
|
106 |
while (KShowIconArrayIds[pos] > 0) |
|
107 |
{ |
|
108 |
// Load the bitmap for play icon |
|
109 |
CFbsBitmap* bitmap= NULL;//iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos]); |
|
110 |
CFbsBitmap* mask= NULL;////iEikonEnv->CreateBitmapL( _L("*"), KIconArrayIds[pos+1] ); |
|
111 |
AknIconUtils::CreateIconL(bitmap, |
|
112 |
mask, |
|
113 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
114 |
KShowIconArrayIds[pos], |
|
115 |
KShowIconArrayIds[pos+1]); |
|
116 |
CleanupStack::PushL(bitmap); |
|
117 |
// Load the mask for play icon |
|
118 |
CleanupStack::PushL(mask); |
|
119 |
// Append the play icon to icon array |
|
120 |
icons->AppendL(CGulIcon::NewL(bitmap, mask) ); |
|
121 |
CleanupStack::Pop(2); // bitmap, mask |
|
122 |
pos+=2; |
|
123 |
} |
|
124 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); |
|
125 |
CleanupStack::Pop(icons); // icons |
|
126 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
127 |
||
128 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
129 |
iPodcastModel.ShowEngine().AddObserver(this); |
|
130 |
||
131 |
iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0)); |
|
132 |
TResourceReader reader; |
|
133 |
iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU); |
|
134 |
iStylusPopupMenu->ConstructFromResourceL(reader); |
|
135 |
CleanupStack::PopAndDestroy(); |
|
136 |
SetEmptyTextL(R_PODCAST_EMPTY_QUEUE); |
|
137 |
} |
|
138 |
||
139 |
TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
140 |
{ |
|
141 |
if (aType == EEventKey) |
|
142 |
{ |
|
143 |
CShowInfo *activeShow = NULL; |
|
144 |
||
145 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
146 |
if(index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
147 |
{ |
|
148 |
activeShow = iPodcastModel.ActiveShowList()[index]; |
|
149 |
} |
|
150 |
||
151 |
if (activeShow != NULL) { |
|
152 |
DP1("aKeyEvent.iCode=%d", aKeyEvent.iCode); |
|
153 |
switch (aKeyEvent.iCode) { |
|
154 |
case 117: |
|
155 |
case '*': |
|
156 |
case EKeySpace: |
|
157 |
if (activeShow->PlayState() == EPlayed) { |
|
158 |
HandleCommandL(EPodcastMarkAsUnplayed); |
|
159 |
} else { |
|
160 |
HandleCommandL(EPodcastMarkAsPlayed); |
|
161 |
} |
|
162 |
break; |
|
163 |
case 106: |
|
164 |
case '#': |
|
165 |
if (activeShow->DownloadState() == ENotDownloaded) { |
|
166 |
HandleCommandL(EPodcastDownloadShow); |
|
167 |
} |
|
168 |
break; |
|
169 |
case EKeyBackspace: |
|
170 |
case EKeyDelete: |
|
171 |
HandleCommandL(EPodcastRemoveDownload); |
|
172 |
break; |
|
173 |
default: |
|
174 |
break; |
|
175 |
} |
|
176 |
UpdateToolbar(); |
|
177 |
} |
|
178 |
} |
|
179 |
return CPodcastListView::OfferKeyEventL(aKeyEvent, aType); |
|
180 |
} |
|
181 |
||
182 |
CPodcastQueueView::~CPodcastQueueView() |
|
183 |
{ |
|
184 |
iPodcastModel.ShowEngine().RemoveObserver(this); |
|
185 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
186 |
||
187 |
if(iStylusPopupMenu) |
|
188 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
189 |
} |
|
190 |
||
191 |
||
192 |
TUid CPodcastQueueView::Id() const |
|
193 |
{ |
|
194 |
return KUidPodcastQueueViewID; |
|
195 |
} |
|
196 |
||
197 |
void CPodcastQueueView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
198 |
TUid aCustomMessageId, const TDesC8& aCustomMessage) |
|
199 |
{ |
|
200 |
DP("CPodcastQueueView::DoActivateL BEGIN"); |
|
201 |
||
202 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
203 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
204 |
||
205 |
UpdateFeedUpdateStateL(); |
|
206 |
UpdateToolbar(); |
|
207 |
DP("CPodcastQueueView::DoActivateL END"); |
|
208 |
} |
|
209 |
||
210 |
void CPodcastQueueView::DoDeactivate() |
|
211 |
{ |
|
212 |
CPodcastListView::DoDeactivate(); |
|
213 |
} |
|
214 |
||
215 |
// Engine callback when new shows are available |
|
216 |
void CPodcastQueueView::ShowListUpdatedL() |
|
217 |
{ |
|
218 |
UpdateListboxItemsL(); |
|
219 |
} |
|
220 |
||
221 |
void CPodcastQueueView::ShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt /*aBytesTotal*/) |
|
222 |
{ |
|
223 |
if (!iListContainer->IsVisible()) |
|
224 |
{ |
|
225 |
return; |
|
226 |
} |
|
227 |
||
228 |
CShowInfo *info = iPodcastModel.ShowEngine().ShowDownloading(); |
|
229 |
if (info) |
|
230 |
{ |
|
231 |
UpdateShowItemL(info->Uid(), aBytesOfCurrentDownload); |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
void CPodcastQueueView::ShowDownloadFinishedL(TUint /*aShowUid*/, TInt aError) |
|
236 |
{ |
|
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
237 |
if (iListContainer->IsVisible()) |
2 | 238 |
{ |
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
239 |
|
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
240 |
iProgressAdded = EFalse; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
241 |
|
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
242 |
iPodcastModel.GetShowsDownloadingL(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
243 |
UpdateListboxItemsL(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
244 |
UpdateToolbar(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
245 |
|
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
246 |
switch(aError) |
2 | 247 |
{ |
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
248 |
case KErrCouldNotConnect: |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
249 |
{ |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
250 |
TBuf<KMaxMessageLength> message; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
251 |
iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR); |
36
e010fc411ddc
Merge, plus minor fix to CFeedEngine
Brendan Donegan <brendand@symbian.org>
diff
changeset
|
252 |
ShowErrorMessageL(message); |
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
253 |
} |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
254 |
break; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
255 |
default: // Do nothing |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
256 |
break; |
2 | 257 |
} |
258 |
} |
|
259 |
} |
|
260 |
||
261 |
||
262 |
void CPodcastQueueView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid) |
|
263 |
{ |
|
264 |
// TODO make use of the fact that we know that the feed download is |
|
265 |
// started instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
266 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
267 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
268 |
{ |
|
8 | 269 |
UpdateFeedUpdateStateL(); |
2 | 270 |
UpdateToolbar(); |
271 |
} |
|
272 |
} |
|
273 |
||
274 |
void CPodcastQueueView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/) |
|
275 |
{ |
|
276 |
DP("CPodcastQueueView::FeedDownloadFinishedL BEGIN"); |
|
277 |
// TODO make use of the fact that we know that the feed download is |
|
278 |
// finished instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
279 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
280 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
281 |
{ |
|
8 | 282 |
UpdateFeedUpdateStateL(); |
2 | 283 |
} |
284 |
DP("CPodcastQueueView::FeedDownloadFinishedL END"); |
|
285 |
} |
|
286 |
||
287 |
void CPodcastQueueView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
288 |
TListBoxEvent aEventType) |
|
289 |
{ |
|
290 |
switch (aEventType) |
|
291 |
{ |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
292 |
#ifndef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
293 |
case EEventItemClicked: |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
294 |
#endif |
2 | 295 |
case EEventEnterKeyPressed: |
296 |
case EEventItemActioned: |
|
297 |
case EEventItemDoubleClicked: |
|
298 |
break; |
|
299 |
default: |
|
300 |
break; |
|
301 |
} |
|
302 |
UpdateToolbar(); |
|
303 |
} |
|
304 |
||
305 |
void CPodcastQueueView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex) |
|
306 |
{ |
|
307 |
TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended(); |
|
34 | 308 |
|
309 |
switch (aShowInfo->DownloadState()) |
|
2 | 310 |
{ |
34 | 311 |
case EDownloaded: |
312 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
313 |
aIconIndex = EDownloadedNewShowIcon; |
|
314 |
} else { |
|
315 |
aIconIndex = EDownloadedShowIcon; |
|
2 | 316 |
} |
34 | 317 |
break; |
318 |
case ENotDownloaded: |
|
319 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
320 |
aIconIndex = ENewShowIcon; |
|
321 |
} else { |
|
322 |
aIconIndex = EShowIcon; |
|
323 |
} |
|
324 |
break; |
|
325 |
case EQueued: |
|
326 |
aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon; |
|
327 |
break; |
|
328 |
case EDownloading: |
|
329 |
aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon; |
|
330 |
break; |
|
331 |
case EFailedDownload: |
|
332 |
aIconIndex = EFailedShowIcon; |
|
333 |
break; |
|
2 | 334 |
} |
335 |
} |
|
336 |
||
337 |
void CPodcastQueueView::UpdateFeedUpdateStateL() |
|
338 |
{ |
|
339 |
TBool listboxDimmed = EFalse; |
|
340 |
||
341 |
if (iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() |
|
342 |
!= NULL && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid()) |
|
343 |
{ |
|
344 |
listboxDimmed = ETrue; |
|
345 |
} |
|
346 |
||
347 |
if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed)) |
|
348 |
{ |
|
349 |
iListContainer->Listbox()->SetDimmed(listboxDimmed); |
|
350 |
} |
|
351 |
UpdateListboxItemsL(); |
|
352 |
UpdateToolbar(); |
|
353 |
} |
|
354 |
||
355 |
void CPodcastQueueView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded) |
|
356 |
{ |
|
357 |
TBuf<32> infoSize; |
|
358 |
TInt iconIndex = 0; |
|
359 |
TBuf<KMaxShortDateFormatSpec*2> showDate; |
|
360 |
GetShowIcons(&aShowInfo, iconIndex); |
|
361 |
||
362 |
if(aSizeDownloaded > 0) |
|
363 |
{ |
|
364 |
if (aShowInfo.ShowSize() > 0) |
|
365 |
{ |
|
366 |
infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb), |
|
367 |
((float)aShowInfo.ShowSize() / (float)KSizeMb)); |
|
368 |
} |
|
369 |
else |
|
370 |
{ |
|
371 |
infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb); |
|
372 |
} |
|
373 |
} |
|
374 |
else if (aShowInfo.ShowSize() > 0) |
|
375 |
{ |
|
376 |
infoSize.Format(KShowsSizeFormatS60(), (float)aShowInfo.ShowSize() / (float)KSizeMb); |
|
377 |
} |
|
378 |
else { |
|
379 |
infoSize = KNullDesC(); |
|
380 |
} |
|
381 |
||
382 |
if (aShowInfo.PubDate().Int64() == 0) |
|
383 |
{ |
|
384 |
showDate = KNullDesC(); |
|
385 |
} |
|
386 |
else |
|
387 |
{ |
|
388 |
aShowInfo.PubDate().FormatL(showDate, KDateFormatShort()); |
|
389 |
} |
|
390 |
||
391 |
if(aShowInfo.LastError() != KErrNone) |
|
392 |
{ |
|
393 |
TBuf<KSizeBufLen> errorBuffer; |
|
394 |
iEikonEnv->GetErrorText(errorBuffer, aShowInfo.LastError()); |
|
395 |
iListboxFormatbuffer.Format(KShowErrorFormat(), iconIndex, &aShowInfo.Title(), &errorBuffer); |
|
396 |
} |
|
397 |
else |
|
398 |
{ |
|
399 |
if (infoSize.Length() > 0) { |
|
400 |
infoSize.Insert(0,_L(", ")); |
|
401 |
} |
|
402 |
||
403 |
iListboxFormatbuffer.Format(KShowQueueFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize); |
|
404 |
} |
|
405 |
} |
|
406 |
||
407 |
void CPodcastQueueView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded) |
|
408 |
{ |
|
409 |
FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded); |
|
410 |
iItemArray->Delete(aIndex); |
|
411 |
if(aIndex>= iItemArray->MdcaCount()) |
|
412 |
{ |
|
413 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
414 |
} |
|
415 |
else |
|
416 |
{ |
|
417 |
iItemArray->InsertL(aIndex, iListboxFormatbuffer); |
|
418 |
} |
|
419 |
} |
|
420 |
||
421 |
void CPodcastQueueView::UpdateShowItemL(TUint aUid, TInt aSizeDownloaded) |
|
422 |
{ |
|
423 |
RShowInfoArray& array = iPodcastModel.ActiveShowList(); |
|
424 |
||
425 |
for (int i=0;i<array.Count();i++) { |
|
426 |
if (array[i]->Uid() == aUid) { |
|
427 |
UpdateShowItemDataL(array[i], i, aSizeDownloaded); |
|
428 |
if (iListContainer->Listbox()->TopItemIndex() <= i && |
|
429 |
iListContainer->Listbox()->BottomItemIndex() >= i) { |
|
430 |
iListContainer->Listbox()->DrawItem(i); |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
} |
|
435 |
||
436 |
void CPodcastQueueView::UpdateListboxItemsL() |
|
437 |
{ |
|
438 |
if (iListContainer->IsVisible()) |
|
439 |
{ |
|
440 |
TListItemProperties itemProps; |
|
441 |
TInt len = 0; |
|
442 |
||
8 | 443 |
iPodcastModel.GetShowsDownloadingL(); |
2 | 444 |
|
445 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
446 |
len = fItems.Count(); |
|
447 |
||
448 |
if (iListContainer->Listbox() != NULL) |
|
449 |
{ |
|
450 |
TBool allUidsMatch = EFalse; |
|
451 |
||
452 |
if (len == iListContainer->Listbox()->Model()->NumberOfItems()) |
|
453 |
{ |
|
454 |
allUidsMatch = ETrue; |
|
455 |
TUint itemId = 0; |
|
456 |
for (TInt loop = 0; loop< len; loop++) |
|
457 |
{ |
|
458 |
itemId = iItemIdArray[loop]; |
|
459 |
if (fItems[loop]->Uid() != itemId) |
|
460 |
{ |
|
461 |
allUidsMatch = EFalse; |
|
462 |
break; |
|
463 |
} |
|
464 |
} |
|
465 |
} |
|
466 |
||
467 |
if (allUidsMatch && len > 0) |
|
468 |
{ |
|
469 |
for (TInt loop = 0; loop< len; loop++) |
|
470 |
{ |
|
471 |
UpdateShowItemDataL(fItems[loop], loop); |
|
472 |
iListContainer->Listbox()->DrawItem(loop); |
|
473 |
} |
|
474 |
} |
|
475 |
else |
|
476 |
{ |
|
477 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
478 |
iListContainer->Listbox()->Reset(); |
|
479 |
iItemIdArray.Reset(); |
|
480 |
iItemArray->Reset(); |
|
481 |
||
482 |
if (len > 0) |
|
483 |
{ |
|
484 |
for (TInt i=0; i<len; i++) |
|
485 |
{ |
|
486 |
CShowInfo *si = fItems[i]; |
|
487 |
FormatShowInfoListBoxItemL(*si); |
|
488 |
iItemIdArray.Append(si->Uid()); |
|
489 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
490 |
} |
|
491 |
} |
|
492 |
else |
|
493 |
{ |
|
494 |
iItemArray->Reset(); |
|
495 |
iItemIdArray.Reset(); |
|
496 |
||
497 |
itemProps.SetDimmed(ETrue); |
|
498 |
itemProps.SetHiddenSelection(ETrue); |
|
499 |
} |
|
500 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
501 |
} |
|
502 |
} |
|
503 |
} |
|
504 |
} |
|
505 |
||
506 |
/** |
|
507 |
* Command handling function intended for overriding by sub classes. |
|
508 |
* Default implementation is empty. |
|
509 |
* @param aCommand ID of the command to respond to. |
|
510 |
*/ |
|
511 |
void CPodcastQueueView::HandleCommandL(TInt aCommand) |
|
512 |
{ |
|
513 |
switch (aCommand) |
|
514 |
{ |
|
515 |
case EPodcastRemoveAllDownloads: |
|
516 |
{ |
|
517 |
TBuf<KMaxMessageLength> msg; |
|
518 |
iEikonEnv->ReadResourceL(msg, R_CLEAR_QUERY); |
|
519 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
23
diff
changeset
|
520 |
if(ShowQueryMessageL(msg)) |
2 | 521 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
23
diff
changeset
|
522 |
iPodcastModel.ShowEngine().RemoveAllDownloadsL(); |
2 | 523 |
UpdateListboxItemsL(); |
524 |
} |
|
525 |
} |
|
526 |
break; |
|
527 |
case EPodcastRemoveDownload: |
|
528 |
{ |
|
529 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
530 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
531 |
{ |
|
532 |
if (iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid())) |
|
533 |
{ |
|
534 |
iItemArray->Delete(index); |
|
535 |
iItemIdArray.Remove(index); |
|
536 |
iListContainer->Listbox()->HandleItemRemovalL(); |
|
537 |
iListContainer->Listbox()->SetCurrentItemIndex(index - 1 > 0 ? index - 1 : 0); |
|
538 |
iListContainer->Listbox()->DrawNow(); |
|
539 |
||
540 |
delete iPodcastModel.ActiveShowList()[index]; |
|
541 |
iPodcastModel.ActiveShowList().Remove(index); |
|
542 |
} |
|
543 |
} |
|
544 |
} |
|
545 |
break; |
|
546 |
case EPodcastSuspendDownloads: |
|
547 |
{ |
|
548 |
iPodcastModel.ShowEngine().SuspendDownloads(); |
|
549 |
UpdateListboxItemsL(); |
|
550 |
} |
|
551 |
break; |
|
552 |
case EPodcastResumeDownloads: |
|
553 |
{ |
|
554 |
iPodcastModel.ShowEngine().ResumeDownloadsL(); |
|
555 |
UpdateListboxItemsL(); |
|
556 |
} |
|
557 |
break; |
|
558 |
default: |
|
559 |
CPodcastListView::HandleCommandL(aCommand); |
|
560 |
break; |
|
561 |
} |
|
562 |
UpdateToolbar(); |
|
563 |
} |
|
564 |
||
565 |
void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
566 |
{ |
|
567 |
if(aResourceId == R_PODCAST_SHOWSVIEW_MENU) |
|
568 |
{ |
|
569 |
aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue); |
|
570 |
} |
|
571 |
} |
|
572 |
||
13 | 573 |
void CPodcastQueueView::UpdateToolbar(TBool aVisible) |
2 | 574 |
{ |
575 |
CAknToolbar* toolbar = Toolbar(); |
|
576 |
||
13 | 577 |
if (toolbar) { |
578 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
579 |
TInt itemCnt = fItems.Count(); |
|
14
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
580 |
if (iListContainer->IsVisible()) { |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
581 |
toolbar->SetToolbarVisibility(aVisible); |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
582 |
} |
13 | 583 |
toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue); |
584 |
toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue); |
|
585 |
toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue); |
|
586 |
toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue); |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
587 |
#ifdef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
588 |
toolbar->HideItem(EPodcastRemoveDownload, EFalse, ETrue); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
589 |
toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
590 |
#endif |
13 | 591 |
} |
2 | 592 |
} |
593 |
||
594 |
void CPodcastQueueView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/) |
|
595 |
{ |
|
596 |
} |
|
597 |
||
598 |
void CPodcastQueueView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
|
599 |
{ |
|
600 |
UpdateListboxItemsL(); |
|
601 |
UpdateToolbar(); |
|
602 |
} |