KWallet

ktimeout.cpp
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2003 George Staikos <staikos@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "ktimeout.h"
9#include <QTimerEvent>
10
11KTimeout::KTimeout(QObject *parent)
12 : QObject(parent)
13{
14}
15
16KTimeout::~KTimeout()
17{
18}
19
20void KTimeout::clear()
21{
22 for (int timerId : std::as_const(_timers)) {
23 killTimer(timerId);
24 }
25 _timers.clear();
26}
27
28void KTimeout::removeTimer(int id)
29{
30 const int timerId = _timers.value(id, 0);
31 if (timerId != 0) {
32 killTimer(timerId);
33 }
34 _timers.remove(id);
35}
36
37void KTimeout::addTimer(int id, int timeout)
38{
39 if (_timers.contains(id)) {
40 return;
41 }
42 _timers.insert(id, startTimer(timeout));
43}
44
45void KTimeout::resetTimer(int id, int timeout)
46{
47 int timerId = _timers.value(id, 0);
48 if (timerId != 0) {
49 killTimer(timerId);
50 _timers.insert(id, startTimer(timeout));
51 }
52}
53
54void KTimeout::timerEvent(QTimerEvent *ev)
55{
57 for (; it != _timers.constEnd(); ++it) {
58 if (it.value() == ev->timerId()) {
59 Q_EMIT timedOut(it.key());
60 return;
61 }
62 }
63}
64
65#include "moc_ktimeout.cpp"
void clear()
const_iterator constBegin() const const
const_iterator constEnd() const const
bool contains(const Key &key) const const
iterator insert(const Key &key, const T &value)
bool remove(const Key &key)
T value(const Key &key) const const
Q_EMITQ_EMIT
void killTimer(int id)
int startTimer(int interval, Qt::TimerType timerType)
int timerId() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.