COPASI API  4.16.103
CProgressBar.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CProgressBar.h,v $
3 // $Revision: 1.25 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/06/21 21:36:26 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #if !defined HANDLER_PROGRESS_BAR
24 #define HANDLER_PROGRESS_BAR
25 
26 #include <QtCore/QDateTime>
27 #include <QtGui/QCloseEvent>
28 #include <QtCore/QMutex>
29 #include <QtCore/QWaitCondition>
30 
32 #include "CQProgressDialog.h"
33 
34 template < typename > class CVector;
35 class CQProgressItem;
36 
37 /**
38  * This is used to call the progress bar code
39  * We do not want to call GUI stuff directly from the CModel.
40  */
42 {
43  Q_OBJECT
44 public:
45  static CProgressBar * create(QWidget* parent = 0,
46  const char* name = 0,
47  Qt::WindowModality windowModality = Qt::WindowModal);
48 
49 private:
50  CProgressBar(QWidget* parent, const char* name, Qt::WindowModality windowModality);
51 
52 public:
53  virtual ~CProgressBar();
54 
55  /**
56  * Report process on item handle. If the return value is false the calling
57  * process must halt execution and return.
58  * @param const size_t & handle
59  * @param bool continue
60  */
61  virtual bool progressItem(const size_t & handle);
62 
63  /**
64  * Check whether processing shall proceed. If the return value is false
65  * the calling process must halt execution and return. This method is
66  * provided so that lengthy processing without advances in any of the
67  * reporting items can check whether continuation is requested.
68  * @param bool continue
69  */
70  virtual bool proceed();
71 
72  /**
73  * Reset item handle. This means that the value of the item has changed
74  * but not as part of a continuous process. If you run multiple processes
75  * call reset between them. If the return value is false the calling
76  * process must halt execution and return.
77  * @param const size_t & handle
78  * @param bool continue
79  */
80  virtual bool resetItem(const size_t & handle);
81 
82  /**
83  * Indicate that all items are finished reporting. All item handles loose
84  * their validity. If the return value is false the calling
85  * process must halt execution and return.
86  * @param bool continue
87  */
88  virtual bool finish();
89 
90  /**
91  * Indicate that item handle is finished reporting. The handle of that
92  * item is no longer valid after the call. If the return value is false
93  * the calling process must halt execution and return.
94  * @param const size_t & handle
95  * @param bool continue
96  */
97  virtual bool finishItem(const size_t & handle);
98 
99  /**
100  * Set the name of the process.
101  * @param const std::string & name
102  * @return success
103  */
104  virtual bool setName(const std::string & name);
105 
106  /**
107  * Add a process report item to to the list of reporting items.
108  * The return value is the handle of the item and can be used to
109  * indicate process, finish, or reset the item. If the method fails
110  * C_INVALID_INDEX is returned.
111  * @param const std::string & name
112  * @param const CCopasiParameter::Type & type
113  * @param const void * pValue
114  * @param const void * pEndValue = NULL
115  * @return size_t handle
116  */
117 protected:
118  virtual size_t addItem(const std::string & name,
119  const CCopasiParameter::Type & type,
120  const void * pValue,
121  const void * pEndValue = NULL);
122 
123 
124  virtual void closeEvent(QCloseEvent *e);
125 
127 
128  QMutex mMutex;
129  QWaitCondition mWaitSlot;
130  QWaitCondition mWaitPause;
131 
132  size_t mLastHItem;
133 
134 private:
136 
138 
139  QWidget * mpMainWidget;
140 
141 signals:
142  void signalAddItem(const int handle);
143  void signalSetName(QString name);
144  void signalProgressAll();
145  void signalFinishItem(const int handle);
146 
147 protected slots:
148 
149  virtual void slotAddItem(const int handle);
150 
151  virtual void slotSetName(QString name);
152 
153  virtual void slotProgressAll();
154 
155  virtual void slotFinishItem(const int handle);
156 
157  virtual void btnStopPressed();
158 
159  virtual void btnContinuePressed();
160 };
161 
162 #endif
virtual void slotAddItem(const int handle)
virtual void closeEvent(QCloseEvent *e)
virtual void slotSetName(QString name)
static CProgressBar * create(QWidget *parent=0, const char *name=0, Qt::WindowModality windowModality=Qt::WindowModal)
CVector< CQProgressItem * > mProgressItemList
Definition: CProgressBar.h:135
virtual bool progressItem(const size_t &handle)
virtual void btnContinuePressed()
void signalFinishItem(const int handle)
virtual size_t addItem(const std::string &name, const CCopasiParameter::Type &type, const void *pValue, const void *pEndValue=NULL)
QDateTime mNextEventProcessing
Definition: CProgressBar.h:137
virtual bool proceed()
CProgressBar(QWidget *parent, const char *name, Qt::WindowModality windowModality)
void signalSetName(QString name)
virtual void slotFinishItem(const int handle)
virtual bool resetItem(const size_t &handle)
virtual ~CProgressBar()
QWaitCondition mWaitPause
Definition: CProgressBar.h:130
virtual bool finishItem(const size_t &handle)
virtual bool setName(const std::string &name)
void signalAddItem(const int handle)
void signalProgressAll()
virtual void btnStopPressed()
virtual void slotProgressAll()
virtual bool finish()
QWidget * mpMainWidget
Definition: CProgressBar.h:139
QWaitCondition mWaitSlot
Definition: CProgressBar.h:129
bool mSlotFinished
Definition: CProgressBar.h:126
size_t mLastHItem
Definition: CProgressBar.h:132