/**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtAddOn.JsonStream module of the Qt. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qtimeoutidledelegate.h" QT_BEGIN_NAMESPACE_PROCESSMANAGER const int kIdleTimerInterval = 1000; /*! \class QTimeoutIdleDelegate \brief The QTimeoutIdleDelegate class generates a periodic timeout. \inmodule QtProcessManager The QTimeoutIdleDelegate class generates a periodic timeout for creation of idle resources. This is not an intelligent class - it doesn't matter what your CPU is doing, it will still generate the periodic timeout. */ /*! \property QTimeoutIdleDelegate::idleInterval \brief Time in milliseconds before a new idle CPU request will be fulfilled */ /*! Construct a QTimeoutIdleDelegate with an optional \a parent. */ QTimeoutIdleDelegate::QTimeoutIdleDelegate(QObject *parent) : QIdleDelegate(parent) { connect(&m_timer, SIGNAL(timeout()), SIGNAL(idleCpuAvailable())); m_timer.setInterval(kIdleTimerInterval); } /*! Turn on or off idle requests based on \a state */ void QTimeoutIdleDelegate::handleStateChange(bool state) { if (state) m_timer.start(); else m_timer.stop(); } /*! Return the current launch interval in milliseconds */ int QTimeoutIdleDelegate::idleInterval() const { return m_timer.interval(); } /*! Set the current idle interval to \a interval milliseconds */ void QTimeoutIdleDelegate::setIdleInterval(int interval) { if (m_timer.interval() != interval) { m_timer.stop(); m_timer.setInterval(interval); if (requested() && enabled()) m_timer.start(); emit idleIntervalChanged(); } } /*! \fn void QTimeoutIdleDelegate::idleIntervalChanged() This signal is emitted when the idleInterval is changed. */ #include "moc_qtimeoutidledelegate.cpp" QT_END_NAMESPACE_PROCESSMANAGER