bool QFutureWatcherBase::event(QEvent *event) { Q_D(QFutureWatcherBase); if (event->type() == QEvent::FutureCallOut) { QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event); if (futureInterface().isPaused()) { d->pendingCallOutEvents.append(callOutEvent->clone()); return true; } if (callOutEvent->callOutType == QFutureCallOutEvent::Resumed && !d->pendingCallOutEvents.isEmpty()) { // send the resume d->sendCallOutEvent(callOutEvent); // next send all pending call outs for (int i = 0; i < d->pendingCallOutEvents.count(); ++i) d->sendCallOutEvent(d->pendingCallOutEvents.at(i)); qDeleteAll(d->pendingCallOutEvents); d->pendingCallOutEvents.clear(); } else { d->sendCallOutEvent(callOutEvent); } return true; } return QObject::event(event); }
/*! \internal */ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment) { if (pendingAssignment) { Q_D(QFutureWatcherBase); d->pendingResultsReady = 0; qDeleteAll(d->pendingCallOutEvents); d->pendingCallOutEvents.clear(); d->finished = false; } futureInterface().d->disconnectOutputInterface(d_func()); }
void QFutureWatcherBase::connectNotify(const char * signal) { Q_D(QFutureWatcherBase); if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0) d->resultAtConnected.ref(); #ifndef QT_NO_DEBUG if (qstrcmp(signal, SIGNAL(finished())) == 0) { if (futureInterface().isRunning()) { //connections should be established before calling stFuture to avoid race. // (The future could finish before the connection is made.) qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); } } #endif }
void QFutureWatcherBase::connectNotify(const QMetaMethod &signal) { Q_D(QFutureWatcherBase); static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt); if (signal == resultReadyAtSignal) d->resultAtConnected.ref(); #ifndef QT_NO_DEBUG static const QMetaMethod finishedSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::finished); if (signal == finishedSignal) { if (futureInterface().isRunning()) { //connections should be established before calling stFuture to avoid race. // (The future could finish before the connection is made.) qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); } } #endif }
/*! \internal */ void QFutureWatcherBase::connectOutputInterface() { futureInterface().d->connectOutputInterface(d_func()); }
/*! \fn int QFutureWatcher::progressMaximum() const Returns the maximum progressValue(). \sa progressValue(), progressMinimum() */ int QFutureWatcherBase::progressMaximum() const { return futureInterface().progressMaximum(); }
/*! \fn void QFutureWatcher::waitForFinished() Waits for the asynchronous computation to finish (including cancel()ed computations). */ void QFutureWatcherBase::waitForFinished() { futureInterface().waitForFinished(); }
/*! \fn void QFutureWatcher::cancel() Cancels the asynchronous computation represented by the future(). Note that the cancelation is asynchronous. Use waitForFinished() after calling cancel() when you need synchronous cancelation. Currently available results may still be accessed on a canceled QFuture, but new results will \e not become available after calling this function. Also, this QFutureWatcher will not deliver progress and result ready signals once canceled. This includes the progressValueChanged(), progressRangeChanged(), progressTextChanged(), resultReadyAt(), and resultsReadyAt() signals. Be aware that not all asynchronous computations can be canceled. For example, the QFuture returned by QtConcurrent::run() cannot be canceled; but the QFuture returned by QtConcurrent::mappedReduced() can. */ void QFutureWatcherBase::cancel() { futureInterface().cancel(); }
/*! \fn bool QFutureWatcher::isCanceled() const Returns true if the asynchronous computation has been canceled with the cancel() function; otherwise returns false. Be aware that the computation may still be running even though this function returns true. See cancel() for more details. */ bool QFutureWatcherBase::isCanceled() const { return futureInterface().queryState(QFutureInterfaceBase::Canceled); }
/*! \fn bool QFutureWatcher::isPaused() const Returns true if the asynchronous computation has been paused with the pause() function; otherwise returns false. Be aware that the computation may still be running even though this function returns true. See setPaused() for more details. \sa setPaused(), togglePaused() */ bool QFutureWatcherBase::isPaused() const { return futureInterface().queryState(QFutureInterfaceBase::Paused); }
/*! \fn QString QFutureWatcher::progressText() const Returns the (optional) textual representation of the progress as reported by the asynchronous computation. Be aware that not all computations provide a textual representation of the progress, and as such, this function may return an empty string. */ QString QFutureWatcherBase::progressText() const { return futureInterface().progressText(); }
/*! \fn bool QFutureWatcher::isRunning() const Returns true if the asynchronous computation represented by the future() is currently running; otherwise returns false. */ bool QFutureWatcherBase::isRunning() const { return futureInterface().queryState(QFutureInterfaceBase::Running); }
/*! \fn void QFutureWatcher::setPaused(bool paused) If \a paused is true, this function pauses the asynchronous computation represented by the future(). If the computation is already paused, this function does nothing. This QFutureWatcher will stop delivering progress and result ready signals while the future is paused. Signal delivery will continue once the computation is resumed. If \a paused is false, this function resumes the asynchronous computation. If the computation was not previously paused, this function does nothing. Be aware that not all computations can be paused. For example, the QFuture returned by QtConcurrent::run() cannot be paused; but the QFuture returned by QtConcurrent::mappedReduced() can. \sa pause(), resume(), togglePaused() */ void QFutureWatcherBase::setPaused(bool paused) { futureInterface().setPaused(paused); }
/*! \fn int QFutureWatcher::progressValue() const Returns the current progress value, which is between the progressMinimum() and progressMaximum(). \sa progressMinimum(), progressMaximum() */ int QFutureWatcherBase::progressValue() const { return futureInterface().progressValue(); }
/*! \fn void QFutureWatcher::togglePaused() Toggles the paused state of the asynchronous computation. In other words, if the computation is currently paused, calling this function resumes it; if the computation is running, it becomes paused. This is a convenience method for calling setPaused(!isPaused()). \sa setPaused(), pause(), resume() */ void QFutureWatcherBase::togglePaused() { futureInterface().togglePaused(); }
/*! \fn void QFutureWatcher::resume() Resumes the asynchronous computation represented by the future(). This is a convenience method that simply calls setPaused(false). \sa pause() */ void QFutureWatcherBase::resume() { futureInterface().setPaused(false); }
/*! \fn void QFutureWatcher::pause() Pauses the asynchronous computation represented by the future(). This is a convenience method that simply calls setPaused(true). \sa resume() */ void QFutureWatcherBase::pause() { futureInterface().setPaused(true); }