Changes in src/Actions/Action.hpp [8a34392:047878]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.hpp
r8a34392 r047878 16 16 class ActionState; 17 17 class ActionSequence; 18 class Dialog; 18 19 19 20 /** … … 44 45 * hasRedo() method respectively. 45 46 * 47 * Note that an Action always has two functions createDialog() and performCall(). The former 48 * returns a Dialog filled with query...() functions for all information that we need from the 49 * user. The latter must not contain any interaction but just uses these values (which are 50 * temporarily stored by class ValueStorage) to perform the Action. 51 * 52 * Furthermore, there is a global action function that makes the action callable with already 53 * present parameters (i.e. without user interaction and for internal use within the code only). 54 * This function is basically just a macro, that puts the parameters into the ValueStorage and 55 * calls Action::call(Action::NonInteractive). 56 * 46 57 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that 47 58 * some condition necessary for this action to be executed is not currently met. For example the … … 78 89 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement 79 90 * the virtual methods. The main code that needs to be executed upon call() should be implemented in 80 * the performCall() method. You should also indicate whether the action supports undo by implementing 91 * the performCall() method. Any user interaction should be placed into the dialog returned by 92 * createDialog(). You should also indicate whether the action supports undo by implementing 81 93 * the shouldUndo() and canUndo() methods to return the appropriate flags. 94 * 95 * Also, create the global function to allow for easy calling of your function internally (i.e. 96 * without user interaction). It should have the name of the Action class without the suffix Action. 82 97 * 83 98 * The constructor of your derived class also needs to call the Base constructor, passing it the … … 122 137 * <li/> derive YourAction from Action 123 138 * <li/> pass name and flag for registry to the base constructor 124 * <li/> implement performCall(), performUndo(), performRedo() 139 * <li/> implement createDialog(), performCall(), performUndo(), performRedo() 140 * <li/> implement the global function call/macro. 125 141 * <li/> implement the functions that return the flags for the undo mechanism 126 142 * <li/> Derive YourActionState from ActionState as necessary … … 130 146 * 131 147 * <ul> 148 * <li/> createDialog(): 149 * <ul> 150 * <li/> Call makeDialog() from the UIFactory. 151 * <li/> Call any needed Dialog->Query...() for the values you need with specific keywords. 152 * <li/> if the action needs to save a state return a custom state object 153 * <li/> otherwise return Action::success 154 * </ul> 132 155 * <li/> performCall(): 133 156 * <ul> 157 * <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching 158 * key words from createDialog(). 134 159 * <li/> do whatever is needed to make the action work 135 160 * <li/> if the action was abborted return Action::failure … … 256 281 public: 257 282 283 enum QueryOptions {Interactive, NonInteractive}; 284 258 285 /** 259 286 * This type is used to store pointers to ActionStates while allowing multiple ownership … … 278 305 * If the call needs to undone you have to use the History, to avoid destroying 279 306 * invariants used by the History. 280 */ 281 void call(); 307 * 308 * Note that this call can be Interactive (i.e. a dialog will ask the user for 309 * necessary information) and NonInteractive (i.e. the information will have to 310 * be present already within the ValueStorage class or else a MissingArgumentException 311 * is thrown) 312 */ 313 void call(enum QueryOptions state = Interactive); 282 314 283 315 /** … … 337 369 static state_ptr failure; 338 370 371 /** 372 * This creates the dialog requesting the information needed for this action from the user 373 * via means of the user interface. 374 */ 375 Dialog * createDialog(); 376 339 377 private: 340 /** 341 * This is called internally when the call is being done. Implement this method to do the actuall 378 379 virtual Dialog * fillDialog(Dialog*)=0; 380 381 /** 382 * This is called internally when the call is being done. Implement this method to do the actual 342 383 * work of the Action. Implement this in your Derived classes. Needs to return a state that can be 343 384 * used to undo the action.
Note:
See TracChangeset
for help on using the changeset viewer.