author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sun, 31 Oct 2010 14:14:17 +0000 | |
branch | RCL_3 |
changeset 320 | e3ec8e436951 |
parent 318 | a231cc388498 |
child 367 | 4b75876aa85a |
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> |
|
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
29 |
#include <akntitle.h> |
2 | 30 |
#include <gulicon.h> |
31 |
#include <eikenv.h> |
|
32 |
#include <e32const.h> |
|
33 |
#include <eikdialg.h> |
|
34 |
#include <aknquerydialog.h> |
|
35 |
#include <caknmemoryselectiondialog.h> |
|
36 |
#include <caknfilenamepromptdialog.h> |
|
37 |
#include <BAUTILS.H> |
|
38 |
#include <pathinfo.h> |
|
39 |
#include <f32file.h> |
|
40 |
#include <akntoolbarextension.h> |
|
41 |
||
42 |
const TInt KMaxFeedNameLength = 100; |
|
43 |
#define KMaxMessageLength 200 |
|
44 |
#define KMaxTitleLength 100 |
|
45 |
_LIT(KSearchResultFormat, "%d\t%S\t%S"); |
|
316 | 46 |
_LIT(KSearchResultFormatLandscape, "%d\t%S"); |
2 | 47 |
|
48 |
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel) |
|
49 |
{ |
|
50 |
CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel); |
|
51 |
CleanupStack::Pop( self ); |
|
52 |
return self; |
|
53 |
} |
|
54 |
||
55 |
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel) |
|
56 |
{ |
|
57 |
CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel); |
|
58 |
CleanupStack::PushL( self ); |
|
59 |
self->ConstructL(); |
|
60 |
return self; |
|
61 |
} |
|
62 |
||
63 |
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel) |
|
64 |
{ |
|
65 |
} |
|
66 |
||
67 |
void CPodcastSearchView::ConstructL() |
|
68 |
{ |
|
69 |
BaseConstructL(R_PODCAST_SEARCHVIEW); |
|
70 |
CPodcastListView::ConstructL(); |
|
71 |
iPodcastModel.FeedEngine().AddObserver(this); |
|
72 |
CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1); |
|
73 |
CleanupStack::PushL( icons ); |
|
74 |
||
75 |
CFbsBitmap* bitmap = NULL; |
|
76 |
CFbsBitmap* mask = NULL;// |
|
77 |
||
140 | 78 |
AknIconUtils::CreateIconL(bitmap, |
79 |
mask, |
|
80 |
iEikonEnv->EikAppUi()->Application()->BitmapStoreName(), |
|
81 |
EMbmPodcastFeed, |
|
82 |
EMbmPodcastFeed_mask); |
|
2 | 83 |
CleanupStack::PushL( bitmap ); |
84 |
CleanupStack::PushL( mask ); |
|
85 |
icons->AppendL( CGulIcon::NewL( bitmap, mask ) ); |
|
86 |
CleanupStack::Pop(2); // bitmap, mask |
|
87 |
||
313
0f30a75610de
First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
312
diff
changeset
|
88 |
iListContainer->SetListboxIcons(icons); |
2 | 89 |
CleanupStack::Pop(icons); // icons |
90 |
||
91 |
SetEmptyTextL(R_PODCAST_EMPTY_SEARCH); |
|
92 |
} |
|
93 |
||
94 |
CPodcastSearchView::~CPodcastSearchView() |
|
95 |
{ |
|
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
96 |
DP("CPodcastSearchView::~CPodcastSearchView BEGIN"); |
2 | 97 |
iPodcastModel.FeedEngine().RemoveObserver(this); |
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
98 |
DP("CPodcastSearchView::~CPodcastSearchView END"); |
2 | 99 |
} |
100 |
||
101 |
TUid CPodcastSearchView::Id() const |
|
102 |
{ |
|
103 |
return KUidPodcastSearchViewID; |
|
104 |
} |
|
105 |
||
106 |
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
107 |
TUid aCustomMessageId, |
|
108 |
const TDesC8& aCustomMessage) |
|
109 |
{ |
|
110 |
CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage); |
|
111 |
iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID); |
|
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
112 |
|
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
113 |
HBufC* text = iEikonEnv->AllocReadResourceLC(R_SEARCH_RESULTS); |
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
114 |
|
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
115 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
116 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
49
43e204e6ae2e
Fix for accidental merge regressions. Text fixes for tool tip and settings.
teknolog
parents:
24
diff
changeset
|
117 |
|
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
118 |
titlePane->SetTextL(*text , ETrue ); |
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
119 |
CleanupStack::PopAndDestroy(text); |
56 | 120 |
UpdateListboxItemsL(); |
2 | 121 |
} |
122 |
||
123 |
void CPodcastSearchView::DoDeactivate() |
|
124 |
{ |
|
125 |
CPodcastListView::DoDeactivate(); |
|
309
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
126 |
|
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
127 |
CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
128 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
129 |
|
d9f6395a50ea
Search view title moved from navi pane to title bar, for consistencey
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
243
diff
changeset
|
130 |
titlePane->SetTextToDefaultL(); |
2 | 131 |
} |
132 |
||
133 |
||
134 |
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType) |
|
135 |
{ |
|
136 |
DP("CPodcastSearchView::HandleListBoxEventL BEGIN"); |
|
137 |
switch(aEventType) |
|
138 |
{ |
|
139 |
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
|
140 |
case EEventItemSingleClicked: |
2 | 141 |
case EEventItemDoubleClicked: |
142 |
case EEventItemActioned: |
|
143 |
{ |
|
144 |
HandleCommandL(EPodcastAddSearchResult); |
|
145 |
} |
|
146 |
break; |
|
147 |
default: |
|
148 |
break; |
|
149 |
} |
|
150 |
DP("CPodcastSearchView::HandleListBoxEventL END"); |
|
151 |
} |
|
152 |
||
153 |
void CPodcastSearchView::UpdateListboxItemsL() |
|
154 |
{ |
|
155 |
DP("CPodcastSearchView::UpdateListboxItemsL BEGIN"); |
|
156 |
if(!iListContainer->IsVisible()) { |
|
157 |
DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)"); |
|
158 |
return; |
|
159 |
} |
|
160 |
const RFeedInfoArray* searchItems = NULL; |
|
161 |
searchItems = &iPodcastModel.FeedEngine().GetSearchResults(); |
|
162 |
TInt len = searchItems->Count(); |
|
163 |
TListItemProperties itemProps; |
|
164 |
iListContainer->Listbox()->Reset(); |
|
317
5afc95a6ad83
Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
316
diff
changeset
|
165 |
//iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL(); |
2 | 166 |
iItemIdArray.Reset(); |
167 |
iItemArray->Reset(); |
|
168 |
||
169 |
if (len > 0) |
|
170 |
{ |
|
171 |
for (int i=0;i<len;i++) |
|
172 |
{ |
|
173 |
CFeedInfo *fi = (*searchItems)[i]; |
|
174 |
iItemIdArray.Append(fi->Uid()); |
|
175 |
TInt iconIndex = 0; |
|
176 |
||
177 |
TBuf<512> descr; |
|
178 |
descr.Copy(fi->Description().Left(512)); |
|
15
93d9f66bf50b
Cleaning description better for second line in search results
teknolog
parents:
14
diff
changeset
|
179 |
PodcastUtils::RemoveAllFormatting(descr); |
2 | 180 |
iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr); |
181 |
iItemArray->AppendL(iListboxFormatbuffer); |
|
317
5afc95a6ad83
Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
316
diff
changeset
|
182 |
iListboxFormatbufferShort.Format(KSearchResultFormatLandscape(), iconIndex, &fi->Title()); |
316 | 183 |
iItemArrayShort->AppendL(iListboxFormatbufferShort); |
317
5afc95a6ad83
Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
316
diff
changeset
|
184 |
//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps); |
2 | 185 |
} |
186 |
} |
|
187 |
else |
|
188 |
{ |
|
189 |
TBuf<KMaxFeedNameLength> itemName; |
|
190 |
iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS); |
|
191 |
iItemArray->Reset(); |
|
316 | 192 |
iItemArrayShort->Reset(); |
2 | 193 |
iItemIdArray.Reset(); |
194 |
||
195 |
TListItemProperties itemProps; |
|
196 |
itemProps.SetDimmed(ETrue); |
|
197 |
itemProps.SetHiddenSelection(ETrue); |
|
317
5afc95a6ad83
Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
316
diff
changeset
|
198 |
//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps); |
2 | 199 |
} |
200 |
iListContainer->Listbox()->HandleItemAdditionL(); |
|
201 |
DP("CPodcastSearchView::UpdateListboxItemsL END"); |
|
202 |
} |
|
203 |
||
204 |
/** |
|
205 |
* Command handling function intended for overriding by sub classes. |
|
206 |
* Default implementation is empty. |
|
207 |
* @param aCommand ID of the command to respond to. |
|
208 |
*/ |
|
209 |
void CPodcastSearchView::HandleCommandL(TInt aCommand) |
|
210 |
{ |
|
211 |
//CloseToolbarExtension(); |
|
212 |
switch(aCommand) |
|
213 |
{ |
|
214 |
case EPodcastAddSearchResult: |
|
215 |
{ |
|
216 |
TInt index = iListContainer->Listbox()->CurrentItemIndex(); |
|
217 |
||
218 |
if(index < iItemArray->MdcaCount() && index >= 0) |
|
219 |
{ |
|
220 |
CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index]; |
|
221 |
||
222 |
// ask if user wants to add the feed |
|
223 |
TBuf<KMaxMessageLength> templ; |
|
224 |
TBuf<KMaxMessageLength> message; |
|
225 |
||
226 |
iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY); |
|
227 |
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
|
228 |
if(ShowQueryMessageL(message)) { |
2 | 229 |
TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo); |
230 |
||
231 |
if (added) |
|
312
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
232 |
{ |
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
233 |
// this is a bit of a hack, first we activate the feeds view normally |
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
234 |
AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(0), KNullDesC8); |
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
235 |
// and then we send the UID of the recently added feed back to feed view for updating |
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
236 |
// this is needed so the update? query comes on top of feed view, not search view |
2faae209e72b
More elegant view handling between search view and feeds view
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
309
diff
changeset
|
237 |
AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID, TUid::Uid(newInfo->Uid()), KNullDesC8); |
2 | 238 |
} |
239 |
else |
|
240 |
{ |
|
241 |
TBuf<KMaxMessageLength> message; |
|
242 |
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
|
243 |
ShowErrorMessageL(message); |
2 | 244 |
} |
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
break; |
|
249 |
default: |
|
250 |
CPodcastListView::HandleCommandL(aCommand); |
|
251 |
break; |
|
252 |
} |
|
253 |
UpdateToolbar(); |
|
254 |
} |
|
255 |
||
7 | 256 |
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/) |
2 | 257 |
{ |
258 |
DP("CPodcastSearchView::OpmlParsingComplete BEGIN"); |
|
56 | 259 |
|
2 | 260 |
DP("CPodcastSearchView::OpmlParsingComplete END"); |
261 |
} |