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
30 #include "../../../common/progress/AbstractProgressViewer.h"
31 #include "../../../common/progress/TaskProgress.h"
32 #include "../Config.h"
33 
34 // Qt
35 #include <QProgressDialog>
36 
37 // STL
38 #include <map>
39 #include <string>
40 
41 namespace te
42 {
43  namespace qt
44  {
45  namespace widgets
46  {
47 
48  /*!
49  \class ProgressViewerDialog
50 
51  \brief A progress dialog.
52 
53  This widget is a dialog with progress information and a
54  cancel button.
55 
56  This viewer is made using Qt Progress Dialog. Feed back will be generated
57  over a dialog window. Multiples tasks will be displayed using ONLY one
58  progress.
59 
60  The proportional value is calculated using TOTALSTEPS / CURRENTSTEPS, where:
61  <ul>
62  <li>TOTALSTEPS: Sum of all total steps of all tasks</li>
63  <li>CURRENTSTEPS: Sum of all current steps of all tasks</li>
64  </ul>
65 
66  The progress message is defined by the task message, if it has more than
67  on task the message will be "MULTI TASKS".
68 
69  \ingroup widgets
70  */
72  {
73  Q_OBJECT
74 
75  public:
76 
77  /*! \brief Default constructor. */
78  ProgressViewerDialog(QWidget* parent);
79 
80  /*! \brief Virtual destructor. */
81  virtual ~ProgressViewerDialog();
82 
83  /*!
84  \brief Insert a new taks to progress viewer container
85 
86  \param t Task pointer.
87  \param id Task identifier.
88  */
89  void addTask(te::common::TaskProgress* t, int id);
90 
91  /*!
92  \brief Removes a task from progress viewer container.
93 
94  \param taskId Task identifier.
95  */
96  void removeTask(int taskId);
97 
98  /*!
99  \brief Cancel a task.
100 
101  \param taskId Task identifier.
102  */
103  void cancelTask(int taskId);
104 
105  /*!
106  \brief Set task total steps.
107 
108  \param taskId Task identifier.
109  */
110  void setTotalValues(int taskId);
111 
112  /*!
113  \brief Update the progress evaluation.
114 
115  \param taskId Task identifier.
116  */
117  void updateValue(int taskId);
118 
119  /*!
120  \brief Update the progress message.
121 
122  \param taskId Task identifier.
123  */
124  void updateMessage(int taskId);
125 
126  protected:
127 
128  /*!
129  \brief Used to receive custom progress events.
130 
131  \param e Event sent to this object.
132  */
133  virtual void customEvent(QEvent* e);
134 
135  public slots:
136 
137  /*! \brief Get the button clicked and cancel ALL tasks. */
138  virtual void cancel();
139 
140  protected:
141 
142  int m_totalSteps; //!< Attribute used to define the total steps of all tasks.
143  int m_currentStep; //!< Attribute used to define the current steps of all task.
144  int m_propStep; //!< Attribute used to define the proportional step (0-100).
145  std::string m_message; //!< Attribute used to define dialog message.
146  std::map<int, te::common::TaskProgress*> m_tasks; //!< Task container.
147  QProgressDialog* m_dlgProgress; //!< GUI Objects used as progress bar dialog.
148  };
149  } // end namespace widgets
150  } // end namespace qt
151 } // end namespace te
152 
153 #endif //__TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERDIALOG_H
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.
A class that defines the interface of an abstract progress viewer.
std::map< int, te::common::TaskProgress * > m_tasks
Task container.
int m_totalSteps
Attribute used to define the total steps of all tasks.
URI C++ Library.
#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.