author | teknolog |
Sat, 03 Apr 2010 13:33:15 +0100 | |
changeset 104 | 4d1286f7f982 |
parent 101 | 867fc277ffea |
child 111 | 12c59f14a031 |
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); |
|
56 | 129 |
|
130 |
// no popup options apply to S^1 |
|
131 |
#ifndef SYMBIAN1_UI |
|
2 | 132 |
iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0)); |
133 |
TResourceReader reader; |
|
134 |
iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU); |
|
135 |
iStylusPopupMenu->ConstructFromResourceL(reader); |
|
136 |
CleanupStack::PopAndDestroy(); |
|
56 | 137 |
#endif |
2 | 138 |
SetEmptyTextL(R_PODCAST_EMPTY_QUEUE); |
139 |
} |
|
140 |
||
141 |
TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
142 |
{ |
|
143 |
if (aType == EEventKey) |
|
144 |
{ |
|
145 |
CShowInfo *activeShow = NULL; |
|
146 |
||
147 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
148 |
if(index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
149 |
{ |
|
150 |
activeShow = iPodcastModel.ActiveShowList()[index]; |
|
151 |
} |
|
152 |
||
153 |
if (activeShow != NULL) { |
|
154 |
DP1("aKeyEvent.iCode=%d", aKeyEvent.iCode); |
|
155 |
switch (aKeyEvent.iCode) { |
|
156 |
case 117: |
|
157 |
case '*': |
|
158 |
case EKeySpace: |
|
159 |
if (activeShow->PlayState() == EPlayed) { |
|
160 |
HandleCommandL(EPodcastMarkAsUnplayed); |
|
161 |
} else { |
|
162 |
HandleCommandL(EPodcastMarkAsPlayed); |
|
163 |
} |
|
164 |
break; |
|
165 |
case 106: |
|
166 |
case '#': |
|
167 |
if (activeShow->DownloadState() == ENotDownloaded) { |
|
168 |
HandleCommandL(EPodcastDownloadShow); |
|
169 |
} |
|
170 |
break; |
|
171 |
case EKeyBackspace: |
|
172 |
case EKeyDelete: |
|
173 |
HandleCommandL(EPodcastRemoveDownload); |
|
174 |
break; |
|
175 |
default: |
|
176 |
break; |
|
177 |
} |
|
178 |
UpdateToolbar(); |
|
179 |
} |
|
180 |
} |
|
181 |
return CPodcastListView::OfferKeyEventL(aKeyEvent, aType); |
|
182 |
} |
|
183 |
||
184 |
CPodcastQueueView::~CPodcastQueueView() |
|
185 |
{ |
|
186 |
iPodcastModel.ShowEngine().RemoveObserver(this); |
|
187 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
188 |
||
189 |
if(iStylusPopupMenu) |
|
190 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
191 |
} |
|
192 |
||
193 |
||
194 |
TUid CPodcastQueueView::Id() const |
|
195 |
{ |
|
196 |
return KUidPodcastQueueViewID; |
|
197 |
} |
|
198 |
||
199 |
void CPodcastQueueView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
200 |
TUid aCustomMessageId, const TDesC8& aCustomMessage) |
|
201 |
{ |
|
202 |
DP("CPodcastQueueView::DoActivateL BEGIN"); |
|
203 |
||
204 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
45
56d4e0784e5d
Nicer way to handle back from queue view to feed/show view
teknolog
parents:
36
diff
changeset
|
205 |
iPreviousView = aPrevViewId; |
2 | 206 |
|
207 |
UpdateFeedUpdateStateL(); |
|
208 |
UpdateToolbar(); |
|
209 |
DP("CPodcastQueueView::DoActivateL END"); |
|
210 |
} |
|
211 |
||
212 |
void CPodcastQueueView::DoDeactivate() |
|
213 |
{ |
|
214 |
CPodcastListView::DoDeactivate(); |
|
215 |
} |
|
216 |
||
217 |
// Engine callback when new shows are available |
|
218 |
void CPodcastQueueView::ShowListUpdatedL() |
|
219 |
{ |
|
220 |
UpdateListboxItemsL(); |
|
221 |
} |
|
222 |
||
223 |
void CPodcastQueueView::ShowDownloadUpdatedL(TInt aBytesOfCurrentDownload, TInt /*aBytesTotal*/) |
|
224 |
{ |
|
225 |
if (!iListContainer->IsVisible()) |
|
226 |
{ |
|
227 |
return; |
|
228 |
} |
|
229 |
||
230 |
CShowInfo *info = iPodcastModel.ShowEngine().ShowDownloading(); |
|
231 |
if (info) |
|
232 |
{ |
|
233 |
UpdateShowItemL(info->Uid(), aBytesOfCurrentDownload); |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
void CPodcastQueueView::ShowDownloadFinishedL(TUint /*aShowUid*/, TInt aError) |
|
238 |
{ |
|
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
239 |
if (iListContainer->IsVisible()) |
2 | 240 |
{ |
33
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 |
iProgressAdded = EFalse; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
243 |
|
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
244 |
iPodcastModel.GetShowsDownloadingL(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
245 |
UpdateListboxItemsL(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
246 |
UpdateToolbar(); |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
247 |
|
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
248 |
switch(aError) |
2 | 249 |
{ |
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
250 |
case KErrCouldNotConnect: |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
251 |
{ |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
252 |
TBuf<KMaxMessageLength> message; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
253 |
iEikonEnv->ReadResourceL(message, R_PODCAST_CONNECTION_ERROR); |
36
e010fc411ddc
Merge, plus minor fix to CFeedEngine
Brendan Donegan <brendand@symbian.org>
diff
changeset
|
254 |
ShowErrorMessageL(message); |
33
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
255 |
} |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
256 |
break; |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
257 |
default: // Do nothing |
64ed1227e68d
Fix for problem when new download can not be started after one is completed
teknolog
parents:
23
diff
changeset
|
258 |
break; |
2 | 259 |
} |
260 |
} |
|
261 |
} |
|
262 |
||
263 |
||
264 |
void CPodcastQueueView::FeedDownloadStartedL(TFeedState /*aState*/, TUint aFeedUid) |
|
265 |
{ |
|
266 |
// TODO make use of the fact that we know that the feed download is |
|
267 |
// started instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
268 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
269 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
270 |
{ |
|
8 | 271 |
UpdateFeedUpdateStateL(); |
2 | 272 |
UpdateToolbar(); |
273 |
} |
|
274 |
} |
|
275 |
||
276 |
void CPodcastQueueView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/) |
|
277 |
{ |
|
278 |
DP("CPodcastQueueView::FeedDownloadFinishedL BEGIN"); |
|
279 |
// TODO make use of the fact that we know that the feed download is |
|
280 |
// finished instead of checking feed engine states in UpdateFeedUpdateStateL. |
|
281 |
if (iPodcastModel.ActiveFeedInfo() != NULL |
|
282 |
&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid) |
|
283 |
{ |
|
8 | 284 |
UpdateFeedUpdateStateL(); |
2 | 285 |
} |
286 |
DP("CPodcastQueueView::FeedDownloadFinishedL END"); |
|
287 |
} |
|
288 |
||
289 |
void CPodcastQueueView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
290 |
TListBoxEvent aEventType) |
|
291 |
{ |
|
292 |
switch (aEventType) |
|
293 |
{ |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
294 |
#ifndef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
295 |
case EEventItemClicked: |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
296 |
#endif |
2 | 297 |
case EEventEnterKeyPressed: |
298 |
case EEventItemActioned: |
|
299 |
case EEventItemDoubleClicked: |
|
300 |
break; |
|
301 |
default: |
|
302 |
break; |
|
303 |
} |
|
304 |
UpdateToolbar(); |
|
305 |
} |
|
306 |
||
307 |
void CPodcastQueueView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex) |
|
308 |
{ |
|
309 |
TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended(); |
|
34 | 310 |
|
311 |
switch (aShowInfo->DownloadState()) |
|
2 | 312 |
{ |
34 | 313 |
case EDownloaded: |
314 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
315 |
aIconIndex = EDownloadedNewShowIcon; |
|
316 |
} else { |
|
317 |
aIconIndex = EDownloadedShowIcon; |
|
2 | 318 |
} |
34 | 319 |
break; |
320 |
case ENotDownloaded: |
|
321 |
if (aShowInfo->PlayState() == ENeverPlayed) { |
|
322 |
aIconIndex = ENewShowIcon; |
|
323 |
} else { |
|
324 |
aIconIndex = EShowIcon; |
|
325 |
} |
|
326 |
break; |
|
327 |
case EQueued: |
|
328 |
aIconIndex = dlStop ? ESuspendedShowIcon : EQuedShowIcon; |
|
329 |
break; |
|
330 |
case EDownloading: |
|
331 |
aIconIndex = dlStop ? ESuspendedShowIcon : EDownloadingShowIcon; |
|
332 |
break; |
|
333 |
case EFailedDownload: |
|
334 |
aIconIndex = EFailedShowIcon; |
|
335 |
break; |
|
2 | 336 |
} |
337 |
} |
|
338 |
||
339 |
void CPodcastQueueView::UpdateFeedUpdateStateL() |
|
340 |
{ |
|
341 |
TBool listboxDimmed = EFalse; |
|
342 |
||
343 |
if (iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() |
|
344 |
!= NULL && iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid()) |
|
345 |
{ |
|
346 |
listboxDimmed = ETrue; |
|
347 |
} |
|
348 |
||
349 |
if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed)) |
|
350 |
{ |
|
351 |
iListContainer->Listbox()->SetDimmed(listboxDimmed); |
|
352 |
} |
|
353 |
UpdateListboxItemsL(); |
|
354 |
UpdateToolbar(); |
|
355 |
} |
|
356 |
||
357 |
void CPodcastQueueView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded) |
|
358 |
{ |
|
359 |
TBuf<32> infoSize; |
|
360 |
TInt iconIndex = 0; |
|
361 |
TBuf<KMaxShortDateFormatSpec*2> showDate; |
|
362 |
GetShowIcons(&aShowInfo, iconIndex); |
|
363 |
||
364 |
if(aSizeDownloaded > 0) |
|
365 |
{ |
|
366 |
if (aShowInfo.ShowSize() > 0) |
|
367 |
{ |
|
368 |
infoSize.Format(KSizeDownloadingOf(), ((float) aSizeDownloaded / (float) KSizeMb), |
|
369 |
((float)aShowInfo.ShowSize() / (float)KSizeMb)); |
|
370 |
} |
|
371 |
else |
|
372 |
{ |
|
373 |
infoSize.Format(KShowsSizeFormatS60(), (float)aSizeDownloaded / (float)KSizeMb); |
|
374 |
} |
|
375 |
} |
|
376 |
else if (aShowInfo.ShowSize() > 0) |
|
377 |
{ |
|
378 |
infoSize.Format(KShowsSizeFormatS60(), (float)aShowInfo.ShowSize() / (float)KSizeMb); |
|
379 |
} |
|
380 |
else { |
|
381 |
infoSize = KNullDesC(); |
|
382 |
} |
|
383 |
||
384 |
if (aShowInfo.PubDate().Int64() == 0) |
|
385 |
{ |
|
386 |
showDate = KNullDesC(); |
|
387 |
} |
|
388 |
else |
|
389 |
{ |
|
390 |
aShowInfo.PubDate().FormatL(showDate, KDateFormatShort()); |
|
391 |
} |
|
392 |
||
95 | 393 |
if (infoSize.Length() > 0) { |
394 |
infoSize.Insert(0,_L(", ")); |
|
395 |
} |
|
396 |
||
397 |
iListboxFormatbuffer.Format(KShowQueueFormat(), iconIndex, &aShowInfo.Title(), &showDate, &infoSize); |
|
2 | 398 |
} |
399 |
||
400 |
void CPodcastQueueView::UpdateShowItemDataL(CShowInfo* aShowInfo,TInt aIndex, TInt aSizeDownloaded) |
|
401 |
{ |
|
402 |
FormatShowInfoListBoxItemL(*aShowInfo, aSizeDownloaded); |
|
403 |
iItemArray->Delete(aIndex); |
|
404 |
if(aIndex>= iItemArray->MdcaCount()) |
|
405 |
{ |
|
406 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
407 |
} |
|
408 |
else |
|
409 |
{ |
|
410 |
iItemArray->InsertL(aIndex, iListboxFormatbuffer); |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
void CPodcastQueueView::UpdateShowItemL(TUint aUid, TInt aSizeDownloaded) |
|
415 |
{ |
|
416 |
RShowInfoArray& array = iPodcastModel.ActiveShowList(); |
|
417 |
||
418 |
for (int i=0;i<array.Count();i++) { |
|
419 |
if (array[i]->Uid() == aUid) { |
|
420 |
UpdateShowItemDataL(array[i], i, aSizeDownloaded); |
|
421 |
if (iListContainer->Listbox()->TopItemIndex() <= i && |
|
422 |
iListContainer->Listbox()->BottomItemIndex() >= i) { |
|
423 |
iListContainer->Listbox()->DrawItem(i); |
|
424 |
} |
|
425 |
} |
|
426 |
} |
|
427 |
} |
|
428 |
||
429 |
void CPodcastQueueView::UpdateListboxItemsL() |
|
430 |
{ |
|
431 |
if (iListContainer->IsVisible()) |
|
432 |
{ |
|
433 |
TListItemProperties itemProps; |
|
434 |
TInt len = 0; |
|
435 |
||
8 | 436 |
iPodcastModel.GetShowsDownloadingL(); |
2 | 437 |
|
438 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
439 |
len = fItems.Count(); |
|
440 |
||
441 |
if (iListContainer->Listbox() != NULL) |
|
442 |
{ |
|
443 |
TBool allUidsMatch = EFalse; |
|
444 |
||
445 |
if (len == iListContainer->Listbox()->Model()->NumberOfItems()) |
|
446 |
{ |
|
447 |
allUidsMatch = ETrue; |
|
448 |
TUint itemId = 0; |
|
449 |
for (TInt loop = 0; loop< len; loop++) |
|
450 |
{ |
|
451 |
itemId = iItemIdArray[loop]; |
|
452 |
if (fItems[loop]->Uid() != itemId) |
|
453 |
{ |
|
454 |
allUidsMatch = EFalse; |
|
455 |
break; |
|
456 |
} |
|
457 |
} |
|
458 |
} |
|
459 |
||
460 |
if (allUidsMatch && len > 0) |
|
461 |
{ |
|
462 |
for (TInt loop = 0; loop< len; loop++) |
|
463 |
{ |
|
464 |
UpdateShowItemDataL(fItems[loop], loop); |
|
465 |
iListContainer->Listbox()->DrawItem(loop); |
|
466 |
} |
|
467 |
} |
|
468 |
else |
|
469 |
{ |
|
470 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
471 |
iListContainer->Listbox()->Reset(); |
|
472 |
iItemIdArray.Reset(); |
|
473 |
iItemArray->Reset(); |
|
474 |
||
475 |
if (len > 0) |
|
476 |
{ |
|
477 |
for (TInt i=0; i<len; i++) |
|
478 |
{ |
|
479 |
CShowInfo *si = fItems[i]; |
|
480 |
FormatShowInfoListBoxItemL(*si); |
|
481 |
iItemIdArray.Append(si->Uid()); |
|
482 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
483 |
} |
|
484 |
} |
|
485 |
else |
|
486 |
{ |
|
487 |
iItemArray->Reset(); |
|
488 |
iItemIdArray.Reset(); |
|
489 |
||
490 |
itemProps.SetDimmed(ETrue); |
|
491 |
itemProps.SetHiddenSelection(ETrue); |
|
492 |
} |
|
493 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
494 |
} |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
||
499 |
/** |
|
500 |
* Command handling function intended for overriding by sub classes. |
|
501 |
* Default implementation is empty. |
|
502 |
* @param aCommand ID of the command to respond to. |
|
503 |
*/ |
|
504 |
void CPodcastQueueView::HandleCommandL(TInt aCommand) |
|
505 |
{ |
|
506 |
switch (aCommand) |
|
507 |
{ |
|
508 |
case EPodcastRemoveAllDownloads: |
|
509 |
{ |
|
510 |
TBuf<KMaxMessageLength> msg; |
|
511 |
iEikonEnv->ReadResourceL(msg, R_CLEAR_QUERY); |
|
512 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
23
diff
changeset
|
513 |
if(ShowQueryMessageL(msg)) |
2 | 514 |
{ |
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
23
diff
changeset
|
515 |
iPodcastModel.ShowEngine().RemoveAllDownloadsL(); |
2 | 516 |
UpdateListboxItemsL(); |
517 |
} |
|
518 |
} |
|
519 |
break; |
|
520 |
case EPodcastRemoveDownload: |
|
521 |
{ |
|
522 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
523 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
524 |
{ |
|
525 |
if (iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid())) |
|
526 |
{ |
|
527 |
iItemArray->Delete(index); |
|
528 |
iItemIdArray.Remove(index); |
|
529 |
iListContainer->Listbox()->HandleItemRemovalL(); |
|
530 |
iListContainer->Listbox()->SetCurrentItemIndex(index - 1 > 0 ? index - 1 : 0); |
|
531 |
iListContainer->Listbox()->DrawNow(); |
|
532 |
||
533 |
delete iPodcastModel.ActiveShowList()[index]; |
|
534 |
iPodcastModel.ActiveShowList().Remove(index); |
|
535 |
} |
|
536 |
} |
|
537 |
} |
|
538 |
break; |
|
539 |
case EPodcastSuspendDownloads: |
|
540 |
{ |
|
541 |
iPodcastModel.ShowEngine().SuspendDownloads(); |
|
542 |
UpdateListboxItemsL(); |
|
543 |
} |
|
544 |
break; |
|
545 |
case EPodcastResumeDownloads: |
|
546 |
{ |
|
547 |
iPodcastModel.ShowEngine().ResumeDownloadsL(); |
|
548 |
UpdateListboxItemsL(); |
|
549 |
} |
|
550 |
break; |
|
551 |
default: |
|
552 |
CPodcastListView::HandleCommandL(aCommand); |
|
553 |
break; |
|
554 |
} |
|
50 | 555 |
iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping |
2 | 556 |
UpdateToolbar(); |
557 |
} |
|
558 |
||
559 |
void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
560 |
{ |
|
561 |
if(aResourceId == R_PODCAST_SHOWSVIEW_MENU) |
|
562 |
{ |
|
563 |
aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue); |
|
564 |
} |
|
565 |
} |
|
566 |
||
13 | 567 |
void CPodcastQueueView::UpdateToolbar(TBool aVisible) |
2 | 568 |
{ |
569 |
CAknToolbar* toolbar = Toolbar(); |
|
570 |
||
13 | 571 |
if (toolbar) { |
572 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
573 |
TInt itemCnt = fItems.Count(); |
|
14
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
574 |
if (iListContainer->IsVisible()) { |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
575 |
toolbar->SetToolbarVisibility(aVisible); |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
576 |
} |
13 | 577 |
toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue); |
578 |
toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue); |
|
579 |
toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue); |
|
580 |
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
|
581 |
#ifdef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
582 |
toolbar->HideItem(EPodcastRemoveDownload, EFalse, ETrue); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
583 |
toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue); |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
584 |
#endif |
13 | 585 |
} |
2 | 586 |
} |
587 |
||
588 |
void CPodcastQueueView::DownloadQueueUpdatedL(TInt /*aDownloadingShows*/, TInt /*aQueuedShows*/) |
|
589 |
{ |
|
101
867fc277ffea
Removed debug code that place the DB in the wrong place; Fix for DL queue not updating show icon correctly when moving to next download.
teknolog
parents:
95
diff
changeset
|
590 |
UpdateListboxItemsL(); |
2 | 591 |
} |
592 |
||
593 |
void CPodcastQueueView::FeedUpdateAllCompleteL(TFeedState /*aState*/) |
|
594 |
{ |
|
595 |
UpdateListboxItemsL(); |
|
596 |
UpdateToolbar(); |
|
597 |
} |