Author: coolo
Date: Sun Dec 9 09:35:50 2007
New Revision: 42855
URL: http://svn.opensuse.org/viewcvs/yast?rev=42855&view=rev
Log:
give checkboxframe examples some love. The 3rd example
does not work though as the evil hack can no longer work.
Modified:
trunk/qt4/src/YQCheckBox.cc
trunk/qt4/src/YQCheckBoxFrame.cc
trunk/qt4/src/YQCheckBoxFrame.h
Modified: trunk/qt4/src/YQCheckBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQCheckBox.cc?rev=42855&r1=42854&r2=42855&view=diff
==============================================================================
--- trunk/qt4/src/YQCheckBox.cc (original)
+++ trunk/qt4/src/YQCheckBox.cc Sun Dec 9 09:35:50 2007
@@ -109,7 +109,7 @@
void YQCheckBox::setEnabled( bool enabled )
{
- setEnabled( enabled );
+ QCheckBox::setEnabled( enabled );
YWidget::setEnabled( enabled );
}
Modified: trunk/qt4/src/YQCheckBoxFrame.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQCheckBoxFrame.cc?rev=42855&r1=42854&r2=42855&view=diff
==============================================================================
--- trunk/qt4/src/YQCheckBoxFrame.cc (original)
+++ trunk/qt4/src/YQCheckBoxFrame.cc Sun Dec 9 09:35:50 2007
@@ -20,8 +20,8 @@
#define y2log_component "qt-ui"
#include
#include
-//Added by qt3to4:
-#include <Q3GroupBox>
+#include <QDebug>
+#include <QVBoxLayout>
#include
#include "YQUI.h"
#include "YEvent.h"
@@ -43,7 +43,6 @@
setWidgetRep ( this );
QGroupBox::setTitle( fromUTF8( label ) );
QGroupBox::setCheckable( true );
- preventQGroupBoxAutoEnablement();
setValue( checked );
}
@@ -70,7 +69,6 @@
setChecked( newValue );
}
-
void YQCheckBoxFrame::setEnabled( bool enabled )
{
if ( enabled )
@@ -88,51 +86,6 @@
}
-void YQCheckBoxFrame::preventQGroupBoxAutoEnablement()
-{
- /*
- * This is a nasty hack. But it is necessary because QGroupBox handles its
- * internal check box too nearsightedly: It forces all children to be
- * enabled or disabled depending on the status of the check box. The
- * behaviour cannot be inverted or suppressed.
- *
- * In some cases, however, it makes sense to let the application decide to
- * handle that differently. Since the YaST2 UI is a toolkit, we leave this
- * decision up to the application rather than forcing any specific behaviour.
- */
-
- // Find the check box in the child hierarchy (as a direct child)
- // NOTE findChild search recursively by default
- _checkBox = QObject::findChild();
-
- if ( ! _checkBox )
- {
- y2warning( "Can't find QCheckBox child" );
-
- connect( this, SIGNAL( toggled ( bool ) ),
- this, SLOT ( stateChanged( bool ) ) );
-
- return;
- }
-
- // Disconnect all signals to this object.
- //
- // In particular, disconnect the connection from the check box's
- // 'toggled()' signal to this object's parent class's (private)
- // setChildrenEnabled() method.
-
- disconnect( _checkBox, // sender
- 0, // signal
- this, // receiver
- 0 ); // slot (private method in parent class)
-
- // Connect the check box directly to this class.
-
- connect( _checkBox, SIGNAL( toggled ( bool ) ),
- this, SLOT ( stateChanged( bool ) ) );
-}
-
-
void YQCheckBoxFrame::stateChanged( bool newState )
{
y2debug( "new state: %d", newState );
@@ -159,16 +112,15 @@
if ( hasChildren() )
{
-#warning possibly this hack is not needed
- /*
- int newChildWidth = max ( 0, newWidth - 2 * frameWidth() - 1 );
- int newChildHeight = max ( 0, newHeight - frameWidth() - fontMetrics().height() - TOP_MARGIN - 1 );
+ int left, top, right, bottom;
+ getContentsMargins( &left, &top, &right, &bottom );
+ int newChildWidth = newWidth - left - right;
+ int newChildHeight = newHeight - bottom - top;
firstChild()->setSize( newChildWidth, newChildHeight );
QWidget * qChild = (QWidget *) firstChild()->widgetRep();
- qChild->move( frameWidth(), fontMetrics().height() + TOP_MARGIN );
- */
+ qChild->move( left, top );
}
}
@@ -180,7 +132,10 @@
preferredWidth = max( childPreferredWidth,
(10 + fontMetrics().width( title() ) ) );
- // preferredWidth += 2*frameWidth() + 1;
+ int left, top, right, bottom;
+ getContentsMargins( &left, &top, &right, &bottom );
+
+ preferredWidth += left + right;
return preferredWidth;
}
@@ -189,7 +144,10 @@
int YQCheckBoxFrame::preferredHeight()
{
int preferredHeight = hasChildren() ? firstChild()->preferredHeight() : 0;
- // preferredHeight += frameWidth() + fontMetrics().height() + TOP_MARGIN + 1;
+ int left, top, right, bottom;
+ getContentsMargins( &left, &top, &right, &bottom );
+
+ preferredHeight += top + left;
return preferredHeight;
}
Modified: trunk/qt4/src/YQCheckBoxFrame.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt4/src/YQCheckBoxFrame.h?rev=42855&r1=42854&r2=42855&view=diff
==============================================================================
--- trunk/qt4/src/YQCheckBoxFrame.h (original)
+++ trunk/qt4/src/YQCheckBoxFrame.h Sun Dec 9 09:35:50 2007
@@ -108,17 +108,6 @@
protected:
/**
- * Prevent standard QGroupBox behaviour to always enable or disable all
- * children according to its check box's status (can't be inverted or left
- * to the application).
- *
- * This is a nasty hack, but it prevents oversights from the Qt designers.
- * Their view on how that check box should affect the frame content appears
- * to be somewhat limiting.
- **/
- void preventQGroupBoxAutoEnablement();
-
- /**
* Reimplemented from QGroupBox to prevent QGroupBox from disabling
* children according to the check box status as the children are inserted.
**/
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org