ProgressViewerDialog.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/progress/ProgressViewerDialog.h
22 
23  \brief A progress dialog.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERDIALOG_H
27 #define __TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERDIALOG_H
28 
29 // TerraLib
31 #include "../Config.h"
32 #include "../../../common/progress/TaskProgress.h"
33 
34 // Qt
35 #include <QProgressDialog>
36 #include <QString>
37 
38 // STL
39 #include <map>
40 #include <string>
41 #include <mutex>
42 
43 namespace te
44 {
45  namespace qt
46  {
47  namespace widgets
48  {
49 
50  /*!
51  \class ProgressViewerDialog
52 
53  \brief A progress dialog.
54 
55  This widget is a dialog with progress information and a
56  cancel button.
57 
58  This viewer is made using Qt Progress Dialog. Feed back will be generated
59  over a dialog window. Multiples tasks will be displayed using ONLY one
60  progress.
61 
62  The proportional value is calculated using TOTALSTEPS / CURRENTSTEPS, where:
63  <ul>
64  <li>TOTALSTEPS: Sum of all total steps of all tasks</li>
65  <li>CURRENTSTEPS: Sum of all current steps of all tasks</li>
66  </ul>
67 
68  The progress message is defined by the task message, if it has more than
69  on task the message will be "MULTI TASKS".
70 
71  \ingroup widgets
72  */
74  {
75  Q_OBJECT
76 
77  public:
78 
79  /*! \brief Default constructor. */
80  ProgressViewerDialog(QWidget* parent, QString title = "");
81 
82  /*! \brief Virtual destructor. */
84 
85  /*!
86  \brief Insert a new taks to progress viewer container
87 
88  \param t Task pointer.
89  \param id Task identifier.
90  */
91  void addTask(te::common::TaskProgress* t, int id);
92 
93  /*!
94  \brief Removes a task from progress viewer container.
95 
96  \param taskId Task identifier.
97  */
98  void removeTask(int taskId);
99 
100  /*!
101  \brief Cancel a task.
102 
103  \param taskId Task identifier.
104  */
105  void cancelTask(int taskId);
106 
107  /*!
108  \brief Set task total steps.
109 
110  \param taskId Task identifier.
111  */
112  void setTotalValues(int taskId);
113 
114  /*!
115  \brief Set title to dialog.
116 
117  \param title A QString title.
118  */
119  void setTitle(QString title);
120 
121  /*!
122  \brief Update the progress evaluation.
123 
124  \param taskId Task identifier.
125  */
126  void updateValue(int taskId);
127 
128  /*!
129  \brief Update the progress message.
130 
131  \param taskId Task identifier.
132  */
133  void updateMessage(int taskId);
134 
135  protected slots:
136 
137  virtual void onSetProgressMessage(const std::string& message);
138 
139  virtual void onSetProgressRange(int min, int max);
140 
141  virtual void onSetProgressValue(int value);
142 
143  virtual void onResetProgress();
144 
145  virtual void cancel();
146 
147  protected:
148 
149  int m_totalSteps; //!< Attribute used to define the total steps of all tasks.
150  int m_currentStep; //!< Attribute used to define the current steps of all task.
151  int m_propStep; //!< Attribute used to define the proportional step (0-100).
152  std::string m_message; //!< Attribute used to define dialog message.
153  std::map<int, te::common::TaskProgress*> m_tasks; //!< Task container.
154  QProgressDialog* m_dlgProgress; //!< GUI Objects used as progress bar dialog.
155 
156  bool m_reset;
157 
158  std::mutex m_mutex;
159  };
160  } // end namespace widgets
161  } // end namespace qt
162 } // end namespace te
163 
164 #endif //__TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERDIALOG_H
#define slots
A class that defines the interface of an abstract qt progress viewer.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
int m_currentStep
Attribute used to define the current steps of all task.
QProgressDialog * m_dlgProgress
GUI Objects used as progress bar dialog.
std::map< int, te::common::TaskProgress * > m_tasks
Task container.
int m_totalSteps
Attribute used to define the total steps of all tasks.
TerraLib.
A class that defines the interface of an abstract qt progress viewer.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
int m_propStep
Attribute used to define the proportional step (0-100).
std::string m_message
Attribute used to define dialog message.