# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# ktimeout.cpp

    00001 /*
    00002    This file is part of the KDE libraries
    00003
    00004    Copyright (c) 2003 George Staikos <staikos@kde.org>
    00005
    00006    This library is free software; you can redistribute it and/or
    00007    modify it under the terms of the GNU Library General Public
    00008    License as published by the Free Software Foundation; either
    00009    version 2 of the License, or (at your option) any later version.
    00010
    00011    This library is distributed in the hope that it will be useful,
    00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014    Library General Public License for more details.
    00015
    00016    You should have received a copy of the GNU Library General Public License
    00017    along with this library; see the file COPYING.LIB.  If not, write to
    00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019    Boston, MA 02111-1307, USA.
    00020
    00021 */
    00022
    00023 #include "ktimeout.h"
    00024
    00025 KTimeout::KTimeout(int size)
    00026 : QObject(), _timers(size) {
    00027     _timers.setAutoDelete(true);
    00028 }
    00029
    00030
    00031 KTimeout::~KTimeout() {
    00032     clear();
    00033 }
    00034
    00035
    00036 void KTimeout::clear() {
    00037     _timers.clear();
    00038 }
    00039
    00040
    00041 void KTimeout::removeTimer(int id) {
    00042     QTimer *t = _timers.find(id);
    00043     if (t != 0L) {
    00044         _timers.remove(id); // autodeletes
    00045     }
    00046 }
    00047
    00048
    00049 void KTimeout::addTimer(int id, int timeout) {
    00050     if (_timers.find(id) != 0L) {
    00051         return;
    00052     }
    00053
    00054     QTimer *t = new QTimer;
    00055     connect(t, SIGNAL(timeout()), this, SLOT(timeout()));
    00056     t->start(timeout);
    00057     _timers.insert(id, t);
    00058 }
    00059
    00060
    00061 void KTimeout::resetTimer(int id, int timeout) {
    00062     QTimer *t = _timers.find(id);
    00063     if (t) {
    00064         t->changeInterval(timeout);
    00065     }
    00066 }
    00067
    00068
    00069 void KTimeout::timeout() {
    00070     const QTimer *t = static_cast<const QTimer*>(sender());
    00071     if (t) {
    00072         QIntDictIterator<QTimer> it(_timers);
    00073         for (; it.current(); ++it) {
    00074             if (it.current() == t) {
    00075                 emit timedOut(it.currentKey());
    00076                 return;
    00077             }
    00078         }
    00079     }
    00080 }
    00081
    00082
    00083 #include "ktimeout.moc"
    00084

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:04 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003