QtProgressWidget.qo.h

Go to the documentation of this file.
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 <graphics/GenericPlotter/ProgressMonitor.h>
00031 #include <casaqt/QtUtilities/QtProgressCompactWidget.ui.h>
00032 #include <casaqt/QtUtilities/QtProgressWidget.ui.h>
00033 
00034 #include <QMutex>
00035 
00036 namespace casa {
00037 
00038 // GUI for displaying progress information.  It also shows "background",
00039 // "cancel", and "pause/resume" buttons for the user.  The parent of this
00040 // widget is responsible for implementing these behaviors as needed.
00041 class QtProgressWidget : public QWidget, public ProgressMonitor {
00042     Q_OBJECT
00043     
00044 public:
00045     // Constructor which takes the PlotMS parent an optional parent widget.
00046     QtProgressWidget(bool allowBackground = true,
00047             bool allowPauseResume = true, bool allowCancel = true,
00048             bool isDialog = true, bool useCompact = false,
00049             QWidget* parent = NULL);
00050     
00051     // Destructor.
00052     ~QtProgressWidget();
00053     
00054     
00055     // Sets which operations the user can request using this widget.
00056     void setAllowedOperations(bool background, bool pauseResume, bool cancel);
00057     
00058     // Returns the mutex used for this widget.
00059     QMutex& mutex();
00060     
00061     void initialize( const String& operationName );
00062     void setProgress(unsigned int progress, const String& status);
00063 
00064 public slots:
00065     // Initializes the GUI with the given operation name.  Should be called
00066     // before the operation starts.
00067     void initialize(const QString& operationName);
00068 
00069     // Sets the status to the given.
00070     void setStatus(const QString& status);
00071     
00072     // Sets the progress percentage (0 - 100) to the given.
00073     void setProgress(unsigned int progress);
00074     
00075     // Sets the progress percentage (0 - 100) and the status to the given.
00076     void setProgress(unsigned int progress, const QString& status);
00077     
00078     // Finalizes the GUI.  Should be called after the operation ends.
00079     void finalize();
00080     
00081 signals:
00082     // Signal for when the user requests "background" for the thread.
00083     void backgroundRequested();
00084     
00085     // Signal for when the user requests "pause" for the thread.
00086     void pauseRequested();
00087     
00088     // Signal for when the user requests "resume" for the thread.
00089     void resumeRequested();
00090     
00091     // Signal for when the user requests "cancel" for the thread.
00092     void cancelRequested();
00093     
00094 protected:
00095     // Overrides QWidget::closeEvent().  Connects closing to the "background"
00096     // signal.
00097     void closeEvent(QCloseEvent* event);
00098     
00099 private:    
00100     // Mutex.
00101     QMutex itsMutex_;
00102     
00103     // Normal widget.
00104     Ui::ProgressWidget* itsProgress_;
00105     
00106     // Compact widget.
00107     Ui::ProgressCompactWidget* itsCompactProgress_;
00108     
00109 private slots:
00110     // For the "background" button.
00111     void background();
00112     
00113     // For the "pause"/"resume" button.
00114     void pauseResume(bool pause);
00115     
00116     // For the "cancel" button.
00117     void cancel();
00118 };
00119 
00120 }
00121 
00122 #endif /* QTPROGRESSWIDGET_QO_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1