application/src/PodcastSearchView.cpp
author Sebastian Brannstrom <sebastianb@symbian.org>
Sun, 31 Oct 2010 13:58:44 +0000
branchtwolistboxes
changeset 318 a231cc388498
parent 317 5afc95a6ad83
child 367 4b75876aa85a
permissions -rw-r--r--
Improved event handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     1
/*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     2
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     3
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     4
* All rights reserved.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     5
* This component and the accompanying materials are made available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     6
* under the terms of the License "Eclipse Public License v1.0"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     7
* which accompanies this distribution, and is available
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     8
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
     9
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    10
* Initial Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    11
* EmbedDev AB - initial contribution.
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    12
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    13
* Contributors:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    14
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    15
* Description:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    16
*
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    17
*/
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    18
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    19
#include "PodcastSearchView.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    20
#include "PodcastAppUi.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    21
#include "FeedEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    22
#include "ShowEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    23
#include "SettingsEngine.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    24
#include "PodcastApp.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    25
#include "PodcastUtils.h"
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    26
#include <caknfileselectiondialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    27
#include <podcast.rsg>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    30
#include <gulicon.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    31
#include <eikenv.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    32
#include <e32const.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    33
#include <eikdialg.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    34
#include <aknquerydialog.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    35
#include <caknmemoryselectiondialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    36
#include <caknfilenamepromptdialog.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    37
#include <BAUTILS.H> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    38
#include <pathinfo.h> 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    39
#include <f32file.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    40
#include <akntoolbarextension.h>
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    41
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    42
const TInt KMaxFeedNameLength = 100;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    43
#define KMaxMessageLength 200
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    44
#define KMaxTitleLength 100
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    45
_LIT(KSearchResultFormat, "%d\t%S\t%S");
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
    46
