1 #ifndef CSM_DOC_OPERATION_H 2 #define CSM_DOC_OPERATION_H 3 4 #include <vector> 5 #include <map> 6 7 #include <QObject> 8 #include <QTimer> 9 #include <QStringList> 10 11 #include "messages.hpp" 12 13 namespace CSMWorld 14 { 15 class UniversalId; 16 } 17 18 namespace CSMDoc 19 { 20 class Stage; 21 22 class Operation : public QObject 23 { 24 Q_OBJECT 25 26 int mType; 27 std::vector<std::pair<Stage *, int> > mStages; // stage, number of steps 28 std::vector<std::pair<Stage *, int> >::iterator mCurrentStage; 29 int mCurrentStep; 30 int mCurrentStepTotal; 31 int mTotalSteps; 32 int mOrdered; 33 bool mFinalAlways; 34 bool mError; 35 bool mConnected; 36 QTimer *mTimer; 37 bool mPrepared; 38 Message::Severity mDefaultSeverity; 39 40 void prepareStages(); 41 42 public: 43 44 Operation (int type, bool ordered, bool finalAlways = false); 45 ///< \param ordered Stages must be executed in the given order. 46 /// \param finalAlways Execute last stage even if an error occurred during earlier stages. 47 48 virtual ~Operation(); 49 50 void appendStage (Stage *stage); 51 ///< The ownership of \a stage is transferred to *this. 52 /// 53 /// \attention Do no call this function while this Operation is running. 54 55 /// \attention Do no call this function while this Operation is running. 56 void setDefaultSeverity (Message::Severity severity); 57 58 bool hasError() const; 59 60 signals: 61 62 void progress (int current, int max, int type); 63 64 void reportMessage (const CSMDoc::Message& message, int type); 65 66 void done (int type, bool failed); 67 68 public slots: 69 70 void abort(); 71 72 void run(); 73 74 private slots: 75 76 void executeStage(); 77 78 protected slots: 79 80 virtual void operationDone(); 81 }; 82 } 83 84 #endif 85