⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logexampleview.cpp

📁 专业的用于查询手机通话记录的代码
💻 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

_LIT(KAllEventsText, "All events");
_LIT(KRecentCallsText, "Recent calls");
_LIT(KIncomingEventsText, "Incoming events");
_LIT(KOutgoingEventsText, "Outgoing events");
_LIT(KVoiceEventsText, "Voice events");
_LIT(KSMSEventsText, "SMS events");
_LIT(KAddedEventText, "Added event");

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CLogExampleView::ConstructL(const TRect& aRect)
// Symbian two-phased constructor
// ---------------------------------------------------------
//
void CLogExampleView::ConstructL()
    {
    BaseConstructL(R_LOGEXAMPLE_VIEW1);

    // Container is created in constructor instead of
    // DoActivateL() because container implements observer
    // interface and it is strictly connected to lifetime of the view.
    iContainer = new (ELeave) CLogExampleContainer;
    iContainer->SetMopParent(this);
    iContainer->ConstructL(ClientRect());
    AppUi()->AddToStackL(*this, iContainer);
    }

// ---------------------------------------------------------
// 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)
    {
    iCurrentEvents = 0;

    switch (aCommand)
        {
        // Command handling related to event filtering
        case ELogExampleCmdViewAll:
            {
            iContainer->ResetEventList();

            // Get model, clear the filter (to get all the events) and start
            // reading the events
            Model()->ClearEventFilter();
            Model()->ReadEventsL();
            iCurrentEvents = ELogExampleCmdViewAll;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KAllEventsText);
            break;
            }
            
        case ELogExampleCmdViewRecent:
            {
            iContainer->ResetEventList();
            
            Model()->ReadRecentEventsL();
            iCurrentEvents = ELogExampleCmdViewRecent;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KRecentCallsText);
            break;
            }
            
        case ELogExampleCmdViewIncoming:
            {
            iContainer->ResetEventList();

            Model()->SetEventFilterDirectionIncoming();
            Model()->ReadEventsL();
            iCurrentEvents = ELogExampleCmdViewIncoming;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KIncomingEventsText);
            break;
            }
            
        case ELogExampleCmdViewOutgoing:
            {
            iContainer->ResetEventList();

            Model()->SetEventFilterDirectionOutgoing();
            Model()->ReadEventsL();
            iCurrentEvents = ELogExampleCmdViewOutgoing;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KOutgoingEventsText);
            break;
            }
            
        case ELogExampleCmdViewVoice:
            {
            iContainer->ResetEventList();

            Model()->SetEventFilterEventTypeVoice();
            Model()->ReadEventsL();
            iCurrentEvents = ELogExampleCmdViewVoice;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KVoiceEventsText);
            break;
            }
            
        case ELogExampleCmdViewSMS:
            {
            iContainer->ResetEventList();

            Model()->SetEventFilterEventTypeSMS();
            Model()->ReadEventsL();
            iCurrentEvents = ELogExampleCmdViewSMS;
            
            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KSMSEventsText);
            break;
            }

        // Command handling related to event adding   
        case ELogExampleCmdAddRandom:
            {
            iContainer->ResetEventList();

            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KAddedEventText);
            Model()->AddRandomEventL();
            break;
            }
            
        case ELogExampleCmdAddOwnEvent:
            {
            iContainer->ResetEventList();

            // Update the title
            CLogExampleAppUi* appUi = static_cast<CLogExampleAppUi*>(AppUi());
            appUi->SetTitleL(KAddedEventText);
            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;
            }
            
        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*/)
    {
    }

// ---------------------------------------------------------
// CLogExampleView::DoDeactivate()
// Deactivates the view
// ---------------------------------------------------------
//
void CLogExampleView::DoDeactivate()
    {
    }

// ---------------------------------------------------------
// 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->ListBoxItemCount() == 0)
        {
        aMenuPane->SetItemDimmed(ELogExampleCmdShowDetails, ETrue);
        aMenuPane->SetItemDimmed(ELogExampleCmdDelete, ETrue);
        }
    }

// ------------------------------------------------------------------------------
//  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 + -