]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/qtTimeout.C
enable Font cache only for MacOSX and inline width() for other platform.
[lyx.git] / src / frontends / qt4 / 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 <QTimerEvent>
16
17 #include "debug.h"
18
19
20 Timeout::Timeout(unsigned int msec, Type t)
21         : pimpl_(new qtTimeout(*this)), type(t), timeout_ms(msec)
22 {}
23
24
25 qtTimeout::qtTimeout(Timeout & owner)
26         : Timeout::Impl(owner), timeout_id(-1)
27 {}
28
29
30 void qtTimeout::timerEvent(QTimerEvent *)
31 {
32         emit();
33 }
34
35
36 void qtTimeout::reset()
37 {
38         if (timeout_id != -1)
39                 killTimer(timeout_id);
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 }