1 /*************************************************************************** 2 * * 3 * This program is free software; you can redistribute it and/or modify * 4 * it under the terms of the GNU General Public License as published by * 5 * the Free Software Foundation; either version 3 of the License, or * 6 * (at your option) any later version. * 7 * * 8 ***************************************************************************/ 9 10 #include "GlobalTimer.h" 11 12 #include <QTimer> 13 GlobalTimer()14GlobalTimer::GlobalTimer() : QObject(NULL), timer(new QTimer()), tickCount(0) { 15 timer->setInterval(1000); 16 timer->setSingleShot(false); 17 18 connect(timer.get(), SIGNAL(timeout()), this, SLOT(slotTick())); 19 20 timer->start(); 21 } 22 ~GlobalTimer()23GlobalTimer::~GlobalTimer() { 24 timer->stop(); 25 26 disconnect(this, 0, 0, 0); 27 } 28 slotTick()29void GlobalTimer::slotTick() { 30 tickCount++; 31 32 emit second(); 33 34 if ((tickCount % 60) == 0) 35 emit minute(); 36 } 37 getTicks() const38quint64 GlobalTimer::getTicks() const { 39 return tickCount; 40 } 41