2013-09-14 14:56:23 +02:00
|
|
|
#ifndef CSM_DOC_OPERATION_H
|
|
|
|
#define CSM_DOC_OPERATION_H
|
2012-12-08 15:25:50 +01:00
|
|
|
|
2012-12-08 17:53:45 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2012-12-08 15:25:50 +01:00
|
|
|
#include <QThread>
|
|
|
|
|
2014-05-08 12:42:29 +02:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class UniversalId;
|
|
|
|
}
|
|
|
|
|
2013-09-14 14:56:23 +02:00
|
|
|
namespace CSMDoc
|
2012-12-08 15:25:50 +01:00
|
|
|
{
|
2012-12-08 17:53:45 +01:00
|
|
|
class Stage;
|
|
|
|
|
2012-12-08 15:25:50 +01:00
|
|
|
class Operation : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
int mType;
|
2012-12-08 17:53:45 +01:00
|
|
|
std::vector<std::pair<Stage *, int> > mStages; // stage, number of steps
|
|
|
|
std::vector<std::pair<Stage *, int> >::iterator mCurrentStage;
|
|
|
|
int mCurrentStep;
|
|
|
|
int mCurrentStepTotal;
|
|
|
|
int mTotalSteps;
|
2013-09-14 15:12:24 +02:00
|
|
|
int mOrdered;
|
2013-09-15 12:03:36 +02:00
|
|
|
bool mFinalAlways;
|
|
|
|
bool mError;
|
2012-12-08 17:53:45 +01:00
|
|
|
|
|
|
|
void prepareStages();
|
2012-12-08 15:25:50 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-15 12:03:36 +02:00
|
|
|
Operation (int type, bool ordered, bool finalAlways = false);
|
|
|
|
///< \param ordered Stages must be executed in the given order.
|
|
|
|
/// \param finalAlways Execute last stage even if an error occurred during earlier stages.
|
2012-12-08 15:25:50 +01:00
|
|
|
|
2012-12-08 17:53:45 +01:00
|
|
|
virtual ~Operation();
|
|
|
|
|
2012-12-08 15:25:50 +01:00
|
|
|
virtual void run();
|
|
|
|
|
2012-12-08 17:53:45 +01:00
|
|
|
void appendStage (Stage *stage);
|
|
|
|
///< The ownership of \a stage is transferred to *this.
|
|
|
|
///
|
|
|
|
/// \attention Do no call this function while this Operation is running.
|
|
|
|
|
2013-09-15 12:03:36 +02:00
|
|
|
bool hasError() const;
|
|
|
|
|
2012-12-08 15:25:50 +01:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void progress (int current, int max, int type);
|
|
|
|
|
2014-05-08 12:42:29 +02:00
|
|
|
void reportMessage (const CSMWorld::UniversalId& id, const std::string& message,
|
|
|
|
int type);
|
2012-12-08 18:38:36 +01:00
|
|
|
|
2014-09-03 19:14:27 +02:00
|
|
|
void done (int type, bool failed);
|
2013-09-15 11:35:12 +02:00
|
|
|
|
2012-12-08 15:25:50 +01:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void abort();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
2013-09-15 09:32:20 +02:00
|
|
|
void executeStage();
|
2013-09-15 11:35:12 +02:00
|
|
|
|
|
|
|
void operationDone();
|
2012-12-08 15:25:50 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|