added operations base class

actorid
Marc Zinnschlag 12 years ago
parent a2b4f43176
commit af9b48f4d3

@ -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

@ -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();
}

@ -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

@ -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)
{}

@ -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();
signals:
void progress (int current, int max, int type);
Verifier();
public slots:
void abort();
private slots:
void verify();
};
}
#endif

Loading…
Cancel
Save