- Timestamp:
- Apr 23, 2021, 9:02:12 PM (5 years ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- 0fbea3
- Parents:
- 5061d9
- git-author:
- Frederik Heber <frederik.heber@…> (04/06/21 20:09:39)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/23/21 21:02:12)
- Location:
- src/Actions
- Files:
-
- 3 added
- 8 edited
-
ActionHistory.cpp (modified) (2 diffs)
-
ActionHistory.hpp (modified) (2 diffs)
-
ActionQueue.cpp (modified) (1 diff)
-
ActionQueue.hpp (modified) (2 diffs)
-
CommandAction/UndoMarkAction.cpp (added)
-
CommandAction/UndoMarkAction.def (added)
-
CommandAction/UndoMarkAction.hpp (added)
-
GlobalListOfActions.hpp (modified) (1 diff)
-
Makefile.am (modified) (3 diffs)
-
UndoAction.cpp (modified) (1 diff)
-
UndoAction.def (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionHistory.cpp
r5061d9 r0ec9f5 64 64 HistoryElement elem = history.back(); 65 65 LOG(1, "INFO: Undoing action " << elem.action->getName()); 66 if ((mark != NULL) && (mark == &elem)) { 67 LOG(2, "DEBUG: Undoing marked item in ActionHistory, hence resetting mark."); 68 mark = NULL; 69 } 66 70 history.pop_back(); 67 71 ActionState::ptr newState = elem.action->undo(elem.state); … … 93 97 } 94 98 99 void ActionHistory::setMark() { 100 mark = &(history.back()); 101 } 102 103 void ActionHistory::unsetMark() { 104 mark = NULL; 105 } 106 107 void ActionHistory::undoTillMark() { 108 if (mark == NULL) { 109 undoLast(); 110 } else { 111 while (mark != &(history.back())) 112 undoLast(); 113 } 114 } 115 95 116 void ActionHistory::addElement(Action* action,ActionState::ptr state){ 96 117 yrotsih.clear(); -
src/Actions/ActionHistory.hpp
r5061d9 r0ec9f5 43 43 bool hasRedo(); 44 44 45 void setMark(); 46 void unsetMark(); 47 void undoTillMark(); 48 45 49 void addElement(Action*,ActionState::ptr); 46 50 void clear(); … … 49 53 std::deque<HistoryElement> history; 50 54 std::deque<HistoryElement> yrotsih; 55 56 //!> marks a specific state in the history to allow undoing directly till that 57 HistoryElement * mark; 51 58 52 59 public: -
src/Actions/ActionQueue.cpp
r5061d9 r0ec9f5 412 412 } 413 413 414 void ActionQueue::setMark() { 415 history->setMark(); 416 } 417 418 void ActionQueue::unsetMark() { 419 history->unsetMark(); 420 } 421 422 void ActionQueue::undoTillMark() 423 { 424 history->undoTillMark(); 425 } 426 414 427 bool ActionQueue::canUndo() const 415 428 { -
src/Actions/ActionQueue.hpp
r5061d9 r0ec9f5 129 129 void outputAsPython(std::ostream &output) const; 130 130 131 /** Undoes last called Ac friend void ::cleanUp();tion.131 /** Undoes last called Action. 132 132 * 133 133 */ … … 138 138 */ 139 139 void redoLast(); 140 141 /** 142 * Marks the current item of the action history to allow returning to that state lateron. 143 */ 144 void setMark(); 145 146 /** 147 * Resets any currently marked item in the action history. 148 */ 149 void unsetMark(); 150 151 /** Undoes actions till a set mark in the ActionHistory. 152 * 153 */ 154 void undoTillMark(); 140 155 141 156 /** Checks whether there is one completed Action stored in ActionHistory in the past. -
src/Actions/GlobalListOfActions.hpp
r5061d9 r0ec9f5 54 54 (CommandSetRandomNumbersDistribution) \ 55 55 (CommandStoreSession) \ 56 (CommandUndoMark) \ 56 57 (CommandVerbose) \ 57 58 (CommandVersion) \ -
src/Actions/Makefile.am
r5061d9 r0ec9f5 207 207 Actions/CommandAction/NoDryRunAction.cpp \ 208 208 Actions/CommandAction/StoreSessionAction.cpp \ 209 Actions/CommandAction/UndoMarkAction.cpp \ 209 210 Actions/CommandAction/VerboseAction.cpp \ 210 211 Actions/CommandAction/VersionAction.cpp \ … … 219 220 Actions/CommandAction/NoDryRunAction.hpp \ 220 221 Actions/CommandAction/StoreSessionAction.hpp \ 222 Actions/CommandAction/UndoMarkAction.hpp \ 221 223 Actions/CommandAction/VerboseAction.hpp \ 222 224 Actions/CommandAction/VersionAction.hpp \ … … 231 233 Actions/CommandAction/NoDryRunAction.def \ 232 234 Actions/CommandAction/StoreSessionAction.def \ 235 Actions/CommandAction/UndoMarkAction.def \ 233 236 Actions/CommandAction/VerboseAction.def \ 234 237 Actions/CommandAction/VersionAction.def \ -
src/Actions/UndoAction.cpp
r5061d9 r0ec9f5 52 52 ActionState::ptr UndoAction::performCall(){ 53 53 // std::cout << "Undo" << std::endl; 54 ActionQueue::getInstance().undoLast(); 54 if (params.undoTillMark.get()) 55 ActionQueue::getInstance().undoTillMark(); 56 else 57 ActionQueue::getInstance().undoLast(); 55 58 return Action::success; 56 59 } -
src/Actions/UndoAction.def
r5061d9 r0ec9f5 13 13 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 14 14 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 15 #undef paramtypes 16 #undef paramreferences 17 #undef paramtokens 18 #undef paramdescriptions 19 #undef paramdefaults 15 #define paramtypes (bool) 16 #define paramtokens ("till-mark") 17 #define paramdescriptions ("whether to undo just a single step (false) or until a previously set mark (true)") 18 #define paramdefaults (PARAM_DEFAULT(false)) 19 #define paramreferences (undoTillMark) 20 #define paramvalids (DummyValidator<bool>()) 20 21 21 22 // some defines for all the names, you may use ACTION, STATE and PARAMS … … 27 28 28 29 // finally the information stored in the ActionTrait specialization 29 #define DESCRIPTION "undo last action "30 #define DESCRIPTION "undo last action or until a given mark" 30 31 #undef SHORTFORM
Note:
See TracChangeset
for help on using the changeset viewer.
