Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYProgressManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  */
19 
20 #ifndef __TY_PROGRESS_MANAGER__
21 #define __TY_PROGRESS_MANAGER__
22 
23 #if TY_USE_IHM
24 
25  #include <qprogressdialog.h>
26  #include <QLabel>
27 
31 class TYProgressDialog : public QProgressDialog
32 {
33 public:
34  TYProgressDialog(QWidget* creator = 0, const char* name = 0, bool modal = false,
35  Qt::WindowFlags f = QFlag(0))
36  : // QProgressDialog(creator, name, modal, f)
37  QProgressDialog(creator, f)
38  {
39  QLabel* label = new QLabel(name);
40  setLabel(label);
41  if (modal)
42  {
43  setWindowModality(Qt::WindowModal);
44  }
45  else
46  {
47  setWindowModality(Qt::NonModal);
48  }
49  }
50  TYProgressDialog(const QString& labelText, const QString& cancelButtonText, int totalSteps,
51  QWidget* creator = 0, const char* name = 0, bool modal = false,
52  Qt::WindowFlags f = QFlag(0))
53  : QProgressDialog(labelText, cancelButtonText, 0, totalSteps, creator, f)
54  {
55  QLabel* label = new QLabel(name);
56  setLabel(label);
57  if (modal)
58  {
59  setWindowModality(Qt::WindowModal);
60  }
61  else
62  {
63  setWindowModality(Qt::NonModal);
64  }
65  }
66 
67 public:
71  virtual void setEnabled(bool)
72  {
73  // Do nothing !
74  }
75 };
76 
84 {
85 public:
92  static void create(QWidget* pParent, const char* name = 0);
93 
100  static void set(int totalSteps, int stepSize = 1);
101 
107  static int getProgress();
108 
114  static void setProgress(int progress);
115 
119  static void step();
126  static void step(bool& wasCancelled);
127 
131  static void stepToEnd();
135  static void setWindowTitle(const char* caption);
139  static void setMessage(const char* message);
143  static TYProgressDialog* getProgressDialog()
144  {
145  return _pProgressDialog;
146  }
147 
148 protected:
152  TYProgressManager() {}
153 
154 private:
156  static TYProgressDialog* _pProgressDialog;
157 
159  static int _stepSize;
160 };
161 
162 #else // TY_USE_IHM
163 
164 class QWidget;
165 
172 {
173 public:
174  static void create(QWidget* pParent, const char* name = 0) {}
175  static void set(int totalSteps, int stepSize = 1) {}
176  static void step() {}
177  static void step(bool& wasCancelled) {}
178  static void stepToEnd() {}
179 
180 protected:
182 };
183 
184 #endif // TY_USE_IHM
185 
186 #endif //__TY_PROGRESS_MANAGER__
const char * name
static void step(bool &wasCancelled)
static void set(int totalSteps, int stepSize=1)
static void create(QWidget *pParent, const char *name=0)
static void stepToEnd()