1 
2 
3 #ifndef PROGRESSINDICATOR_H
4 #define PROGRESSINDICATOR_H
5 
6 #include <QWidget>
7 #include <QDateTime>
8 
9 class QProgressBar;
10 class QLabel;
11 
12 
13 class TrailingAverage
14 {
15 public:
16     TrailingAverage();
17     ~TrailingAverage();
18 
19     void setCount( int _count );
20     void addData( float _deltaTime, float _deltaValue );
21     float average();
22 
23 private:
24     int count;
25     QList<float> deltaTime;
26     QList<float> deltaValue;
27 };
28 
29 /**
30  * @short Displays the current progress
31  * @author Daniel Faust <hessijames@gmail.com>
32  * @version 0.3
33  */
34 class ProgressIndicator : public QWidget
35 {
36     Q_OBJECT
37 public:
38     enum Feature
39     {
40         FeatureNone  = 0,
41         FeatureSpeed = 1,
42         FeatureTime  = 2
43     };
44 
45     ProgressIndicator( QWidget *parent, Feature features = FeatureNone );
46     ~ProgressIndicator();
47 
48 public slots:
49     void timeChanged( float timeDelta );
50     void timeFinished( float timeDelta );
51     void finished( bool reset );
52 
53     void update( float timeProgress );
main(void)54 
55 private:
56     QProgressBar *pBar;
57     QLabel *lSpeed;
58     QLabel *lTime;
59 
60     float totalTime;
61     float processedTime;
62 
63     QTime updateTime;
64     float lastProcessedTime;
65     TrailingAverage timeAverage;
66     TrailingAverage speedAverage;
67 
68 signals:
69     void progressChanged( const QString& progress );
70 };
71 
72 #endif // PROGRESSINDICATOR_H
73