Changeset 0012e6 for molecuilder/src/Actions/small_actions.cpp
- Timestamp:
- Mar 24, 2010, 4:26:21 PM (16 years ago)
- Children:
- 521e29
- Parents:
- 91379c
- File:
-
- 1 edited
-
molecuilder/src/Actions/small_actions.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/Actions/small_actions.cpp
r91379c r0012e6 14 14 /****** ChangeMoleculeNameAction *****/ 15 15 16 // memento to remember the state when undoing 17 18 class ChangeMoleculeNameState : public ActionState { 19 public: 20 ChangeMoleculeNameState(molecule* _mol,std::string _lastName) : 21 mol(_mol), 22 lastName(_lastName) 23 {} 24 molecule* mol; 25 std::string lastName; 26 }; 27 16 28 char ChangeMoleculeNameAction::NAME[] = "Change filename of Molecule"; 17 29 … … 24 36 {} 25 37 26 void ChangeMoleculeNameAction::call() {38 ActionState* ChangeMoleculeNameAction::performCall() { 27 39 string filename; 28 40 molecule *mol = NULL; … … 31 43 dialog->queryMolecule("Enter index of molecule: ",&mol,molecules); 32 44 dialog->queryString("Enter name: ",&filename); 45 33 46 if(dialog->display()) { 47 string oldName = mol->getName(); 34 48 mol->setName(filename); 49 delete dialog; 50 return new ChangeMoleculeNameState(mol,oldName); 35 51 } 36 37 delete dialog; 52 return 0; 38 53 } 39 54 40 void ChangeMoleculeNameAction::undo() { 55 ActionState* ChangeMoleculeNameAction::performUndo(ActionState* _state) { 56 ChangeMoleculeNameState *state = dynamic_cast<ChangeMoleculeNameState*>(_state); 57 ASSERT(state,"State passed to ChangeMoleculeNameAction::performUndo did not have correct type"); 41 58 59 string newName = state->mol->getName(); 60 state->mol->setName(state->lastName); 61 62 return new ChangeMoleculeNameState(state->mol,newName); 63 } 64 65 ActionState* ChangeMoleculeNameAction::performRedo(ActionState *_state){ 66 // Undo and redo have to do the same for this action 67 return performUndo(_state); 42 68 } 43 69 44 70 bool ChangeMoleculeNameAction::canUndo() { 45 return false;71 return true; 46 72 } 47 73
Note:
See TracChangeset
for help on using the changeset viewer.
