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