1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

added operations base class

This commit is contained in:
Marc Zinnschlag 2012-12-08 15:25:50 +01:00
parent a2b4f43176
commit af9b48f4d3
5 changed files with 77 additions and 49 deletions

View file

@ -7,7 +7,7 @@ set (OPENCS_SRC
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/tools/tools.cpp model/tools/verifier.cpp
model/tools/tools.cpp model/tools/operation.cpp model/tools/verifier.cpp
view/doc/viewmanager.cpp view/doc/view.cpp view/doc/operations.cpp view/doc/operation.cpp
@ -23,7 +23,7 @@ set (OPENCS_HDR
model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp
model/world/commands.hpp
model/tools/tools.hpp model/tools/verifier.hpp
model/tools/tools.hpp model/tools/operation.hpp model/tools/verifier.hpp
view/doc/viewmanager.hpp view/doc/view.hpp view/doc/operations.hpp view/doc/operation.hpp

View file

@ -0,0 +1,35 @@
#include "operation.hpp"
#include <QTimer>
#include "../doc/state.hpp"
CSMTools::Operation::Operation (int type) : mType (type) {}
void CSMTools::Operation::run()
{
mStep = 0;
QTimer timer;
timer.connect (&timer, SIGNAL (timeout()), this, SLOT (verify()));
timer.start (0);
exec();
}
void CSMTools::Operation::abort()
{
exit();
}
void CSMTools::Operation::verify()
{
++mStep;
emit progress (mStep, 1000, mType);
if (mStep>=1000)
exit();
}

View file

@ -0,0 +1,35 @@
#ifndef CSM_TOOLS_OPERATION_H
#define CSM_TOOLS_OPERATION_H
#include <QThread>
namespace CSMTools
{
class Operation : public QThread
{
Q_OBJECT
int mType;
int mStep;
public:
Operation (int type);
virtual void run();
signals:
void progress (int current, int max, int type);
public slots:
void abort();
private slots:
void verify();
};
}
#endif

View file

@ -1,33 +1,7 @@
#include "verifier.hpp"
#include <QTimer>
#include "../doc/state.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::State_Verifying);
if (mStep>=1000)
exit();
}
CSMTools::Verifier::Verifier() : Operation (CSMDoc::State_Verifying)
{}

View file

@ -1,33 +1,17 @@
#ifndef CSM_TOOLS_VERIFIER_H
#define CSM_TOOLS_VERIFIER_H
#include <QThread>
#include "operation.hpp"
namespace CSMTools
{
class Verifier : public QThread
class Verifier : public Operation
{
Q_OBJECT
int mStep;
public:
virtual void run();
Verifier();
signals:
void progress (int current, int max, int type);
public slots:
void abort();
private slots:
void verify();
};
}
#endif