Author: sh-sh-sh
Date: Tue Jun 26 17:29:52 2007
New Revision: 39035
URL: http://svn.opensuse.org/viewcvs/yast?rev=39035&view=rev
Log:
- migrated CheckBox
- enabled special handling for not-so-standard properties
Modified:
branches/tmp/sh/mod-ui/core/libyui/src/YAlignment.cc
branches/tmp/sh/mod-ui/core/libyui/src/YApplication.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.h
branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc
branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.h
branches/tmp/sh/mod-ui/core/libyui/src/YEmpty.cc
branches/tmp/sh/mod-ui/core/libyui/src/YFrame.cc
branches/tmp/sh/mod-ui/core/libyui/src/YFrame.h
branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc
branches/tmp/sh/mod-ui/core/libyui/src/YInputField.h
branches/tmp/sh/mod-ui/core/libyui/src/YLabel.cc
branches/tmp/sh/mod-ui/core/libyui/src/YLabel.h
branches/tmp/sh/mod-ui/core/libyui/src/YLayoutBox.cc
branches/tmp/sh/mod-ui/core/libyui/src/YProperty.cc
branches/tmp/sh/mod-ui/core/libyui/src/YProperty.h
branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.cc
branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.cc
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.h
branches/tmp/sh/mod-ui/core/libyui/src/YSpacing.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSquash.cc
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
branches/tmp/sh/mod-ui/qt/src/YQCheckBox.cc
branches/tmp/sh/mod-ui/qt/src/YQCheckBox.h
branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc
branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h
branches/tmp/sh/mod-ui/qt/src/YQUI.h
branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YAlignment.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YAlignment.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YAlignment.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YAlignment.cc Tue Jun 26 17:29:52 2007
@@ -69,7 +69,7 @@
: YSingleChildContainerWidget( parent )
, priv( new YAlignmentPrivate( horAlign, vertAlign ) )
{
- // NOP
+ YUI_CHECK_NEW( priv );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YApplication.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YApplication.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YApplication.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YApplication.cc Tue Jun 26 17:29:52 2007
@@ -33,7 +33,7 @@
YApplication::YApplication()
: priv( new YApplicationPrivate() )
{
-
+ YUI_CHECK_NEW( priv );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Tue Jun 26 17:29:52 2007
@@ -41,6 +41,7 @@
#include "YAlignment.h"
#include "YBarGraph.h"
+#include "YCheckBox.h"
#include "YCheckBoxFrame.h"
#include "YComboBox.h"
#include "YDumbTab.h"
@@ -1400,26 +1401,30 @@
* A checkbox widget has two states: Checked and not checked. It returns no
* user input but you can query and change its state via the <tt>Value</tt>
* property.
- *
**/
YWidget *
YCPDialogParser::parseCheckBox( YWidget * parent, YWidgetOpt & opt,
const YCPTerm & term, const YCPList & optList, int argnr )
{
- int s = term->size() - argnr;
- if ( s < 1 || s > 2
- || !term->value(argnr)->isString()
- || (s == 2 && !term->value(argnr+1)->isBoolean()))
+ int size = term->size() - argnr;
+ if ( size < 1 || size > 2
+ || !term->value( argnr )->isString()
+ || ( size == 2 && ! term->value(argnr+1)->isBoolean() ) )
{
y2error( "Invalid arguments for the CheckBox widget: %s",
term->toString().c_str() );
return 0;
}
rejectAllOptions( term,optList );
- YCPBoolean checked( false );
- if ( s == 2 ) checked = term->value( argnr+1 )->asBoolean();
- return YUI::ui()->createCheckBox( parent, opt, term->value( argnr )->asString(), checked->value() );
+
+ string label = term->value( argnr )->asString()->value();
+ bool checked = false;
+
+ if ( size == 2 )
+ checked = term->value( argnr+1 )->asBoolean()->value();
+
+ return YUI::widgetFactory()->createCheckBox( parent, label, checked );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc Tue Jun 26 17:29:52 2007
@@ -17,8 +17,6 @@
/-*/
-#include
-#include
#define y2log_component "ui"
#include
@@ -27,69 +25,104 @@
#include "YCheckBox.h"
-YCheckBox::YCheckBox( const YWidgetOpt & opt, const YCPString & label )
- : YWidget( opt )
- , label( label )
+struct YCheckBoxPrivate
{
+ YCheckBoxPrivate( const string & label )
+ : label( label )
+ , useBoldFont( false )
+ {}
+
+ string label;
+ bool useBoldFont;
+};
+
+
+YCheckBox::YCheckBox( YWidget * parent, const string & label )
+ : YWidget( parent )
+ , priv( new YCheckBoxPrivate( label ) )
+{
+ YUI_CHECK_NEW( priv );
+}
+
+
+YCheckBox::~YCheckBox()
+{
+ // NOP
}
-void YCheckBox::setLabel( const YCPString & label )
+void YCheckBox::setLabel( const string & newLabel )
{
- this->label = label;
+ priv->label = newLabel;
}
-YCPString YCheckBox::getLabel()
+string YCheckBox::label() const
{
- return label;
+ return priv->label;
}
-YCPValue YCheckBox::changeWidget( const YCPSymbol & property, const YCPValue & newvalue )
+bool YCheckBox::useBoldFont() const
{
- string s = property->symbol();
+ return priv->useBoldFont;
+}
+
+
+void YCheckBox::setUseBoldFont( bool bold )
+{
+ priv->useBoldFont = bold;
+}
+
- if ( s == YUIProperty_Value )
+const YPropertySet &
+YCheckBox::propertySet()
+{
+ static YPropertySet propSet;
+
+ if ( propSet.isEmpty() )
{
- if ( newvalue->isBoolean() ||
- newvalue->isVoid() ) // -> tri-state - neither on nor off
- {
- setValue( newvalue );
- return YCPBoolean( true );
- }
- else
- {
- y2error( "CheckBox: Invalid parameter %s for property `Value. Must be boolean or nil.",
- newvalue->toString().c_str() );
- return YCPBoolean( false );
- }
+ /*
+ * @property boolean Value the on/off state; nil for "don't care" (tristate)
+ * @property string Label the text on the CheckBox
+ */
+
+ propSet.add( YProperty( YUIProperty_Value, YOtherProperty ) );
+ propSet.add( YProperty( YUIProperty_Label, YStringProperty ) );
+ propSet.add( YWidget::propertySet() );
}
- else if ( s == YUIProperty_Label )
+
+ return propSet;
+}
+
+
+bool
+YCheckBox::setProperty( const string & propertyName, const YPropertyValue & val )
+{
+ propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
+
+ if ( propertyName == YUIProperty_Value ) return false; // need special processing
+ else if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() );
+ else
{
- if ( newvalue->isString() )
- {
- setLabel( newvalue->asString() );
- return YCPBoolean( true );
- }
- else
- {
- y2error( "CheckBox: Invalid parameter %s for property `Label. Must be string.",
- newvalue->toString().c_str() );
- return YCPBoolean( false );
- }
+ YWidget::setProperty( propertyName, val );
}
- else return YWidget::changeWidget( property, newvalue );
-}
+ return true; // success -- no special processing necessary
+}
-YCPValue YCheckBox::queryWidget( const YCPSymbol & property )
+YPropertyValue
+YCheckBox::getProperty( const string & propertyName )
{
- string s = property->symbol();
- if ( s == YUIProperty_Value ) return getValue();
- else if ( s == YUIProperty_Label ) return getLabel();
- else return YWidget::queryWidget( property );
+ propertySet().check( propertyName ); // throws exceptions if not found
+
+ if ( propertyName == YUIProperty_Value ) return YPropertyValue( YOtherProperty );
+ else if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() );
+ else
+ {
+ return YWidget::getProperty( propertyName );
+ }
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.h Tue Jun 26 17:29:52 2007
@@ -19,22 +19,35 @@
#ifndef YCheckBox_h
#define YCheckBox_h
-#include "YWidget.h"
-#include
+#include <string>
+#include "YWidget.h"
+#include "ImplPtr.h"
+using std::string;
class YMacroRecorder;
+class YCheckBoxPrivate;
+
+enum YCheckBoxState
+{
+ YCheckBox_dont_care = -1, // tristate
+ YCheckBox_off = 0,
+ YCheckBox_on = 1
+};
+
-/**
- * @short Implementation of the CheckBox widget
- **/
class YCheckBox : public YWidget
{
public:
/**
- * Constructor
+ * Constructor.
+ **/
+ YCheckBox( YWidget * parent, const string & label );
+
+ /**
+ * Destructor.
**/
- YCheckBox( const YWidgetOpt & opt, const YCPString & label );
+ virtual ~YCheckBox();
/**
* Returns a descriptive name of this widget class for logging,
@@ -42,68 +55,124 @@
**/
virtual const char * widgetClass() { return "YCheckBox"; }
-#if 0
+
/**
- * Set a property.
- * Reimplemented from YWidget.
+ * Get the current value:
*
- * This method may throw exceptions, for example
- * - if there is no property with that name
- * - if the expected type and the type mismatch
- * - if the value is out of range
+ * YCheckBox_on CheckBox is checked
+ * YCheckBox_off CheckBox is unchecked
+ *
+ * YCheckBox_dont_care tri-state: CheckBox is greyed out,
+ * neither checked nor unchecked
+ *
+ * The user cannot set YCheckBox_dont_care directly. This status is always
+ * only set from the outside, usually because a setting cannot be clearly
+ * determined. For example, a checkbox
+ *
+ * [ ] Read only
+ *
+ * would be set to "don't care" (by the application, not directly by the
+ * user) when it is to display the read-only state of a group of files
+ * where some are read-only and some are writeable.
+ *
+ * Derived classes are required to implement this function.
+ * (Intentionally not const)
**/
- virtual void setProperty( const YProperty & prop );
+ virtual YCheckBoxState value() = 0;
/**
- * Get a property.
- * Reimplemented from YWidget.
+ * Set the CheckBox value (on/off/don't care).
*
- * This method may throw exceptions, for example
- * - if there is no property with that name
+ * Derived classes are required to implement this.
**/
- virtual YProperty getProperty( const std::string & propertyName );
-#endif
-
+ virtual void setValue( YCheckBoxState state ) = 0;
+
/**
- * Implements the ui command changeWidget.
+ * Simplified access to value(): Return 'true' if the CheckBox is checked.
**/
- YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
+ bool isChecked() { return value() == YCheckBox_on; }
/**
- * Implements the ui command queryWidget
+ * Simplified access to setValue(): Check of uncheck the CheckBox.
**/
- YCPValue queryWidget( const YCPSymbol & property );
+ void setChecked( bool checked )
+ { setValue( checked ? YCheckBox_on : YCheckBox_off ); }
/**
- * Set the check box on or off
+ * Simplified access to tri-state ("don't care").
+ **/
+ bool dontCare() { return value() == YCheckBox_dont_care; }
+
+ /**
+ * Simplified access to setting tri-state ("don't care").
**/
- virtual void setValue( const YCPValue & checked ) = 0;
+ void setDontCare() { setValue( YCheckBox_dont_care ); }
+
+ /**
+ * Get the label (the text on the CheckBox).
+ **/
+ string label() const;
/**
- * Returns whether the checkbox is checked.
- * This may return 'true' or 'false' or 'nil' for a tristate check box.
+ * Set the label (the text on the CheckBox).
+ *
+ * Derived classes are free to reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
**/
- virtual YCPValue getValue() = 0;
+ virtual void setLabel( const string & label );
/**
- * Change the check box label. Overload this, but call
- * YCheckBox::setLabel at the end of your own function.
+ * Returns 'true' if a bold font should be used.
**/
- virtual void setLabel( const YCPString & label );
+ bool useBoldFont() const;
/**
- * Get the current check box label. This method cannot be overidden.
- * The value of the label cannot be changed other than by calling setLabel,
- * i.e. not by the ui. Therefore setLabel stores the current label in #label.
+ * Indicate whether or not a bold font should be used.
+ *
+ * Derived classes are free to reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
+ **/
+ virtual void setUseBoldFont( bool bold = true );
+
+ /**
+ * Set a property.
+ * Reimplemented from YWidget.
+ *
+ * This method may throw exceptions, for example
+ * - if there is no property with that name
+ * - if the expected type and the type mismatch
+ * - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- YCPString getLabel();
+ virtual bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
+
+ /**
+ * Get a property.
+ * Reimplemented from YWidget.
+ *
+ * This method may throw exceptions, for example
+ * - if there is no property with that name
+ **/
+ virtual YPropertyValue getProperty( const string & propertyName );
+
+ /**
+ * Return this class's property set.
+ * This also initializes the property set upon the first call.
+ *
+ * Reimplemented from YWidget.
+ **/
+ virtual const YPropertySet & propertySet();
/**
* Get the string of this widget that holds the keyboard shortcut.
*
* Reimplemented from YWidget.
**/
- virtual string shortcutString() { return getLabel()->value(); }
+ virtual string shortcutString() { return label(); }
/**
* Set the string of this widget that holds the keyboard shortcut.
@@ -111,22 +180,14 @@
* Reimplemented from YWidget.
**/
virtual void setShortcutString( const string & str )
- { setLabel( YCPString( str ) ); }
+ { setLabel( str ); }
-
/**
* The name of the widget property that will return user input.
* Inherited from YWidget.
**/
const char *userInputProperty() { return YUIProperty_Value; }
-
-protected:
- /**
- * The CheckBox label
- **/
- YCPString label;
-
private:
@@ -136,6 +197,8 @@
* handled by the abstract libyui level, not by a specific UI.
**/
virtual void saveUserInput( YMacroRecorder *macroRecorder );
+
+ ImplPtr<YCheckBoxPrivate> priv;
};
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc Tue Jun 26 17:29:52 2007
@@ -47,6 +47,8 @@
: YSingleChildContainerWidget( parent )
, priv( new YCheckBoxFramePrivate( label ) )
{
+ YUI_CHECK_NEW( priv );
+
#if 0
// FIXME
_debugLabelWidget = this;
@@ -128,7 +130,7 @@
}
-void
+bool
YCheckBoxFrame::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -139,6 +141,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.h Tue Jun 26 17:29:52 2007
@@ -145,8 +145,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YEmpty.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YEmpty.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YEmpty.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YEmpty.cc Tue Jun 26 17:29:52 2007
@@ -31,7 +31,7 @@
:YWidget( parent )
, priv( new YEmptyPrivate )
{
- // NOP
+ YUI_CHECK_NEW( priv );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YFrame.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YFrame.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YFrame.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YFrame.cc Tue Jun 26 17:29:52 2007
@@ -39,7 +39,7 @@
: YSingleChildContainerWidget( parent )
, priv( new YFramePrivate( YShortcut::cleanShortcutString( label ) ) )
{
- // NOP
+ YUI_CHECK_NEW( priv );
}
@@ -80,7 +80,7 @@
}
-void
+bool
YFrame::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -90,6 +90,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YFrame.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YFrame.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YFrame.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YFrame.h Tue Jun 26 17:29:52 2007
@@ -67,8 +67,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc Tue Jun 26 17:29:52 2007
@@ -148,7 +148,7 @@
}
-void
+bool
YInputField::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -161,6 +161,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YInputField.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YInputField.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YInputField.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YInputField.h Tue Jun 26 17:29:52 2007
@@ -137,9 +137,14 @@
* Set a property.
* Reimplemented from YWidget.
*
- * This method may throw YUIPropertyExceptions.
+ * This function may throw YUIPropertyExceptions.
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName, const YPropertyValue & val );
+ virtual bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
/**
* Get a property.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YLabel.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YLabel.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YLabel.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YLabel.cc Tue Jun 26 17:29:52 2007
@@ -54,7 +54,7 @@
: YWidget( parent )
, priv( new YLabelPrivate( text, isHeading, isOutputField ) )
{
- // NOP
+ YUI_CHECK_NEW( priv );
}
@@ -123,7 +123,7 @@
}
-void
+bool
YLabel::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -135,6 +135,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YLabel.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YLabel.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YLabel.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YLabel.h Tue Jun 26 17:29:52 2007
@@ -125,8 +125,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const std::string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YLayoutBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YLayoutBox.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YLayoutBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YLayoutBox.cc Tue Jun 26 17:29:52 2007
@@ -55,6 +55,7 @@
: YWidget( parent )
, priv( new YLayoutBoxPrivate( primaryDimension ) )
{
+ YUI_CHECK_NEW( priv );
setChildrenManager( new YWidgetChildrenManager( this ) );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YProperty.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YProperty.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YProperty.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YProperty.cc Tue Jun 26 17:29:52 2007
@@ -101,14 +101,15 @@
if ( it->isReadOnly() )
YUI_THROW( YUISetReadOnlyPropertyException( *it ) );
- if ( it->type() == type )
+ if ( it->type() == type ||
+ it->type() == YOtherProperty ) // "Other" could be anything
return true;
YUIPropertyTypeMismatchException exception( *it, type );
if ( it->type() == YWidgetPtrProperty )
{
- // Kludge for YWidet * properties: Those typically throw an
+ // Kludge for YWidget * properties: Those typically throw an
// exception (and the caller tries again with the correct
// type), so let's at least not appear it in the log file.
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YProperty.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YProperty.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YProperty.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YProperty.h Tue Jun 26 17:29:52 2007
@@ -111,19 +111,19 @@
/**
* Constructor for bool properties.
**/
- YPropertyValue( bool b ):
+ explicit YPropertyValue( bool b ):
_type( YBoolProperty ), _boolVal( b ) {}
/**
* Constructor for numerical (YCP integer) properties.
**/
- YPropertyValue( YInteger num ):
+ explicit YPropertyValue( YInteger num ):
_type( YIntegerProperty ), _integerVal( num ) {}
/**
* Constructor for numerical (YCP integer) properties.
**/
- YPropertyValue( int num ):
+ explicit YPropertyValue( int num ):
_type( YIntegerProperty ), _integerVal( num ) {}
/**
@@ -132,6 +132,9 @@
YPropertyValue( YWidget * widget ):
_type( YWidgetPtrProperty ), _widgetPtrVal( widget ) {}
+ explicit YPropertyValue( YPropertyType type ) :
+ _type( type ) {}
+
/**
* Default constructor
**/
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
Files branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.cc (original) and branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.cc Tue Jun 26 17:29:52 2007 differ
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YPushButton.h Tue Jun 26 17:29:52 2007
@@ -86,9 +86,13 @@
* Set a property.
* Reimplemented from YWidget.
*
- * This method may throw YUIPropertyExceptions.
+ * This function may throw YUIPropertyExceptions.
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc Tue Jun 26 17:29:52 2007
@@ -125,7 +125,7 @@
}
-void
+bool
YRadioButton::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -136,6 +136,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.h Tue Jun 26 17:29:52 2007
@@ -132,8 +132,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.cc Tue Jun 26 17:29:52 2007
@@ -48,6 +48,7 @@
: YSingleChildContainerWidget( parent )
, priv( new YRadioButtonGroupPrivate() )
{
+ YUI_CHECK_NEW( priv );
}
@@ -139,7 +140,7 @@
}
-void
+bool
YRadioButtonGroup::setProperty( const string & propertyName, const YPropertyValue & val )
{
propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
@@ -156,7 +157,7 @@
if ( newCurrentButton )
{
newCurrentButton->setValue( true );
- return;
+ return true; // success -- no special processing necessary
}
}
@@ -176,6 +177,8 @@
{
YWidget::setProperty( propertyName, val );
}
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButtonGroup.h Tue Jun 26 17:29:52 2007
@@ -93,8 +93,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const std::string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
/**
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSpacing.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSpacing.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSpacing.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSpacing.cc Tue Jun 26 17:29:52 2007
@@ -39,6 +39,7 @@
: YWidget( parent )
, priv( new YSpacingPrivate( dim, YUI::ui()->deviceUnits( dim, layoutUnits ) ) )
{
+ YUI_CHECK_NEW( priv );
setStretchable( dim, stretchable );
setStretchable( dim == YD_HORIZ ? YD_VERT : YD_HORIZ, false );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSquash.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSquash.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSquash.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSquash.cc Tue Jun 26 17:29:52 2007
@@ -39,6 +39,7 @@
: YSingleChildContainerWidget( parent )
, priv( new YSquashPrivate( horSquash, vertSquash ) )
{
+ YUI_CHECK_NEW( priv );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Tue Jun 26 17:29:52 2007
@@ -340,6 +340,13 @@
YCPValue evaluatePollInput ();
/**
+ * Handlers for not-so-simple property types.
+ **/
+ YCPValue queryWidgetComplexTypes ( YWidget * widget, const string & propertyName );
+ void changeWidgetComplexTypes( YWidget * widget, const string & propertyName, const YCPValue & val );
+
+
+ /**
* This method implements the UI thread in case it is existing.
* The loop consists of calling idleLoop, getting the next
* command from the @ref YCPUIComponent, evaluating it, which
@@ -442,7 +449,6 @@
virtual YWidget *createRichText( YWidget *parent, YWidgetOpt & opt, const YCPString & text ) = 0;
virtual YWidget *createLogView( YWidget *parent, YWidgetOpt & opt, const YCPString & label, int visibleLines, int maxLines ) = 0;
virtual YWidget *createMenuButton( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
- virtual YWidget *createCheckBox( YWidget *parent, YWidgetOpt & opt, const YCPString & label, bool checked ) = 0;
virtual YWidget *createMultiLineEdit( YWidget *parent, YWidgetOpt & opt, const YCPString & label, const YCPString & text ) = 0;
virtual YWidget *createSelectionBox( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
virtual YWidget *createMultiSelectionBox( YWidget *parent, YWidgetOpt & opt, const YCPString & label ) = 0;
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUIException.h Tue Jun 26 17:29:52 2007
@@ -572,7 +572,7 @@
YUIBadPropertyArgException( const YProperty & property,
YWidget * widget,
- const string & message )
+ const string & message = "" )
: YUIPropertyException( property, widget )
{ setMsg( message ); }
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc Tue Jun 26 17:29:52 2007
@@ -53,6 +53,7 @@
#include "YCPValueWidgetID.h"
#include "YCPDialogParser.h"
#include "YOptionalWidgetFactory.h"
+#include "YCheckBox.h"
using std::string;
@@ -65,7 +66,7 @@
* widget of this kind. Do not use this to check for ordinary widgets like
* PushButton etc. - just the widgets where the widget documentation explicitly
* states it is an optional widget not supported by all UIs.
- *
+ *
* Returns true if the UI supports the special widget and false if not.
*/
@@ -847,7 +848,7 @@
* @return boolean Returns true on success.
*/
-YCPValue YUI::evaluateChangeWidget( const YCPValue & id_value, const YCPValue & property, const YCPValue & new_value )
+YCPValue YUI::evaluateChangeWidget( const YCPValue & id_value, const YCPValue & property, const YCPValue & newValue )
{
if ( ! YCPDialogParser::isSymbolOrId( id_value ) )
{
@@ -876,7 +877,7 @@
// FIXME: Get rid of this
y2debug( "Old style UI::ChangeWidget() for %s::%s",
widget->widgetClass(), sym->symbol().c_str() );
- ret = widget->changeWidget( sym, new_value );
+ ret = widget->changeWidget( sym, newValue );
// FIXME: Get rid of this
// FIXME: Get rid of this
// FIXME: Get rid of this
@@ -885,15 +886,17 @@
{
// y2milestone( "New style UI::ChangeWidget() for %s::%s", widget->widgetClass(), sym->symbol().c_str() );
+ string propertyName = sym->symbol();
YPropertyValue val;
- if ( new_value->isString() ) val = YPropertyValue( new_value->asString()->value() );
- else if ( new_value->isInteger() ) val = YPropertyValue( new_value->asInteger()->value() );
- else if ( new_value->isBoolean() ) val = YPropertyValue( new_value->asBoolean()->value() );
+ if ( newValue->isString() ) val = YPropertyValue( newValue->asString()->value() );
+ else if ( newValue->isInteger() ) val = YPropertyValue( newValue->asInteger()->value() );
+ else if ( newValue->isBoolean() ) val = YPropertyValue( newValue->asBoolean()->value() );
+ else if ( newValue->isVoid() ) changeWidgetComplexTypes( widget, propertyName, newValue );
else
{
y2error( "Unknown type for property %s::%s: %s",
- widget->widgetClass(), sym->symbol().c_str(), new_value->toString().c_str() );
+ widget->widgetClass(), sym->symbol().c_str(), newValue->toString().c_str() );
unblockEvents();
return YCPBoolean( false );
@@ -901,7 +904,11 @@
try
{
- widget->setProperty( sym->symbol(), val );
+ bool success = widget->setProperty( propertyName, val );
+
+ if ( ! success )
+ changeWidgetComplexTypes( widget, propertyName, newValue );
+
ret = YCPBoolean( true );
}
catch ( YUIPropertyTypeMismatchException & typeMismatchException )
@@ -914,8 +921,8 @@
// YCPStrings or YCPIntegers (which is legal): It's not at all clear if that kind of
// YCPValue should be passed as a YCPString or as a widget ID. So now that YCPString
// failed, let's try again with a widget.
-
- YWidget * refWidget = YCPDialogParser::findWidgetWithId( new_value );
+
+ YWidget * refWidget = YCPDialogParser::findWidgetWithId( newValue );
widget->setProperty( sym->symbol(), YPropertyValue( refWidget ) );
ret = YCPBoolean( true );
}
@@ -941,7 +948,7 @@
else
{
blockEvents(); // We don't want self-generated events from UI::ChangeWidget().
- YCPValue result = widget->changeWidgetTerm( property->asTerm(), new_value );
+ YCPValue result = widget->changeWidgetTerm( property->asTerm(), newValue );
unblockEvents();
return result;
@@ -1000,15 +1007,18 @@
{
// y2debug( "New style UI::QueryWidget() for %s::%s", widget->widgetClass(), sym->symbol().c_str() );
+ string propertyName = sym->symbol();
+
try
{
- YPropertyValue val = widget->getProperty( sym->symbol() );
+ YPropertyValue val = widget->getProperty( propertyName );
switch ( val.type() )
{
case YStringProperty: return YCPString ( val.stringVal() );
case YBoolProperty: return YCPBoolean( val.boolVal() );
case YIntegerProperty: return YCPInteger( val.integerVal() );
+ case YOtherProperty: return queryWidgetComplexTypes( widget, propertyName );
case YWidgetPtrProperty:
{
YWidget * widget = val.widgetPtrVal();
@@ -1046,6 +1056,66 @@
}
+/**
+ * This is the messy part of UI::QueryWidget(): Here all special cases
+ * (property type YOtherProperty) are handled. It's not pretty, but at some
+ * place a mapping from C++ types to YCPValues has to be done.
+ **/
+YCPValue
+YUI::queryWidgetComplexTypes( YWidget * widget, const string & propertyName )
+{
+ if ( propertyName == YUIProperty_Value )
+ {
+ YCheckBox * checkBox = dynamic_cast (widget);
+
+ if ( checkBox )
+ {
+ switch ( checkBox->value() )
+ {
+ case YCheckBox_on: return YCPBoolean( true );
+ case YCheckBox_off: return YCPBoolean( false );
+ case YCheckBox_dont_care: return YCPVoid(); // nil
+ }
+ }
+ }
+
+ y2warning( "Can't handle property %s::%s - returning 'nil'",
+ widget->widgetClass(), propertyName.c_str() );
+
+ return YCPVoid();
+}
+
+
+void
+YUI::changeWidgetComplexTypes( YWidget * widget, const string & propertyName, const YCPValue & val )
+{
+ // y2debug( "%s::%s", widget->widgetClass(), propertyName.c_str() );
+
+ if ( propertyName == YUIProperty_Value )
+ {
+ YCheckBox * checkBox = dynamic_cast (widget);
+
+ if ( checkBox )
+ {
+ if ( val->isBoolean() )
+ {
+ checkBox->setChecked( val->asBoolean()->value() );
+ return;
+ }
+ else if ( val->isVoid() )
+ {
+ checkBox->setDontCare();
+ return;
+ }
+
+ YUI_THROW( YUIBadPropertyArgException( YProperty( propertyName, YOtherProperty ), widget ) );
+ }
+ }
+
+ y2warning( "Can't handle property %s::%s - returning 'nil'",
+ widget->widgetClass(), propertyName.c_str() );
+}
+
/**
* @builtin ReplaceWidget
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Tue Jun 26 17:29:52 2007
@@ -96,7 +96,7 @@
YWidget::YWidget( const YWidgetOpt & opt )
: priv( new YWidgetPrivate( new YWidgetChildrenRejector( this ) ) )
{
-
+ YUI_CHECK_NEW( priv );
}
// FIXME: Obsolete
// FIXME: Obsolete
@@ -357,7 +357,7 @@
}
-void
+bool
YWidget::setProperty( const std::string & propertyName, const YPropertyValue & val )
{
try
@@ -372,6 +372,8 @@
if ( propertyName == YUIProperty_Enabled ) setEnabled( val.boolVal() );
else if ( propertyName == YUIProperty_Notify ) setNotify ( val.boolVal() );
+
+ return true; // success -- no special processing necessary
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.h Tue Jun 26 17:29:52 2007
@@ -135,8 +135,12 @@
* - if there is no property with that name
* - if the expected type and the type mismatch
* - if the value is out of range
+ *
+ * This function returns 'true' if the value was successfully set and
+ * 'false' if that value requires special handling (not in error cases:
+ * those are covered by exceptions).
**/
- virtual void setProperty( const string & propertyName,
+ virtual bool setProperty( const string & propertyName,
const YPropertyValue & val );
// FIXME: = 0
Modified: branches/tmp/sh/mod-ui/qt/src/YQCheckBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQCheckBox.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQCheckBox.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQCheckBox.cc Tue Jun 26 17:29:52 2007
@@ -31,123 +31,125 @@
#define SPACING 8
-YQCheckBox::YQCheckBox( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
- bool initiallyChecked )
- : QGroupBox( parent )
- , YCheckBox( opt, label )
- , _dont_care( false )
+YQCheckBox::YQCheckBox( YWidget * parent,
+ const string & label,
+ bool checked )
+ : QGroupBox( (QWidget *) parent->widgetRep() )
+ , YCheckBox( parent, label )
{
setWidgetRep( this );
setFrameStyle( NoFrame );
QBoxLayout * layout = new QBoxLayout( this, QBoxLayout::LeftToRight );
- _qt_checkbox = new QCheckBox( fromUTF8( label->value() ), this );
+ _qt_checkBox = new QCheckBox( fromUTF8( label ), this );
+ YUI_CHECK_NEW( _qt_checkBox );
+
layout->addSpacing( SPACING );
- layout->addWidget( _qt_checkbox );
+ layout->addWidget( _qt_checkBox );
layout->addSpacing( SPACING );
- _qt_checkbox->setFont( opt.boldFont.value() ?
- YQUI::ui()->boldFont() :
- YQUI::ui()->currentFont() );
- _qt_checkbox->setChecked( initiallyChecked );
- connect( _qt_checkbox, SIGNAL( stateChanged( int ) ),
+ _qt_checkBox->setChecked( checked );
+
+ connect( _qt_checkBox, SIGNAL( stateChanged( int ) ),
this, SLOT ( stateChanged( int ) ) );
}
-int YQCheckBox::preferredWidth()
+YQCheckBox::~YQCheckBox()
{
- return 2*SPACING + _qt_checkbox->sizeHint().width();
+ // NOP
}
-int YQCheckBox::preferredHeight()
+YCheckBoxState
+YQCheckBox::value()
{
- return _qt_checkbox->sizeHint().height();
-}
-
+ switch ( _qt_checkBox->state() )
+ {
+ case QButton::On: return YCheckBox_on;
+ case QButton::Off: return YCheckBox_off;
+ case QButton::NoChange: return YCheckBox_dont_care;
+ }
-void YQCheckBox::setSize( int newWidth, int newHeight )
-{
- _qt_checkbox->resize( newWidth - 2*SPACING, newHeight );
- resize( newWidth, newHeight );
+ return YCheckBox_off;
}
-YCPValue
-YQCheckBox::getValue()
+void
+YQCheckBox::setValue( YCheckBoxState newValue )
{
- switch ( _qt_checkbox->state() )
+ switch ( newValue )
{
- case QButton::On: return YCPBoolean( true );
- case QButton::Off: return YCPBoolean( false );
- case QButton::NoChange: return YCPVoid(); // nil
+ case YCheckBox_on:
+ _qt_checkBox->setChecked( true );
+ _qt_checkBox->setTristate( false );
+ break;
+
+ case YCheckBox_off:
+ _qt_checkBox->setChecked( false );
+ _qt_checkBox->setTristate( false );
+ break;
+
+ case YCheckBox_dont_care:
+ _qt_checkBox->setTristate( true );
+ _qt_checkBox->setNoChange();
+ break;
}
-
- y2error( "Unknown QCheckBox state: %d", (int) _qt_checkbox->state() );
- return YCPVoid();
}
-void
-YQCheckBox::setValue( const YCPValue & val )
+void YQCheckBox::setLabel( const string & label )
{
- if ( val->isBoolean() )
- {
- setTristate( false );
- _qt_checkbox->setChecked( val->asBoolean()->value() );
- }
- else // "Nil" -> set TriState: neither on nor off
- {
- setTristate( true );
- }
+ _qt_checkBox->setText( fromUTF8( label ) );
+ YCheckBox::setLabel( label );
}
-bool
-YQCheckBox::isTristate()
+void YQCheckBox::setUseBoldFont( bool useBold )
{
- return _dont_care;
+ _qt_checkBox->setFont( useBold ?
+ YQUI::ui()->boldFont() :
+ YQUI::ui()->currentFont() );
+
+ YCheckBox::setUseBoldFont( useBold );
}
-void
-YQCheckBox::setTristate( bool tristate )
+void YQCheckBox::setEnabled( bool enabled )
{
- _dont_care = tristate;
- _qt_checkbox->setTristate( tristate );
+ _qt_checkBox->setEnabled( enabled );
+ YWidget::setEnabled( enabled );
+}
+
- if ( tristate )
- _qt_checkbox->setNoChange();
+int YQCheckBox::preferredWidth()
+{
+ return 2*SPACING + _qt_checkBox->sizeHint().width();
}
-void YQCheckBox::setLabel( const YCPString & label )
+int YQCheckBox::preferredHeight()
{
- _qt_checkbox->setText( fromUTF8( label->value() ) );
- YCheckBox::setLabel( label );
+ return _qt_checkBox->sizeHint().height();
}
-void YQCheckBox::setEnabled( bool enabled )
+void YQCheckBox::setSize( int newWidth, int newHeight )
{
- _qt_checkbox->setEnabled( enabled );
- YWidget::setEnabled( enabled );
+ _qt_checkBox->resize( newWidth - 2*SPACING, newHeight );
+ resize( newWidth, newHeight );
}
bool YQCheckBox::setKeyboardFocus()
{
- _qt_checkbox->setFocus();
+ _qt_checkBox->setFocus();
return true;
}
-
void YQCheckBox::stateChanged( int newState )
{
// y2milestone( "new state: %d", newState );
Modified: branches/tmp/sh/mod-ui/qt/src/YQCheckBox.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQCheckBox.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQCheckBox.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQCheckBox.h Tue Jun 26 17:29:52 2007
@@ -37,69 +37,83 @@
/**
* Constructor.
**/
- YQCheckBox( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
- bool initiallyChecked );
+ YQCheckBox( YWidget * parent,
+ const string & label,
+ bool checked );
/**
- * Inherited from YWidget: Sets the enabled state of the
- * widget. All new widgets are enabled per definition. Only
- * enabled widgets can take user input.
+ * Destructor.
**/
- void setEnabled( bool enabled );
+ virtual ~YQCheckBox();
/**
- * Preferred width of the widget.
+ * Get the current value:
*
- * Reimplemented from YWidget.
+ * YCheckBox_on CheckBox is checked
+ * YCheckBox_off CheckBox is unchecked
+ *
+ * YCheckBox_dont_care tri-state: CheckBox is greyed out,
+ * neither checked nor unchecked
+ *
+ * Reimplemented from YCheckBox.
**/
- virtual int preferredWidth();
-
+ virtual YCheckBoxState value();
+
/**
- * Preferred height of the widget.
+ * Set the CheckBox value (on/off/don't care).
*
- * Reimplemented from YWidget.
+ * Reimplemented from YCheckBox.
**/
- virtual int preferredHeight();
+ virtual void setValue( YCheckBoxState state );
/**
- * Set the new size of the widget.
+ * Change the label (the text) on the RadioButton.
*
- * Reimplemented from YWidget.
+ * Reimplemented from YRadioButton.
**/
- virtual void setSize( int newWidth, int newHeight );
+ virtual void setLabel( const string & label );
/**
- * Sets the checked-state of the checkbox
+ * Use a bold font.
+ *
+ * Reimplemented from YRadioButton.
**/
- void setValue( const YCPValue & checked );
+ virtual void setUseBoldFont( bool bold = true );
/**
- * Returns whether the checkbox is checked.
- * This may return 'true' or 'false' or 'nil' for a tristate check box.
+ * Set enabled / disabled state.
+ *
+ * Reimplemented from YWidget.
**/
- YCPValue getValue();
+ virtual void setEnabled( bool enabled );
/**
- * Changes the label of the text entry.
+ * Preferred width of the widget.
+ *
+ * Reimplemented from YWidget.
**/
- void setLabel( const YCPString & label );
+ virtual int preferredWidth();
/**
- * Accept the keyboard focus.
+ * Preferred height of the widget.
+ *
+ * Reimplemented from YWidget.
**/
- virtual bool setKeyboardFocus();
+ virtual int preferredHeight();
/**
- * Returns whether tristate condition is set ( i.e. neither on nor off )
+ * Set the new size of the widget.
+ *
+ * Reimplemented from YWidget.
**/
- bool isTristate();
+ virtual void setSize( int newWidth, int newHeight );
/**
- * Set tristate condition
+ * Accept the keyboard focus.
+ *
+ * Reimplemented from YWidget.
**/
- void setTristate( bool tristate );
+ virtual bool setKeyboardFocus();
private slots:
@@ -112,16 +126,7 @@
protected:
- /**
- * Pointer to the qt widget that actually does the job
- **/
- QCheckBox * _qt_checkbox;
-
- /**
- * Flag that indicates tristate condition: neither on nor off
- **/
- bool _dont_care;
-
+ QCheckBox * _qt_checkBox;
};
#endif // YQCheckBox_h
Modified: branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc Tue Jun 26 17:29:52 2007
@@ -50,13 +50,13 @@
QBoxLayout * layout = new QBoxLayout( this, QBoxLayout::LeftToRight );
- _qt_radiobutton = new QRadioButton( fromUTF8( label ), this );
+ _qt_radioButton = new QRadioButton( fromUTF8( label ), this );
layout->addSpacing( SPACING );
- layout->addWidget( _qt_radiobutton );
+ layout->addWidget( _qt_radioButton );
layout->addSpacing( SPACING );
- _qt_radiobutton->setChecked( checked );
+ _qt_radioButton->setChecked( checked );
- connect ( _qt_radiobutton, SIGNAL( toggled ( bool ) ),
+ connect ( _qt_radioButton, SIGNAL( toggled ( bool ) ),
this, SLOT ( changed ( bool ) ) );
}
@@ -64,7 +64,7 @@
void
YQRadioButton::setUseBoldFont( bool useBold )
{
- _qt_radiobutton->setFont( useBold ?
+ _qt_radioButton->setFont( useBold ?
YQUI::ui()->boldFont() :
YQUI::ui()->currentFont() );
@@ -74,33 +74,33 @@
int YQRadioButton::preferredWidth()
{
- return 2 * SPACING + _qt_radiobutton->sizeHint().width();
+ return 2 * SPACING + _qt_radioButton->sizeHint().width();
}
int YQRadioButton::preferredHeight()
{
- return _qt_radiobutton->sizeHint().height();
+ return _qt_radioButton->sizeHint().height();
}
void YQRadioButton::setSize( int newWidth, int newHeight )
{
- _qt_radiobutton->resize( newWidth - 2*SPACING, newHeight );
+ _qt_radioButton->resize( newWidth - 2*SPACING, newHeight );
resize( newWidth, newHeight );
}
bool YQRadioButton::value()
{
- return _qt_radiobutton->isChecked();
+ return _qt_radioButton->isChecked();
}
void YQRadioButton::setValue( bool newValue )
{
- _qt_radiobutton->blockSignals( true );
- _qt_radiobutton->setChecked( newValue );
+ _qt_radioButton->blockSignals( true );
+ _qt_radioButton->setChecked( newValue );
if ( newValue )
{
@@ -110,33 +110,33 @@
group->uncheckOtherButtons( this );
}
- _qt_radiobutton->blockSignals( false );
+ _qt_radioButton->blockSignals( false );
}
void YQRadioButton::setLabel( const string & label )
{
- _qt_radiobutton->setText( fromUTF8( label ) );
+ _qt_radioButton->setText( fromUTF8( label ) );
YRadioButton::setLabel( label );
}
void YQRadioButton::setEnabled( bool enabled )
{
- _qt_radiobutton->setEnabled( enabled );
+ _qt_radioButton->setEnabled( enabled );
YWidget::setEnabled( enabled );
}
QRadioButton * YQRadioButton::getQtButton()
{
- return _qt_radiobutton;
+ return _qt_radioButton;
}
bool YQRadioButton::setKeyboardFocus()
{
- _qt_radiobutton->setFocus();
+ _qt_radioButton->setFocus();
return true;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h Tue Jun 26 17:29:52 2007
@@ -21,11 +21,13 @@
#define YQRadioButton_h
#include
-
#include "YRadioButton.h"
+
class QRadioButton;
+using std::string;
+
class YQRadioButton : public QGroupBox, public YRadioButton
{
@@ -36,7 +38,7 @@
* Constructor.
**/
YQRadioButton( YWidget * parent,
- const std::string & label,
+ const string & label,
bool checked );
/**
@@ -58,7 +60,7 @@
*
* Reimplemented from YRadioButton.
**/
- virtual void setLabel( const std::string & label );
+ virtual void setLabel( const string & label );
/**
* Use a bold font.
@@ -117,7 +119,7 @@
protected:
- QRadioButton * _qt_radiobutton;
+ QRadioButton * _qt_radioButton;
};
#endif // YQRadioButton_h
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI.h?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Tue Jun 26 17:29:52 2007
@@ -446,7 +446,6 @@
YContainerWidget * createWeight ( YWidget * parent, YWidgetOpt & opt, YUIDimension dim, long weight);
- YWidget * createCheckBox ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, bool checked);
YWidget * createComboBox ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
YWidget * createImage ( YWidget * parent, YWidgetOpt & opt, YCPByteblock imageData, YCPString fallbackText );
YWidget * createImage ( YWidget * parent, YWidgetOpt & opt, YCPString fileName, YCPString fallbackText );
Modified: branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Tue Jun 26 17:29:52 2007
@@ -152,14 +152,6 @@
return new YQMenuButton( (QWidget *) ( parent->widgetRep() ), opt, label);
}
-YWidget * YQUI::createCheckBox ( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label,
- bool checked )
-{
- return new YQCheckBox( (QWidget *) ( parent->widgetRep() ), opt, label, checked);
-}
-
YWidget * YQUI::createMultiLineEdit( YWidget * parent,
YWidgetOpt & opt,
Modified: branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc?rev=39035&r1=39034&r2=39035&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc Tue Jun 26 17:29:52 2007
@@ -119,7 +119,10 @@
YQCheckBox *
YQWidgetFactory::createCheckBox( YWidget * parent, const string & label, bool isChecked )
{
- return 0; // FIXME: TO DO
+ YQCheckBox * checkBox = new YQCheckBox( parent, label, isChecked );
+ YUI_CHECK_NEW( checkBox );
+
+ return checkBox;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org