effectui 추가
형태소분석기 숫자 정렬 추가 batch run 시 결과값이 올바르게 나오지 않는 현상 디버깅 git-svn-id: svn://192.168.0.12/source@297 8346c931-da38-4b9b-9d4c-e48b93cbd075
This commit is contained in:
92
EffectUI/stimer.cpp
Normal file
92
EffectUI/stimer.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "stimer.h"
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
|
||||
namespace
|
||||
{
|
||||
const int TIME = 300000; // 5 minute
|
||||
}
|
||||
STimer::STimer(): m_pTimer(new QTimer), m_nPreviousHour(-1)
|
||||
{
|
||||
m_pTimer->setInterval(TIME);
|
||||
connect(&(*m_pTimer), &QTimer::timeout, this, &checkTimeout);
|
||||
}
|
||||
|
||||
STimer::~STimer()
|
||||
{
|
||||
disconnect(&(*m_pTimer), &QTimer::timeout, this, &checkTimeout);
|
||||
}
|
||||
|
||||
STimer::STimer(int time): STimer()
|
||||
{
|
||||
if (0 <= time && time < 24)
|
||||
m_setTime.insert(time);
|
||||
}
|
||||
|
||||
STimer::STimer(QVector<int> times): STimer()
|
||||
{
|
||||
foreach (int time, times)
|
||||
{
|
||||
if (0 <= time && time < 24)
|
||||
m_setTime.insert(time);
|
||||
}
|
||||
}
|
||||
|
||||
void STimer::start()
|
||||
{
|
||||
if (!m_pTimer->isActive())
|
||||
m_pTimer->start();
|
||||
}
|
||||
|
||||
void STimer::stop()
|
||||
{
|
||||
if (m_pTimer->isActive())
|
||||
m_pTimer->stop();
|
||||
}
|
||||
|
||||
bool STimer::isActive() const noexcept
|
||||
{
|
||||
return m_pTimer->isActive();
|
||||
}
|
||||
|
||||
void STimer::set(int time)
|
||||
{
|
||||
if (0 <= time && time < 24)
|
||||
m_setTime.insert(time);
|
||||
}
|
||||
|
||||
void STimer::set(QVector<int> times)
|
||||
{
|
||||
foreach (int time, times)
|
||||
{
|
||||
set(time);
|
||||
}
|
||||
}
|
||||
|
||||
void STimer::unset(int time)
|
||||
{
|
||||
m_setTime.remove(time);
|
||||
}
|
||||
|
||||
void STimer::unset(QVector<int> times)
|
||||
{
|
||||
foreach (int time, times)
|
||||
{
|
||||
unset(time);
|
||||
}
|
||||
}
|
||||
|
||||
int STimer::timerId() const
|
||||
{
|
||||
return m_pTimer->timerId();
|
||||
}
|
||||
|
||||
void STimer::checkTimeout()
|
||||
{
|
||||
QTime now = QTime::currentTime();
|
||||
bool bChangedHour = (m_nPreviousHour == now.hour()) ? false : true;
|
||||
m_nPreviousHour = now.hour();
|
||||
if (bChangedHour && m_setTime.contains(now.hour()))
|
||||
emit timeout();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user