_LIT(KSearchResultFormatLandscape, "%d\t%S");
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    47
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    48
CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    49
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    50
    CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    51
    CleanupStack::Pop( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    52
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    53
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    54
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    55
CPodcastSearchView* CPodcastSearchView::NewLC(CPodcastModel& aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    56
    {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    57
    CPodcastSearchView* self = new ( ELeave ) CPodcastSearchView(aPodcastModel);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    58
    CleanupStack::PushL( self );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    59
    self->ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    60
    return self;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    61
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    62
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    63
CPodcastSearchView::CPodcastSearchView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    64
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    65
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    66
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    67
void CPodcastSearchView::ConstructL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    68
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    69
	BaseConstructL(R_PODCAST_SEARCHVIEW);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    70
	CPodcastListView::ConstructL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    71
	iPodcastModel.FeedEngine().AddObserver(this);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    72
	CArrayPtr< CGulIcon >* icons = new(ELeave) CArrayPtrFlat< CGulIcon >(1);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    73
	CleanupStack::PushL( icons );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    74
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    75
	CFbsBitmap* bitmap = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    76
	CFbsBitmap* mask = NULL;//	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    77
	
140
68b48f53a8ec Updated help files merged from symbian1 branch
teknolog
parents: 137
diff changeset
    78
	AknIconUtils::CreateIconL(bitmap,
68b48f53a8ec Updated help files merged from symbian1 branch
teknolog
parents: 137
diff changeset
    79
							  mask,
68b48f53a8ec Updated help files merged from symbian1 branch
teknolog
parents: 137
diff changeset
    80
							  iEikonEnv->EikAppUi()->Application()->BitmapStoreName(),
68b48f53a8ec Updated help files merged from symbian1 branch
teknolog
parents: 137
diff changeset
    81
							  EMbmPodcastFeed,
68b48f53a8ec Updated help files merged from symbian1 branch
teknolog
parents: 137
diff changeset
    82
							  EMbmPodcastFeed_mask);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    83
	CleanupStack::PushL( bitmap );		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    84
	CleanupStack::PushL( mask );		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    85
	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    86
	CleanupStack::Pop(2); // bitmap, mask
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    87
	
313
0f30a75610de First implementation of two listboxes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 312
diff changeset
    88
	iListContainer->SetListboxIcons(icons);
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    89
	CleanupStack::Pop(icons); // icons
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    90
	
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    91
	SetEmptyTextL(R_PODCAST_EMPTY_SEARCH);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    92
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    93
    
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    94
CPodcastSearchView::~CPodcastSearchView()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
    99
    }
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   100
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   101
TUid CPodcastSearchView::Id() const
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   102
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   103
	return KUidPodcastSearchViewID;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   104
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   105
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   106
void CPodcastSearchView::DoActivateL(const TVwsViewId& aPrevViewId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   107
	                                  TUid aCustomMessageId,
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   108
	                                  const TDesC8& aCustomMessage)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   109
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   110
	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
c5cd47bc11ef Fix for bug 2152 plus minor fix for S1 UI
teknolog
parents: 50
diff changeset
   120
	UpdateListboxItemsL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   121
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   122
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   123
void CPodcastSearchView::DoDeactivate()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   124
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   131
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   132
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   133
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   134
void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   135
{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   136
	DP("CPodcastSearchView::HandleListBoxEventL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   137
	switch(aEventType)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   138
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   141
	case EEventItemDoubleClicked:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   142
	case EEventItemActioned:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   143
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   144
		HandleCommandL(EPodcastAddSearchResult);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   145
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   146
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   147
	default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   148
		break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   149
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   150
	DP("CPodcastSearchView::HandleListBoxEventL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   151
}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   152
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   153
void CPodcastSearchView::UpdateListboxItemsL()
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   154
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   155
	DP("CPodcastSearchView::UpdateListboxItemsL BEGIN");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   156
	if(!iListContainer->IsVisible()) {
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   157
		DP("CPodcastSearchView::UpdateListboxItemsL END (not visible)");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   158
		return;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   159
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   160
	const RFeedInfoArray* searchItems = NULL;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   161
	searchItems = &iPodcastModel.FeedEngine().GetSearchResults();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   162
	TInt len = searchItems->Count();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   163
	TListItemProperties itemProps;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   164
	iListContainer->Listbox()->Reset();
317
5afc95a6ad83 Stability fixes
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 316
diff changeset
   165
	//iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   166
	iItemIdArray.Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   167
	iItemArray->Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   168
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   169
	if (len > 0) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   170
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   171
		for (int i=0;i<len;i++) 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   172
			{				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   173
			CFeedInfo *fi = (*searchItems)[i];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   174
			iItemIdArray.Append(fi->Uid());
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   175
			TInt iconIndex = 0;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   176
			
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   177
			TBuf<512> descr;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   180
			iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   185
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   186
		} 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   187
	else 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   188
		{					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   189
		TBuf<KMaxFeedNameLength> itemName;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   190
		iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   191
		iItemArray->Reset();
316
841ccfa933ac More cleanup
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 314
diff changeset
   192
		iItemArrayShort->Reset();
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   193
		iItemIdArray.Reset();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   194
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   195
		TListItemProperties itemProps;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   196
		itemProps.SetDimmed(ETrue);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   199
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   200
	iListContainer->Listbox()->HandleItemAdditionL();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   201
	DP("CPodcastSearchView::UpdateListboxItemsL END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   202
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   203
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   204
/** 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   205
 * Command handling function intended for overriding by sub classes. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   206
 * Default implementation is empty.  
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   207
 * @param aCommand ID of the command to respond to. 
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   208
 */
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   209
void CPodcastSearchView::HandleCommandL(TInt aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   210
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   211
	//CloseToolbarExtension();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   212
	switch(aCommand)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   213
		{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   214
		case EPodcastAddSearchResult:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   215
			{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   216
			TInt index = iListContainer->Listbox()->CurrentItemIndex();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   217
		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   218
			if(index < iItemArray->MdcaCount() && index >= 0)
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   219
				{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   220
				CFeedInfo *newInfo = iPodcastModel.FeedEngine().GetSearchResults()[index];
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   221
				
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   222
				// ask if user wants to add the feed
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   223
				TBuf<KMaxMessageLength> templ;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   224
				TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   225
								
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   226
				iEikonEnv->ReadResourceL(templ, R_ADD_FEED_QUERY);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   229
					TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   230
					
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   238
						}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   239
					else
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   240
						{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   241
						TBuf<KMaxMessageLength> message;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   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
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   244
						}		
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   245
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   246
				}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   247
			}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   248
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   249
		default:
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   250
			CPodcastListView::HandleCommandL(aCommand);
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   251
			break;
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   252
		}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   253
		UpdateToolbar();
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   254
	}
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   255
7
a7a43293ae56 Added error handling for searching
teknolog
parents: 2
diff changeset
   256
void CPodcastSearchView::OpmlParsingComplete(TInt /*aError*/, TUint /*aNumFeedsImported*/)
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   257
	{
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   258
	DP("CPodcastSearchView::OpmlParsingComplete BEGIN");
56
c5cd47bc11ef Fix for bug 2152 plus minor fix for S1 UI
teknolog
parents: 50
diff changeset
   259
2
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   260
	DP("CPodcastSearchView::OpmlParsingComplete END");
29cda98b007e Initial import of Podcatcher from the Bergamot project
skip
parents:
diff changeset
   261
	}