2013-09-14 12:56:23 +00:00
|
|
|
#ifndef CSM_DOC_OPERATION_H
|
|
|
|
#define CSM_DOC_OPERATION_H
|
2012-12-08 14:25:50 +00:00
|
|
|
|
2012-12-08 16:53:45 +00:00
|
|
|
#include <vector>
|
2015-06-20 12:21:52 +00:00
|
|
|
#include <map>
|
2012-12-08 16:53:45 +00:00
|
|
|
|
2015-03-14 11:00:24 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
2015-06-20 12:21:52 +00:00
|
|
|
#include <QStringList>
|
2012-12-08 14:25:50 +00:00
|
|
|
|
2015-06-20 15:56:42 +00:00
|
|
|
#include "messages.hpp"
|
|
|
|
|
2014-05-08 10:42:29 +00:00
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class UniversalId;
|
|
|
|
}
|
|
|
|
|
2013-09-14 12:56:23 +00:00
|
|
|
namespace CSMDoc
|
2012-12-08 14:25:50 +00:00
|
|
|
{
|
2012-12-08 16:53:45 +00:00
|
|
|
class Stage;
|
|
|
|
|
2015-03-14 11:00:24 +00:00
|
|
|
class Operation : public QObject
|
2012-12-08 14:25:50 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
int mType;
|
2012-12-08 16:53:45 +00: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 13:12:24 +00:00
|
|
|
int mOrdered;
|
2013-09-15 10:03:36 +00:00
|
|
|
bool mFinalAlways;
|
|
|
|
bool mError;
|
2015-03-14 11:00:24 +00:00
|
|
|
bool mConnected;
|
|
|
|
QTimer *mTimer;
|
2015-06-20 12:21:52 +00:00
|
|
|
bool mPrepared;
|
2015-06-20 17:04:19 +00:00
|
|
|
Message::Severity mDefaultSeverity;
|
2012-12-08 16:53:45 +00:00
|
|
|
|
|
|
|
void prepareStages();
|
2012-12-08 14:25:50 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-09-15 10:03:36 +00: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 14:25:50 +00:00
|
|
|
|
2012-12-08 16:53:45 +00:00
|
|
|
virtual ~Operation();
|
|
|
|
|
|
|
|
void appendStage (Stage *stage);
|
|
|
|
///< The ownership of \a stage is transferred to *this.
|
|
|
|
///
|
|
|
|
/// \attention Do no call this function while this Operation is running.
|
|
|
|
|
2015-06-20 17:04:19 +00:00
|
|
|
/// \attention Do no call this function while this Operation is running.
|
|
|
|
void setDefaultSeverity (Message::Severity severity);
|
|
|
|
|
2013-09-15 10:03:36 +00:00
|
|
|
bool hasError() const;
|
|
|
|
|
2012-12-08 14:25:50 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
void progress (int current, int max, int type);
|
|
|
|
|
2015-06-20 15:56:42 +00:00
|
|
|
void reportMessage (const CSMDoc::Message& message, int type);
|
2012-12-08 17:38:36 +00:00
|
|
|
|
2014-09-03 17:14:27 +00:00
|
|
|
void done (int type, bool failed);
|
2013-09-15 09:35:12 +00:00
|
|
|
|
2012-12-08 14:25:50 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void abort();
|
|
|
|
|
2015-03-14 11:00:24 +00:00
|
|
|
void run();
|
|
|
|
|
2012-12-08 14:25:50 +00:00
|
|
|
private slots:
|
|
|
|
|
2013-09-15 07:32:20 +00:00
|
|
|
void executeStage();
|
2013-09-15 09:35:12 +00:00
|
|
|
|
2015-08-16 13:24:48 +00:00
|
|
|
protected slots:
|
|
|
|
|
|
|
|
virtual void operationDone();
|
2012-12-08 14:25:50 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-03-14 11:00:24 +00:00
|
|
|
#endif
|