casa
$Rev:20696$
|
00001 //# QtProgressWidget.qo.h: Qt widget for displaying progress information. 00002 //# Copyright (C) 2009 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: $ 00027 #ifndef QTPROGRESSWIDGET_QO_H_ 00028 #define QTPROGRESSWIDGET_QO_H_ 00029 00030 #include <casaqt/QtUtilities/QtProgressCompactWidget.ui.h> 00031 #include <casaqt/QtUtilities/QtProgressWidget.ui.h> 00032 00033 #include <QMutex> 00034 00035 namespace casa { 00036 00037 // GUI for displaying progress information. It also shows "background", 00038 // "cancel", and "pause/resume" buttons for the user. The parent of this 00039 // widget is responsible for implementing these behaviors as needed. 00040 class QtProgressWidget : public QWidget { 00041 Q_OBJECT 00042 00043 public: 00044 // Constructor which takes the PlotMS parent an optional parent widget. 00045 QtProgressWidget(bool allowBackground = true, 00046 bool allowPauseResume = true, bool allowCancel = true, 00047 bool isDialog = true, bool useCompact = false, 00048 QWidget* parent = NULL); 00049 00050 // Destructor. 00051 ~QtProgressWidget(); 00052 00053 00054 // Sets which operations the user can request using this widget. 00055 void setAllowedOperations(bool background, bool pauseResume, bool cancel); 00056 00057 // Returns the mutex used for this widget. 00058 QMutex& mutex(); 00059 00060 public slots: 00061 // Initializes the GUI with the given operation name. Should be called 00062 // before the operation starts. 00063 void initialize(const QString& operationName); 00064 00065 // Sets the status to the given. 00066 void setStatus(const QString& status); 00067 00068 // Sets the progress percentage (0 - 100) to the given. 00069 void setProgress(unsigned int progress); 00070 00071 // Sets the progress percentage (0 - 100) and the status to the given. 00072 void setProgress(unsigned int progress, const QString& status); 00073 00074 // Finalizes the GUI. Should be called after the operation ends. 00075 void finalize(); 00076 00077 signals: 00078 // Signal for when the user requests "background" for the thread. 00079 void backgroundRequested(); 00080 00081 // Signal for when the user requests "pause" for the thread. 00082 void pauseRequested(); 00083 00084 // Signal for when the user requests "resume" for the thread. 00085 void resumeRequested(); 00086 00087 // Signal for when the user requests "cancel" for the thread. 00088 void cancelRequested(); 00089 00090 protected: 00091 // Overrides QWidget::closeEvent(). Connects closing to the "background" 00092 // signal. 00093 void closeEvent(QCloseEvent* event); 00094 00095 private: 00096 // Mutex. 00097 QMutex itsMutex_; 00098 00099 // Normal widget. 00100 Ui::ProgressWidget* itsProgress_; 00101 00102 // Compact widget. 00103 Ui::ProgressCompactWidget* itsCompactProgress_; 00104 00105 private slots: 00106 // For the "background" button. 00107 void background(); 00108 00109 // For the "pause"/"resume" button. 00110 void pauseResume(bool pause); 00111 00112 // For the "cancel" button. 00113 void cancel(); 00114 }; 00115 00116 } 00117 00118 #endif /* QTPROGRESSWIDGET_QO_H_ */