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 | |
QProgressBar * | getProgressBar (QWidget *parent=0) |
Returns an instance of the progress bar. | |
bool | isBlocking () const |
Returns true if the running sequencer is blocking any user input. | |
void | pause () |
This restores the last overridden cursor and release the keyboard while the progress bar is running. | |
void | resume () |
This sets the wait cursor again and grabs the keyboard. | |
Static Public Member Functions | |
static Sequencer * | instance () |
Returns the sequencer object. | |
Protected Member Functions | |
void | nextStep (bool canAbort) |
Increase the progress bar. | |
void | resetData () |
Resets the sequencer. | |
Sequencer () | |
Construction. | |
void | setProgress (size_t) |
Sets the progress indicator to a certain position. | |
void | setText (const char *pszTxt) |
Puts text to the status bar. | |
void | showRemainingTime () |
void | startStep () |
Starts the progress bar. | |
~Sequencer () | |
Destruction. | |
Friends | |
class | ProgressBar |
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.
Definition at line 88 of file ProgressBar.h.
Sequencer::Sequencer | ( | ) | [protected] |
Construction.
Definition at line 89 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::SequencerPrivate::guiThread, and Gui::SequencerPrivate::waitCursor.
Referenced by instance().
Sequencer::~Sequencer | ( | ) | [protected] |
Destruction.
Definition at line 97 of file ProgressBar.cpp.
QProgressBar * Sequencer::getProgressBar | ( | QWidget * | parent = 0 |
) |
Returns an instance of the progress bar.
It creates one if needed.
Definition at line 325 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, and ProgressBar.
Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().
Sequencer * Sequencer::instance | ( | void | ) | [static] |
Returns the sequencer object.
Definition at line 78 of file ProgressBar.cpp.
References Sequencer().
Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().
bool Sequencer::isBlocking | ( | ) | const [virtual] |
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.
Definition at line 320 of file ProgressBar.cpp.
References Gui::SequencerPrivate::guiThread.
void Sequencer::nextStep | ( | bool | canAbort | ) | [protected, virtual] |
Increase the progress bar.
Reimplemented from Base::SequencerBase.
Definition at line 155 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::ProgressBar::canAbort(), Base::SequencerBase::nProgress, pause(), Base::SequencerBase::rejectCancel(), resume(), and Base::SequencerBase::wasCanceled().
void Sequencer::pause | ( | ) | [virtual] |
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.
Definition at line 102 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::WaitCursor::restoreCursor(), and Gui::SequencerPrivate::waitCursor.
Referenced by nextStep().
void Sequencer::resetData | ( | ) | [protected, virtual] |
Resets the sequencer.
Reimplemented from Base::SequencerBase.
Definition at line 261 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::getMainWindow(), Gui::MainWindow::setPaneText(), Gui::MainWindow::showMessage(), and Gui::SequencerPrivate::waitCursor.
Referenced by Gui::ProgressBar::eventFilter().
void Sequencer::resume | ( | ) | [virtual] |
This sets the wait cursor again and grabs the keyboard.
Reimplemented from Base::SequencerBase.
Definition at line 115 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::WaitCursor::setWaitCursor(), and Gui::SequencerPrivate::waitCursor.
Referenced by nextStep().
void Sequencer::setProgress | ( | size_t | step | ) | [protected, virtual] |
Sets the progress indicator to a certain position.
Reimplemented from Base::SequencerBase.
Definition at line 184 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar.
void Sequencer::setText | ( | const char * | pszTxt | ) | [protected, virtual] |
Puts text to the status bar.
Reimplemented from Base::SequencerBase.
Definition at line 302 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::getMainWindow(), Gui::MainWindow::showMessage(), and Gui::SequencerPrivate::text.
void Sequencer::showRemainingTime | ( | ) | [protected] |
Definition at line 227 of file ProgressBar.cpp.
References Gui::SequencerPrivate::bar, Gui::getMainWindow(), Py::int, Gui::SequencerPrivate::measureTime, Gui::MainWindow::showMessage(), and Gui::SequencerPrivate::text.
void Sequencer::startStep | ( | ) | [protected, virtual] |
Starts the progress bar.
Reimplemented from Base::SequencerBase.
Definition at line 128 of file ProgressBar.cpp.
References Gui::ProgressBar::aboutToShow(), Gui::SequencerPrivate::bar, Gui::SequencerPrivate::guiThread, Gui::SequencerPrivate::measureTime, Base::SequencerBase::nTotalSteps, Gui::SequencerPrivate::progressTime, and Gui::SequencerPrivate::waitCursor.
friend class ProgressBar [friend] |
Definition at line 133 of file ProgressBar.h.
Referenced by getProgressBar().