26 #define YUILogComponent "qt-ui"
27 #include <yui/YUILog.h>
28 #include <qcheckbox.h>
30 #include <QVBoxLayout>
33 #include <yui/YEvent.h>
36 #include "YQCheckBoxFrame.h"
48 : QGroupBox( (QWidget *) parent->widgetRep() )
49 , YCheckBoxFrame( parent, label, checked)
51 setWidgetRep (
this );
52 QGroupBox::setTitle( fromUTF8( label ) );
53 QGroupBox::setCheckable(
true );
56 connect(
this, &pclass(
this)::toggled,
57 this, &pclass(
this)::stateChanged );
63 YCheckBoxFrame::setLabel( newLabel );
64 QGroupBox::setTitle( fromUTF8( label() ) );
70 return QGroupBox::isChecked();
76 setChecked( newValue );
85 QGroupBox::setEnabled(
true );
86 handleChildrenEnablement(
value() );
90 QGroupBox::setEnabled(
true );
91 YWidget::setChildrenEnabled(
false );
94 YWidget::setEnabled( enabled );
98 void YQCheckBoxFrame::stateChanged(
bool newState )
105 bool YQCheckBoxFrame::event( QEvent *e )
107 bool oldChildEnabled =
true;
109 if ( YCheckBoxFrame::hasChildren() )
110 oldChildEnabled = YCheckBoxFrame::firstChild()->isEnabled();
112 bool oldStatus = QGroupBox::isChecked();
113 bool ret = QGroupBox::event( e );
114 bool newStatus = QGroupBox::isChecked();
116 if ( oldStatus != newStatus )
118 yuiDebug() <<
"Status change of " <<
this <<
" : now " << std::boolalpha << newStatus << endl;
122 handleChildrenEnablement( newStatus );
126 if ( YCheckBoxFrame::hasChildren() )
127 YCheckBoxFrame::firstChild()->setEnabled( oldChildEnabled );
137 if ( event->added() )
145 QGroupBox::childEvent( event );
152 resize ( newWidth, newHeight );
156 QMargins margins = contentsMargins();
157 int newChildWidth = newWidth - margins.left() - margins.right();
158 int newChildHeight = newHeight - margins.bottom() - margins.top();
160 firstChild()->setSize( newChildWidth, newChildHeight );
162 QWidget * qChild = (QWidget *) firstChild()->widgetRep();
163 qChild->move( margins.left(), margins.top() );
170 int preferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
171 QMargins margins = contentsMargins();
179 int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
180 QMargins margins = contentsMargins();