- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CmdAction/VerboseAction.cpp
r623e89 r680470 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Actions/CmdAction/VerboseAction.hpp" 11 #include "Actions/ActionRegistry.hpp" 9 12 #include "log.hpp" 10 13 #include "verbose.hpp" … … 17 20 #include "UIElements/UIFactory.hpp" 18 21 #include "UIElements/Dialog.hpp" 19 #include "Actions/MapOfActions.hpp" 22 #include "UIElements/ValueStorage.hpp" 23 24 // memento to remember the state when undoing 25 26 class CommandLineVerboseState : public ActionState { 27 public: 28 CommandLineVerboseState(int _verbosity) : 29 verbosity(_verbosity) 30 {} 31 int verbosity; 32 }; 33 20 34 21 35 const char CommandLineVerboseAction::NAME[] = "verbose"; … … 28 42 {} 29 43 44 void CommandVerbose(int verbosity) { 45 ValueStorage::getInstance().setCurrentValue(CommandLineVerboseAction::NAME, verbosity); 46 ActionRegistry::getInstance().getActionByName(CommandLineVerboseAction::NAME)->call(Action::NonInteractive); 47 }; 48 49 Dialog* CommandLineVerboseAction::fillDialog(Dialog *dialog) { 50 ASSERT(dialog,"No Dialog given when filling action dialog"); 51 52 dialog->queryInt(NAME, ValueStorage::getInstance().getDescription(NAME)); 53 54 return dialog; 55 } 56 30 57 Action::state_ptr CommandLineVerboseAction::performCall() { 31 Dialog *dialog = UIFactory::getInstance().makeDialog();32 58 int verbosity = 2; 33 59 34 dialog->queryInt(NAME, &verbosity, MapOfActions::getInstance().getDescription(NAME));60 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 35 61 36 if(dialog->display()) { 37 setVerbosity(verbosity); 38 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 39 delete dialog; 40 return Action::success; 41 } else { 42 delete dialog; 43 return Action::failure; 44 } 62 setVerbosity(verbosity); 63 DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl); 64 return Action::success; 45 65 } 46 66 47 67 Action::state_ptr CommandLineVerboseAction::performUndo(Action::state_ptr _state) { 48 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());68 CommandLineVerboseState *state = assert_cast<CommandLineVerboseState*>(_state.get()); 49 69 50 return Action::failure;51 // string newName = state->mol->getName();52 // state->mol->setName(state->lastName); 53 // 54 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));70 int verbosity = 2; 71 ValueStorage::getInstance().queryCurrentValue(NAME, verbosity); 72 73 setVerbosity(state->verbosity); 74 return Action::state_ptr(new CommandLineVerboseState(verbosity)); 55 75 } 56 76 57 77 Action::state_ptr CommandLineVerboseAction::performRedo(Action::state_ptr _state){ 58 return Action::failure;78 return performUndo(_state); 59 79 } 60 80 61 81 bool CommandLineVerboseAction::canUndo() { 62 return false;82 return true; 63 83 } 64 84 65 85 bool CommandLineVerboseAction::shouldUndo() { 66 return false;86 return true; 67 87 } 68 88
Note:
See TracChangeset
for help on using the changeset viewer.