| 1 | /* | 
|---|
| 2 | * QtStatusBar.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Feb 17, 2010 | 
|---|
| 5 | *      Author: crueger | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef QTSTATUSBAR_HPP_ | 
|---|
| 9 | #define QTSTATUSBAR_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #include <map> | 
|---|
| 18 | #include <utility> | 
|---|
| 19 | #include <string> | 
|---|
| 20 | #include <QtGui/QStatusBar> | 
|---|
| 21 |  | 
|---|
| 22 | #include "CodePatterns/Observer/Observer.hpp" | 
|---|
| 23 |  | 
|---|
| 24 | class QBoxLayout; | 
|---|
| 25 | class QLabel; | 
|---|
| 26 | class QProgressBar; | 
|---|
| 27 | class QTimer; | 
|---|
| 28 |  | 
|---|
| 29 | namespace MoleCuilder { | 
|---|
| 30 | class ActionStatusList; | 
|---|
| 31 | class Process; | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | class QtStatusBar : public QStatusBar, public Observer | 
|---|
| 35 | { | 
|---|
| 36 | Q_OBJECT | 
|---|
| 37 |  | 
|---|
| 38 | struct progressIndicator{ | 
|---|
| 39 | progressIndicator(const std::string &name); | 
|---|
| 40 | ~progressIndicator(); | 
|---|
| 41 | QLabel *label; | 
|---|
| 42 | QProgressBar *bar; | 
|---|
| 43 | QBoxLayout *layout; | 
|---|
| 44 | QWidget *container; | 
|---|
| 45 | }; | 
|---|
| 46 | public: | 
|---|
| 47 | QtStatusBar(QWidget *parent=0); | 
|---|
| 48 | virtual ~QtStatusBar(); | 
|---|
| 49 |  | 
|---|
| 50 | void update(Observable *subject); | 
|---|
| 51 | void subjectKilled(Observable *subject); | 
|---|
| 52 | void recieveNotification(Observable *_publisher, Notification *_notification); | 
|---|
| 53 |  | 
|---|
| 54 | private slots: | 
|---|
| 55 | void updateProgressBar( | 
|---|
| 56 | const std::string name, | 
|---|
| 57 | const unsigned int maxsteps, | 
|---|
| 58 | const unsigned int currentstep, | 
|---|
| 59 | const bool StopStatus); | 
|---|
| 60 | void updateStatusMessage(); | 
|---|
| 61 |  | 
|---|
| 62 | signals: | 
|---|
| 63 | void redrawProgressBar( | 
|---|
| 64 | const std::string name, | 
|---|
| 65 | const unsigned int maxsteps, | 
|---|
| 66 | const unsigned int currentstep, | 
|---|
| 67 | const bool StopStatus); | 
|---|
| 68 |  | 
|---|
| 69 | private: | 
|---|
| 70 | void redrawStatus(); | 
|---|
| 71 |  | 
|---|
| 72 | void startTimer(); | 
|---|
| 73 | void stopTimer(); | 
|---|
| 74 |  | 
|---|
| 75 | int atomCount; | 
|---|
| 76 | int moleculeCount; | 
|---|
| 77 |  | 
|---|
| 78 | QLabel *statusLabel; | 
|---|
| 79 | QWidget *parent; | 
|---|
| 80 | typedef std::map<std::string,progressIndicator*> progressBars_t; | 
|---|
| 81 | progressBars_t progressBars; | 
|---|
| 82 | std::string activeProcess; | 
|---|
| 83 | //!> reference to the StatusList we are signed on | 
|---|
| 84 | MoleCuilder::ActionStatusList& StatusList; | 
|---|
| 85 | //!> indicates whether we are currently signed on | 
|---|
| 86 | bool StatusList_signedOn; | 
|---|
| 87 | //!> QTimer instance that causes regular updates of status messages | 
|---|
| 88 | QTimer *timer; | 
|---|
| 89 | //!> time interval in milliseconds | 
|---|
| 90 | const int timer_interval; | 
|---|
| 91 | }; | 
|---|
| 92 |  | 
|---|
| 93 | #endif /* QTSTATUSBAR_HPP_ */ | 
|---|