3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include <QTimerEvent>
23 * This class executes the callback when the timeout expires
26 class Timeout::Impl : QObject {
29 Impl(Timeout & owner) : owner_(owner), timeout_id(-1) {}
31 bool running() const { return timeout_id != -1; }
39 unsigned int timeout_ms() const { return owner_.timeout_ms; }
43 void timerEvent(QTimerEvent *) { owner_.emit(); }
53 void Timeout::Impl::reset()
56 killTimer(timeout_id);
61 void Timeout::Impl::start()
64 lyxerr << "Timeout::start: already running!" << std::endl;
65 timeout_id = startTimer(timeout_ms());
69 void Timeout::Impl::stop()
80 Timeout::Timeout(unsigned int msec, Type t)
81 : pimpl_(new Impl(*this)), type(t), timeout_ms(msec)
92 bool Timeout::running() const
94 return pimpl_->running();
110 void Timeout::restart()
121 if (type == CONTINUOUS)
126 Timeout & Timeout::setType(Type t)
133 Timeout & Timeout::setTimeout(unsigned int msec)
135 // Can't have a timeout of zero!