logwidget 추가
git-svn-id: svn://192.168.0.12/source@301 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
153
EffectUI/srunningprocess.cpp
Normal file
153
EffectUI/srunningprocess.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include "srunningprocess.h"
|
||||
#include <QTimer>
|
||||
|
||||
namespace{
|
||||
const int ONE_SECOND = 1000; // 1 second
|
||||
const int HALF_SECOND = 500; // 0.5 second
|
||||
}
|
||||
|
||||
|
||||
SRunningProcess::SRunningProcess():
|
||||
m_pTimer(new QTimer(this)), m_pErrorProcess(new SErrorProcess),
|
||||
m_pCompanyProcess(new SCompanyProcess), m_eMode(E_PROCESS_MODE::WAIT),
|
||||
m_pCurrentProcess(nullptr)
|
||||
{
|
||||
m_pTimer->setInterval(ONE_SECOND);
|
||||
initConnect();
|
||||
}
|
||||
|
||||
bool SRunningProcess::isRunning()
|
||||
{
|
||||
if (m_pCurrentProcess == nullptr && !m_pTimer->isActive())
|
||||
return true;
|
||||
else
|
||||
return m_pCurrentProcess->isWaiting() && !m_pTimer->isActive();
|
||||
}
|
||||
|
||||
void SRunningProcess::setList(const QVector<SEffectRow>& _list)
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
m_pCurrentProcess = m_pErrorProcess;
|
||||
m_pCurrentProcess->setList(_list);
|
||||
}
|
||||
}
|
||||
|
||||
void SRunningProcess::setList(QVector<SEffectRow>&& _list)
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
m_pCurrentProcess = m_pErrorProcess;
|
||||
m_pCurrentProcess->setList(std::move(_list));
|
||||
}
|
||||
}
|
||||
|
||||
void SRunningProcess::setList(const QVector<int>& _list)
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
m_pCurrentProcess = m_pCompanyProcess;
|
||||
m_pCurrentProcess->setList(_list);
|
||||
}
|
||||
}
|
||||
|
||||
void SRunningProcess::setList(QVector<int>&& _list)
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
m_pCurrentProcess = m_pCompanyProcess;
|
||||
m_pCurrentProcess->setList(std::move(_list));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void SRunningProcess::start(QVector<T>&& _list)
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
setList(std::forward(_list));
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void SRunningProcess::start()
|
||||
{
|
||||
if (!isRunning())
|
||||
{
|
||||
m_pTimer->start();
|
||||
emit signalLog("Start Effect Process");
|
||||
}
|
||||
}
|
||||
|
||||
void SRunningProcess::update()
|
||||
{
|
||||
m_pCurrentProcess->update();
|
||||
}
|
||||
|
||||
void SRunningProcess::slotLog(const QString &_strLog)
|
||||
{
|
||||
emit signalLog(_strLog);
|
||||
}
|
||||
|
||||
void SRunningProcess::terminate()
|
||||
{
|
||||
m_pTimer->stop();
|
||||
m_pCurrentProcess->setModeWait();
|
||||
emit signalLog("Terminate Process");
|
||||
}
|
||||
|
||||
void SRunningProcess::slotUserAbort()
|
||||
{
|
||||
terminate();
|
||||
emit signalUserAbort();
|
||||
}
|
||||
|
||||
void SRunningProcess::stop()
|
||||
{
|
||||
m_pCurrentProcess->stop();
|
||||
}
|
||||
|
||||
void SRunningProcess::slotCompanyComplete(int _num)
|
||||
{
|
||||
SReportSummary summary = m_pCurrentProcess->getReportSummary(_num);
|
||||
emit signalCompanyComplete(_num, summary);
|
||||
}
|
||||
|
||||
void SRunningProcess::slotSuccessErrorCompany(int _num)
|
||||
{
|
||||
emit signalSuccessErrorCompany(_num);
|
||||
}
|
||||
|
||||
void SRunningProcess::slotTerminateError()
|
||||
{
|
||||
terminate();
|
||||
SError error = m_pCurrentProcess->getError();
|
||||
emit signalTerminateError(error);
|
||||
}
|
||||
|
||||
void SRunningProcess::slotTerminateNormal()
|
||||
{
|
||||
terminate();
|
||||
QVector<SEffectRow> errors = m_pCurrentProcess->getErrorList();
|
||||
QMap<int, SReportSummary> reportSummary = m_pCurrentProcess->getReportSummary();
|
||||
emit signalTerminateNormal(errors, reportSummary);
|
||||
}
|
||||
|
||||
void SRunningProcess::initConnect()
|
||||
{
|
||||
QObject::connect(&(*m_pTimer), &QTimer::timeout, this, &SRunningProcess::update);
|
||||
|
||||
QObject::connect(&(*m_pCompanyProcess), &SCompanyProcess::signalLog, this, &SRunningProcess::slotLog);
|
||||
QObject::connect(&(*m_pErrorProcess), &SErrorProcess::signalLog, this, &SRunningProcess::slotLog);
|
||||
|
||||
QObject::connect(&(*m_pCompanyProcess), &SCompanyProcess::signalTerminate, this, &SRunningProcess::slotTerminateError);
|
||||
QObject::connect(&(*m_pErrorProcess), &SErrorProcess::signalTerminate, this, &SRunningProcess::slotTerminateError);
|
||||
|
||||
QObject::connect(&(*m_pCompanyProcess), &SCompanyProcess::signalTerminateNormal, this, &SRunningProcess::slotTerminateNormal);
|
||||
QObject::connect(&(*m_pErrorProcess), &SErrorProcess::signalTerminateNormal, this, &SRunningProcess::slotTerminateNormal);
|
||||
|
||||
QObject::connect(&(*m_pCompanyProcess), &SCompanyProcess::signalTerminateCompany, this, &SRunningProcess::slotCompanyComplete);
|
||||
QObject::connect(&(*m_pErrorProcess), &SErrorProcess::signalTerminateCompany, this, &SRunningProcess::slotSuccessErrorCompany);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user