direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
timerThread.h
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #ifndef TIMERTHREAD_H
22 #define TIMERTHREAD_H
23 
24 #include <QThread>
25 #include <QTime>
26 
27 
34 class TimerThread : public QThread
35 {
36  Q_OBJECT
37 
38  public:
39  TimerThread();
40  ~TimerThread();
41 
45  void stop();
46 
50  virtual void run();
51 
56  bool init();
57 
58 
59  signals:
68  void message(QString text, bool CR=true, bool sayIt=false, bool addTimestamp=true);
69 
73  void checkNetworkState();
74 
78  void networkMessage();
79 
80 
81  private:
82  QTime startTime;
83  QTime now;
84  volatile bool stopped;
85 
87  static const int timeToNetworkCheck = 3; // time in seconds
88 
89  // Every thread sleeps some time, for having a bit more time fo the other threads!
90  // Time in milliseconds
91  static const unsigned long THREADSLEEPTIME = 1000; // 1000 ms
92 
93 };
94 
95 #endif