]> git.lyx.org Git - features.git/blob - src/frontends/qt3/qtTimeout.C
This is the merging of the GUI API cleanup branch that was developed in svn+ssh:...
[features.git] / src / frontends / qt3 / qtTimeout.C
1 /**
2  * \file qtTimeout.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "qtTimeout.h"
14
15 #include "debug.h"
16
17 // stupid Qt
18 #undef emit
19
20
21 Timeout::Timeout(unsigned int msec, Type t)
22         : pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec)
23 {}
24
25
26 qtTimeout::qtTimeout(Timeout & owner)
27         : Timeout::Impl(owner), timeout_id(-1)
28 {}
29
30
31 void qtTimeout::timerEvent(QTimerEvent *)
32 {
33         emit();
34 }
35
36
37 void qtTimeout::reset()
38 {
39         killTimers();
40         timeout_id = -1;
41 }
42
43
44 bool qtTimeout::running() const
45 {
46         return timeout_id != -1;
47 }
48
49
50 void qtTimeout::start()
51 {
52         if (running())
53                 lyxerr << "Timeout::start: already running!" << std::endl;
54         timeout_id = startTimer(timeout_ms());
55 }
56
57
58 void qtTimeout::stop()
59 {
60         if (running())
61                 reset();
62 }