Qt 4.8
Public Slots | Signals | Public Functions | Protected Functions | Private Functions | List of all members
QFutureWatcherBase Class Referenceabstract

#include <qfuturewatcher.h>

Inheritance diagram for QFutureWatcherBase:
QObject QFutureWatcher< T >

Public Slots

void cancel ()
 
void pause ()
 
void resume ()
 
void setPaused (bool paused)
 
void togglePaused ()
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void canceled ()
 
void finished ()
 
void paused ()
 
void progressRangeChanged (int minimum, int maximum)
 
void progressTextChanged (const QString &progressText)
 
void progressValueChanged (int progressValue)
 
void resultReadyAt (int resultIndex)
 
void resultsReadyAt (int beginIndex, int endIndex)
 
void resumed ()
 
void started ()
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
bool isCanceled () const
 
bool isFinished () const
 
bool isPaused () const
 
bool isRunning () const
 
bool isStarted () const
 
int progressMaximum () const
 
int progressMinimum () const
 
QString progressText () const
 
int progressValue () const
 
 QFutureWatcherBase (QObject *parent=0)
 
void setPendingResultsLimit (int limit)
 
void waitForFinished ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
void connectOutputInterface ()
 
void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
void disconnectOutputInterface (bool pendingAssignment=false)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Private Functions

virtual const QFutureInterfaceBasefutureInterface () const =0
 
virtual QFutureInterfaceBasefutureInterface ()=0
 

Additional Inherited Members

- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 62 of file qfuturewatcher.h.

Constructors and Destructors

◆ QFutureWatcherBase()

QFutureWatcherBase::QFutureWatcherBase ( QObject parent = 0)

Definition at line 109 of file qfuturewatcher.cpp.

110  :QObject(*new QFutureWatcherBasePrivate, parent)
111 { }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

Functions

◆ cancel

void QFutureWatcherBase::cancel ( )
slot

Definition at line 141 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

142 {
144 }
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ canceled

void QFutureWatcherBase::canceled ( )
signal

◆ connectNotify()

void QFutureWatcherBase::connectNotify ( const char *  signal)
protectedvirtual

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, use QLatin1String and the SIGNAL() macro as follows:

if (QLatin1String(signal) == SIGNAL(valueChanged(int))) {
// signal is valueChanged(int)
}

If the signal contains multiple parameters or parameters that contain spaces, call QMetaObject::normalizedSignature() on the result of the SIGNAL() macro.

Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.
See also
connect(), disconnectNotify()

Reimplemented from QObject.

Definition at line 411 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

412 {
414  if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0)
415  d->resultAtConnected.ref();
416 #ifndef QT_NO_DEBUG
417  if (qstrcmp(signal, SIGNAL(finished())) == 0) {
418  if (futureInterface().isRunning()) {
419  //connections should be established before calling stFuture to avoid race.
420  // (The future could finish before the connection is made.)
421  qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race");
422  }
423  }
424 #endif
425 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
Q_CORE_EXPORT void qWarning(const char *,...)
void resultReadyAt(int resultIndex)
virtual const QFutureInterfaceBase & futureInterface() const =0
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336
bool isRunning() const

◆ connectOutputInterface()

void QFutureWatcherBase::connectOutputInterface ( )
protected
Warning
This function is not part of the public interface.

Definition at line 445 of file qfuturewatcher.cpp.

446 {
448 }
QFutureInterfaceBasePrivate * d
void connectOutputInterface(QFutureCallOutInterface *iface)
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ disconnectNotify()

void QFutureWatcherBase::disconnectNotify ( const char *  signal)
protectedvirtual

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

Warning
This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.
See also
disconnect(), connectNotify()

Reimplemented from QObject.

Definition at line 427 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

428 {
430  if (qstrcmp(signal, SIGNAL(resultReadyAt(int))) == 0)
431  d->resultAtConnected.deref();
432 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void resultReadyAt(int resultIndex)
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336

◆ disconnectOutputInterface()

void QFutureWatcherBase::disconnectOutputInterface ( bool  pendingAssignment = false)
protected
Warning
This function is not part of the public interface.

Definition at line 453 of file qfuturewatcher.cpp.

454 {
455  if (pendingAssignment) {
457  d->pendingResultsReady = 0;
458  qDeleteAll(d->pendingCallOutEvents);
459  d->pendingCallOutEvents.clear();
460  d->finished = false;
461  }
462 
464 }
double d
Definition: qnumeric_p.h:62
QFutureInterfaceBasePrivate * d
#define Q_D(Class)
Definition: qglobal.h:2482
void disconnectOutputInterface(QFutureCallOutInterface *iface)
virtual const QFutureInterfaceBase & futureInterface() const =0
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ event()

bool QFutureWatcherBase::event ( QEvent e)
virtual

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented from QObject.

Definition at line 376 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

377 {
379  if (event->type() == QEvent::FutureCallOut) {
380  QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event);
381 
382  if (futureInterface().isPaused()) {
383  d->pendingCallOutEvents.append(callOutEvent->clone());
384  return true;
385  }
386 
387  if (callOutEvent->callOutType == QFutureCallOutEvent::Resumed
388  && !d->pendingCallOutEvents.isEmpty()) {
389  // send the resume
390  d->sendCallOutEvent(callOutEvent);
391 
392  // next send all pending call outs
393  for (int i = 0; i < d->pendingCallOutEvents.count(); ++i)
394  d->sendCallOutEvent(d->pendingCallOutEvents.at(i));
395  qDeleteAll(d->pendingCallOutEvents);
396  d->pendingCallOutEvents.clear();
397  } else {
398  d->sendCallOutEvent(callOutEvent);
399  }
400  return true;
401  }
402  return QObject::event(event);
403 }
double d
Definition: qnumeric_p.h:62
QFutureCallOutEvent * clone() const
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
#define Q_D(Class)
Definition: qglobal.h:2482
bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
virtual const QFutureInterfaceBase & futureInterface() const =0
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ finished

void QFutureWatcherBase::finished ( )
signal

Referenced by connectNotify().

◆ futureInterface() [1/2]

virtual const QFutureInterfaceBase& QFutureWatcherBase::futureInterface ( ) const
privatepure virtual

◆ futureInterface() [2/2]

virtual QFutureInterfaceBase& QFutureWatcherBase::futureInterface ( )
privatepure virtual

Implemented in QFutureWatcher< T >.

◆ isCanceled()

bool QFutureWatcherBase::isCanceled ( ) const

Definition at line 328 of file qfuturewatcher.cpp.

329 {
331 }
bool queryState(State state) const
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ isFinished()

bool QFutureWatcherBase::isFinished ( ) const

Definition at line 298 of file qfuturewatcher.cpp.

299 {
300  Q_D(const QFutureWatcherBase);
301  return d->finished;
302 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ isPaused()

bool QFutureWatcherBase::isPaused ( ) const

Definition at line 346 of file qfuturewatcher.cpp.

347 {
349 }
bool queryState(State state) const
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ isRunning()

bool QFutureWatcherBase::isRunning ( ) const

Definition at line 312 of file qfuturewatcher.cpp.

Referenced by connectNotify().

313 {
315 }
bool queryState(State state) const
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ isStarted()

bool QFutureWatcherBase::isStarted ( ) const

Definition at line 285 of file qfuturewatcher.cpp.

286 {
288 }
bool queryState(State state) const
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ pause

void QFutureWatcherBase::pause ( )
slot

Definition at line 181 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

182 {
183  futureInterface().setPaused(true);
184 }
void setPaused(bool paused)
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ paused

void QFutureWatcherBase::paused ( )
signal

◆ progressMaximum()

int QFutureWatcherBase::progressMaximum ( ) const

Definition at line 256 of file qfuturewatcher.cpp.

257 {
258  return futureInterface().progressMaximum();
259 }
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ progressMinimum()

int QFutureWatcherBase::progressMinimum ( ) const

Definition at line 242 of file qfuturewatcher.cpp.

243 {
244  return futureInterface().progressMinimum();
245 }
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ progressRangeChanged

void QFutureWatcherBase::progressRangeChanged ( int  minimum,
int  maximum 
)
signal

◆ progressText()

QString QFutureWatcherBase::progressText ( ) const

Definition at line 272 of file qfuturewatcher.cpp.

273 {
274  return futureInterface().progressText();
275 }
QString progressText() const
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ progressTextChanged

void QFutureWatcherBase::progressTextChanged ( const QString progressText)
signal

◆ progressValue()

int QFutureWatcherBase::progressValue ( ) const

Definition at line 228 of file qfuturewatcher.cpp.

229 {
230  return futureInterface().progressValue();
231 }
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ progressValueChanged

void QFutureWatcherBase::progressValueChanged ( int  progressValue)
signal

◆ resultReadyAt

void QFutureWatcherBase::resultReadyAt ( int  resultIndex)
signal

Referenced by connectNotify(), and disconnectNotify().

◆ resultsReadyAt

void QFutureWatcherBase::resultsReadyAt ( int  beginIndex,
int  endIndex 
)
signal

◆ resume

void QFutureWatcherBase::resume ( )
slot

Definition at line 196 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

197 {
198  futureInterface().setPaused(false);
199 }
void setPaused(bool paused)
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ resumed

void QFutureWatcherBase::resumed ( )
signal

◆ setPaused

void QFutureWatcherBase::setPaused ( bool  paused)
slot

Definition at line 166 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

167 {
169 }
void setPaused(bool paused)
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ setPendingResultsLimit()

void QFutureWatcherBase::setPendingResultsLimit ( int  limit)

Definition at line 405 of file qfuturewatcher.cpp.

406 {
408  d->maximumPendingResultsReady = limit;
409 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ started

void QFutureWatcherBase::started ( )
signal

◆ togglePaused

void QFutureWatcherBase::togglePaused ( )
slot

Definition at line 213 of file qfuturewatcher.cpp.

Referenced by QFutureWatcherBasePrivate::sendCallOutEvent().

214 {
216 }
virtual const QFutureInterfaceBase & futureInterface() const =0

◆ waitForFinished()

void QFutureWatcherBase::waitForFinished ( )

Definition at line 359 of file qfuturewatcher.cpp.

360 {
362 }
virtual const QFutureInterfaceBase & futureInterface() const =0

The documentation for this class was generated from the following files: