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
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  public slots:
132 
133  virtual void onSetProgressMessage(const std::string& message) override;
134 
135  virtual void onSetProgressRange(int min, int max) override;
136 
137  virtual void onSetProgressValue(int value) override;
138 
139  virtual void onResetProgress() override;
140 
141  protected:
142 
143  int m_totalSteps; //!< Attribute used to define the total steps of all tasks.
144  int m_currentStep; //!< Attribute used to define the current steps of all task.
145  int m_propStep; //!< Attribute used to define the proportional step (0-100).
146  std::map<int, te::common::TaskProgress*> m_tasks; //!< Task container.
147  QGridLayout* m_layout; //!< GUI Objects used to build the custom widget.
148  QProgressBar* m_progressBar; //!< GUI Objects used to build the custom widget.
149 
150  bool m_reset;
151  };
152  } // end namespace widgets
153  } // end namespace qt
154 } // end namespace te
155 
156 #endif //__TERRALIB_QT_WIDGETS_PROGRESS_INTERNAL_PROGRESSVIEWERBAR_H
#define slots
std::map< int, te::common::TaskProgress * > m_tasks
Task container.
A class that defines the interface of an abstract qt progress viewer.
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
int m_propStep
Attribute used to define the proportional step (0-100).
TerraLib.
A class that defines the interface of a qt bar progress viewer.
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_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.