author | larspson |
Wed, 13 Oct 2010 13:36:47 +0200 | |
branch | podcatcher_qt_symbian4 |
changeset 227 | 325137e6edd1 |
parent 140 | 68b48f53a8ec |
child 243 | 44d205147a83 |
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 "PodcastSearchView.h" |
|
20 |
#include "PodcastAppUi.h" |
|
21 |
#include "FeedEngine.h" |
|
22 |
#include "ShowEngine.h" |
|
23 |
#include "SettingsEngine.h" |
|
24 |
#include "PodcastApp.h" |
|
25 |
#include "PodcastUtils.h" |
|
26 |
#include <caknfileselectiondialog.h> |
|
27 |
#include <podcast.rsg> |
|
28 |
#include <podcast.mbg> |
|
29 |
#include <gulicon.h> |
|
30 |
#include <eikenv.h> |
|
31 |
#include <e32const.h> |
|
32 |
#include <eikdialg.h> |
|
33 |
#include <aknquerydialog.h> |
|
34 |
#include <caknmemoryselectiondialog.h> |
|
35 |
#include <caknfilenamepromptdialog.h> |
|
36 |
#include <BAUTILS.H> |
|
37 |
#include <pathinfo.h> |
|
38 |
#include <f32file.h> |
|
39 |
#include <akntoolbarextension.h> |
|
40 |
||
41 |
const TInt KMaxFeedNameLength = 100; |
|
42 |
#define KMaxMessageLength 200 |
|
43 |
#define KMaxTitleLength 100 |
|
44 |
_LIT(KSearchResultFormat, "%d\t%S\t%S"); |
|
45 |
||
46 |
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) |
|
47 |
{ |
|
48 |
CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) |
|
54 |
{ |
|
55 |
CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); |
|
56 |
CleanupStack::PushL( self ); |
|
57 |
self->ConstructL(); |
|
58 |
return self; |
|
59 |
} |
|
60 |
||
61 |
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
62 |
{ |
|
63 |
} |
|
64 |
||
65 |
void CPodcastSearchView::ConstructL() |
|
66 |
{ |
|
67 |
BaseConstructL(R_PODCAST_SEARCHVIEW); |
|
68 |
CPodcastListView::ConstructL(); |
|
69 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
70 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
71 |
CleanupStack::PushL( icons ); |
|
72 |
||
73 |
CFbsBitmap* bitmap = NULL; |
|
74 |
CFbsBitmap* mask = NULL;// |
|
75 |
||
140 | 76 |
AknIconUtils::CreateIconL(bitmap, |
77 |
mask, |
|
78 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
79 |
EMbmPodcastFeed, |
|
80 |
EMbmPodcastFeed_mask); |
|
2 | 81 |
CleanupStack::PushL( bitmap ); |
82 |
CleanupStack::PushL( mask ); |
|
83 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
84 |
CleanupStack::Pop(2); // bitmap, mask |
|
85 |
||
86 |
iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
87 |
CleanupStack::Pop(icons); // icons |
|
88 |
||
89 |
iListContainer->Listbox()->SetListBoxObserver(this); |
|
90 |
||
91 |
SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); |
|
92 |
} |
|
93 |
||
94 |
CPodcastSearchView::~CPodcastSearchView() |
|
95 |
{ |
|
96 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
|
97 |
||
98 |
if(iLongTapDetector) |
|
99 |
delete iLongTapDetector, iLongTapDetector = NULL; |
|
100 |
||
101 |
if(iStylusPopupMenu) |
|
102 |
delete iStylusPopupMenu, iStylusPopupMenu = NULL; |
|
103 |
||
104 |
} |
|
105 |
||
106 |
TUid CPodcastSearchView::Id() const |
|
107 |
{ |
|
108 |
return KUidPodcastSearchViewID; |
|
109 |
} |
|
110 |
||
111 |
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
112 |
TUid aCustomMessageId, |
|
113 |
const TDesC8& aCustomMessage) |
|
114 |
{ |
|
115 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
116 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
117 |
|
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
118 |
((CPodcastAppUi*)AppUi())->NaviSetTextL(R_SEARCH_RESULTS); |
56 | 119 |
|
120 |
UpdateListboxItemsL(); |
|
2 | 121 |
} |
122 |
||
123 |
void CPodcastSearchView::DoDeactivate() |
|
124 |
{ |
|
125 |
CPodcastListView::DoDeactivate(); |
|
117
3b59b88b089e
Fixed Code Scanner L-issues; Further improvements to HTTP robustness
teknolog
parents:
113
diff
changeset
|
126 |
TRAP_IGNORE(((CPodcastAppUi*)AppUi())->NaviShowTabGroupL()); |
2 | 127 |
} |
128 |
||
129 |
||
130 |
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
131 |
{ |
|
132 |
DP("CPodcastSearchView::HandleListBoxEventL BEGIN"); |
|
133 |
switch(aEventType) |
|
134 |
{ |
|
135 |
case EEventEnterKeyPressed: |
|
137
eefed4bda2e2
Minor fixes to comply with single tap technical solution description. By this I consider bug 2056 closed.
teknolog
parents:
126
diff
changeset
|
136 |
case EEventItemSingleClicked: |
2 | 137 |
case EEventItemDoubleClicked: |
138 |
case EEventItemActioned: |
|
139 |
{ |
|
140 |
HandleCommandL(EPodcastAddSearchResult); |
|
141 |
} |
|
142 |
break; |
|
143 |
default: |
|
144 |
break; |
|
145 |
} |
|
146 |
DP("CPodcastSearchView::HandleListBoxEventL END"); |
|
147 |
} |
|
148 |
||
149 |
void CPodcastSearchView::UpdateListboxItemsL() |
|
150 |
{ |
|
151 |
DP("CPodcastSearchView::UpdateListboxItemsL BEGIN"); |
|
152 |
if(!iListContainer->IsVisible()) { |
|
153 |
DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)"); |
|
154 |
return; |
|
155 |
} |
|
156 |
const RFeedInfoArray* searchItems = NULL; |
|
157 |
searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); |
|
158 |
TInt len = searchItems->Count(); |
|
159 |
TListItemProperties itemProps; |
|
160 |
iListContainer->Listbox()->Reset(); |
|
161 |
iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
|
162 |
iItemIdArray.Reset(); |
|
163 |
iItemArray->Reset(); |
|
164 |
||
165 |
if (len > 0) |
|
166 |
{ |
|
167 |
for (int i=0;i<len;i++) |
|
168 |
{ |
|
169 |
CFeedInfo *fi = (*searchItems)[i]; |
|
170 |
iItemIdArray.Append(fi->Uid()); |
|
171 |
TInt iconIndex = 0; |
|
172 |
||
173 |
TBuf<512> descr; |
|
174 |
descr.Copy(fi->Description().Left(512)); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
14
diff
changeset
|
175 |
PodcastUtils::RemoveAllFormatting(descr); |
2 | 176 |
iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); |
177 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
178 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); |
|
179 |
} |
|
180 |
} |
|
181 |
else |
|
182 |
{ |
|
183 |
TBuf<KMaxFeedNameLength> itemName; |
|
184 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); |
|
185 |
iItemArray->Reset(); |
|
186 |
iItemIdArray.Reset(); |
|
187 |
||
188 |
TListItemProperties itemProps; |
|
189 |
itemProps.SetDimmed(ETrue); |
|
190 |
itemProps.SetHiddenSelection(ETrue); |
|
191 |
iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
|
192 |
} |
|
193 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
194 |
DP("CPodcastSearchView::UpdateListboxItemsL END"); |
|
195 |
} |
|
196 |
||
197 |
/** |
|
198 |
* Command handling function intended for overriding by sub classes. |
|
199 |
* Default implementation is empty. |
|
200 |
* @param aCommand ID of the command to respond to. |
|
201 |
*/ |
|
202 |
void CPodcastSearchView::HandleCommandL(TInt aCommand) |
|
203 |
{ |
|
204 |
//CloseToolbarExtension(); |
|
205 |
switch(aCommand) |
|
206 |
{ |
|
207 |
case EPodcastAddSearchResult: |
|
208 |
{ |
|
209 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
210 |
||
211 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
212 |
{ |
|
213 |
CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; |
|
214 |
||
215 |
// ask if user wants to add the feed |
|
216 |
TBuf<KMaxMessageLength> templ; |
|
217 |
TBuf<KMaxMessageLength> message; |
|
218 |
||
219 |
iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); |
|
220 |
message.Format(templ, &newInfo->Title()); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
221 |
if(ShowQueryMessageL(message)) { |
2 | 222 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); |
223 |
||
224 |
if (added) |
|
225 |
{ |
|
226 |
// ask if user wants to update it now |
|
227 |
TBuf<KMaxMessageLength> message; |
|
228 |
iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
229 |
if(ShowQueryMessageL(message)) |
2 | 230 |
{ |
231 |
CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newInfo->Uid()); |
|
232 |
||
233 |
iPodcastModel.SetActiveFeedInfo(info); |
|
234 |
AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID, TUid::Uid(0), KNullDesC8()); |
|
235 |
iPodcastModel.FeedEngine().UpdateFeedL(info->Uid()); |
|
236 |
} |
|
237 |
} |
|
238 |
else |
|
239 |
{ |
|
240 |
TBuf<KMaxMessageLength> message; |
|
241 |
iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
24
diff
changeset
|
242 |
ShowErrorMessageL(message); |
2 | 243 |
} |
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
break; |
|
248 |
default: |
|
249 |
CPodcastListView::HandleCommandL(aCommand); |
|
250 |
break; |
|
251 |
} |
|
252 |
UpdateToolbar(); |
|
253 |
} |
|
254 |
||
7 | 255 |
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) |
2 | 256 |
{ |
257 |
DP("CPodcastSearchView::OpmlParsingComplete BEGIN"); |
|
56 | 258 |
|
2 | 259 |
DP("CPodcastSearchView::OpmlParsingComplete END"); |
260 |
} |