casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QProgressPanel.qo.h
Go to the documentation of this file.
1 //# QProgressPanel.qo.h: Convenience class with a label and progress meter.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef QPROGRESSPANEL_H_
28 #define QPROGRESSPANEL_H_
29 
30 #include <casaqt/QtBrowser/QProgressPanel.ui.h>
31 
32 #include <QtGui>
33 
34 #include <casa/BasicSL/String.h>
35 
36 namespace casa {
37 
38 // <summary>
39 // Convenience class with a label and progress meter.
40 // </summary>
41 //
42 // <synopsis>
43 // A QProgressPanel is a convenience class that provides a common
44 // functionality: displaying a progress meter along with a label.
45 // QProgressPanel also has two optional buttons: a "Hide" button and a "Close"
46 // button - pressing either of these buttons sends a signal. <b>Important</b>:
47 // it is the responsibility of the caller/parent to handle these signals.
48 // </synopsis>
49 
50 class QProgressPanel : public QWidget, Ui::ProgressPanel {
51  Q_OBJECT
52 
53 public:
54  // Builds a QProgressPanel with the given label and a progress meter at 0%
55  // completion. If hideable is true, the optional "Hide" button is shown;
56  // similarly, if cancelable is true, the optional "Cancel" button is shown.
57  QProgressPanel(casacore::String label, bool hideable = true, bool cancelable = true);
58 
60 
61 
62  // Returns the progress meter (QProgressBar).
63  QProgressBar* getProgressBar();
64 
65  // Returns the label (QLabel).
66  QLabel* getLabel();
67 
68  // Sets the text of the label to the given String.
69  void setLabel(casacore::String newLabel);
70 
71 public slots:
72  // Sets the value of the progress meter to the given value. Note that the
73  // progress meter is on a scale of 0 - 100. Also, due to some weirdness
74  // with Qt's GUI thread system, calling setValue actually emits a signal
75  // which is caught by the progress meter rather than setting the value
76  // directly.
77  void setValue(int value);
78 
79 signals:
80  // The cancelRequested signal is emitted whenever the "Cancel" button is
81  // clicked. If the QProgressPanel was created without the cancel button,
82  // this signal is never emitted.
83  void cancelRequested();
84 
85  // The hideRequested signal is emitted whenever the "Hide" button is
86  // clicked. If the QProgressPanel was created without the hide button,
87  // this signal is never emitted.
88  void hideRequested();
89 
90  // This is the signal used by setValue() to get around Qt's GUI thread
91  // issues.
92  void updateValue(int value);
93 
94 private slots:
95  // Slot to handle the "Cancel" button's clicked() signal. Emits the
96  // cancelRequested() signal.
97  void cancel();
98 
99  // Slot to handle the "Hide" button's clicked() signal. Emits the
100  // hideRequested() signal.
101  void hide();
102 };
103 
104 // <summary>
105 // Wrapper around a QProgressPanel or other QLabel/QProgressBar pairing.
106 // </summary>
107 //
108 // <synopsis>
109 // A ProgressHelper is a convenience class that provides methods dealing with
110 // any QLabel/QProgressBar pair. Progress is seen as a number of steps, and as
111 // progress is made the "steps" counter increases.
112 // </synopsis>
113 
115 public:
116  // Constructor that takes a pointer to a QProgressPanel. If qpp is NULL,
117  // the ProgressHelper is invalid.
119 
120  // Constructor that takes a reference to a QProgressPanel.
122 
123  // Constructor that takes any QLabel and QProgressBar pointers. If either
124  // are NULL, the ProgressHelper is invalid.
125  ProgressHelper(QLabel* label, QProgressBar* pb);
126 
127  // Constructor that takes any QLabel and QProgressBar references.
128  ProgressHelper(QLabel& label, QProgressBar& pb);
129 
130  // Copy Constructor. If ph is NULL, the ProgressHelper is invalid.
132 
133  // Copy Constructor.
135 
136  ~ProgressHelper();
137 
138 
139  // Returns the label (QLabel).
140  QLabel* getLabel();
141 
142  // Returns the progress meter (QProgressBar).
143  QProgressBar* getBar();
144 
145  // Set the text of the QLabel to the given String.
146  void setLabel(casacore::String label);
147 
148  // Set the total number of steps in the task.
149  void setSteps(int steps);
150 
151 
152  // Indicates that one step of progress has been made. The progress meter
153  // is updated accordingly.
154  void step();
155 
156  // Indicate that the task has been completed; the label and progress meter
157  // are updated accordingly.
158  void done();
159 
160  // Rest the progress meter and set the label with the given text.
161  void reset(casacore::String newLabel);
162 
163 private:
164  // Indicates whether this object is valid or not. (See constructors.)
165  bool valid;
166 
167  // Pointer to the label.
168  QLabel* label;
169 
170  // Pointer to the progress meter.
171  QProgressBar* bar;
172 
173  // Steps counter.
174  int s;
175 };
176 
177 }
178 
179 #endif /* QPROGRESSPANEL_H_ */
void setLabel(casacore::String newLabel)
Sets the text of the label to the given String.
void hideRequested()
The hideRequested signal is emitted whenever the &quot;Hide&quot; button is clicked.
void cancel()
Slot to handle the &quot;Cancel&quot; button&#39;s clicked() signal.
void step()
Indicates that one step of progress has been made.
QProgressBar * bar
Pointer to the progress meter.
void updateValue(int value)
This is the signal used by setValue() to get around Qt&#39;s GUI thread issues.
void setValue(int value)
Sets the value of the progress meter to the given value.
void done()
Indicate that the task has been completed; the label and progress meter are updated accordingly...
void cancelRequested()
The cancelRequested signal is emitted whenever the &quot;Cancel&quot; button is clicked.
void hide()
Slot to handle the &quot;Hide&quot; button&#39;s clicked() signal.
Wrapper around a QProgressPanel or other QLabel/QProgressBar pairing.
void setLabel(casacore::String label)
Set the text of the QLabel to the given String.
QProgressBar * getProgressBar()
Returns the progress meter (QProgressBar).
QLabel * getLabel()
Returns the label (QLabel).
int s
Steps counter.
void reset(casacore::String newLabel)
Rest the progress meter and set the label with the given text.
ProgressHelper(QProgressPanel *qpp)
Constructor that takes a pointer to a QProgressPanel.
QProgressPanel(casacore::String label, bool hideable=true, bool cancelable=true)
Builds a QProgressPanel with the given label and a progress meter at 0% completion.
void setSteps(int steps)
Set the total number of steps in the task.
QLabel * label
Pointer to the label.
Convenience class with a label and progress meter.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
QLabel * getLabel()
Returns the label (QLabel).
QProgressBar * getBar()
Returns the progress meter (QProgressBar).
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
bool valid
Indicates whether this object is valid or not.