OpenMW
apps/opencs/model/doc/operation.hpp
Go to the documentation of this file.
00001 #ifndef CSM_DOC_OPERATION_H
00002 #define CSM_DOC_OPERATION_H
00003 
00004 #include <vector>
00005 
00006 #include <QThread>
00007 
00008 namespace CSMDoc
00009 {
00010     class Stage;
00011 
00012     class Operation : public QThread
00013     {
00014             Q_OBJECT
00015 
00016             int mType;
00017             std::vector<std::pair<Stage *, int> > mStages; // stage, number of steps
00018             std::vector<std::pair<Stage *, int> >::iterator mCurrentStage;
00019             int mCurrentStep;
00020             int mCurrentStepTotal;
00021             int mTotalSteps;
00022             int mOrdered;
00023             bool mFinalAlways;
00024             bool mError;
00025 
00026             void prepareStages();
00027 
00028         public:
00029 
00030             Operation (int type, bool ordered, bool finalAlways = false);
00033 
00034             virtual ~Operation();
00035 
00036             virtual void run();
00037 
00038             void appendStage (Stage *stage);
00042 
00043             bool hasError() const;
00044 
00045         signals:
00046 
00047             void progress (int current, int max, int type);
00048 
00049             void reportMessage (const QString& message, int type);
00050 
00051             void done (int type);
00052 
00053         public slots:
00054 
00055             void abort();
00056 
00057         private slots:
00058 
00059             void executeStage();
00060 
00061             void operationDone();
00062     };
00063 }
00064 
00065 #endif