📄 cmmslappui.cpp
字号:
/* Copyright (c) 2003, Nokia. All rights reserved */
// INCLUDE FILES
#include <aknnotewrappers.h>
#include <aknselectionlist.h>
#include <avkon.hrh>
#include <PAlbFetch.h>
#include <PAlbImageData.h>
#include <PAlbSettings.h>
#include <eikdialg.h>
#include "CMmslAppUi.h"
#include <mmslist.rsg>
#include "mmslist.hrh"
#include "CMmslContainer.h"
#include "CMmslController.h"
#include "CMmslDialog.h"
// ================= MEMBER FUNCTIONS =======================
//
// ---------------------------------------------------------------------------
// CMmslAppUi::CMmslAppUi()
// Constructor.
// ---------------------------------------------------------------------------
//
CMmslAppUi::CMmslAppUi()
{
// No implementation required
}
// ---------------------------------------------------------------------------
// CMmslAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// ---------------------------------------------------------------------------
//
void CMmslAppUi::ConstructL()
{
// Initialise app UI with standard values.
BaseConstructL();
iMsgMonitor = CMmslController::NewL( *this );
iContainer = new ( ELeave ) CMmslContainer;
iContainer->SetMopParent( this );
iContainer->ConstructL( ClientRect() );
iMsgMonitor->SetContainer( iContainer );
AddToStackL( iContainer );
}
// ---------------------------------------------------------------------------
// CMmslAppUi::~CMmslAppUi()
// Destructor.
// Frees reserved resources.
// ---------------------------------------------------------------------------
//
CMmslAppUi::~CMmslAppUi()
{
if ( iContainer )
{
RemoveFromStack( iContainer );
delete iContainer;
}
delete static_cast< CMmslController* > ( iMsgMonitor );
}
// ---------------------------------------------------------------------------
// CMmslAppUi::HandleKeyEventL()
// Takes care of key event handling.
// ---------------------------------------------------------------------------
//
TKeyResponse CMmslAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
{
return EKeyWasConsumed;
}
// ---------------------------------------------------------------------------
// CMmslAppUi::ServerDown()
// This method print error coce and exits the program.
// ---------------------------------------------------------------------------
//
void CMmslAppUi::ServerDown( TInt aReason )
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSLIST_MSV_ERROR, aReason );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSLIST_EXIT );
CEikonEnv::Static()->AlertWin( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 );
User::Exit( 0 );
}
// ---------------------------------------------------------------------------
// CMmslAppUi::ViewDialogL()
// This method find selected mms and start view dialog.
// ---------------------------------------------------------------------------
//
void CMmslAppUi::ViewDialogL()
{
//To simplify notation, get a temporary for pointing to listbox
CEikTextListBox* listBox = iContainer->iListBox;
TInt curItem( listBox->CurrentItemIndex() );
if ( curItem == -1 ) // There is nothing to view.
{
HBufC16* buf = StringLoader::LoadLC( R_MMSLIST_NO_MMS_SELECTED );
CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
note->ExecuteLD( buf->Des() );
CleanupStack::PopAndDestroy( buf );
return;
}
// Find pointer to listbox item.
const TPtrC ptr = listBox->Model()->ItemTextArray()->MdcaPoint( curItem );
CMmslDialog* viewMmsDialog = new ( ELeave )
CMmslDialog( iMsgMonitor, ptr );
// Execute the dialog following the data in the resource file.
viewMmsDialog->ExecuteLD( R_MMSLIST_VIEW_DIALOG );
}
// ---------------------------------------------------------------------------
// CMmslAppUi::DeleteDialogL()
// Execute delete confirmation query. This method find selected mms and
// forward it to DeleteItemL -method.
// ---------------------------------------------------------------------------
//
void CMmslAppUi::DeleteDialogL()
{
//To simplify notation, get a temporary for pointing to listbox.
CEikTextListBox* listBox = iContainer->iListBox;
TInt curItem( -1 );
curItem = listBox->CurrentItemIndex();
if ( curItem == -1 ) // Nothing to delete
{
HBufC16* buf = StringLoader::LoadLC( R_MMSLIST_NO_MMS_SELECTED );
CAknInformationNote* note = new ( ELeave )CAknInformationNote();
note->ExecuteLD( buf->Des() );
CleanupStack::PopAndDestroy( buf );
return;
}
if ( !ShowDeleteConfirmationQueryL( R_MMSLIST_DELETE_MESSAGE ) )
{
return;
}
const TPtrC ptr( listBox->Model()->ItemTextArray()->MdcaPoint(
curItem ) );
TInt retval( iMsgMonitor->DeleteItemL( ptr ) );
if( retval != KErrNone )
{
HBufC16* buf = StringLoader::LoadLC( R_MMSLIST_ERROR_DELETE, retval );
CAknInformationNote* dialog = new ( ELeave )CAknInformationNote();
dialog->ExecuteLD( buf->Des() );
CleanupStack::PopAndDestroy( buf );
}
}
// ---------------------------------------------------------------------------
// CMmslAppUi::ShowDeleteConfirmationQueryL()
// Shows delete confirmation query.
// ---------------------------------------------------------------------------
//
TBool CMmslAppUi::ShowDeleteConfirmationQueryL(
const TInt aTextResourceId )
{
HBufC* prompt = StringLoader::LoadLC( aTextResourceId );
CAknQueryDialog* dlg = CAknQueryDialog::NewL();
CleanupStack::PushL( dlg );
dlg->SetPromptL( prompt->Des() );
CleanupStack::Pop( dlg );
TInt retCode( dlg->ExecuteLD( R_MMSLIST_CONFIRMATION_QUERY ) );
CleanupStack::PopAndDestroy( prompt );
return retCode;
}
// ---------------------------------------------------------------------------
// CMmslAppUi::HandleCommandL()
// Takes care of key event handling.
// ---------------------------------------------------------------------------
//
void CMmslAppUi::HandleCommandL( TInt aCommand )
{
switch ( aCommand )
{
case EAknSoftkeyExit:
case EEikCmdExit:
Exit();
break;
case EMmslCmdDelete:
DeleteDialogL();
break;
case EMmslCmdView:
ViewDialogL();
break;
default:
break;
}
}
// ---------------------------------------------------------------------------
// CMmslAppUi::Model()
// ---------------------------------------------------------------------------
//
CMmslModel* CMmslAppUi::Model()
{
return iMsgMonitor->Model();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -