casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtButtonGroup.qo.h
Go to the documentation of this file.
1 //# QtButtonGroup.qo.h: Like QButtonGroup but with additional functionality.
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 QTBUTTONGROUP_QO_H_
28 #define QTBUTTONGROUP_QO_H_
29 
30 #include <QAbstractButton>
31 
32 namespace casa {
33 
34 // This class meant to be used almost identically to an exclusive QButtonGroup.
35 // The difference is that this class allows all QAbstractButtons to be
36 // unchecked; in other words, either one button is checked or none are. Some
37 // methods from QButtonGroup have not been included, but they would be easy to
38 // include if desired.
39 class QtButtonGroup : public QObject {
40  Q_OBJECT
41 
42 public:
43  // Constructor that takes optional parent object.
44  QtButtonGroup(QObject* parent);
45 
46  // Destructor.
48 
49 
50  // See QButtonGroup::buttons().
51  QList<QAbstractButton*> buttons() const;
52 
53  // See QButtonGroup::checkedButton(). Will return NULL if no button is
54  // currently checked.
55  QAbstractButton* checkedButton() const;
56 
57  // See QButtonGroup::addButton().
58  void addButton(QAbstractButton* button);
59 
60  // See QButtonGroup::removeButton().
61  void removeButton(QAbstractButton* button);
62 
63  // Returns whether this group is enabled or not.
64  bool isEnabled() const;
65 
66 public slots:
67  // Sets all buttons to enabled.
68  void setEnabled(bool enabled);
69 
70  // Sets all buttons to disabled.
71  void setDisabled(bool disabled) { setEnabled(!disabled); }
72 
73 signals:
74  // See QButtonGroup::buttonClicked().
75  void buttonClicked(QAbstractButton* button);
76 
77  // See QButtonGroup::buttonPressed().
78  void buttonPressed(QAbstractButton* button);
79 
80  // See QButtonGroup::buttonReleased().
81  void buttonReleased(QAbstractButton* button);
82 
83  // This signals is emitted when all buttons in the group have been
84  // unchecked.
85  void unchecked();
86 
87 private:
88  // Enabled flag.
89  bool isEnabled_;
90 
91  // Currently checked button, or NULL if none are checked.
92  QAbstractButton* itsCheckedButton_;
93 
94  // Buttons in group.
95  QList<QAbstractButton*> itsButtons_;
96 
97 
98  // Method for when a button is the group is checked or toggled.
99  void toggled_(QAbstractButton* button, bool checked);
100 
101 private slots:
102  // Slot for QAbstractButton::clicked(), which calls toggled_() as needed.
103  void clicked(bool checked);
104 
105  // Slot for QAbstractButton::toggled(), which calls toggled_() as needed.
106  void toggled(bool checked);
107 
108  // Slot for QAbstractButton::pressed().
109  void pressed();
110 
111  // Slot for QAbstractButton::released().
112  void released();
113 };
114 
115 }
116 
117 #endif /* QTBUTTONGROUP_QO_H_ */
void buttonReleased(QAbstractButton *button)
See QButtonGroup::buttonReleased().
void toggled(bool checked)
Slot for QAbstractButton::toggled(), which calls toggled_() as needed.
void removeButton(QAbstractButton *button)
See QButtonGroup::removeButton().
QList< QAbstractButton * > itsButtons_
Buttons in group.
void buttonPressed(QAbstractButton *button)
See QButtonGroup::buttonPressed().
void addButton(QAbstractButton *button)
See QButtonGroup::addButton().
QtButtonGroup(QObject *parent)
Constructor that takes optional parent object.
void unchecked()
This signals is emitted when all buttons in the group have been unchecked.
void clicked(bool checked)
Slot for QAbstractButton::clicked(), which calls toggled_() as needed.
void buttonClicked(QAbstractButton *button)
See QButtonGroup::buttonClicked().
~QtButtonGroup()
Destructor.
QAbstractButton * checkedButton() const
See QButtonGroup::checkedButton().
void toggled_(QAbstractButton *button, bool checked)
Method for when a button is the group is checked or toggled.
void setEnabled(bool enabled)
Sets all buttons to enabled.
void pressed()
Slot for QAbstractButton::pressed().
This class meant to be used almost identically to an exclusive QButtonGroup.
void setDisabled(bool disabled)
Sets all buttons to disabled.
bool isEnabled_
Enabled flag.
QAbstractButton * itsCheckedButton_
Currently checked button, or NULL if none are checked.
bool isEnabled() const
Returns whether this group is enabled or not.
void released()
Slot for QAbstractButton::released().
QList< QAbstractButton * > buttons() const
See QButtonGroup::buttons().