KoProgressUpdater Class Reference

Allow multiple subtasks to safely update and report progress. More...

#include <KoProgressUpdater.h>

List of all members.

Public Member Functions

 KoProgressUpdater (KoProgressProxy *progressBar)
 Constructor.
virtual ~KoProgressUpdater ()
 destructor
void start (int range=100, const QString &text="%p%")
 Start a new task.
KoUpdater startSubtask (int weight=1)
 After calling start() you can create any number of Updaters, one for each subtask.
void cancel ()
 Cancelling the action will make each subtask be marked as 'interrupted' and set the total progress to 100%.

Protected Member Functions

void scheduleUpdate ()

Friends

class KoProgressUpdaterPrivate


Detailed Description

Allow multiple subtasks to safely update and report progress.

This class is able to update a progress bar with the total progress of a project that may be separated into different subtasks. Each subtask will use one KoUpdater which that subtask can then report progress to. Each KoUpdater.setProgress() call will automatically calculate the total progress over the whole tasks made and update the progress bar with the total progress so far.

This class is created specifically with threading in mind so that subtasks can report their progress from their personal subthread and the progress bar will be updated correctly and not more often then repaints can return.

Typical usage can be:

  KoProgressUpdater *pu = new KoProgressUpdater(myProgressBar);
  pu->start(100);
  // create the subtasks
  KoUpdater smooth = pu->startSubtask(5);
  KoUpdater scale = pu->startSubtask(5);
  KoUpdater cleanup = pu->startSubtask(1);
Doing an smooth.setProgress(50) will move the progress bar to 50% of the share of task 'smooth' which is 5 / 11 of the total and thus to 22.


Constructor & Destructor Documentation

KoProgressUpdater::KoProgressUpdater ( KoProgressProxy progressBar  ) 

Constructor.

Parameters:
progressBar the progress bar to update.


Member Function Documentation

void KoProgressUpdater::start ( int  range = 100,
const QString &  text = "%p%" 
)

Start a new task.

This will invalidate any previously created subtasks and set the range of the progressBar as well as the text in the progressbar.

Parameters:
range the total range of progress bar makes.
text The text to show in the progressBar.
See also:
KoProgressProxy::setRange()

KoProgressProxy::setFormat()

KoUpdater KoProgressUpdater::startSubtask ( int  weight = 1  ) 

After calling start() you can create any number of Updaters, one for each subtask.

Parameters:
weight use a weight to specify the weight this subtask has compared to the rest of the subtasks.


The documentation for this class was generated from the following files:
Generated on Sun May 11 22:36:11 2008 for libs by  doxygen 1.4.7