[b9c847] | 1 | /*
|
---|
| 2 | * SetOutputFormatsAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 8, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
| 10 | #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
|
---|
| 11 | #include "Parser/ChangeTracker.hpp"
|
---|
| 12 | #include "Parser/FormatParserStorage.hpp"
|
---|
| 13 | #include "log.hpp"
|
---|
| 14 | #include "verbose.hpp"
|
---|
| 15 | #include "World.hpp"
|
---|
| 16 |
|
---|
| 17 | #include <iostream>
|
---|
| 18 | #include <string>
|
---|
| 19 |
|
---|
| 20 | using namespace std;
|
---|
| 21 |
|
---|
| 22 | #include "UIElements/UIFactory.hpp"
|
---|
| 23 | #include "UIElements/Dialog.hpp"
|
---|
| 24 | #include "Actions/MapOfActions.hpp"
|
---|
| 25 |
|
---|
| 26 | const char WorldSetOutputFormatsAction::NAME[] = "set-output";
|
---|
| 27 |
|
---|
| 28 | WorldSetOutputFormatsAction::WorldSetOutputFormatsAction() :
|
---|
| 29 | Action(NAME)
|
---|
| 30 | {}
|
---|
| 31 |
|
---|
| 32 | WorldSetOutputFormatsAction::~WorldSetOutputFormatsAction()
|
---|
| 33 | {}
|
---|
| 34 |
|
---|
| 35 | Action::state_ptr WorldSetOutputFormatsAction::performCall() {
|
---|
| 36 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 37 | vector<std::string> FormatList;
|
---|
| 38 |
|
---|
| 39 | dialog->queryStrings(NAME, &FormatList, MapOfActions::getInstance().getDescription(NAME));
|
---|
| 40 |
|
---|
| 41 | if(dialog->display()) {
|
---|
| 42 | for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
|
---|
| 43 | if (*iter == "mpqc") {
|
---|
| 44 | FormatParserStorage::getInstance().addMpqc();
|
---|
| 45 | DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
|
---|
| 46 | } else if (*iter == "pcp") {
|
---|
| 47 | FormatParserStorage::getInstance().addPcp();
|
---|
| 48 | DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
|
---|
| 49 | } else if (*iter == "tremolo") {
|
---|
| 50 | FormatParserStorage::getInstance().addTremolo();
|
---|
| 51 | DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
|
---|
| 52 | } else if (*iter == "xyz") {
|
---|
| 53 | FormatParserStorage::getInstance().addXyz();
|
---|
| 54 | DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
|
---|
| 55 | } else {
|
---|
| 56 | DoeLog(1) && (eLog() << Verbose(1) << "Unknown format." << endl);
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | ChangeTracker::getInstance().saveStatus();
|
---|
| 60 | delete dialog;
|
---|
| 61 | return Action::success;
|
---|
| 62 | } else {
|
---|
| 63 | delete dialog;
|
---|
| 64 | return Action::failure;
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | Action::state_ptr WorldSetOutputFormatsAction::performUndo(Action::state_ptr _state) {
|
---|
| 69 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 70 |
|
---|
| 71 | return Action::failure;
|
---|
| 72 | // string newName = state->mol->getName();
|
---|
| 73 | // state->mol->setName(state->lastName);
|
---|
| 74 | //
|
---|
| 75 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | Action::state_ptr WorldSetOutputFormatsAction::performRedo(Action::state_ptr _state){
|
---|
| 79 | return Action::failure;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | bool WorldSetOutputFormatsAction::canUndo() {
|
---|
| 83 | return false;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | bool WorldSetOutputFormatsAction::shouldUndo() {
|
---|
| 87 | return false;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | const string WorldSetOutputFormatsAction::getName() {
|
---|
| 91 | return NAME;
|
---|
| 92 | }
|
---|