📄 searchresultsview.cpp
字号:
/*
========================================================================
Name : SearchResultsView.cpp
Author :
Copyright : Copyright 2006 Nokia Corporation
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <barsread.h>
#include <stringloader.h>
#include <aknlists.h>
#include <eikenv.h>
#include <akniconarray.h>
#include <eikclbd.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <gdi.h>
#include <eikedwin.h>
#include <aknquerydialog.h>
#include <aknnotewrappers.h>
#include <Yahoo.rsg>
// ]]] end generated region [Generated System Includes]
// [[[ begin generated region: do not modify [Generated User Includes]
#include "Yahoo.hrh"
#include "SearchResultsView.h"
#include "SearchResults.hrh"
#include "SearchResults.h"
// ]]] end generated region [Generated User Includes]
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]
const int MAX_SEARCH_STRING_LENGTH = 100;
/**
* First phase of Symbian two-phase construction. Should not contain any
* code that could leave.
*/
CSearchResultsView::CSearchResultsView()
{
// [[[ begin generated region: do not modify [Generated Contents]
iSearchResults = NULL;
iWebClient = NULL;
// ]]] end generated region [Generated Contents]
iSearchModel = NULL;
iSelectedItem = -1;
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CSearchResultsView::~CSearchResultsView()
{
// [[[ begin generated region: do not modify [Generated Contents]
delete iSearchResults;
iSearchResults = NULL;
delete iWebClient;
iWebClient = NULL;
TRAPD( err_WaitDialog, RemoveWaitDialogL() );
// ]]] end generated region [Generated Contents]
delete iSearchModel;
delete iImageDisplayer;
iImageBuffer.Close();
}
/**
* Symbian two-phase constructor.
* This creates an instance then calls the second-phase constructor
* without leaving the instance on the cleanup stack.
* @return new instance of CSearchResultsView
*/
CSearchResultsView* CSearchResultsView::NewL()
{
CSearchResultsView* self = CSearchResultsView::NewLC();
CleanupStack::Pop( self );
return self;
}
/**
* Symbian two-phase constructor.
* This creates an instance, pushes it on the cleanup stack,
* then calls the second-phase constructor.
* @return new instance of CSearchResultsView
*/
CSearchResultsView* CSearchResultsView::NewLC()
{
CSearchResultsView* self = new (ELeave) CSearchResultsView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CSearchResultsView::ConstructL()
{
// [[[ begin generated region: do not modify [Generated Code]
BaseConstructL( R_SEARCH_RESULTS_SEARCH_RESULTS_VIEW );
iWebClient = CWebClientEngine::NewL( *this );
// ]]] end generated region [Generated Code]
iSearchModel = new (ELeave) CYahooSearchModel;
iSearchModel->ConstructL();
iImageDisplayer = new (ELeave) CImageDisplayer;
iImageDisplayer->ConstructL();
}
/**
* @return The UID for this view
*/
TUid CSearchResultsView::Id() const
{
return TUid::Uid( ESearchResultsViewId );
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CSearchResultsView::HandleCommandL( TInt aCommand )
{
// [[[ begin generated region: do not modify [Generated Code]
TBool commandHandled = EFalse;
switch ( aCommand )
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case ESearchResultsViewNew_searchMenuItemCommand:
commandHandled = HandleNew_searchMenuItemSelectedL( aCommand );
break;
case ESearchResultsViewInfoMenuItemCommand:
commandHandled = HandleInfoMenuItemSelectedL( aCommand );
break;
default:
break;
}
if ( !commandHandled )
{
if ( aCommand == EAknSoftkeyExit )
{
AppUi()->HandleCommandL( EEikCmdExit );
}
}
// ]]] end generated region [Generated Code]
}
/**
*
* @param aPrevViewId
* @param aCustomMessageId
* @param aCustomMessage
*/
void CSearchResultsView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
// [[[ begin generated region: do not modify [Generated Contents]
SetupStatusPaneL();
if ( iSearchResults == NULL )
{
iSearchResults = CreateContainerL();
iSearchResults->SetMopParent( this );
AppUi()->AddToStackL( *this, iSearchResults );
}
// ]]] end generated region [Generated Contents]
PopulateSearchResultsL();
if (iSelectedItem >= 0)
iSearchResults->ListBox()->SetCurrentItemIndex(iSelectedItem);
}
/**
*/
void CSearchResultsView::DoDeactivate()
{
// [[[ begin generated region: do not modify [Generated Contents]
CleanupStatusPane();
if ( iSearchResults != NULL )
{
AppUi()->RemoveFromViewStack( *this, iSearchResults );
delete iSearchResults;
iSearchResults = NULL;
}
// ]]] end generated region [Generated Contents]
}
// [[[ begin generated function: do not modify
void CSearchResultsView::SetupStatusPaneL()
{
// reset the context pane
TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
CEikStatusPaneBase::TPaneCapabilities subPaneContext =
StatusPane()->PaneCapabilities( contextPaneUid );
if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
{
CAknContextPane* context = static_cast< CAknContextPane* > (
StatusPane()->ControlL( contextPaneUid ) );
context->SetPictureToDefaultL();
}
// setup the title pane
TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
CEikStatusPaneBase::TPaneCapabilities subPaneTitle =
StatusPane()->PaneCapabilities( titlePaneUid );
if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
{
CAknTitlePane* title = static_cast< CAknTitlePane* >(
StatusPane()->ControlL( titlePaneUid ) );
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_SEARCH_RESULTS_TITLE_RESOURCE );
title->SetFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CSearchResultsView::CleanupStatusPane()
{
}
// ]]] end generated function
/**
* Handle status pane size change for this view (override)
*/
void CSearchResultsView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange();
// this may fail, but we're not able to propagate exceptions here
TInt result;
TRAP( result, SetupStatusPaneL() );
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientOpenFailed( CWebClientEngine& anEngine )
* An error occurred opening the HTTP session. The calling code
* will leave after this method returns.
* @param anError: the error code
* Most common error; no access point configured, and session creation
* leaves with KErrNotFound.
*/
void CSearchResultsView::ClientOpenSessionFailedL( CWebClientEngine& anEngine, TInt anError )
{
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientConnecting()
* Called to notify that a connection was initiated
*/
void CSearchResultsView::ClientConnectingL( CWebClientEngine& anEngine )
{
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientHeaderReceived()
* Called when HTTP header is received.
* @param aHeaderData: Header field name and value
*/
void CSearchResultsView::ClientHeaderReceivedL( CWebClientEngine& anEngine, const TDesC& aHeaderData )
{
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientBodyReceived()
* Called when a part of the HTTP body is received.
* @param aBodyData: Part of the body data received. (e.g. part of
* the received HTML page)
*/
void CSearchResultsView::ClientBodyReceivedL( CWebClientEngine& anEngine, const TDesC8& aBodyData )
{
// [[[ begin generated region: do not modify [Generated Code]
HandleWebClientBodyReceivedL( anEngine, aBodyData );
// ]]] end generated region [Generated Code]
}
/**
* ClientConnectionCanceled()
* Called to notify that a connection attempt has been canceled
*/
void CSearchResultsView::ClientConnectionCanceledL( CWebClientEngine& anEngine )
{
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientResponseComplete
* Called to notify that a transaction's response is complete.
* See TTransactionEvent::EResponseComplete
*/
void CSearchResultsView::ClientResponseCompleteL( CWebClientEngine& anEngine )
{
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
/**
* ClientTransactionSucceeded()
* Called to notify that a transaction completed successfully
* See TTransactionEvent::ESucceeded
*/
void CSearchResultsView::ClientTransactionSucceededL( CWebClientEngine& anEngine )
{
// [[[ begin generated region: do not modify [Generated Code]
RemoveWaitDialogL();
HandleWebClientTransactionSucceededL( anEngine );
// ]]] end generated region [Generated Code]
}
/**
* ClientTransactionFailed()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -