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