www.pudn.com > UIQ_Code1.rar > CommandsView.cpp
// CommandsView.cpp // // © Symbian Software Ltd 2005. All rights reserved. // #include "CommandsView.h" #include "CommandsAppUi.h" #include "CommandsExternalInterface.h" #include "CommandsViewModel.h" #include "Commands.hrh" #include/** Creates and constructs the view. @param aAppUi Reference to the AppUi @return Pointer to a CCommandsView object */ CCommandsView* CCommandsView::NewLC(CQikAppUi& aAppUi) { CCommandsView* self = new(ELeave) CCommandsView(aAppUi); CleanupStack::PushL(self); self->ConstructL(); return self; } /** Constructor for the view. Adds the references to the command manager. Passes the application UI reference to the construction of the super class. KNullViewId should normally be passed as parent view for the applications default view. The parent view is the logical view that is normally activated when a go back command is issued. KNullViewId will activate the system default view. @param aAppUi Reference to the application UI */ CCommandsView::CCommandsView(CQikAppUi& aAppUi) : CQikMultiPageViewBase(aAppUi, KNullViewId) { } /** Destructor for the view. Deletes the infoprint text. */ CCommandsView::~CCommandsView() { delete iInfoprintCmd; delete iCommandsViewModel; } /** 2nd stage construction of the view. */ void CCommandsView::ConstructL() { // Calls ConstructL that initiate the standard values. // This should always be called in the concrete view implementations. CQikMultiPageViewBase::ConstructL(); // Read the default name from resource. iInfoprintCmd = iEikonEnv->AllocReadResourceL(R_COMMANDS_INFOPRINT_CMD_TEXT); // Create the CCommandViewModel that handles all domain logic. // We do this as we want to separate logic from presentation iCommandsViewModel = CCommandsViewModel::NewL(*this, *iCoeEnv); } /** Inherited from CQikViewBase and called upon by the UI Framework. It creates the view with commands from resource. */ void CCommandsView::ViewConstructL() { // Loads information about the UI configurations this view supports // together with definition of each view, its layout and commands. ViewConstructFromResourceL(R_COMMANDS_VIEW_UI_CONFIGURATIONS); } /** Returns the view Id @return Returns the Uid of the view */ TVwsViewId CCommandsView::ViewId()const { return TVwsViewId(KUidCommandsApp, KUidCommandsView); } /** Handles all commands that are not application specific. Passes unknown commands to the base class. Can also be called by the CCommandsViewModel when there is a command that is not recognized. The command Ids are defined in the .hrh file. @param aCommand The command to be executed @see CQikViewBase::HandleCommandL */ void CCommandsView::HandleCommandL(CQikCommand& aCommand) { CQikMultiPageViewBase::HandleCommandL(aCommand); } /** Launch an infoprint with the command text for that command that has been activated by the user. @param aCommand The command that has been activated */ void CCommandsView::InfoprintCmdL(const CQikCommand& aCommand) const { // Shows an infoprint HBufC* buf = HBufC::NewL(iInfoprintCmd->Length()+aCommand.Text().Length()); // Adds the text - Cmd: "Command text" TPtr ptr(buf->Des()); ptr.Append(*iInfoprintCmd); ptr.Append(aCommand.Text()); iEikonEnv->InfoMsg(*buf); delete buf; } /** When the application needs to display a view, the view framework calls the view's ViewActivatedL() function. In some cases, the view is also passed a parameter that tells it what to display. In this view page1 is activated when the view gets visible. @param aPrevViewId The composite view id of the previous view @param aCustomMessageId The id of the message @param aCustomMessage The message */ void CCommandsView::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, const TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) { // View for page1 tab shall always be activacted when the view // is activated if(ActivePageId() != ECommandsViewPage1) { ActivatePageL(ECommandsViewPage1); } } /** For every command inserted to a command list, the client will receive the callback where a command can be initialized or removed. @param aCommand The command to edit. @param aControlAddingCommands A reference to a control. @return the aCommand after approval and any update of appearance. */ CQikCommand* CCommandsView::DynInitOrDeleteCommandL(CQikCommand* aCommand, const CCoeControl& aControlAddingCommands) { return iCommandsViewModel->DynInitOrDeleteCommandL(aCommand, aControlAddingCommands); } /** Returns the object that is responsible for executing each Command (i.e. who's HandleCommandL that shall be called when the Command is activated). Called from the CommandManager for each command being added. @param aCommand The command that is added which do not already has its command handler. @return The command handler to set for the command. */ MQikCommandHandler* CCommandsView::MapCommandHandler(CQikCommand& aCommand) { return iCommandsViewModel->MapCommandHandler(aCommand); }