Gui::SequencerBar Class Reference

FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples: More...

#include <ProgressBar.h>

Public Member Functions

virtual void checkAbort () override
 Check if the operation is aborted by user. More...
 
QProgressBargetProgressBar (QWidget *parent=nullptr)
 Returns an instance of the progress bar. More...
 
bool isBlocking () const override
 Returns true if the running sequencer is blocking any user input. More...
 
void pause () override
 This restores the last overridden cursor and release the keyboard while the progress bar is running. More...
 
void resume () override
 This sets the wait cursor again and grabs the keyboard. More...
 
- Public Member Functions inherited from Base::SequencerBase
virtual void checkAbort ()
 Check if the operation is aborted by user. More...
 
virtual bool isBlocking () const
 Returns true if the running sequencer is blocking any user input. More...
 
bool isLocked () const
 Returns true if the sequencer was locked, false otherwise. More...
 
bool isRunning () const
 Returns true if the sequencer is running, otherwise returns false. More...
 
bool setLocked (bool bLock)
 If bLock is true then the sequencer gets locked. More...
 
bool wasCanceled () const
 Returns true if the pending operation was canceled. More...
 

Static Public Member Functions

static SequencerBarinstance ()
 Returns the sequencer object. More...
 
- Static Public Member Functions inherited from Base::SequencerBase
static SequencerBaseInstance ()
 Returns the last created sequencer instance. More...
 

Protected Member Functions

void nextStep (bool canAbort) override
 Increase the progress bar. More...
 
void resetData () override
 Resets the sequencer. More...
 
 SequencerBar ()
 Construction. More...
 
void setProgress (size_t) override
 Sets the progress indicator to a certain position. More...
 
void setText (const char *pszTxt) override
 Puts text to the status bar. More...
 
void showRemainingTime ()
 
void startStep () override
 Starts the progress bar. More...
 
 ~SequencerBar ()
 Destruction. More...
 
- Protected Member Functions inherited from Base::SequencerBase
bool next (bool canAbort=false)
 Performs the next step and returns true if the operation is not yet finished. More...
 
virtual void nextStep (bool canAbort)
 This method can be reimplemented in sub-classes to give the user a feedback when the next is performed. More...
 
size_t numberOfSteps () const
 Returns the number of steps. More...
 
SequencerBaseoperator= (const SequencerBase &)=default
 
virtual void pause ()
 Breaks the sequencer if needed. More...
 
int progressInPercent () const
 Returns the current state of progress in percent. More...
 
void rejectCancel ()
 If you tried to cancel but then decided to continue the operation. More...
 
virtual void resetData ()
 Resets internal data. More...
 
virtual void resume ()
 Continues with progress. More...
 
 SequencerBase ()
 construction More...
 
 SequencerBase (const SequencerBase &)=default
 
virtual void setProgress (size_t)
 Sets the progress indicator to a certain position. More...
 
virtual void setText (const char *pszTxt)
 Sets a text what the pending operation is doing. More...
 
bool start (const char *pszStr, size_t steps)
 Starts a new operation, returns false if there is already a pending operation, otherwise it returns true. More...
 
virtual void startStep ()
 This method can be reimplemented in sub-classes to give the user a feedback when a new sequence starts. More...
 
bool stop ()
 Stops the sequencer if all operations are finished. More...
 
void tryToCancel ()
 Try to cancel the pending operation(s). More...
 
virtual ~SequencerBase ()
 Destruction. More...
 

for internal use only

class ProgressBar
 

Additional Inherited Members

- Protected Attributes inherited from Base::SequencerBase
size_t nProgress
 Stores the current amount of progress. More...
 
size_t nTotalSteps
 Stores the total number of steps. More...
 

Detailed Description

FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples:

unsigned long steps = ...
Base::SequencerLauncher seq("Starting progress bar", 0);
for (unsigned long i=0; i<steps;i++)
{
seq.next();
// do one step of your algorithm
}

The example below shows how to use two nested progresses.

void function1()
{
unsigned long steps = ...
Base::SequencerLauncger seq("Starting progress bar", 0);
for (unsigned long i=0; i<steps;i++)
{
seq.next();
// do one step of your algorithm
}
}
void function2()
{
unsigned long steps = ...
Base::SequencerLauncher seq("Starting progress bar", 0);
for (unsigned long i=0; i<steps;i++)
{
seq.next();
// do one step of your algorithm calling function1
function1();
}
}

If the total number of steps cannot be determined before, use 0 instead of to show just a busy indicator instead of percentage steps.

Author
Werner Mayer

Constructor & Destructor Documentation

◆ SequencerBar()

SequencerBar::SequencerBar ( )
protected

◆ ~SequencerBar()

SequencerBar::~SequencerBar ( )
protected

Destruction.

Member Function Documentation

◆ checkAbort()

void SequencerBar::checkAbort ( )
overridevirtual

◆ getProgressBar()

QProgressBar * SequencerBar::getProgressBar ( QWidget parent = nullptr)

Returns an instance of the progress bar.

It creates one if needed.

References Gui::SequencerBarPrivate::bar, and ProgressBar.

Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().

◆ instance()

SequencerBar * SequencerBar::instance ( void  )
static

◆ isBlocking()

bool SequencerBar::isBlocking ( ) const
overridevirtual

Returns true if the running sequencer is blocking any user input.

This might be only of interest of the GUI where the progress bar or dialog is used from a thread. If started from a thread this method should return false, otherwise true. The default implementation always returns true.

Reimplemented from Base::SequencerBase.

References Gui::SequencerBarPrivate::guiThread.

◆ nextStep()

void SequencerBar::nextStep ( bool  canAbort)
overrideprotectedvirtual

◆ pause()

void SequencerBar::pause ( )
overridevirtual

This restores the last overridden cursor and release the keyboard while the progress bar is running.

This is useful e.g. if a modal dialog appears while a long operation is performed to indicate that the user can click on the dialog. Every pause() must eventually be followed by a corresponding resume().

Reimplemented from Base::SequencerBase.

References Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::guiThread, Gui::WaitCursor::restoreCursor(), and Gui::SequencerBarPrivate::waitCursor.

Referenced by checkAbort(), and nextStep().

◆ resetData()

◆ resume()

void SequencerBar::resume ( )
overridevirtual

This sets the wait cursor again and grabs the keyboard.

See also
pause()

Reimplemented from Base::SequencerBase.

References Gui::SequencerBarPrivate::bar, Gui::SequencerBarPrivate::guiThread, Gui::WaitCursor::setWaitCursor(), and Gui::SequencerBarPrivate::waitCursor.

Referenced by checkAbort(), and nextStep().

◆ setProgress()

void SequencerBar::setProgress ( size_t  step)
overrideprotectedvirtual

Sets the progress indicator to a certain position.

Reimplemented from Base::SequencerBase.

References Gui::SequencerBarPrivate::bar.

◆ setText()

void SequencerBar::setText ( const char *  pszTxt)
overrideprotectedvirtual

◆ showRemainingTime()

◆ startStep()

Friends And Related Function Documentation

◆ ProgressBar

friend class ProgressBar
friend

Referenced by getProgressBar().


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