📄 logexampleappui.cpp
字号:
/*
* ============================================================================
* Name : CLogExampleAppUi from LogExampleAppui.cpp
* 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 "LogExampleAppui.h"
#include "LogExampleView.h"
#include "LogExampleView2.h"
#include "LogExampleLogDatabaseObserver.h"
#include "LogExEngine.h"
#include "LogExample.hrh"
#include <akntitle.h>
#include <eikmenup.h>
#include <AknGlobalNote.h> //CAknGlobalNote
#include <LogExample.rsg>
#include <avkon.hrh>
//CONSTANTS
_LIT(KRecentEventsTextNote, "Recent events");
_LIT(KEventsTextNote, "Events");
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CLogExampleAppUi::ConstructL()
// Two phased constructor
// ----------------------------------------------------------
//
void CLogExampleAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
iLogEngine = CLogExEngine::NewL();
// Show tabs for main views from resources
CEikStatusPane* sp = StatusPane();
// Fetch pointer to the default navi pane control
iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
TUid::Uid(EEikStatusPaneUidNavi));
// Tabgroup has been read from resource and it was pushed to the navi pane.
// Get pointer to the navigation decorator with the ResourceDecorator() function.
// Application owns the decorator and it has responsibility to delete the object.
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
// If Null, doesn't make sense to continue
User::LeaveIfNull(iDecoratedTabGroup);
iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
iTabGroup->SetObserver( this );
CLogExampleView* view1 = new (ELeave) CLogExampleView;
CleanupStack::PushL( view1 );
view1->ConstructL();
AddViewL( view1 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop( view1 );
CLogExampleView2* view2 = new (ELeave) CLogExampleView2;
CleanupStack::PushL( view2 );
view2->ConstructL();
AddViewL( view2 ); // transfer ownership to CAknViewAppUi
CleanupStack::Pop( view2 );
iLogDatabaseObserver = CLogExampleLogDatabaseObserver::NewL(*this);
iLogDatabaseObserver->NotifyChange();
iLogEngine->SetObserver(view1->GetObserver());
iLogEngine->SetRecentObserver(view2->GetObserver());
SetDefaultViewL(*view1);
SetTitleL(KEventsTextNote);
}
// ----------------------------------------------------
// CLogExampleAppUi::~CLogExampleAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CLogExampleAppUi::~CLogExampleAppUi()
{
delete iLogDatabaseObserver;
delete iDecoratedTabGroup;
delete iLogEngine;
}
//
// ----------------------------------------------------
// CLogExampleAppUi::Model()
// Returns model
// ----------------------------------------------------
//
CLogExEngine* CLogExampleAppUi::Model()
{
return iLogEngine;
}
//
// ----------------------------------------------------
// CLogExampleAppUi::NotifyChangeL()
// Shows notify of change in database
// ----------------------------------------------------
//
void CLogExampleAppUi::NotifyChangeL()
{
TInt index = iTabGroup->ActiveTabIndex();
switch (index)
{
//Update events tab
case 0:
{
CLogExampleView* view = static_cast<CLogExampleView*>(View(TUid::Uid(iTabGroup->TabIdFromIndex(index))));
view->RefreshL();
break;
}
//Update recent event tab
case 1:
{
CLogExampleView2* view = static_cast<CLogExampleView2*>(View(TUid::Uid(iTabGroup->TabIdFromIndex(index))));
view->ResetEventList();
iLogEngine->ClearEventFilter();
// Start reading recent events from the log database
iLogEngine->ReadRecentEventsL();
break;
}
default:
break;
}
}
// ------------------------------------------------------------------------------
// CLogExampleAppUi::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 CLogExampleAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CLogExampleAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode aType)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CLogExampleAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
if ( iTabGroup == NULL )
{
return EKeyWasNotConsumed;
}
if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
{
return iTabGroup->OfferKeyEventL( aKeyEvent, aType );
}
else
{
return EKeyWasNotConsumed;
}
}
// ----------------------------------------------------
// CLogExampleAppUi::SetTitleL(const TDesC& aTitle)
// Sets the title of the title pane
// ----------------------------------------------------
//
void CLogExampleAppUi::SetTitleL(const TDesC& aTitle)
{
TUid tPaneUid;
tPaneUid.iUid = EEikStatusPaneUidTitle;
CEikStatusPane* sPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane = sPane->PaneCapabilities(tPaneUid);
// Check if title pane can be accessed
if (subPane.IsPresent() && subPane.IsAppOwned())
{
CAknTitlePane* tPane = (CAknTitlePane*) sPane->ControlL(tPaneUid);
tPane->SetTextL(aTitle);
}
}
// ----------------------------------------------------
// CLogExampleAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CLogExampleAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
{
Exit();
break;
}
default:
break;
}
}
// ----------------------------------------------------
// CLogExampleAppUi::TabChangedL(TInt aIndex)
// This method gets called when CAknTabGroup active
// tab has changed.
// ----------------------------------------------------
//
void CLogExampleAppUi::TabChangedL(TInt aIndex)
{
switch (aIndex)
{
case 0:
{
SetTitleL(KEventsTextNote);
break;
}
case 1:
{
iLogEngine->ClearEventFilter();
// Start reading recent events from the log database
iLogEngine->ReadRecentEventsL();
SetTitleL(KRecentEventsTextNote);
break;
}
default:
break;
}
ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(aIndex)));
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -