Cute Chess  0.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
Worker Class Referenceabstract

#include <worker.h>

Inheritance diagram for Worker:
QObject PgnImporter

Public Slots

void cancel ()
 

Signals

void cancelled ()
 
void error (int error)
 
void finished ()
 
void progressChanged (int value)
 
void started ()
 
void statusChanged (const QString &statusMessage)
 

Public Member Functions

void run () override
 
QTime startTime () const
 
QString title () const
 
 Worker (const QString &title)
 
virtual ~Worker ()
 

Protected Member Functions

bool cancelRequested () const
 
virtual void work ()=0
 

Detailed Description

An abstraction of a long-running task.

Constructor & Destructor Documentation

Worker::Worker ( const QString title)
explicit

Creates a new Worker object with the given title.

The title describes the purpose of this Worker so that it can be identified.

Worker::~Worker ( )
virtual

Destructs the Worker object.

Member Function Documentation

void Worker::cancel ( )
slot

Request cancellation of the worker.

After this slot has been called the worker should try to cancel its tasks as quickly as possible. The finished() signal is called after the cancellation is complete.

void Worker::cancelled ( )
signal

Emitted if the user requested to cancel the worker.

This signal is emitted automatically just before the finished() signal and should not manually emitted.

bool Worker::cancelRequested ( ) const
protected

Returns true if the user requested cancellation of the task with the cancel() slot.

void Worker::error ( int  error)
signal

Signals that an error error has occured during the execution of the task. The meaning of error depends on the implementation.

void Worker::finished ( )
signal

Emitted after the worker has finished its tasks.

This signal is automatically emitted and should not manually emitted.

void Worker::progressChanged ( int  value)
signal

Emitted when the worker has made progress.

The value should be in the range 0 - 100.

void Worker::started ( )
signal

Emitted after the worker has been started but before any tasks are performed.

This signal is emitted automatically should not manually emitted.

QTime Worker::startTime ( ) const

Returns the time when the worker was started.

void Worker::statusChanged ( const QString statusMessage)
signal

Emitted in when the status of the worker has changed.

The purpose of this signal is to give a textual description on what tasks are currently performed.

In case of an error this signal can be used to give a textual description of the error.

QString Worker::title ( ) const

Returns the title of the worker.

virtual void Worker::work ( )
protectedpure virtual

Perform the long running task.

Periodically check for cancelRequested() to see if the work should be cancelled.

Optionally emit the progressChanged and statusChanged to reflect the current status of the work.

If any error occurs emit the error() and statusChanged() signals and return from the function.

Implemented in PgnImporter.


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