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