26 #define YUILogComponent "qt-ui"
27 #include <yui/YUILog.h>
28 #include <qcheckbox.h>
30 #include <QVBoxLayout>
33 #include <yui/YEvent.h>
38 #include "YQCheckBoxFrame.h"
44 const std::string & label,
46 : QGroupBox( (QWidget *) parent->widgetRep() )
47 , YCheckBoxFrame( parent, label, checked)
49 setWidgetRep (
this );
50 QGroupBox::setTitle( fromUTF8( label ) );
51 QGroupBox::setCheckable(
true );
54 connect(
this, &pclass(
this)::toggled,
55 this, &pclass(
this)::stateChanged );
61 YCheckBoxFrame::setLabel( newLabel );
62 QGroupBox::setTitle( fromUTF8( label() ) );
68 return QGroupBox::isChecked();
74 setChecked( newValue );
83 QGroupBox::setEnabled(
true );
84 handleChildrenEnablement(
value() );
88 QGroupBox::setEnabled(
true );
89 YWidget::setChildrenEnabled(
false );
92 YWidget::setEnabled( enabled );
96 void YQCheckBoxFrame::stateChanged(
bool newState )
103 bool YQCheckBoxFrame::event( QEvent *e )
105 bool oldChildEnabled =
true;
107 if ( YCheckBoxFrame::hasChildren() )
108 oldChildEnabled = YCheckBoxFrame::firstChild()->isEnabled();
110 bool oldStatus = QGroupBox::isChecked();
111 bool ret = QGroupBox::event( e );
112 bool newStatus = QGroupBox::isChecked();
114 if ( oldStatus != newStatus )
116 yuiDebug() <<
"Status change of " <<
this <<
" : now " << std::boolalpha << newStatus << std::endl;
120 handleChildrenEnablement( newStatus );
124 if ( YCheckBoxFrame::hasChildren() )
125 YCheckBoxFrame::firstChild()->setEnabled( oldChildEnabled );
135 if ( event->added() )
143 QGroupBox::childEvent( event );
150 resize ( newWidth, newHeight );
154 int left, top, right, bottom;
155 getContentsMargins( &left, &top, &right, &bottom );
156 int newChildWidth = newWidth - left - right;
157 int newChildHeight = newHeight - bottom - top;
159 firstChild()->setSize( newChildWidth, newChildHeight );
161 QWidget * qChild = (QWidget *) firstChild()->widgetRep();
162 qChild->move( left, top );
169 int preferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
170 int left, top, right, bottom;
171 getContentsMargins( &left, &top, &right, &bottom );
173 return preferredWidth + left + right;
179 int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
180 int left, top, right, bottom;
181 getContentsMargins( &left, &top, &right, &bottom );
183 return preferredHeight + top + left;
197 #include "YQCheckBoxFrame.moc"