author | teknolog |
Tue, 27 Apr 2010 19:26:48 +0100 | |
changeset 60 | 4d230e702aa3 |
parent 34 | a6046405f1aa |
child 65 | bcd88ba95046 |
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 |
||
35 |
#define KMaxMessageLength 200 |
|
36 |
||
37 |
||
38 |
CPodcastQueueView* CPodcastQueueView::NewL(CPodcastModel& aPodcastModel) |
|
39 |
{ |
|
40 |
CPodcastQueueView* self = CPodcastQueueView::NewLC(aPodcastModel); |
|
41 |
CleanupStack::Pop(self); |
|
42 |
return self; |
|
43 |
} |
|
44 |
||
45 |
CPodcastQueueView* CPodcastQueueView::NewLC(CPodcastModel& aPodcastModel) |
|
46 |
{ |
|
47 |
CPodcastQueueView* self = new ( ELeave ) CPodcastQueueView(aPodcastModel); |
|
48 |
CleanupStack::PushL(self); |
|
49 |
self->ConstructL(); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
CPodcastQueueView::CPodcastQueueView(CPodcastModel& aPodcastModel) : |
|
60 | 54 |
CPodcastShowsView(aPodcastModel) |
2 | 55 |
{ |
56 |
} |
|
57 |
||
58 |
void CPodcastQueueView::ConstructL() |
|
59 |
{ |
|
60 |
BaseConstructL(R_PODCAST_QUEUEVIEW); |
|
61 |
CPodcastListView::ConstructL(); |
|
60 | 62 |
|
63 |
CreateIconsL(); |
|
64 |
||
2 | 65 |
iListContainer->Listbox()->SetListBoxObserver(this); |
66 |
||
67 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
68 |
iPodcastModel.ShowEngine().AddObserver(this); |
|
69 |
||
60 | 70 |
|
71 |
// no popup options apply to S^1 |
|
72 |
#ifndef SYMBIAN1_UI |
|
2 | 73 |
iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0)); |
74 |
TResourceReader reader; |
|
75 |
iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU); |
|
76 |
iStylusPopupMenu->ConstructFromResourceL(reader); |
|
77 |
CleanupStack::PopAndDestroy(); |
|
60 | 78 |
#endif |
2 | 79 |
SetEmptyTextL(R_PODCAST_EMPTY_QUEUE); |
80 |
} |
|
81 |
||
82 |
TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
83 |
{ |
|
84 |
if (aType == EEventKey) |
|
85 |
{ |
|
86 |
CShowInfo *activeShow = NULL; |
|
87 |
||
88 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
89 |
if(index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
90 |
{ |
|
91 |
activeShow = iPodcastModel.ActiveShowList()[index]; |
|
92 |
} |
|
93 |
||
94 |
if (activeShow != NULL) { |
|
95 |
DP1("aKeyEvent.iCode=%d", aKeyEvent.iCode); |
|
96 |
switch (aKeyEvent.iCode) { |
|
97 |
case EKeyBackspace: |
|
98 |
case EKeyDelete: |
|
99 |
HandleCommandL(EPodcastRemoveDownload); |
|
100 |
break; |
|
101 |
default: |
|
102 |
break; |
|
103 |
} |
|
104 |
UpdateToolbar(); |
|
105 |
} |
|
106 |
} |
|
107 |
return CPodcastListView::OfferKeyEventL(aKeyEvent, aType); |
|
108 |
} |
|
109 |
||
110 |
CPodcastQueueView::~CPodcastQueueView() |
|
111 |
{ |
|
112 |
iPodcastModel.ShowEngine().RemoveObserver(this); |
|
113 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
114 |
||
115 |
if(iStylusPopupMenu) |
|
116 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
117 |
} |
|
118 |
||
119 |
||
120 |
TUid CPodcastQueueView::Id() const |
|
121 |
{ |
|
122 |
return KUidPodcastQueueViewID; |
|
123 |
} |
|
124 |
||
125 |
void CPodcastQueueView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
126 |
TUid aCustomMessageId, const TDesC8& aCustomMessage) |
|
127 |
{ |
|
128 |
DP("CPodcastQueueView::DoActivateL BEGIN"); |
|
129 |
||
130 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
60 | 131 |
iPreviousView = aPrevViewId; |
2 | 132 |
|
133 |
UpdateFeedUpdateStateL(); |
|
134 |
UpdateToolbar(); |
|
135 |
DP("CPodcastQueueView::DoActivateL END"); |
|
136 |
} |
|
137 |
||
138 |
void CPodcastQueueView::DoDeactivate() |
|
139 |
{ |
|
140 |
CPodcastListView::DoDeactivate(); |
|
141 |
} |
|
142 |
||
143 |
void CPodcastQueueView::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
144 |
TListBoxEvent aEventType) |
|
145 |
{ |
|
146 |
switch (aEventType) |
|
147 |
{ |
|
23
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
148 |
#ifndef SYMBIAN1_UI |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
149 |
case EEventItemClicked: |
cf4b850bbffb
Added macro SYMBIAN1_UI that toggles between single and double tap UI
teknolog
parents:
14
diff
changeset
|
150 |
#endif |
2 | 151 |
case EEventEnterKeyPressed: |
152 |
case EEventItemActioned: |
|
153 |
case EEventItemDoubleClicked: |
|
154 |
break; |
|
155 |
default: |
|
156 |
break; |
|
157 |
} |
|
158 |
UpdateToolbar(); |
|
159 |
} |
|
160 |
||
161 |
void CPodcastQueueView::UpdateListboxItemsL() |
|
162 |
{ |
|
163 |
if (iListContainer->IsVisible()) |
|
164 |
{ |
|
165 |
TListItemProperties itemProps; |
|
166 |
TInt len = 0; |
|
167 |
||
8 | 168 |
iPodcastModel.GetShowsDownloadingL(); |
2 | 169 |
|
170 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
171 |
len = fItems.Count(); |
|
172 |
||
173 |
if (iListContainer->Listbox() != NULL) |
|
174 |
{ |
|
175 |
TBool allUidsMatch = EFalse; |
|
176 |
||
177 |
if (len == iListContainer->Listbox()->Model()->NumberOfItems()) |
|
178 |
{ |
|
179 |
allUidsMatch = ETrue; |
|
180 |
TUint itemId = 0; |
|
181 |
for (TInt loop = 0; loop< len; loop++) |
|
182 |
{ |
|
183 |
itemId = iItemIdArray[loop]; |
|
184 |
if (fItems[loop]->Uid() != itemId) |
|
185 |
{ |
|
186 |
allUidsMatch = EFalse; |
|
187 |
break; |
|
188 |
} |
|
189 |
} |
|
190 |
} |
|
191 |
||
192 |
if (allUidsMatch && len > 0) |
|
193 |
{ |
|
194 |
for (TInt loop = 0; loop< len; loop++) |
|
195 |
{ |
|
196 |
UpdateShowItemDataL(fItems[loop], loop); |
|
197 |
iListContainer->Listbox()->DrawItem(loop); |
|
198 |
} |
|
199 |
} |
|
200 |
else |
|
201 |
{ |
|
202 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
203 |
iListContainer->Listbox()->Reset(); |
|
204 |
iItemIdArray.Reset(); |
|
205 |
iItemArray->Reset(); |
|
206 |
||
207 |
if (len > 0) |
|
208 |
{ |
|
209 |
for (TInt i=0; i<len; i++) |
|
210 |
{ |
|
211 |
CShowInfo *si = fItems[i]; |
|
212 |
FormatShowInfoListBoxItemL(*si); |
|
213 |
iItemIdArray.Append(si->Uid()); |
|
214 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
215 |
} |
|
216 |
} |
|
217 |
else |
|
218 |
{ |
|
219 |
iItemArray->Reset(); |
|
220 |
iItemIdArray.Reset(); |
|
221 |
||
222 |
itemProps.SetDimmed(ETrue); |
|
223 |
itemProps.SetHiddenSelection(ETrue); |
|
224 |
} |
|
225 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
/** |
|
232 |
* Command handling function intended for overriding by sub classes. |
|
233 |
* Default implementation is empty. |
|
234 |
* @param aCommand ID of the command to respond to. |
|
235 |
*/ |
|
236 |
void CPodcastQueueView::HandleCommandL(TInt aCommand) |
|
237 |
{ |
|
238 |
switch (aCommand) |
|
239 |
{ |
|
240 |
case EPodcastRemoveAllDownloads: |
|
241 |
{ |
|
242 |
TBuf<KMaxMessageLength> msg; |
|
243 |
iEikonEnv->ReadResourceL(msg, R_CLEAR_QUERY); |
|
244 |
||
60 | 245 |
if(ShowQueryMessageL(msg)) |
2 | 246 |
{ |
60 | 247 |
iPodcastModel.ShowEngine().RemoveAllDownloadsL(); |
2 | 248 |
UpdateListboxItemsL(); |
249 |
} |
|
250 |
} |
|
251 |
break; |
|
252 |
case EPodcastRemoveDownload: |
|
253 |
{ |
|
254 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
255 |
if (index >= 0 && index < iPodcastModel.ActiveShowList().Count()) |
|
256 |
{ |
|
60 | 257 |
TRAP_IGNORE(iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid())); |
2 | 258 |
} |
259 |
} |
|
260 |
break; |
|
261 |
case EPodcastSuspendDownloads: |
|
262 |
{ |
|
263 |
iPodcastModel.ShowEngine().SuspendDownloads(); |
|
264 |
UpdateListboxItemsL(); |
|
265 |
} |
|
266 |
break; |
|
267 |
case EPodcastResumeDownloads: |
|
268 |
{ |
|
269 |
iPodcastModel.ShowEngine().ResumeDownloadsL(); |
|
270 |
UpdateListboxItemsL(); |
|
271 |
} |
|
272 |
break; |
|
273 |
default: |
|
274 |
CPodcastListView::HandleCommandL(aCommand); |
|
275 |
break; |
|
276 |
} |
|
60 | 277 |
iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping |
2 | 278 |
UpdateToolbar(); |
279 |
} |
|
280 |
||
281 |
void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
282 |
{ |
|
283 |
if(aResourceId == R_PODCAST_SHOWSVIEW_MENU) |
|
284 |
{ |
|
285 |
aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue); |
|
286 |
} |
|
287 |
} |
|
288 |
||
13 | 289 |
void CPodcastQueueView::UpdateToolbar(TBool aVisible) |
2 | 290 |
{ |
291 |
CAknToolbar* toolbar = Toolbar(); |
|
292 |
||
13 | 293 |
if (toolbar) { |
294 |
RShowInfoArray &fItems = iPodcastModel.ActiveShowList(); |
|
295 |
TInt itemCnt = fItems.Count(); |
|
14
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
296 |
if (iListContainer->IsVisible()) { |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
297 |
toolbar->SetToolbarVisibility(aVisible); |
4e75731546eb
Fix so toolbars only change visibility for the visible view
teknolog
parents:
13
diff
changeset
|
298 |
} |
13 | 299 |
toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue); |
300 |
toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue); |
|
301 |
toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue); |
|
302 |
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
|
303 |
toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue); |
13 | 304 |
} |
2 | 305 |
} |