mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-21 15:11:33 +00:00
preliminary multi-threaded verify implementation (does not actually perfom any document verification yet)
This commit is contained in:
parent
1c80390bce
commit
fdc7e93835
7 changed files with 189 additions and 25 deletions
|
@ -7,6 +7,8 @@ set (OPENCS_SRC
|
||||||
model/world/universalid.cpp model/world/idcollection.cpp model/world/data.cpp model/world/idtable.cpp
|
model/world/universalid.cpp model/world/idcollection.cpp model/world/data.cpp model/world/idtable.cpp
|
||||||
model/world/commands.cpp model/world/idtableproxymodel.cpp model/world/record.cpp
|
model/world/commands.cpp model/world/idtableproxymodel.cpp model/world/record.cpp
|
||||||
|
|
||||||
|
model/tools/tools.cpp model/tools/verifier.cpp
|
||||||
|
|
||||||
view/doc/viewmanager.cpp view/doc/view.cpp view/doc/operations.cpp view/doc/operation.cpp
|
view/doc/viewmanager.cpp view/doc/view.cpp view/doc/operations.cpp view/doc/operation.cpp
|
||||||
|
|
||||||
view/world/subview.cpp view/world/table.cpp view/world/tablesubview.cpp
|
view/world/subview.cpp view/world/table.cpp view/world/tablesubview.cpp
|
||||||
|
@ -21,6 +23,8 @@ set (OPENCS_HDR
|
||||||
model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp
|
model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp
|
||||||
model/world/commands.hpp
|
model/world/commands.hpp
|
||||||
|
|
||||||
|
model/tools/tools.hpp model/tools/verifier.hpp
|
||||||
|
|
||||||
view/doc/viewmanager.hpp view/doc/view.hpp view/doc/operations.hpp view/doc/operation.hpp
|
view/doc/viewmanager.hpp view/doc/view.hpp view/doc/operations.hpp view/doc/operation.hpp
|
||||||
|
|
||||||
view/world/subview.hpp view/world/table.hpp view/world/tablesubview.hpp
|
view/world/subview.hpp view/world/table.hpp view/world/tablesubview.hpp
|
||||||
|
|
|
@ -7,13 +7,16 @@ CSMDoc::Document::Document (const std::string& name)
|
||||||
|
|
||||||
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
|
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
|
||||||
|
|
||||||
|
connect (&mTools, SIGNAL (progress (int, int, int)), this, SLOT (progress (int, int, int)));
|
||||||
|
connect (&mTools, SIGNAL (done (int)), this, SLOT (operationDone (int)));
|
||||||
|
|
||||||
// dummy implementation -> remove when proper save is implemented.
|
// dummy implementation -> remove when proper save is implemented.
|
||||||
mSaveCount = 0;
|
mSaveCount = 0;
|
||||||
connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving()));
|
connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving()));
|
||||||
|
|
||||||
// dummy implementation -> remove when proper verify is implemented.
|
// dummy implementation -> remove when proper verify is implemented.
|
||||||
mVerifyCount = 0;
|
mVerifyCount = 0;
|
||||||
connect (&mVerifyTimer, SIGNAL(timeout()), this, SLOT (verifying()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack& CSMDoc::Document::getUndoStack()
|
QUndoStack& CSMDoc::Document::getUndoStack()
|
||||||
|
@ -53,23 +56,19 @@ void CSMDoc::Document::save()
|
||||||
void CSMDoc::Document::verify()
|
void CSMDoc::Document::verify()
|
||||||
{
|
{
|
||||||
mVerifyCount = 1;
|
mVerifyCount = 1;
|
||||||
mVerifyTimer.start (500);
|
|
||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
emit progress (1, 20, State_Verifying, 1, this);
|
mTools.runVerifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::abortOperation (int type)
|
void CSMDoc::Document::abortOperation (int type)
|
||||||
{
|
{
|
||||||
|
mTools.abortOperation (type);
|
||||||
|
|
||||||
if (type==State_Saving)
|
if (type==State_Saving)
|
||||||
{
|
{
|
||||||
mSaveTimer.stop();
|
mSaveTimer.stop();
|
||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
}
|
}
|
||||||
else if (type==State_Verifying)
|
|
||||||
{
|
|
||||||
mVerifyTimer.stop();
|
|
||||||
emit stateChanged (getState(), this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::modificationStateChanged (bool clean)
|
void CSMDoc::Document::modificationStateChanged (bool clean)
|
||||||
|
@ -77,6 +76,14 @@ void CSMDoc::Document::modificationStateChanged (bool clean)
|
||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::Document::operationDone (int type)
|
||||||
|
{
|
||||||
|
if (type==State_Verifying)
|
||||||
|
mVerifyCount = 0;
|
||||||
|
|
||||||
|
emit stateChanged (getState(), this);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::saving()
|
void CSMDoc::Document::saving()
|
||||||
{
|
{
|
||||||
++mSaveCount;
|
++mSaveCount;
|
||||||
|
@ -92,20 +99,6 @@ void CSMDoc::Document::saving()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::verifying()
|
|
||||||
{
|
|
||||||
++mVerifyCount;
|
|
||||||
|
|
||||||
emit progress (mVerifyCount, 20, State_Verifying, 1, this);
|
|
||||||
|
|
||||||
if (mVerifyCount>19)
|
|
||||||
{
|
|
||||||
mVerifyCount = 0;
|
|
||||||
mVerifyTimer.stop();
|
|
||||||
emit stateChanged (getState(), this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const CSMWorld::Data& CSMDoc::Document::getData() const
|
const CSMWorld::Data& CSMDoc::Document::getData() const
|
||||||
{
|
{
|
||||||
return mData;
|
return mData;
|
||||||
|
@ -115,3 +108,8 @@ CSMWorld::Data& CSMDoc::Document::getData()
|
||||||
{
|
{
|
||||||
return mData;
|
return mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::Document::progress (int current, int max, int type)
|
||||||
|
{
|
||||||
|
emit progress (current, max, type, 1, this);
|
||||||
|
}
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
#include "../world/data.hpp"
|
#include "../world/data.hpp"
|
||||||
|
|
||||||
|
#include "../tools/tools.hpp"
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
class Document : public QObject
|
class Document : public QObject
|
||||||
|
@ -32,12 +34,12 @@ namespace CSMDoc
|
||||||
std::string mName; ///< \todo replace name with ESX list
|
std::string mName; ///< \todo replace name with ESX list
|
||||||
QUndoStack mUndoStack;
|
QUndoStack mUndoStack;
|
||||||
CSMWorld::Data mData;
|
CSMWorld::Data mData;
|
||||||
|
CSMTools::Tools mTools;
|
||||||
|
|
||||||
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
||||||
QTimer mSaveTimer; ///< 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.
|
int mVerifyCount; ///< dummy implementation -> remove when proper verify is implemented.
|
||||||
QTimer mVerifyTimer; ///< dummy implementation -> remove when proper verify is implemented.
|
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Document (const Document&);
|
Document (const Document&);
|
||||||
|
@ -75,11 +77,14 @@ namespace CSMDoc
|
||||||
|
|
||||||
void modificationStateChanged (bool clean);
|
void modificationStateChanged (bool clean);
|
||||||
|
|
||||||
|
void operationDone (int type);
|
||||||
|
|
||||||
void saving();
|
void saving();
|
||||||
///< dummy implementation -> remove when proper save is implemented.
|
///< dummy implementation -> remove when proper save is implemented.
|
||||||
|
|
||||||
void verifying();
|
public slots:
|
||||||
///< dummy implementation -> remove when proper verify is implemented.
|
|
||||||
|
void progress (int current, int max, int type);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
apps/opencs/model/tools/tools.cpp
Normal file
46
apps/opencs/model/tools/tools.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
#include "tools.hpp"
|
||||||
|
|
||||||
|
#include <QThreadPool>
|
||||||
|
|
||||||
|
#include "verifier.hpp"
|
||||||
|
|
||||||
|
#include "../doc/document.hpp"
|
||||||
|
|
||||||
|
CSMTools::Verifier *CSMTools::Tools::getVerifier()
|
||||||
|
{
|
||||||
|
if (!mVerifier)
|
||||||
|
{
|
||||||
|
mVerifier = new Verifier;
|
||||||
|
|
||||||
|
connect (mVerifier, SIGNAL (progress (int, int, int)), this, SIGNAL (progress (int, int, int)));
|
||||||
|
connect (mVerifier, SIGNAL (finished()), this, SLOT (verifierDone()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return mVerifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMTools::Tools::Tools() : mVerifier (0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMTools::Tools::~Tools()
|
||||||
|
{
|
||||||
|
delete mVerifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::Tools::runVerifier()
|
||||||
|
{
|
||||||
|
getVerifier()->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::Tools::abortOperation (int type)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::Tools::verifierDone()
|
||||||
|
{
|
||||||
|
emit done (CSMDoc::Document::State_Verifying);
|
||||||
|
}
|
45
apps/opencs/model/tools/tools.hpp
Normal file
45
apps/opencs/model/tools/tools.hpp
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef CSM_TOOLS_TOOLS_H
|
||||||
|
#define CSM_TOOLS_TOOLS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
class Verifier;
|
||||||
|
|
||||||
|
class Tools : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Verifier *mVerifier;
|
||||||
|
|
||||||
|
// not implemented
|
||||||
|
Tools (const Tools&);
|
||||||
|
Tools& operator= (const Tools&);
|
||||||
|
|
||||||
|
Verifier *getVerifier();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Tools();
|
||||||
|
|
||||||
|
virtual ~Tools();
|
||||||
|
|
||||||
|
void runVerifier();
|
||||||
|
|
||||||
|
void abortOperation (int type);
|
||||||
|
///< \attention The operation is not aborted immediately.
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void verifierDone();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void progress (int current, int max, int type);
|
||||||
|
|
||||||
|
void done (int type);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
33
apps/opencs/model/tools/verifier.cpp
Normal file
33
apps/opencs/model/tools/verifier.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
#include "verifier.hpp"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../doc/document.hpp"
|
||||||
|
|
||||||
|
void CSMTools::Verifier::run()
|
||||||
|
{
|
||||||
|
mStep = 0;
|
||||||
|
|
||||||
|
QTimer timer;
|
||||||
|
|
||||||
|
timer.connect (&timer, SIGNAL (timeout()), this, SLOT (verify()));
|
||||||
|
|
||||||
|
timer.start (0);
|
||||||
|
|
||||||
|
exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::Verifier::abort()
|
||||||
|
{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMTools::Verifier::verify()
|
||||||
|
{
|
||||||
|
++mStep;
|
||||||
|
emit progress (mStep, 1000, CSMDoc::Document::State_Verifying);
|
||||||
|
|
||||||
|
if (mStep>=1000)
|
||||||
|
exit();
|
||||||
|
}
|
33
apps/opencs/model/tools/verifier.hpp
Normal file
33
apps/opencs/model/tools/verifier.hpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef CSM_TOOLS_VERIFIER_H
|
||||||
|
#define CSM_TOOLS_VERIFIER_H
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
namespace CSMTools
|
||||||
|
{
|
||||||
|
class Verifier : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
int mStep;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual void run();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void progress (int current, int max, int type);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void abort();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void verify();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue