📄 logexampleview.cpp
字号:
/*
* ============================================================================
* Name : CLogExampleView from LogExampleView.h
* Part of : LogExample
* Created : 26.05.2005 by Forum Nokia
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <LogExample.rsg>
#include "LogExample.hrh"
#include "LogExampleView.h"
#include "LogExampleContainer.h"
#include "LogExampleAppUi.h"
#include "LogExEngine.h"
#include <eikmenup.h> // DynInitMenuPaneL
#include <aknquerydialog.h> // CAknQueryDialog
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CLogExampleView::ConstructL(const TRect& aRect)
// Symbian two-phased constructor
// ---------------------------------------------------------
//
void CLogExampleView::ConstructL()
{
BaseConstructL( R_LOGEXAMPLE_VIEW1 );
}
// ---------------------------------------------------------
// CLogExampleView::~CLogExampleView()
// destructor
// ---------------------------------------------------------
//
CLogExampleView::~CLogExampleView()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
// ---------------------------------------------------------
// MEventsObserver CLogExampleView::GetObserver()
// Returns observer
// ---------------------------------------------------------
//
MEventsObserver* CLogExampleView::GetObserver()
{
return iContainer;
}
// ---------------------------------------------------------
// TUid CLogExampleView::Id()
// Returns Uid of view
// ---------------------------------------------------------
//
TUid CLogExampleView::Id() const
{
return KViewId;
}
// ---------------------------------------------------------
// CLogExampleView::HandleCommandL(TInt aCommand)
// Takes care of view command handling
// ---------------------------------------------------------
//
void CLogExampleView::HandleCommandL(TInt aCommand)
{
//variable for setting visibility boolean
TBool visible = ETrue;
iCurrentEvents = 0;
switch ( aCommand )
{
// Command handling related to event filtering
case ELogExampleCmdViewAll:
{
// Reset eventlist and make it visible
iContainer->ResetEventList();
MakeContainerVisible(visible);
// Get model, clear the filter (to get all the events) and start reading the events
Model()->ClearEventFilter();
Model()->ReadEventsL();
iCurrentEvents = ELogExampleCmdViewAll;
break;
}
case ELogExampleCmdViewIncoming:
{
iContainer->ResetEventList();
MakeContainerVisible(visible);
Model()->SetEventFilterDirectionIncoming();
Model()->ReadEventsL();
iCurrentEvents = ELogExampleCmdViewIncoming;
break;
}
case ELogExampleCmdViewOutgoing:
{
iContainer->ResetEventList();
MakeContainerVisible(visible);
Model()->SetEventFilterDirectionOutgoing();
Model()->ReadEventsL();
iCurrentEvents = ELogExampleCmdViewOutgoing;
break;
}
case ELogExampleCmdViewVoice:
{
iContainer->ResetEventList();
MakeContainerVisible(visible);
Model()->SetEventFilterEventTypeVoice();
Model()->ReadEventsL();
iCurrentEvents = ELogExampleCmdViewVoice;
break;
}
case ELogExampleCmdViewSMS:
{
iContainer->ResetEventList();
MakeContainerVisible(visible);
Model()->SetEventFilterEventTypeSMS();
Model()->ReadEventsL();
iCurrentEvents = ELogExampleCmdViewSMS;
break;
}
// Command handling related to event adding
case ELogExampleCmdAddRandom:
{
Model()->AddRandomEventL();
break;
}
case ELogExampleCmdAddOwnEvent:
{
Model()->AddOwnEventL();
break;
}
case ELogExampleCmdShowDetails:
{
iContainer->ShowEventDetailsL();
break;
}
case ELogExampleCmdDelete:
{
CAknQueryDialog* deleteQuery = CAknQueryDialog::NewL();
if(deleteQuery->ExecuteLD(R_LOGEXAMPLE_DELETECONFIRMATION_QUERY))
{
TLogId selectedId = -1;
iContainer->GetSelectedId(selectedId);
Model()->DeleteEventL(selectedId);
}
break;
}
case EAknSoftkeyBack:
{
visible = EFalse;
MakeContainerVisible(visible);
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CLogExampleView::HandleClientRectChange()
// Reacts if rectangle's size changes
// ---------------------------------------------------------
//
void CLogExampleView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CLogExampleView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
// TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/))
// Activates the view
// ---------------------------------------------------------
//
void CLogExampleView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
if (!iContainer)
{
iContainer = new (ELeave) CLogExampleContainer;
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
// Set container as an observer
CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
CLogExEngine* model = appUi->Model();
model->SetObserver(iContainer);
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
Cba()->DrawNow();
}
}
// ---------------------------------------------------------
// CLogExampleView::DoDeactivate()
// Deactivates the view
// ---------------------------------------------------------
//
void CLogExampleView::DoDeactivate()
{
if ( iContainer )
{
// Remove observer to cancel notifications
CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
CLogExEngine* model = appUi->Model();
model->RemoveObserver();
AppUi()->RemoveFromViewStack( *this, iContainer );
delete iContainer;
iContainer = NULL;
}
}
// ---------------------------------------------------------
// CLogExampleView::Model()
// Returns appUi's model
// ---------------------------------------------------------
//
CLogExEngine* CLogExampleView::Model()
{
CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
CLogExEngine* model = appUi->Model();
return model;
}
// ------------------------------------------------------------------------------
// CLogExampleView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CLogExampleView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
{
/*
Simple dynamic menu.
Items are dimmed depending on state of the application.
Note: This can only be used with Series60 where items are hidden when dimmed.
*/
if (aResourceId == R_LOGEXAMPLE_VIEW1_MENU && iContainer->IsListBoxVisible() &&
iContainer->ListBoxItemCount() == 0)
{
// Show only Exit
aMenuPane->SetItemDimmed(ELogExampleCmdAppView, ETrue);
aMenuPane->SetItemDimmed(ELogExampleCmdAppAddEvent, ETrue);
aMenuPane->SetItemDimmed(ELogExampleCmdShowDetails, ETrue);
aMenuPane->SetItemDimmed(ELogExampleCmdDelete, ETrue);
}
else if(aResourceId == R_LOGEXAMPLE_VIEW1_MENU &&
iContainer->IsListBoxVisible() )
{
aMenuPane->SetItemDimmed(ELogExampleCmdAppView, ETrue);
aMenuPane->SetItemDimmed(ELogExampleCmdAppAddEvent, ETrue);
}
else if (aResourceId == R_LOGEXAMPLE_VIEW1_MENU &&
!iContainer->IsListBoxVisible())
{
aMenuPane->SetItemDimmed(ELogExampleCmdShowDetails, ETrue);
aMenuPane->SetItemDimmed(ELogExampleCmdDelete, ETrue);
}
}
// ------------------------------------------------------------------------------
// CLogExampleView::MakeContainerVisible(TBool& aVisible)
// Hides or unhides the container and changes the CBA accordingly.
// ------------------------------------------------------------------------------
//
void CLogExampleView::MakeContainerVisible(TBool& aVisible)
{
iContainer->MakeVisible(aVisible);
if (aVisible)
{
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_SELECTION_LIST);
}
else
{
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT);
}
Cba()->DrawNow();
}
// ------------------------------------------------------------------------------
// CLogExampleView::RefreshL()
// Refreshes the events.
// ------------------------------------------------------------------------------
//
void CLogExampleView::RefreshL()
{
if (iCurrentEvents != 0)
{
HandleCommandL(iCurrentEvents);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -