|
|
|
@ -7,6 +7,7 @@
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
|
|
#include "../world/universalid.hpp"
|
|
|
|
|
#include "../settings/usersettings.hpp"
|
|
|
|
|
|
|
|
|
|
#include "state.hpp"
|
|
|
|
|
#include "stage.hpp"
|
|
|
|
@ -23,13 +24,16 @@ void CSMDoc::Operation::prepareStages()
|
|
|
|
|
{
|
|
|
|
|
iter->second = iter->first->setup();
|
|
|
|
|
mTotalSteps += iter->second;
|
|
|
|
|
|
|
|
|
|
for (std::map<QString, QStringList>::const_iterator iter2 (mSettings.begin()); iter2!=mSettings.end(); ++iter2)
|
|
|
|
|
iter->first->updateUserSetting (iter2->first, iter2->second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMDoc::Operation::Operation (int type, bool ordered, bool finalAlways)
|
|
|
|
|
: mType (type), mStages(std::vector<std::pair<Stage *, int> >()), mCurrentStage(mStages.begin()),
|
|
|
|
|
mCurrentStep(0), mCurrentStepTotal(0), mTotalSteps(0), mOrdered (ordered),
|
|
|
|
|
mFinalAlways (finalAlways), mError(false), mConnected (false)
|
|
|
|
|
mFinalAlways (finalAlways), mError(false), mConnected (false), mPrepared (false)
|
|
|
|
|
{
|
|
|
|
|
mTimer = new QTimer (this);
|
|
|
|
|
}
|
|
|
|
@ -49,8 +53,8 @@ void CSMDoc::Operation::run()
|
|
|
|
|
connect (mTimer, SIGNAL (timeout()), this, SLOT (executeStage()));
|
|
|
|
|
mConnected = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prepareStages();
|
|
|
|
|
|
|
|
|
|
mPrepared = false;
|
|
|
|
|
|
|
|
|
|
mTimer->start (0);
|
|
|
|
|
}
|
|
|
|
@ -60,6 +64,14 @@ void CSMDoc::Operation::appendStage (Stage *stage)
|
|
|
|
|
mStages.push_back (std::make_pair (stage, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMDoc::Operation::configureSettings (const std::vector<QString>& settings)
|
|
|
|
|
{
|
|
|
|
|
for (std::vector<QString>::const_iterator iter (settings.begin()); iter!=settings.end(); ++iter)
|
|
|
|
|
{
|
|
|
|
|
mSettings.insert (std::make_pair (*iter, CSMSettings::UserSettings::instance().definitions (*iter)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CSMDoc::Operation::hasError() const
|
|
|
|
|
{
|
|
|
|
|
return mError;
|
|
|
|
@ -84,8 +96,22 @@ void CSMDoc::Operation::abort()
|
|
|
|
|
mCurrentStage = mStages.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMDoc::Operation::updateUserSetting (const QString& name, const QStringList& value)
|
|
|
|
|
{
|
|
|
|
|
std::map<QString, QStringList>::iterator iter = mSettings.find (name);
|
|
|
|
|
|
|
|
|
|
if (iter!=mSettings.end())
|
|
|
|
|
iter->second = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMDoc::Operation::executeStage()
|
|
|
|
|
{
|
|
|
|
|
if (!mPrepared)
|
|
|
|
|
{
|
|
|
|
|
prepareStages();
|
|
|
|
|
mPrepared = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Messages messages;
|
|
|
|
|
|
|
|
|
|
while (mCurrentStage!=mStages.end())
|
|
|
|
|