ProgressBar.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_PROGRESSBAR_H
00025 #define GUI_PROGRESSBAR_H
00026 
00027 #include <QProgressBar>
00028 
00029 #include <Base/Sequencer.h>
00030 
00031 namespace Gui {
00032 
00033 struct SequencerPrivate;
00034 struct ProgressBarPrivate;
00035 class ProgressBar;
00036 
00088 class GuiExport Sequencer : public Base::SequencerBase
00089 {
00090 public:
00092     static Sequencer* instance();
00098     void pause();
00100     void resume();
00101     bool isBlocking() const;
00103     QProgressBar* getProgressBar(QWidget* parent=0);
00104 
00105 protected:
00107     Sequencer ();
00109     ~Sequencer ();
00110 
00112     void setText (const char* pszTxt);
00114     void startStep();
00116     void nextStep(bool canAbort);
00118     void setProgress(size_t);
00120     void resetData();
00121     void showRemainingTime();
00122 
00123 private:
00126     void setValue(int step);
00128     void abort();
00130     SequencerPrivate* d;
00131     static Sequencer* _pclSingleton;
00132 
00133     friend class ProgressBar;
00134 };
00135 
00136 class ProgressBar : public QProgressBar
00137 {
00138     Q_OBJECT
00139 
00140 public:
00142     ProgressBar (Sequencer* s, QWidget * parent=0);
00144     ~ProgressBar ();
00145 
00149     bool eventFilter(QObject* o, QEvent* e);
00152     int minimumDuration() const;
00153 
00154 public Q_SLOTS:
00157     void setMinimumDuration (int ms);
00158 
00159     bool canAbort() const;
00160 
00161 protected:
00162     void showEvent(QShowEvent*);
00163     void hideEvent(QHideEvent*);
00164 
00165 protected Q_SLOTS:
00166     /* Shows the progress bar if it is still hidden after the operation has been started
00167     * and minimumDuration milliseconds have passed.
00168     */
00169     void delayedShow();
00170     void aboutToShow();
00171 
00172 private:
00175     void resetObserveEventFilter();
00177     void enterControlEvents();
00179     void leaveControlEvents();
00181     ProgressBarPrivate* d;
00182     Sequencer* sequencer;
00183 
00184     friend class Sequencer;
00185 };
00186 
00187 } // namespace Gui
00188 
00189 #endif // GUI_PROGRESSBAR_H

Generated on Wed Nov 23 19:00:30 2011 for FreeCAD by  doxygen 1.6.1