ProgressViewerBar.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/ProgressViewerBar.h
22 
23  \brief A class that defines the interface of a qt bar progress viewer.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERBAR_H
27 #define __TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERBAR_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 <QGridLayout>
36 #include <QProgressBar>
37 #include <QPushButton>
38 
39 // STL
40 #include <map>
41 #include <string>
42 
43 namespace te
44 {
45  namespace qt
46  {
47  namespace widgets
48  {
49 
50  /*!
51  \class ProgressViewerBar
52 
53  \brief A class that defines the interface of a qt bar progress viewer.
54 
55  It can be use inside a status bar.
56 
57  This viewer is made using QtProgressBar object. Feed back will be generated
58  over a custom widget. Multiples tasks will be displayed using ONLY one
59  progress.
60 
61  The proportional value is calculated using TOTALSTEPS / CURRENTSTEPS.
62 
63  TOTALSTEPS - Sum of all total steps of all tasks
64  CURRENTSTEPS - Sum of all current steps of all tasks
65 
66  This viwer does NOT have message information. A Qt Button objected has located
67  at the right side of the bar. The button clicked can be accessed getting
68  clicked() signal.
69 
70  \ingroup widgets
71 
72  \sa AbstractProgressViewer, QtProgressBar
73 
74  \note In this viewer, tasks can NOT be deleted.
75  */
77  {
78  Q_OBJECT
79 
80  public:
81 
82  /*! \brief Default constructor. */
83  ProgressViewerBar(QWidget* parent);
84 
85  /*! \brief Virtual destructor. */
87 
88  /*!
89  \brief Insert a new taks to progress viewer container
90 
91  \param t Task pointer
92  \param id Task identifier
93  */
94  void addTask(te::common::TaskProgress* t, int id);
95 
96  /*!
97  \brief Removes a task from progress viewer container
98 
99  \param taskId Task identifier
100  */
101  void removeTask(int taskId);
102 
103  /*!
104  \brief Cancel a task
105 
106  \param taskId Task identifier
107  */
108  void cancelTask(int taskId);
109 
110  /*!
111  \brief Set task total steps
112 
113  \param taskId Task identifier
114  */
115  void setTotalValues(int taskId);
116 
117  /*!
118  \brief Update the progress evaluation
119 
120  \param taskId Task identifier
121  */
122  void updateValue(int taskId);
123 
124  /*!
125  \brief Update the progress message
126 
127  \param taskId Task identifier
128  */
129  void updateMessage(int taskId);
130 
131  void setButtonText(const std::string& value);
132 
133  protected:
134 
135  /*!
136  \brief Used to receive custom progress events.
137 
138  \param e Event sent to this object.
139  */
140  virtual void customEvent(QEvent* e);
141 
142  public slots:
143 
144  /*! \brief Used to get the button clicked (internal function). */
145  virtual void onReleased();
146 
147  signals:
148 
149  /*! \brief Emit a signal if the button was clicked. */
150  void clicked();
151 
152  protected:
153 
154  int m_totalSteps; //!< Attribute used to define the total steps of all tasks.
155  int m_currentStep; //!< Attribute used to define the current steps of all task.
156  int m_propStep; //!< Attribute used to define the proportional step (0-100).
157  std::map<int, te::common::TaskProgress*> m_tasks; //!< Task container.
158  QGridLayout* m_layout; //!< GUI Objects used to build the custom widget.
159  QProgressBar* m_progressBar; //!< GUI Objects used to build the custom widget.
160  QPushButton* m_button; //!< GUI Objects used to build the custom widget.
161  };
162  } // end namespace widgets
163  } // end namespace qt
164 } // end namespace te
165 
166 #endif //__TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERBAR_H
QPushButton * m_button
GUI Objects used to build the custom widget.
std::map< int, te::common::TaskProgress * > m_tasks
Task container.
QGridLayout * m_layout
GUI Objects used to build the custom widget.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
A class that defines the interface of an abstract progress viewer.
int m_propStep
Attribute used to define the proportional step (0-100).
URI C++ Library.
A class that defines the interface of a qt bar 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_currentStep
Attribute used to define the current steps of all task.
QProgressBar * m_progressBar
GUI Objects used to build the custom widget.
int m_totalSteps
Attribute used to define the total steps of all tasks.