|
@@ -28,13 +28,26 @@
|
|
|
#include "ctkWidgetsExport.h"
|
|
|
|
|
|
/// A QGroupBox with an arrow indicator that shows/hides the groupbox contents
|
|
|
-/// when clicked.
|
|
|
+/// when clicked. It responds to the slot QGroupBox::setChecked(bool) or
|
|
|
+/// ctkCollapsibleGroupBox::setCollapsed(bool)
|
|
|
+/// When checked is true, the groupbox is expanded
|
|
|
+/// When checked is false, the groupbox is collapsed
|
|
|
class CTK_WIDGETS_EXPORT ctkCollapsibleGroupBox : public QGroupBox
|
|
|
{
|
|
|
Q_OBJECT
|
|
|
public:
|
|
|
explicit ctkCollapsibleGroupBox(QWidget* parent = 0);
|
|
|
virtual ~ctkCollapsibleGroupBox();
|
|
|
+
|
|
|
+ /// Utility function to collapse the groupbox
|
|
|
+ /// Collapse(close) the group box if collapse is true, expand(open)
|
|
|
+ /// it otherwise.
|
|
|
+ /// \sa QGroupBox::setChecked(bool)
|
|
|
+ inline void setCollapsed(bool collapse);
|
|
|
+
|
|
|
+ /// Return the collapse state of the groupbox
|
|
|
+ /// true if the groupbox is collapsed (closed), false if it is expanded(open)
|
|
|
+ inline bool collapsed()const;
|
|
|
|
|
|
/// Reimplemtented for internal reasons
|
|
|
virtual int heightForWidth(int w) const;
|
|
@@ -45,6 +58,7 @@ public:
|
|
|
|
|
|
protected slots:
|
|
|
/// called when the arrow indicator is clicked
|
|
|
+ /// users can call it programatically by calling setChecked(bool)
|
|
|
virtual void expand(bool expand);
|
|
|
|
|
|
protected:
|
|
@@ -64,4 +78,16 @@ protected:
|
|
|
int MaxHeight;
|
|
|
};
|
|
|
|
|
|
+//----------------------------------------------------------------------------
|
|
|
+bool ctkCollapsibleGroupBox::collapsed()const
|
|
|
+{
|
|
|
+ return !this->isChecked();
|
|
|
+}
|
|
|
+
|
|
|
+//----------------------------------------------------------------------------
|
|
|
+void ctkCollapsibleGroupBox::setCollapsed(bool collapse)
|
|
|
+{
|
|
|
+ this->setChecked(!collapse);
|
|
|
+}
|
|
|
+
|
|
|
#endif
|