Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.hpp

    r8a34392 r047878  
    1616class ActionState;
    1717class ActionSequence;
     18class Dialog;
    1819
    1920/**
     
    4445 * hasRedo() method respectively.
    4546 *
     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 *
    4657 * Actions can be set to be active or inactive. If an action is set to inactive it is signaling, that
    4758 * some condition necessary for this action to be executed is not currently met. For example the
     
    7889 * Building actions is fairly easy. Simply derive from the abstract Action base class and implement
    7990 * 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
    8193 * 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.
    8297 *
    8398 * The constructor of your derived class also needs to call the Base constructor, passing it the
     
    122137 *  <li/> derive YourAction from Action
    123138 *  <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.
    125141 *  <li/> implement the functions that return the flags for the undo mechanism
    126142 *  <li/> Derive YourActionState from ActionState as necessary
     
    130146 *
    131147 * <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>
    132155 *  <li/> performCall():
    133156 *  <ul>
     157 *   <li/> obtain parameters you need by ValueStorage::getCurrentValue, matching
     158 *         key words from createDialog().
    134159 *   <li/> do whatever is needed to make the action work
    135160 *   <li/> if the action was abborted return Action::failure
     
    256281public:
    257282
     283  enum QueryOptions {Interactive, NonInteractive};
     284
    258285  /**
    259286   * This type is used to store pointers to ActionStates while allowing multiple ownership
     
    278305   * If the call needs to undone you have to use the History, to avoid destroying
    279306   * 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);
    282314
    283315  /**
     
    337369  static state_ptr failure;
    338370
     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
    339377private:
    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
    342383   * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
    343384   * used to undo the action.
Note: See TracChangeset for help on using the changeset viewer.