diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 2bd0f2e3e0..d8ad5ff01d 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -13,9 +13,6 @@ CSMDoc::Document::Document (const std::string& name) // dummy implementation -> remove when proper save is implemented. mSaveCount = 0; connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving())); - - // dummy implementation -> remove when proper verify is implemented. - mVerifyCount = 0; } QUndoStack& CSMDoc::Document::getUndoStack() @@ -33,8 +30,8 @@ int CSMDoc::Document::getState() const if (mSaveCount) state |= State_Locked | State_Saving | State_Operation; - if (mVerifyCount) - state |= State_Locked | State_Verifying | State_Operation; + if (int operations = mTools.getRunningOperations()) + state |= State_Locked | State_Operation | operations; return state; } @@ -54,9 +51,8 @@ void CSMDoc::Document::save() void CSMDoc::Document::verify() { - mVerifyCount = 1; - emit stateChanged (getState(), this); mTools.runVerifier(); + emit stateChanged (getState(), this); } void CSMDoc::Document::abortOperation (int type) @@ -77,9 +73,6 @@ void CSMDoc::Document::modificationStateChanged (bool clean) void CSMDoc::Document::operationDone (int type) { - if (type==State_Verifying) - mVerifyCount = 0; - emit stateChanged (getState(), this); } diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 6226e31655..40f8c0ea11 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -29,8 +29,6 @@ namespace CSMDoc int mSaveCount; ///< dummy implementation -> remove when proper save is implemented. QTimer mSaveTimer; ///< dummy implementation -> remove when proper save is implemented. - int mVerifyCount; ///< dummy implementation -> remove when proper verify is implemented. - // not implemented Document (const Document&); Document& operator= (const Document&); diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 95375332cb..608244a3ca 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -7,6 +7,21 @@ #include "../doc/state.hpp" +CSMTools::Operation *CSMTools::Tools::get (int type) +{ + switch (type) + { + case CSMDoc::State_Verifying: return mVerifier; + } + + return 0; +} + +const CSMTools::Operation *CSMTools::Tools::get (int type) const +{ + return const_cast (this)->get (type); +} + CSMTools::Verifier *CSMTools::Tools::getVerifier() { if (!mVerifier) @@ -37,7 +52,26 @@ void CSMTools::Tools::runVerifier() void CSMTools::Tools::abortOperation (int type) { + if (Operation *operation = get (type)) + operation->abort(); +} +int CSMTools::Tools::getRunningOperations() const +{ + static const int sOperations[] = + { + CSMDoc::State_Verifying, + -1 + }; + + int result = 0; + + for (int i=0; sOperations[i]!=-1; ++i) + if (const Operation *operation = get (sOperations[i])) + if (operation->isRunning()) + result |= sOperations[i]; + + return result; } void CSMTools::Tools::verifierDone() diff --git a/apps/opencs/model/tools/tools.hpp b/apps/opencs/model/tools/tools.hpp index 65b1d16840..ab18637387 100644 --- a/apps/opencs/model/tools/tools.hpp +++ b/apps/opencs/model/tools/tools.hpp @@ -6,6 +6,7 @@ namespace CSMTools { class Verifier; + class Operation; class Tools : public QObject { @@ -19,6 +20,12 @@ namespace CSMTools Verifier *getVerifier(); + Operation *get (int type); + ///< Returns a 0-pointer, if operation hasn't been used yet. + + const Operation *get (int type) const; + ///< Returns a 0-pointer, if operation hasn't been used yet. + public: Tools(); @@ -30,6 +37,8 @@ namespace CSMTools void abortOperation (int type); ///< \attention The operation is not aborted immediately. + int getRunningOperations() const; + private slots: void verifierDone();