QCloseableWidget.qo.h

Go to the documentation of this file.
00001 //# QCloseableWidget.qo.h: Wrapper around a QWidget with a "Close" button.
00002 //# Copyright (C) 2005
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 QCLOSEABLEWIDGET_H_
00028 #define QCLOSEABLEWIDGET_H_
00029 
00030 #include <casaqt/QtBrowser/QCloseableWidget.ui.h>
00031 
00032 #include <QtGui>
00033 
00034 #include <casa/BasicSL/String.h>
00035 
00036 namespace casa {
00037 
00038 // <summary>
00039 // Wrapper around a QWidget with a "Close" button
00040 // </summary>
00041 //
00042 // <synopsis>
00043 // A QCloseableWidget is a convenience class that adds a "close" functionality
00044 // to any QWidget subclass.  It does this by providing methods (such as getting,
00045 // setting, and clearing the QWidget) and signals indicating when the close
00046 // button has been pressed.  <b>Important</b>: it is the responsibility of the
00047 // caller/parent to actually close the object; the QCloseableWidget just
00048 // provides the signal.
00049 // </synopsis>
00050 
00051 class QCloseableWidget : public QWidget, Ui::Widget {
00052     Q_OBJECT
00053     
00054 public:
00055     // Default Constructor.  Creates a blank widget with a close button.
00056     QCloseableWidget();
00057     
00058     // Constructor that takes the initial widget to display and the text for
00059     // the close button.  If the text is empty, the default close button text
00060     // is displayed.
00061     QCloseableWidget(QWidget* widget, String closeText = "");
00062 
00063     ~QCloseableWidget();
00064 
00065     
00066     // Returns the current widget held by the wrapper.
00067     QWidget* getCurrentWidget();
00068 
00069     // Sets the current widget to the given widget.  If shouldDeleteOld is true,
00070     // the old widget held by the wrapper is deleted.
00071     void setWidget(QWidget* widget, bool shouldDeleteOld = false);
00072     
00073     // Sets the text on the "close" button to the given String.
00074     void setCloseButtonText(String name);
00075 
00076     
00077     // "Clears" the current widget by replacing it with a blank widget.
00078     // This method does delete the old widget.
00079     void clearWidget();
00080 
00081 signals:
00082     // The closeRequested signal is emitted whenever the "Close" button is
00083     // pressed.  The widget paramater points to the currently shown widget,
00084         // or NULL if there is none.
00085     void closeRequested(QWidget* widget);
00086     
00087 private:
00088     // Convenience pointer to the layout of this QCloseableWidget.
00089     QGridLayout* grid;
00090 
00091     // The current widget held by the wrapper.
00092     QWidget* currWidget;
00093     
00094     
00095     // Initial set-up of GUI components.
00096     void setup();
00097 
00098 private slots:
00099     // Slot to handle the "Close" button's clicked() signal.  Emits the
00100     // closeRequested() signal.
00101     void closeRequest();
00102 };
00103 
00104 }
00105 
00106 #endif /* QCLOSEABLEWIDGET_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1