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