www.pudn.com > UIQ_Code1.rar > CommandsViewModel.h
// CommandsViewModel.h // // © Symbian Software Ltd 2005. All rights reserved. // #ifndef COMMANDSVIEWMODEL_H #define COMMANDSVIEWMODEL_H #include#include #include /** This model takes care of all view specific commands for CCommandsView. For each page that has page specific commands there exist one class that handles all their commands. This demonstrates how the responsibility for the commands can be divided. For example all page commands for page 2 is handled by CCommandsHandlerPage2. Page1 don't have any page specific command, it only only contains the view specific commands, which means that all of these commands are also available on the other pages. The view specific commands are used to show how commands can be added and removed from a command list. The commands that are added and removed are defined in the resource file. The purpose of these added commands is to show how a command text can be changed and how to use a command state monitor. Close (debug) is only available in debug mode; it closes the application. This command shall only be visible in debug mode because it is only used to find memory leaks during development of the application. Change phone style makes it possible to toggle between pen style and softkey style. Expand commands show how you can add and remove commands that are defined in the resource file during runtime. It adds two cascading menus, Current state and Set current state. In Set current state, two checkboxes change application states (ECommandsApplicationState1 and ECommandsApplicationState2) in the command state monitor. The command state monitor then changes the availability to the commands in the Current state cascading menu. If ECommandsApplicationState1 is true, the commands Cmd A (State 1) and Cmd B (State 1) will be available. If ECommandsApplicationState2 is true, the command Cmd C (State 2) will be available. If both ECommandsApplicationState1 and ECommandsApplicationState2 are true the command Cmd D (State 1 & 2) will also be available. Commands that are not available will be shown in different ways depending on which phone style is used. In pen style, the commands will be dimmed. If all of the commands in the menu are dimmed, the cascading menu itself will also be dimmed. It is possible to open the cascading menu to see the dimmed commands, but it is not possible to activate them. In softkey style, the commands are invisible. If all of the commands in a menu are invisible the cascading menu will also be invisible. */ class CCommandsView; class CQikCommandStateMonitor; class CCommandsHandlerPage2; class CCommandsHandlerPage3; class CCommandsHandlerPage4; class CCommandsViewModel : public CBase, public MQikCommandHandler, public MQikCommandStateController, public MQUiConfigChangedObserver { public: static CCommandsViewModel* NewL(CCommandsView& aCommandsView, CCoeEnv& aCoeEnv); ~CCommandsViewModel(); // from MQikCommandListOwner MQikCommandHandler* MapCommandHandler(CQikCommand& aCommand); // from MQikCommandModelOwner CQikCommand* DynInitOrDeleteCommandL(CQikCommand* aCommand, const CCoeControl& /*aControlAddingCommands*/); // from MQikCommandHandler void HandleCommandL(CQikCommand& aCommand); // from MQikCommandStateController TBool DoUpdateCommandStateL(CQikCommandStateMonitor& aMonitor, CQikCommand& aCommand, const TQikUiConfig& aUiConfig) const; // from MQUiConfigChangedObserver void HandleUiConfigChangedL(); private: CCommandsViewModel(CCommandsView& aCommandsView, CCoeEnv& aCoeEnv); void ConstructL(); private: /** Reference to the command manager that are used to change commands with. */ CQikCommandManager& iCommandManager; /** Reference to the command view. */ CCommandsView& iCommandsView; /** Reference to the configClient for accessing UI configurations. */ CQUiConfigClient& iConfigClient; /** Command state monitor class to show how commands can be updated accordingly different state in the monitor. */ CQikCommandStateMonitor* iCommandStateMonitor; /** Indicate if commands should be populated or emptied to the command list. */ TBool iExtraCommandsState; /** Implementation of commands for this view are distributed to one handler per page. */ CCommandsHandlerPage2* iCommandsHandlerPage2; CCommandsHandlerPage3* iCommandsHandlerPage3; CCommandsHandlerPage4* iCommandsHandlerPage4; }; #endif // COMMANDSVIEWMODEL_H