www.pudn.com > UIQ_Code1.rar > CommandsHandlerPage4.cpp
// CommandsHandlerPage4.cpp // // © Symbian Software Ltd 2005. All rights reserved. // #include "CommandsHandlerPage4.h" #include "CommandsView.h" #include "Commands.hrh" #include/** Creates and constructs the command handler for page 4. @param aCommandView Reference to the CCommandsView @return Pointer to a CCommandsHandlerPage4 object */ CCommandsHandlerPage4* CCommandsHandlerPage4::NewL(CCommandsView& aCommandsView, CQikCommandManager& aCommandManager) { CCommandsHandlerPage4* self = new(ELeave) CCommandsHandlerPage4(aCommandsView, aCommandManager); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); return self; } /** Constructor for the model. Adds the references to the command manager and command view. @param aCommandsView Reference to the CCommandsView */ CCommandsHandlerPage4::CCommandsHandlerPage4(CCommandsView& aCommandsView, CQikCommandManager& aCommandManager) : iCommandManager(aCommandManager), iCommandsView(aCommandsView) { } /** 2nd stage construction of the model. Creates the command state monitor that initialized all states to 0. Changes the values for the state properties for applicationState1 and applicationState2. */ void CCommandsHandlerPage4::ConstructL() { } /** Destructor for the model. Deletes the command state monitor. */ CCommandsHandlerPage4::~CCommandsHandlerPage4() { } /** The purpose of page4 commands is to show how sorting and priority is handled. Commands appearing in the same menu will be sorted first by type, then by priority. To check how sorting accoring type is done see page3 commands. A developer must explicitly set the type of a command but can omit the priority. In that case commands will be sorted in the order they were added, as default priority is 0. Priority can be set to a positive or negative integer value, a negative value is sorted before a positive like this: {-10, -3, 0, 5, 10}. It's also possible to sort on alphabetically on its Text() member instead of on its Priority() member. @param aCommand The command to be executed */ void CCommandsHandlerPage4::HandleCommandL(CQikCommand& aCommand) { // Launch an infoprint with the command text iCommandsView.InfoprintCmdL(aCommand); switch(aCommand.Id()) { case ECommandsPage4AlphabeticallyCmd: case ECommandsPage4PriorityCmd: { // Get the sorting state by checking which command id that is // activated. const TBool sortAlphabetically = aCommand.Id() == ECommandsPage4AlphabeticallyCmd; // Decides if the sort commands shall be sorted on alphabetic or // priority iCommandManager.SetSortAlphabetic(iCommandsView, ECommandsPage4APriority2Cmd, sortAlphabetically); iCommandManager.SetSortAlphabetic(iCommandsView, ECommandsPage4BPriority1Cmd, sortAlphabetically); break; } case ECommandsPage4APriority2Cmd: case ECommandsPage4BPriority1Cmd: { // Do nothing. In a normal application something should happen // here when the command has been activated. // If commands are not handle by the view they will be propageted // to the appUi. break; } default: { iCommandsView.HandleCommandL(aCommand); break; } } }