mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 15:45:37 +00:00
addded messages interface for operations/stages
This commit is contained in:
parent
89b4497331
commit
72623652e4
@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
#include "operation.hpp"
|
#include "operation.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "../doc/state.hpp"
|
#include "../doc/state.hpp"
|
||||||
@ -54,6 +57,8 @@ void CSMTools::Operation::abort()
|
|||||||
|
|
||||||
void CSMTools::Operation::verify()
|
void CSMTools::Operation::verify()
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> messages;
|
||||||
|
|
||||||
while (mCurrentStage!=mStages.end())
|
while (mCurrentStage!=mStages.end())
|
||||||
{
|
{
|
||||||
if (mCurrentStep>=mCurrentStage->second)
|
if (mCurrentStep>=mCurrentStage->second)
|
||||||
@ -63,7 +68,7 @@ void CSMTools::Operation::verify()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mCurrentStage->first->perform (mCurrentStep++);
|
mCurrentStage->first->perform (mCurrentStep++, messages);
|
||||||
++mCurrentStepTotal;
|
++mCurrentStepTotal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -71,6 +76,9 @@ void CSMTools::Operation::verify()
|
|||||||
|
|
||||||
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
|
emit progress (mCurrentStepTotal, mTotalSteps ? mTotalSteps : 1, mType);
|
||||||
|
|
||||||
|
for (std::vector<std::string>::const_iterator iter (messages.begin()); iter!=messages.end(); ++iter)
|
||||||
|
emit reportMessage (iter->c_str(), mType);
|
||||||
|
|
||||||
if (mCurrentStage==mStages.end())
|
if (mCurrentStage==mStages.end())
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
@ -39,6 +39,8 @@ namespace CSMTools
|
|||||||
|
|
||||||
void progress (int current, int max, int type);
|
void progress (int current, int max, int type);
|
||||||
|
|
||||||
|
void reportMessage (const QString& message, int type);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef CSM_TOOLS_STAGE_H
|
#ifndef CSM_TOOLS_STAGE_H
|
||||||
#define CSM_TOOLS_STAGE_H
|
#define CSM_TOOLS_STAGE_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace CSMTools
|
namespace CSMTools
|
||||||
{
|
{
|
||||||
class Stage
|
class Stage
|
||||||
@ -12,7 +15,8 @@ namespace CSMTools
|
|||||||
virtual int setup() = 0;
|
virtual int setup() = 0;
|
||||||
///< \return number of steps
|
///< \return number of steps
|
||||||
|
|
||||||
virtual void perform (int stage) = 0;
|
virtual void perform (int stage, std::vector<std::string>& messages) = 0;
|
||||||
|
///< Messages resulting from this tage will be appended to \a messages.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ CSMTools::Verifier *CSMTools::Tools::getVerifier()
|
|||||||
|
|
||||||
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||||
connect (mVerifier, SIGNAL (finished()), this, SLOT (verifierDone()));
|
connect (mVerifier, SIGNAL (finished()), this, SLOT (verifierDone()));
|
||||||
|
connect (mVerifier, SIGNAL (reportMessage (const QString&, int)),
|
||||||
|
this, SLOT (verifierMessage (const QString&, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mVerifier;
|
return mVerifier;
|
||||||
@ -77,4 +79,12 @@ int CSMTools::Tools::getRunningOperations() const
|
|||||||
void CSMTools::Tools::verifierDone()
|
void CSMTools::Tools::verifierDone()
|
||||||
{
|
{
|
||||||
emit done (CSMDoc::State_Verifying);
|
emit done (CSMDoc::State_Verifying);
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
void CSMTools::Tools::verifierMessage (const QString& message, int type)
|
||||||
|
{
|
||||||
|
/// \todo store it in a result model instead
|
||||||
|
|
||||||
|
std::cout << message.toStdString() << std::endl;
|
||||||
}
|
}
|
@ -43,6 +43,8 @@ namespace CSMTools
|
|||||||
|
|
||||||
void verifierDone();
|
void verifierDone();
|
||||||
|
|
||||||
|
void verifierMessage (const QString& message, int type);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void progress (int current, int max, int type);
|
void progress (int current, int max, int type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user