00001
00002
00003
00004
00005
00006
00007 #include "FileCmdAbstract.h"
00008 #include "FileCmdFactory.h"
00009 #include "FileCmdScript.h"
00010 #include "FileCmdSerialize.h"
00011 #include "Logger.h"
00012 #include "MainWindow.h"
00013 #include <QFile>
00014 #include <QXmlStreamReader>
00015 #include "Xml.h"
00016
00017 FileCmdScript::FileCmdScript(const QString &fileCmdScriptFile)
00018 {
00019
00020 QFile file (fileCmdScriptFile);
00021
00022 QXmlStreamReader reader (&file);
00023 file.open(QIODevice::ReadOnly | QIODevice::Text);
00024
00025
00026 FileCmdFactory factory;
00027 while (!reader.atEnd() && !reader.hasError()) {
00028
00029 if ((loadNextFromReader (reader) == QXmlStreamReader::StartElement) &&
00030 (reader.name() == FILE_CMD_SERIALIZE_CMD)) {
00031
00032
00033 m_fileCmdStack.push_back (factory.createFileCmd (reader));
00034 }
00035 }
00036 file.close();
00037 }
00038
00039 FileCmdScript::~FileCmdScript()
00040 {
00041 }
00042
00043 bool FileCmdScript::canRedo() const
00044 {
00045 LOG4CPP_INFO_S ((*mainCat)) << "FileCmdScript::canRedo";
00046
00047 return (m_fileCmdStack.count () > 0);
00048 }
00049
00050 void FileCmdScript::redo(MainWindow &mainWindow)
00051 {
00052 LOG4CPP_INFO_S ((*mainCat)) << "FileCmdScript::redo";
00053
00054 m_fileCmdStack.first()->redo(mainWindow);
00055 m_fileCmdStack.pop_front();
00056 }