casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QCloseableWidget.qo.h
Go to the documentation of this file.
1 //# QCloseableWidget.qo.h: Wrapper around a QWidget with a "Close" button.
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 QCLOSEABLEWIDGET_H_
28 #define QCLOSEABLEWIDGET_H_
29 
30 #include <casaqt/QtBrowser/QCloseableWidget.ui.h>
31 
32 #include <QtGui>
33 
34 #include <casa/BasicSL/String.h>
35 
36 namespace casa {
37 
38 // <summary>
39 // Wrapper around a QWidget with a "Close" button
40 // </summary>
41 //
42 // <synopsis>
43 // A QCloseableWidget is a convenience class that adds a "close" functionality
44 // to any QWidget subclass. It does this by providing methods (such as getting,
45 // setting, and clearing the QWidget) and signals indicating when the close
46 // button has been pressed. <b>Important</b>: it is the responsibility of the
47 // caller/parent to actually close the object; the QCloseableWidget just
48 // provides the signal.
49 // </synopsis>
50 
51 class QCloseableWidget : public QWidget, Ui::Widget {
52  Q_OBJECT
53 
54 public:
55  // Default Constructor. Creates a blank widget with a close button.
57 
58  // Constructor that takes the initial widget to display and the text for
59  // the close button. If the text is empty, the default close button text
60  // is displayed.
61  QCloseableWidget(QWidget* widget, casacore::String closeText = "");
62 
64 
65 
66  // Returns the current widget held by the wrapper.
67  QWidget* getCurrentWidget();
68 
69  // Sets the current widget to the given widget. If shouldDeleteOld is true,
70  // the old widget held by the wrapper is deleted.
71  void setWidget(QWidget* widget, bool shouldDeleteOld = false);
72 
73  // Sets the text on the "close" button to the given String.
75 
76 
77  // "Clears" the current widget by replacing it with a blank widget.
78  // This method does delete the old widget.
79  void clearWidget();
80 
81 signals:
82  // The closeRequested signal is emitted whenever the "Close" button is
83  // pressed. The widget paramater points to the currently shown widget,
84  // or NULL if there is none.
85  void closeRequested(QWidget* widget);
86 
87 private:
88  // Convenience pointer to the layout of this QCloseableWidget.
89  QGridLayout* grid;
90 
91  // The current widget held by the wrapper.
92  QWidget* currWidget;
93 
94 
95  // Initial set-up of GUI components.
96  void setup();
97 
98 private slots:
99  // Slot to handle the "Close" button's clicked() signal. Emits the
100  // closeRequested() signal.
101  void closeRequest();
102 };
103 
104 }
105 
106 #endif /* QCLOSEABLEWIDGET_H_ */
QGridLayout * grid
Convenience pointer to the layout of this QCloseableWidget.
QCloseableWidget()
Default Constructor.
QWidget * getCurrentWidget()
Returns the current widget held by the wrapper.
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
void closeRequested(QWidget *widget)
The closeRequested signal is emitted whenever the &quot;Close&quot; button is pressed.
void setCloseButtonText(casacore::String name)
Sets the text on the &quot;close&quot; button to the given String.
void setWidget(QWidget *widget, bool shouldDeleteOld=false)
Sets the current widget to the given widget.
QWidget * currWidget
The current widget held by the wrapper.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Wrapper around a QWidget with a &quot;Close&quot; button.
void setup()
Initial set-up of GUI components.
void clearWidget()
&quot;Clears&quot; the current widget by replacing it with a blank widget.
void closeRequest()
Slot to handle the &quot;Close&quot; button&#39;s clicked() signal.