casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtProgressWidget.qo.h
Go to the documentation of this file.
1 //# QtProgressWidget.qo.h: Qt widget for displaying progress information.
2 //# Copyright (C) 2009
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 QTPROGRESSWIDGET_QO_H_
28 #define QTPROGRESSWIDGET_QO_H_
29 
31 #include <casaqt/QtUtilities/QtProgressCompactWidget.ui.h>
32 #include <casaqt/QtUtilities/QtProgressWidget.ui.h>
33 
34 #include <QMutex>
35 
36 namespace casa {
37 
38 // GUI for displaying progress information. It also shows "background",
39 // "cancel", and "pause/resume" buttons for the user. The parent of this
40 // widget is responsible for implementing these behaviors as needed.
41 class QtProgressWidget : public QWidget, public ProgressMonitor {
42  Q_OBJECT
43 
44 public:
45  // Constructor which takes the PlotMS parent an optional parent widget.
46  QtProgressWidget(bool allowBackground = true,
47  bool allowPauseResume = true, bool allowCancel = true,
48  bool isDialog = true, bool useCompact = false,
49  QWidget* parent = NULL);
50 
51  // Destructor.
53 
54 
55  // Sets which operations the user can request using this widget.
56  void setAllowedOperations(bool background, bool pauseResume, bool cancel);
57 
58  // Returns the mutex used for this widget.
59  QMutex& mutex();
60 
61  void initialize( const casacore::String& operationName );
62  void setProgress(unsigned int progress, const casacore::String& status);
63 
64 public slots:
65  // Initializes the GUI with the given operation name. Should be called
66  // before the operation starts.
67  void initialize(const QString& operationName);
68 
69  // Sets the status to the given.
70  void setStatus(const QString& status);
71 
72  // Sets the progress percentage (0 - 100) to the given.
73  void setProgress(unsigned int progress);
74 
75  // Sets the progress percentage (0 - 100) and the status to the given.
76  void setProgress(unsigned int progress, const QString& status);
77 
78  // Finalizes the GUI. Should be called after the operation ends.
79  void finalize();
80 
81 signals:
82  // Signal for when the user requests "background" for the thread.
83  void backgroundRequested();
84 
85  // Signal for when the user requests "pause" for the thread.
86  void pauseRequested();
87 
88  // Signal for when the user requests "resume" for the thread.
89  void resumeRequested();
90 
91  // Signal for when the user requests "cancel" for the thread.
92  void cancelRequested();
93 
94 protected:
95  // Overrides QWidget::closeEvent(). Connects closing to the "background"
96  // signal.
97  void closeEvent(QCloseEvent* event);
98 
99 private:
100  // Mutex.
101  QMutex itsMutex_;
102 
103  // casacore::Normal widget.
104  Ui::ProgressWidget* itsProgress_;
105 
106  // Compact widget.
107  Ui::ProgressCompactWidget* itsCompactProgress_;
108 
109 private slots:
110  // For the "background" button.
111  void background();
112 
113  // For the "pause"/"resume" button.
114  void pauseResume(bool pause);
115 
116  // For the "cancel" button.
117  void cancel();
118 };
119 
120 }
121 
122 #endif /* QTPROGRESSWIDGET_QO_H_ */
void setAllowedOperations(bool background, bool pauseResume, bool cancel)
Sets which operations the user can request using this widget.
Ui::ProgressCompactWidget * itsCompactProgress_
Compact widget.
void background()
For the &quot;background&quot; button.
~QtProgressWidget()
Destructor.
void setProgress(unsigned int progress, const casacore::String &status)
Set the progress to a specific amount and status.
void setStatus(const QString &status)
Sets the status to the given.
void closeEvent(QCloseEvent *event)
Overrides QWidget::closeEvent().
void finalize()
Finalizes the GUI.
Abstraction for a display widget that can show the progress of an operation.
void pauseRequested()
Signal for when the user requests &quot;pause&quot; for the thread.
void resumeRequested()
Signal for when the user requests &quot;resume&quot; for the thread.
void backgroundRequested()
Signal for when the user requests &quot;background&quot; for the thread.
void cancel()
For the &quot;cancel&quot; button.
void cancelRequested()
Signal for when the user requests &quot;cancel&quot; for the thread.
QMutex & mutex()
Returns the mutex used for this widget.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
GUI for displaying progress information.
void pauseResume(bool pause)
For the &quot;pause&quot;/&quot;resume&quot; button.
void initialize(const casacore::String &operationName)
Initialize the monitor with the identifying operation.
Ui::ProgressWidget * itsProgress_
casacore::Normal widget.
QtProgressWidget(bool allowBackground=true, bool allowPauseResume=true, bool allowCancel=true, bool isDialog=true, bool useCompact=false, QWidget *parent=NULL)
Constructor which takes the PlotMS parent an optional parent widget.