Author: coolo
Date: Sun Dec 9 11:16:38 2007
New Revision: 42856
URL: http://svn.opensuse.org/viewcvs/yast?rev=42856&view=rev
Log:
reworked the hack to be more generic and less specific
to Qt3 internals
Modified:
trunk/qt4/src/YQCheckBoxFrame.cc
trunk/qt4/src/YQCheckBoxFrame.h
Modified: trunk/qt4/src/YQCheckBoxFrame.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQCheckBoxFrame.cc?rev=42856&r1=42855&r2=42856&view=diff
==============================================================================
--- trunk/qt4/src/YQCheckBoxFrame.cc (original)
+++ trunk/qt4/src/YQCheckBoxFrame.cc Sun Dec 9 11:16:38 2007
@@ -44,6 +44,8 @@
QGroupBox::setTitle( fromUTF8( label ) );
QGroupBox::setCheckable( true );
+ connect( this, SIGNAL( toggled( bool ) ),
+ SLOT( stateChanged( bool ) ) );
setValue( checked );
}
@@ -88,13 +90,49 @@
void YQCheckBoxFrame::stateChanged( bool newState )
{
- y2debug( "new state: %d", newState );
handleChildrenEnablement( newState );
if ( notify() )
YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
}
+bool YQCheckBoxFrame::event(QEvent *e)
+{
+ /* now on to something very fishy. The purpose of this widget
+ * is for whatever reason to provide a checkbox with a groupbox
+ * without the children having any connection to it.
+ *
+ * So we use this trick to undo everything the base class did
+ */
+ QHash widgetState;
+
+ QObjectList childList = children();
+ for (int i = 0; i < childList.size(); ++i)
+ {
+ QObject *o = childList.at(i);
+ if (o->isWidgetType())
+ {
+ QWidget *w = static_cast(o);
+ widgetState[w] = w->isEnabled();
+ }
+ }
+
+ bool ret = QGroupBox::event( e );
+
+ childList = children();
+ for (int i = 0; i < childList.size(); ++i)
+ {
+ QObject *o = childList.at(i);
+ if (o->isWidgetType())
+ {
+ QWidget *w = static_cast(o);
+ if ( widgetState.contains( w ) )
+ w->setEnabled( widgetState[w] );
+ }
+ }
+
+ return ret;
+}
void YQCheckBoxFrame::childEvent( QChildEvent * )
{
@@ -127,11 +165,7 @@
int YQCheckBoxFrame::preferredWidth()
{
- int preferredWidth;
- int childPreferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
-
- preferredWidth = max( childPreferredWidth,
- (10 + fontMetrics().width( title() ) ) );
+ int preferredWidth = hasChildren() ? firstChild()->preferredWidth() : 0;
int left, top, right, bottom;
getContentsMargins( &left, &top, &right, &bottom );
Modified: trunk/qt4/src/YQCheckBoxFrame.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQCheckBoxFrame.h?rev=42856&r1=42855&r2=42856&view=diff
==============================================================================
--- trunk/qt4/src/YQCheckBoxFrame.h (original)
+++ trunk/qt4/src/YQCheckBoxFrame.h Sun Dec 9 11:16:38 2007
@@ -113,6 +113,7 @@
**/
virtual void childEvent( QChildEvent * );
+ virtual bool event(QEvent *e);
//
// Data members
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org