equal
deleted
inserted
replaced
|
1 |
|
2 |
|
3 #include "timedcontroller.h" |
|
4 |
|
5 TimedController::TimedController(): m_delay(10), m_interval(0){ |
|
6 m_exTime = QTime::currentTime(); |
|
7 m_exTimestamp =QTime::currentTime(); |
|
8 m_timer.setSingleShot(false); |
|
9 doStart(); |
|
10 } |
|
11 |
|
12 TimedController::~TimedController(){ |
|
13 doStop(); |
|
14 } |
|
15 |
|
16 |
|
17 void TimedController::handleTimedUpdate() |
|
18 { |
|
19 int timeDiff = m_exTime.msecsTo(QTime::currentTime()); |
|
20 if (timeDiff< m_delay) return; |
|
21 updateCoordinates(); |
|
22 m_exTime = QTime::currentTime(); |
|
23 } |
|
24 |
|
25 |
|
26 |
|
27 void TimedController::doStart(){ |
|
28 m_timer.start(m_delay); |
|
29 connect(&m_timer, SIGNAL(timeout()), this, SLOT(handleTimedUpdate())); |
|
30 } |
|
31 |
|
32 |
|
33 void TimedController::doStop(){ |
|
34 disconnect(&m_timer); |
|
35 m_timer.stop(); |
|
36 } |