Files
pilotclient/src/blackgui/timerbasedcomponent.cpp
Klaus Basan 52b88ab24e refs #239, added a helper class for timer based pulls
* changed user componet to use new component
* all new components (aircraft, ATC stations) will use this timer
* it is implemented as "has a" timer based component, as inheriting from 2 QObjects would be problematic
2014-05-14 23:38:09 +02:00

30 lines
756 B
C++

#include "timerbasedcomponent.h"
namespace BlackGui
{
CTimerBasedComponent::CTimerBasedComponent(const char *slot, QObject *parent) :
QObject(parent), m_timer(nullptr)
{
this->m_timer = new QTimer(this);
this->connect(this->m_timer, SIGNAL(timeout()), parent, slot);
}
CTimerBasedComponent::~CTimerBasedComponent()
{
this->m_timer->stop();
this->disconnect(this->parent());
}
void CTimerBasedComponent::setUpdateInterval(int milliSeconds)
{
if (milliSeconds < 100)
this->m_timer->stop();
else
{
this->m_timer->setInterval(milliSeconds);
if (!this->m_timer->isActive()) this->m_timer->start();
}
}
} // guard