Author: sh-sh-sh
Date: Mon Oct 8 17:08:04 2007
New Revision: 41285
URL: http://svn.opensuse.org/viewcvs/yast?rev=41285&view=rev
Log:
ported IntField
Modified:
branches/tmp/sh/mod-ui/core/libyui/doc/examples/IntField2.ycp
branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc
branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc
branches/tmp/sh/mod-ui/core/libyui/src/YIntField.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h
branches/tmp/sh/mod-ui/qt/src/YQIntField.cc
branches/tmp/sh/mod-ui/qt/src/YQIntField.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/doc/examples/IntField2.ycp
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/doc/examples/IntField2.ycp?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/doc/examples/IntField2.ycp (original)
+++ branches/tmp/sh/mod-ui/core/libyui/doc/examples/IntField2.ycp Mon Oct 8 17:08:04 2007
@@ -1,3 +1,4 @@
+// Simple IntField example
{
UI::OpenDialog(
`VBox(
@@ -5,9 +6,10 @@
`PushButton(`opt(`default), "&OK")
)
);
+ UI::ChangeWidget(`perc, `Value, 42 );
UI::UserInput();
- integer percentage = (integer) UI::QueryWidget(`id(`perc), `Value);
+ integer percentage = (integer) UI::QueryWidget(`perc, `Value);
UI::CloseDialog();
UI::OpenDialog(
@@ -17,4 +19,5 @@
)
);
UI::UserInput();
+ UI::CloseDialog();
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/ChangeLog Mon Oct 8 17:08:04 2007
@@ -349,3 +349,17 @@
- much streamlined with the other selection widgets
- QueryWidget(table) can now return the complete item term
as well as individual cells
+
+ Look at YQTable for a sample implementation.
+
+
+2007-10-08 17:00 sh@suse.de
+
+* Added support for QueryWidget(`id(...), `Items ) for SelectionWidgets:
+ - SelectionBox
+ - ComboBox
+ - MultiSelectionBox
+ - Tree
+ - Table
+
+* Ported IntField
\ No newline at end of file
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=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Mon Oct 8 17:08:04 2007
@@ -52,6 +52,7 @@
#include "YFrame.h"
#include "YImage.h"
#include "YInputField.h"
+#include "YIntField.h"
#include "YLabel.h"
#include "YLayoutBox.h"
#include "YMenuButton.h"
@@ -2435,12 +2436,12 @@
rejectAllOptions( term,optList );
- YCPString label = term->value( argnr )->asString();
- int minValue = term->value( argnr+1 )->asInteger()->value();
- int maxValue = term->value( argnr+2 )->asInteger()->value();
- int initialValue = term->value( argnr+3 )->asInteger()->value();
+ string label = term->value( argnr )->asString()->value();
+ int minValue = term->value( argnr+1 )->asInteger()->value();
+ int maxValue = term->value( argnr+2 )->asInteger()->value();
+ int initialValue = term->value( argnr+3 )->asInteger()->value();
- return YUI::ui()->createIntField( parent, opt, label, minValue, maxValue, initialValue );
+ return YUI::widgetFactory()->createIntField( parent, label, minValue, maxValue, initialValue );
}
@@ -2513,7 +2514,6 @@
else logUnknownOption( term, optList->value(o) );
}
-
return YUI::widgetFactory()->createPackageSelector( parent, modeFlags );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc Mon Oct 8 17:08:04 2007
@@ -17,117 +17,174 @@
/-*/
-#include
-#include
#define y2log_component "ui"
#include
-#include "YUISymbols.h"
#include "YMacroRecorder.h"
#include "YIntField.h"
-YIntField::YIntField( const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue )
- : YWidget( opt )
- , _label( label )
- , _minValue( minValue )
- , _maxValue( maxValue )
- , _value( initialValue )
+struct YIntFieldPrivate
{
+ YIntFieldPrivate( const string & label,
+ int minValue,
+ int maxValue )
+ : label( label )
+ , minValue( minValue )
+ , maxValue( maxValue )
+ {}
+
+ string label;
+ int minValue;
+ int maxValue;
+};
+
+
+
+
+YIntField::YIntField( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue )
+ : YWidget( parent )
+ , priv( new YIntFieldPrivate( label, minValue, maxValue ) )
+{
+ YUI_CHECK_NEW( priv );
+
setDefaultStretchable( YD_HORIZ, true );
setStretchable( YD_VERT, false );
}
-void YIntField::setLabel( const YCPString & newLabel )
+YIntField::~YIntField()
{
- _label = newLabel;
+ // NOP
}
-void YIntField::setValue( int newValue )
+
+int
+YIntField::enforceRange( int val ) const
{
- _value = newValue;
+ if ( val < priv->minValue )
+ val = priv->minValue;
+
+ if ( val > priv->maxValue )
+ val = priv->maxValue;
+
+ return val;
}
-YCPValue YIntField::changeWidget( const YCPSymbol & property,
- const YCPValue & newValue )
+int
+YIntField::minValue() const
{
- string sym = property->symbol();
+ return priv->minValue;
+}
- /**
- * @property integer Value the numerical value
- */
- if ( sym == YUIProperty_Value )
- {
- if ( newValue->isInteger() )
- {
- int val = newValue->asInteger()->value();
-
- if ( val < minValue() )
- {
- y2warning( "YIntField::changeWidget( `Value ): "
- "Warning: New value %d below minValue ( %d )",
- val, minValue() );
- setValue( minValue() );
- }
- else if ( val > maxValue() )
- {
- y2warning( "YIntField::changeWidget( `Value ): "
- "Warning: New value %d above maxValue ( %d )",
- val, maxValue() );
- setValue( maxValue() );
- }
- else
- {
- setValue( val );
- }
-
- return YCPBoolean( true );
- }
- else
- {
- y2error( "YIntField::changeWidget( `Value ): "
- "Error: Expecting integer value, not %s",
- newValue->toString().c_str() );
- return YCPBoolean( false );
- }
- }
- /**
- * @property string Label the slider label
- */
- else if ( sym == YUIProperty_Label )
- {
- if ( newValue->isString() )
- {
- setLabel( newValue->asString() );
- return YCPBoolean( true );
- }
- else
- {
- y2error( "YIntField::changeWidget( `Value ): "
- "Error: Expecting string, not %s",
- newValue->toString().c_str() );
+void
+YIntField::setMinValue( int val )
+{
+ priv->minValue = val;
+
+ int oldValue = value();
+ int newValue = enforceRange ( oldValue );
+
+ if ( oldValue != newValue )
+ setValue( newValue ); // This might be expensive
+}
+
+
+int
+YIntField::maxValue() const
+{
+ return priv->maxValue;
+}
+
+
+void
+YIntField::setMaxValue( int val )
+{
+ priv->maxValue = val;
+
+ int oldValue = value();
+ int newValue = enforceRange ( oldValue );
- return YCPBoolean( false );
- }
+ if ( oldValue != newValue )
+ setValue( newValue ); // This might be expensive
+}
+
+
+string
+YIntField::label() const
+{
+ return priv->label;
+}
+
+
+void
+YIntField::setLabel( const string & label )
+{
+ priv->label = label;
+}
+
+
+
+const YPropertySet &
+YIntField::propertySet()
+{
+ static YPropertySet propSet;
+
+ if ( propSet.isEmpty() )
+ {
+ /*
+ * @property integer Value the field's contents (the user input)
+ * @property integer MinValue the minimum value
+ * @property integer MaxValue the maximum value
+ * @property string Label caption above the field
+ */
+ propSet.add( YProperty( YUIProperty_Value, YIntegerProperty ) );
+ propSet.add( YProperty( YUIProperty_MinValue, YIntegerProperty ) );
+ propSet.add( YProperty( YUIProperty_MaxValue, YIntegerProperty ) );
+ propSet.add( YProperty( YUIProperty_Label, YStringProperty ) );
+ propSet.add( YWidget::propertySet() );
}
- else return YWidget::changeWidget( property, newValue );
+
+ return propSet;
}
+bool
+YIntField::setProperty( const string & propertyName, const YPropertyValue & val )
+{
+ propertySet().check( propertyName, val.type() ); // throws exceptions if not found or type mismatch
+
+ if ( propertyName == YUIProperty_Value ) setValue ( val.integerVal() );
+ else if ( propertyName == YUIProperty_MinValue ) setMinValue( val.integerVal() );
+ else if ( propertyName == YUIProperty_MaxValue ) setMaxValue( val.integerVal() );
+ else if ( propertyName == YUIProperty_Label ) setLabel( val.stringVal() );
+ else
+ {
+ return YWidget::setProperty( propertyName, val );
+ }
-YCPValue YIntField::queryWidget( const YCPSymbol & property )
+ return true; // success -- no special processing necessary
+}
+
+
+YPropertyValue
+YIntField::getProperty( const string & propertyName )
{
- string s = property->symbol();
- if ( s == YUIProperty_Value ) return YCPInteger( value() );
- else if ( s == YUIProperty_Label ) return label();
- else return YWidget::queryWidget( property );
+ propertySet().check( propertyName ); // throws exceptions if not found
+
+ if ( propertyName == YUIProperty_Value ) return YPropertyValue( value() );
+ if ( propertyName == YUIProperty_MinValue ) return YPropertyValue( minValue() );
+ if ( propertyName == YUIProperty_MaxValue ) return YPropertyValue( maxValue() );
+ else if ( propertyName == YUIProperty_Label ) return YPropertyValue( label() );
+ else
+ {
+ return YWidget::getProperty( propertyName );
+ }
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YIntField.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YIntField.h?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YIntField.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YIntField.h Mon Oct 8 17:08:04 2007
@@ -20,68 +20,151 @@
#define YIntField_h
#include "YWidget.h"
-#include
-#include
+class YIntFieldPrivate;
+using std::string;
+
+
+/**
+ * IntField: Input field for integer values. Enforces input range between a
+ * specified minimum and maximum value.
+ **/
class YIntField : public YWidget
{
protected:
/**
- * Constructor
- **/
- YIntField( const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue );
+ * Constructor.
+ *
+ * Create an IntField with 'label' as the caption, and the specified minimum
+ * and maximum values.
+ *
+ * Note that YWidgetFactory::createIntField() also has an 'initialValue'
+ * parameter that is not used here (because the current value is not stored
+ * in this base class, but in the derived class).
+ **/
+ YIntField( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue );
public:
/**
- * Returns a descriptive name of this widget class for logging,
+ * Destructor.
+ **/
+ virtual ~YIntField();
+
+ /**
+ * Return a descriptive name of this widget class for logging,
* debugging etc.
**/
virtual const char * widgetClass() const { return "YIntField"; }
/**
- * Implements the ChangeWidget() UI command.
+ * Get the current value (the number entered by the user or set from the
+ * outside) of this IntField.
+ *
+ * Derived classes are required to implement this.
**/
- YCPValue changeWidget( const YCPSymbol & property,
- const YCPValue & newValue );
+ virtual int value() = 0;
/**
- * Implements the QueryWidget() UI command.
+ * Set the current value (the number entered by the user or set from the
+ * outside) of this IntField. This method enforces 'val to be between
+ * minValue and maxValue.
**/
- YCPValue queryWidget( const YCPSymbol & property );
+ void setValue( int val ) { setValueInternal( enforceRange( val ) ); }
+
+protected:
/**
- * Change the IntField label.
+ * Set the current value (the number entered by the user or set from the
+ * outside) of this IntField. 'val' is guaranteed to be between minValue
+ * and maxValue; no further checks are required.
*
- * Overwrite this, but call YIntField::setLabel
- * at the end of your own method.
+ * Derived classes are required to implement this method.
+ **/
+ virtual void setValueInternal( int val ) = 0;
+
+ /**
+ * Enforce 'val' to be between minValue and maxValue.
+ * Return a value that is in range. This does not change the internally
+ * stored value of this IntField in any way.
+ **/
+ int enforceRange( int val ) const;
+
+public:
+
+ /**
+ * Return the minimum value.
+ **/
+ int minValue() const;
+
+ /**
+ * Set a new minimum value. If the current value is less than that, it will
+ * be set to the new minimum.
**/
- virtual void setLabel( const YCPString & label );
+ void setMinValue( int val );
/**
- * Change the slider value.
+ * Return the maximum value.
+ **/
+ int maxValue() const;
+
+ /**
+ * Set a new maximum value. If the current value is greater than that, it
+ * will be set to the new maximum.
+ **/
+ void setMaxValue( int val );
+
+ /**
+ * Get the label (the caption above the input field).
+ **/
+ string label() const;
+
+ /**
+ * Set the label (the caption above the input field).
*
- * Overload this, but call YIntField::setValue()
- * at the end of your own method.
+ * Derived classes are free to reimplement this, but they should call this
+ * base class method at the end of the overloaded function.
**/
- virtual void setValue( int newValue );
+ virtual void setLabel( const string & label );
- virtual int value() { return _value; }
- int minValue() { return _minValue; }
- int maxValue() { return _maxValue; }
- YCPString label() { return _label; }
+ /**
+ * Set a property.
+ * Reimplemented from YWidget.
+ *
+ * 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 bool setProperty( const string & propertyName,
+ const YPropertyValue & val );
+
+ /**
+ * Get a property.
+ * Reimplemented from YWidget.
+ *
+ * This method may throw YUIPropertyExceptions.
+ **/
+ virtual YPropertyValue getProperty( const string & propertyName );
+
+ /**
+ * Return this class's property set.
+ * This also initializes the property 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 label()->value(); }
+ virtual string shortcutString() { return label(); }
/**
* Set the string of this widget that holds the keyboard shortcut.
@@ -89,14 +172,13 @@
* 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; }
+ const char * userInputProperty() { return YUIProperty_Value; }
private:
@@ -108,10 +190,8 @@
**/
virtual void saveUserInput( YMacroRecorder *macroRecorder );
- YCPString _label;
- int _minValue;
- int _maxValue;
- int _value;
+
+ ImplPtr<YIntFieldPrivate> 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=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Mon Oct 8 17:08:04 2007
@@ -455,7 +455,6 @@
virtual YDialog *createDialog( YWidgetOpt & opt ) = 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 *createIntField( YWidget *parent, YWidgetOpt & opt, const YCPString & label, int minValue, int maxValue, int initialValue ) = 0;
// FIXME: Obsolete
// FIXME: Obsolete
// FIXME: Obsolete
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUISymbols.h Mon Oct 8 17:08:04 2007
@@ -146,8 +146,8 @@
// Widget properties
#define YUIProperty_Cell "Cell"
-#define YUIProperty_CurrentButton "CurrentButton"
#define YUIProperty_CurrentBranch "CurrentBranch"
+#define YUIProperty_CurrentButton "CurrentButton"
#define YUIProperty_CurrentItem "CurrentItem"
#define YUIProperty_DebugLabel "DebugLabel"
#define YUIProperty_DialogDebugLabel "DialogDebugLabel"
@@ -162,6 +162,8 @@
#define YUIProperty_Label "Label"
#define YUIProperty_Labels "Labels"
#define YUIProperty_LastLine "LastLine"
+#define YUIProperty_MaxValue "MaxValue"
+#define YUIProperty_MinValue "MinValue"
#define YUIProperty_Notify "Notify"
#define YUIProperty_OpenItems "OpenItems"
#define YUIProperty_SelectedItems "SelectedItems"
Modified: branches/tmp/sh/mod-ui/qt/src/YQIntField.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQIntField.cc?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQIntField.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQIntField.cc Mon Oct 8 17:08:04 2007
@@ -28,24 +28,22 @@
#include "YQWidgetCaption.h"
-YQIntField::YQIntField( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue )
-
- : QVBox( parent )
- , YIntField( opt, label, minValue, maxValue, initialValue )
+YQIntField::YQIntField( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue,
+ int initialValue )
+ : QVBox( (QWidget *) parent->widgetRep() )
+ , YIntField( parent, label, minValue, maxValue )
{
setWidgetRep( this );
setSpacing( YQWidgetSpacing );
setMargin( YQWidgetMargin );
-
- _caption = new YQWidgetCaption( this, label->value() );
+
+ _caption = new YQWidgetCaption( this, label );
YUI_CHECK_NEW( _caption );
-
+
_qt_spinbox = new QSpinBox( minValue, maxValue,
1, // step
this );
@@ -56,69 +54,80 @@
setValue( initialValue );
- connect( _qt_spinbox, SIGNAL( valueChanged(int) ),
- this, SLOT ( setValueSlot(int) ) );
+ connect( _qt_spinbox, SIGNAL( valueChanged( int ) ),
+ this, SLOT ( valueChanged( int ) ) );
}
-void YQIntField::setEnabled( bool enabled )
+YQIntField::~YQIntField()
{
- _caption->setEnabled ( enabled );
- _qt_spinbox->setEnabled( enabled );
- YWidget::setEnabled( enabled );
+ // NOP
}
-int YQIntField::preferredWidth()
+int
+YQIntField::value()
{
- return sizeHint().width();
+ return _qt_spinbox->value();
}
-int YQIntField::preferredHeight()
+void
+YQIntField::setValueInternal( int newValue )
{
- return sizeHint().height();
+ YQSignalBlocker sigBlocker( _qt_spinbox );
+ _qt_spinbox->setValue( newValue );
}
-void YQIntField::setSize( int newWidth, int newHeight )
+void
+YQIntField::valueChanged( int newValue )
{
- resize( newWidth, newHeight );
+ if ( notify() )
+ YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
}
-void YQIntField::setLabel( const YCPString & newLabel )
+void
+YQIntField::setLabel( const string & newLabel )
{
- _caption->setText( newLabel->value() );
YIntField::setLabel( newLabel );
+ _caption->setText( newLabel );
}
-void YQIntField::setValue( int newValue )
+void
+YQIntField::setEnabled( bool enabled )
{
- YQSignalBlocker sigBlocker( _qt_spinbox );
-
- _qt_spinbox->setValue( newValue );
- YIntField::setValue( newValue );
+ _caption->setEnabled ( enabled );
+ _qt_spinbox->setEnabled( enabled );
+ YWidget::setEnabled( enabled );
}
-int YQIntField::value()
-{
- YIntField::setValue( _qt_spinbox->value() );
- return YIntField::value();
+
+int
+YQIntField::preferredWidth()
+{
+ return sizeHint().width();
}
-void YQIntField::setValueSlot( int newValue )
+int
+YQIntField::preferredHeight()
{
- setValue( newValue );
+ return sizeHint().height();
+}
- if ( notify() )
- YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
+
+void
+YQIntField::setSize( int newWidth, int newHeight )
+{
+ resize( newWidth, newHeight );
}
-bool YQIntField::setKeyboardFocus()
+bool
+YQIntField::setKeyboardFocus()
{
_qt_spinbox->setFocus();
Modified: branches/tmp/sh/mod-ui/qt/src/YQIntField.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQIntField.h?rev=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQIntField.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQIntField.h Mon Oct 8 17:08:04 2007
@@ -20,7 +20,6 @@
#ifndef YQIntField_h
#define YQIntField_h
-#include
#include
#include
#include
@@ -42,18 +41,51 @@
/**
* Constructor.
**/
- YQIntField( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue );
+ YQIntField( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue,
+ int initialValue );
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YQIntField();
+
+ /**
+ * Get the current value (the number entered by the user or set from the
+ * outside) of this IntField.
+ *
+ * Implemented from YIntField.
+ **/
+ virtual int value();
+
+protected:
+
+ /**
+ * Set the current value (the number entered by the user or set from the
+ * outside) of this IntField. 'val' is guaranteed to be between minValue
+ * and maxValue; no further checks are required.
+ *
+ * Implemented from YIntField.
+ **/
+ virtual void setValueInternal( int val );
+
+public:
+
+ /**
+ * Set the label (the caption above the input field).
+ *
+ * Reimplemented from YIntField.
+ **/
+ virtual void setLabel( const string & label );
/**
* Sets the widget's enabled state.
+ *
* Inherited from YWidget.
**/
- void setEnabled( bool enabled );
+ virtual void setEnabled( bool enabled );
/**
* Preferred width of the widget.
@@ -77,33 +109,20 @@
virtual void setSize( int newWidth, int newHeight );
/**
- * Change the IntField label.
- * Calls YIntField::setLabel at the end.
- * Inherited from YIntField.
- **/
- void setLabel( const YCPString & label );
-
- /**
* Accept the keyboard focus.
+ *
+ * Reimplemented from YWidget.
**/
virtual bool setKeyboardFocus();
- /**
- * Change the value.
- * Calls YIntField::setProgress at the end.
- * Inherited from YIntField.
- **/
- void setValue( int newValue );
- virtual int value();
+protected slots:
-public slots:
/**
- * Slot for setting the value.
- * This is needed separately from setValue() to avoid infinite loops via
- * ChangeWidget().
+ * Slot for "value changed". This will send a ValueChanged event if
+ * 'notify' is set.
**/
- void setValueSlot( int newValue );
+ void valueChanged( int newValue );
protected:
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=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Mon Oct 8 17:08:04 2007
@@ -432,7 +432,6 @@
/*** Widget creation methods, all reimplemented from YUI ***/
- YWidget * createIntField ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, int minValue, int maxValue, int initialValue);
YWidget * createLogView ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, int visibleLines, int maxLines );
YWidget * createMenuButton ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
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=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Mon Oct 8 17:08:04 2007
@@ -107,22 +107,6 @@
}
-YWidget * YQUI::createIntField ( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue )
-{
- return new YQIntField( (QWidget *) ( parent->widgetRep() ),
- opt,
- label,
- minValue,
- maxValue,
- initialValue );
-}
-
-
//========= Optional widgets ========================================================
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=41285&r1=41284&r2=41285&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQWidgetFactory.cc Mon Oct 8 17:08:04 2007
@@ -221,7 +221,10 @@
YQIntField *
YQWidgetFactory::createIntField( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal )
{
- return 0; // FIXME: TO DO
+ YQIntField * intField = new YQIntField( parent, label, minVal, maxVal, initialVal );
+ YUI_CHECK_NEW( intField );
+
+ return intField;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org