Author: sh-sh-sh
Date: Wed Nov 7 18:22:07 2007
New Revision: 41865
URL: http://svn.opensuse.org/viewcvs/yast?rev=41865&view=rev
Log:
ported slider widget
Modified:
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/YCheckBoxFrame.cc
branches/tmp/sh/mod-ui/core/libyui/src/YComboBox.cc
branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc
branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc
branches/tmp/sh/mod-ui/core/libyui/src/YMultiLineEdit.cc
branches/tmp/sh/mod-ui/core/libyui/src/YMultiSelectionBox.cc
branches/tmp/sh/mod-ui/core/libyui/src/YPartitionSplitter.cc
branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSlider.cc
branches/tmp/sh/mod-ui/core/libyui/src/YSlider.h
branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc
branches/tmp/sh/mod-ui/core/libyui/src/YUI.h
branches/tmp/sh/mod-ui/core/libyui/src/YUI_builtins.cc
branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc
branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc
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/YQOptionalWidgetFactory.cc
branches/tmp/sh/mod-ui/qt/src/YQSlider.cc
branches/tmp/sh/mod-ui/qt/src/YQSlider.h
branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCPDialogParser.cc Wed Nov 7 18:22:07 2007
@@ -70,6 +70,7 @@
#include "YReplacePoint.h"
#include "YRichText.h"
#include "YSelectionBox.h"
+#include "YSlider.h"
#include "YSpacing.h"
#include "YSquash.h"
#include "YTable.h"
@@ -2982,21 +2983,12 @@
rejectAllOptions( term,optList );
YWidget *slider;
- if ( YUI::ui()->hasSlider() )
- {
- 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();
- slider = YUI::ui()->createSlider( parent, opt, label, minValue, maxValue, initialValue );
- }
- else
- {
- y2error( "This UI does not support the Slider widget." );
- return 0;
- }
+ 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 slider;
+ return YUI::optionalWidgetFactory()->createSlider( parent, label, minValue, maxValue, initialValue );
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBox.cc Wed Nov 7 18:22:07 2007
@@ -126,7 +126,8 @@
}
-void YCheckBox::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YCheckBox::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YCheckBoxFrame.cc Wed Nov 7 18:22:07 2007
@@ -160,7 +160,8 @@
}
-void YCheckBoxFrame::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YCheckBoxFrame::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YComboBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YComboBox.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YComboBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YComboBox.cc Wed Nov 7 18:22:07 2007
@@ -239,7 +239,8 @@
-void YComboBox::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YComboBox::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YInputField.cc Wed Nov 7 18:22:07 2007
@@ -174,7 +174,8 @@
}
-void YInputField::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YInputField::saveUserInput( YMacroRecorder *macroRecorder )
{
#if 0
// FIXME
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YIntField.cc Wed Nov 7 18:22:07 2007
@@ -188,7 +188,8 @@
}
-void YIntField::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YIntField::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YMultiLineEdit.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YMultiLineEdit.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YMultiLineEdit.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YMultiLineEdit.cc Wed Nov 7 18:22:07 2007
@@ -149,7 +149,8 @@
}
-void YMultiLineEdit::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YMultiLineEdit::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YMultiSelectionBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YMultiSelectionBox.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YMultiSelectionBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YMultiSelectionBox.cc Wed Nov 7 18:22:07 2007
@@ -126,7 +126,8 @@
-void YMultiSelectionBox::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YMultiSelectionBox::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_CurrentItem );
macroRecorder->recordWidgetProperty( this, YUIProperty_SelectedItems );
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YPartitionSplitter.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YPartitionSplitter.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YPartitionSplitter.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YPartitionSplitter.cc Wed Nov 7 18:22:07 2007
@@ -119,7 +119,8 @@
-void YPartitionSplitter::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YPartitionSplitter::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YRadioButton.cc Wed Nov 7 18:22:07 2007
@@ -186,7 +186,8 @@
}
-void YRadioButton::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YRadioButton::saveUserInput( YMacroRecorder *macroRecorder )
{
if ( value() )
{
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSelectionBox.cc Wed Nov 7 18:22:07 2007
@@ -148,7 +148,8 @@
}
-void YSelectionBox::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YSelectionBox::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_CurrentItem );
}
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSlider.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSlider.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSlider.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSlider.cc Wed Nov 7 18:22:07 2007
@@ -17,123 +17,51 @@
/-*/
-#include
-#include
#define y2log_component "ui"
#include
-#include "YUISymbols.h"
-#include "YMacroRecorder.h"
#include "YSlider.h"
-YSlider::YSlider( const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue )
- : YWidget( opt )
- , _label( label )
- , _minValue( minValue )
- , _maxValue( maxValue )
- , _value( initialValue )
+struct YSliderPrivate
{
- setDefaultStretchable( YD_HORIZ, true );
- setStretchable( YD_VERT, false );
-}
+ YSliderPrivate()
+ {}
+ bool dummy;
+};
-void YSlider::setLabel( const YCPString & newLabel )
-{
- _label = newLabel;
-}
-void YSlider::setValue( int newValue )
-{
- _value = newValue;
-}
-YCPValue YSlider::changeWidget( const YCPSymbol & property,
- const YCPValue & newValue )
+YSlider::YSlider( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue )
+ : YIntField( parent, label, minValue, maxValue )
+ , priv( new YSliderPrivate() )
{
- string sym = property->symbol();
-
- /**
- * @property integer Value the numerical value
- */
- if ( sym == YUIProperty_Value )
- {
- if ( newValue->isInteger() )
- {
- int val = newValue->asInteger()->value();
-
- if ( val < minValue() )
- {
- y2warning( "YSlider::changeWidget( `Value ): "
- "Warning: New value %d below minValue ( %d )",
- val, minValue() );
- setValue( minValue() );
- }
- else if ( val > maxValue() )
- {
- y2warning( "YSlider::changeWidget( `Value ): "
- "Warning: New value %d above maxValue ( %d )",
- val, maxValue() );
- setValue( maxValue() );
- }
- else
- {
- setValue( val );
- }
-
- return YCPBoolean( true );
- }
- else
- {
- y2error( "YSlider::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( "YSlider::changeWidget( `Value ): "
- "Error: Expecting string, not %s",
- newValue->toString().c_str() );
-
- return YCPBoolean( false );
- }
- }
- else return YWidget::changeWidget( property, newValue );
+ YUI_CHECK_NEW( priv );
+
+ setDefaultStretchable( YD_HORIZ, true );
+ setStretchable( YD_VERT, false );
}
-
-YCPValue YSlider::queryWidget( const YCPSymbol & property )
+YSlider::~YSlider()
{
- string s = property->symbol();
- if ( s == YUIProperty_Value ) return YCPInteger( value() );
- else if ( s == YUIProperty_Label ) return label();
- else return YWidget::queryWidget( property );
+ // NOP
}
+//
+// Property documentation - all inherited from YIntField:
+//
-void YSlider::saveUserInput( YMacroRecorder *macroRecorder )
-{
- macroRecorder->recordWidgetProperty( this, YUIProperty_Value );
-}
+/*
+ * @property integer Value the slider value
+ * @property integer MinValue the minimum value
+ * @property integer MaxValue the maximum value
+ * @property string Label caption above the slider
+ */
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YSlider.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YSlider.h?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YSlider.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YSlider.h Wed Nov 7 18:22:07 2007
@@ -19,103 +19,56 @@
#ifndef YSlider_h
#define YSlider_h
-#include "YWidget.h"
-#include
-#include
+#include "YIntField.h"
class YMacroRecorder;
+class YSliderPrivate;
-class YSlider : public YWidget
+/**
+ * Slider: Input widget for an integer value between a minimum and a maximum
+ * value. Very similar to IntField in semantics, but with a graphical slider
+ * that can be dragged to the desired value. It also contains an IntField to
+ * allow entering the value directly.
+ *
+ * Don't confuse this widget with ProgressBar: ProgressBar is output-only.
+ *
+ *
+ * This is an optional widget, i.e. not all UIs support it.
+ **/
+class YSlider : public YIntField
{
protected:
/**
- * Constructor
- **/
- YSlider( const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue );
-
-public:
- /**
- * Returns a descriptive name of this widget class for logging,
- * debugging etc.
- **/
- virtual const char * widgetClass() const { return "YSlider"; }
-
- /**
- * Implements the ChangeWidget() UI command.
- **/
- YCPValue changeWidget( const YCPSymbol & property,
- const YCPValue & newValue );
-
- /**
- * Implements the QueryWidget() UI command.
- **/
- YCPValue queryWidget( const YCPSymbol & property );
-
- /**
- * Change the Slider label.
- *
- * Overwrite this, but call YSlider::setLabel
- * at the end of your own method.
- **/
- virtual void setLabel( const YCPString & label );
-
- /**
- * Change the slider value.
+ * Constructor.
*
- * Overload this, but call YSlider::setValue()
- * at the end of your own method.
- **/
- virtual void setValue( int newValue );
-
-
- YCPString label() { return _label; }
- int value() { return _value; }
- int minValue() { return _minValue; }
- int maxValue() { return _maxValue; }
-
-
- /**
- * Get the string of this widget that holds the keyboard shortcut.
+ * Create a Slider with 'label' as the caption, and the specified minimum
+ * and maximum values.
*
- * Reimplemented from YWidget.
- **/
- virtual string shortcutString() { return label()->value(); }
+ * Note that YWidgetFactory::createSlider() 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).
+ **/
+ YSlider( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue );
+public:
/**
- * Set the string of this widget that holds the keyboard shortcut.
- *
- * Reimplemented from YWidget.
+ * Destructor.
**/
- virtual void setShortcutString( const string & str )
- { setLabel( YCPString( str ) ); }
-
+ virtual ~YSlider();
/**
- * The name of the widget property that will return user input.
- * Inherited from YWidget.
+ * Returns a descriptive name of this widget class for logging,
+ * debugging etc.
**/
- const char *userInputProperty() { return YUIProperty_Value; }
-
+ virtual const char * widgetClass() const { return "YSlider"; }
private:
- /**
- * Save the widget's user input to a macro recorder.
- * Intentionally declared as "private" so all macro recording internals are
- * handled by the abstract libyui level, not by a specific UI.
- **/
- virtual void saveUserInput( YMacroRecorder *macroRecorder );
-
-
- YCPString _label;
- int _minValue;
- int _maxValue;
- int _value;
+ ImplPtr<YSliderPrivate> priv;
};
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YTable.cc Wed Nov 7 18:22:07 2007
@@ -206,7 +206,8 @@
}
-void YTable::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YTable::saveUserInput( YMacroRecorder *macroRecorder )
{
macroRecorder->recordWidgetProperty( this, YUIProperty_CurrentItem );
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI.h (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI.h Wed Nov 7 18:22:07 2007
@@ -492,22 +492,6 @@
virtual YWidget * createDumbTab( YWidget *parent, YWidgetOpt & opt );
virtual bool hasDumbTab() { return false; }
-
- /**
- * Creates a Slider widget.
- *
- * This is a special widget that the UI may or may not support.
- * Overwrite this method at your own discretion.
- * If you do, remember to overwrite the has...() method as well!
- **/
- virtual YWidget * createSlider( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue );
- virtual bool hasSlider() { return false; }
-
/**
* Creates a PartitionSplitter widget.
*
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=41865&r1=41864&r2=41865&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 Wed Nov 7 18:22:07 2007
@@ -90,7 +90,7 @@
else if ( symbol == YUISpecialWidget_DownloadProgress ) hasWidget = hasDownloadProgress();
else if ( symbol == YUISpecialWidget_HMultiProgressMeter ) hasWidget = fact->hasMultiProgressMeter();
else if ( symbol == YUISpecialWidget_VMultiProgressMeter ) hasWidget = fact->hasMultiProgressMeter();
- else if ( symbol == YUISpecialWidget_Slider ) hasWidget = hasSlider();
+ else if ( symbol == YUISpecialWidget_Slider ) hasWidget = fact->hasSlider();
else if ( symbol == YUISpecialWidget_PatternSelector ) hasWidget = fact->hasPatternSelector();
else if ( symbol == YUISpecialWidget_PartitionSplitter ) hasWidget = hasPartitionSplitter();
else if ( symbol == YUISpecialWidget_SimplePatchSelector ) hasWidget = fact->hasSimplePatchSelector();
Modified: branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YUI_special_widgets.cc Wed Nov 7 18:22:07 2007
@@ -79,17 +79,6 @@
}
-YWidget * YUI::createSlider( YWidget *parent, YWidgetOpt & opt,
- const YCPString & label,
- int minValue, int maxValue, int initialValue )
-{
- y2error( "Default createSlider() method called - "
- "forgot to call HasSpecialWidget()?" );
-
- return 0;
-}
-
-
YWidget * YUI::createPartitionSplitter( YWidget * parent,
YWidgetOpt & opt,
int usedSize,
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc (original)
+++ branches/tmp/sh/mod-ui/core/libyui/src/YWidget.cc Wed Nov 7 18:22:07 2007
@@ -678,7 +678,8 @@
}
-void YWidget::saveUserInput( YMacroRecorder *macroRecorder )
+void
+YWidget::saveUserInput( YMacroRecorder *macroRecorder )
{
for ( YWidgetListConstIterator it = childrenBegin();
it != childrenEnd();
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQIntField.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQIntField.cc Wed Nov 7 18:22:07 2007
@@ -46,17 +46,17 @@
_caption = new YQWidgetCaption( this, label );
YUI_CHECK_NEW( _caption );
- _qt_spinbox = new QSpinBox( minValue, maxValue,
+ _qt_spinBox = new QSpinBox( minValue, maxValue,
1, // step
this );
- YUI_CHECK_NEW( _qt_spinbox );
- _qt_spinbox->setValue( initialValue );
+ YUI_CHECK_NEW( _qt_spinBox );
+ _qt_spinBox->setValue( initialValue );
- _caption->setBuddy( _qt_spinbox );
+ _caption->setBuddy( _qt_spinBox );
setValue( initialValue );
- connect( _qt_spinbox, SIGNAL( valueChanged( int ) ),
+ connect( _qt_spinBox, SIGNAL( valueChanged( int ) ),
this, SLOT ( valueChanged( int ) ) );
}
@@ -70,15 +70,15 @@
int
YQIntField::value()
{
- return _qt_spinbox->value();
+ return _qt_spinBox->value();
}
void
YQIntField::setValueInternal( int newValue )
{
- YQSignalBlocker sigBlocker( _qt_spinbox );
- _qt_spinbox->setValue( newValue );
+ YQSignalBlocker sigBlocker( _qt_spinBox );
+ _qt_spinBox->setValue( newValue );
}
@@ -102,7 +102,7 @@
YQIntField::setEnabled( bool enabled )
{
_caption->setEnabled ( enabled );
- _qt_spinbox->setEnabled( enabled );
+ _qt_spinBox->setEnabled( enabled );
YWidget::setEnabled( enabled );
}
@@ -131,7 +131,7 @@
bool
YQIntField::setKeyboardFocus()
{
- _qt_spinbox->setFocus();
+ _qt_spinBox->setFocus();
return true;
}
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQIntField.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQIntField.h Wed Nov 7 18:22:07 2007
@@ -126,7 +126,7 @@
protected:
YQWidgetCaption * _caption;
- QSpinBox * _qt_spinbox;
+ QSpinBox * _qt_spinBox;
};
Modified: branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQOptionalWidgetFactory.cc Wed Nov 7 18:22:07 2007
@@ -80,17 +80,20 @@
bool YQOptionalWidgetFactory::hasSlider()
{
- return false;
+ return true;
}
YQSlider *
-YQOptionalWidgetFactory::createSlider( YWidget * parent,
+YQOptionalWidgetFactory::createSlider( YWidget * parent,
const string & label,
int minVal,
int maxVal,
int initialVal )
{
- THROW_UNSUPPORTED( "YQSlider" );
+ YQSlider * slider = new YQSlider( parent, label, minVal, maxVal, initialVal );
+ YUI_CHECK_NEW( slider );
+
+ return slider;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQSlider.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQSlider.cc?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQSlider.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQSlider.cc Wed Nov 7 18:22:07 2007
@@ -17,9 +17,13 @@
/-*/
+#include
+#include
+#include
+#include
+
#define y2log_component "qt-ui"
#include
-#include <algorithm>
#include "utf8.h"
#include "YQUI.h"
@@ -29,22 +33,21 @@
#include "YQWidgetCaption.h"
-YQSlider::YQSlider( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
+YQSlider::YQSlider( YWidget * parent,
+ const string & label,
int minValue,
int maxValue,
int initialValue )
- : QVBox( parent )
- , YSlider( opt, label, minValue, maxValue, initialValue )
+ : QVBox( (QWidget *) parent->widgetRep() )
+ , YSlider( parent, label, minValue, maxValue )
{
setWidgetRep( this );
setSpacing( YQWidgetSpacing );
setMargin ( YQWidgetMargin );
- _caption = new YQWidgetCaption( this, label->value() );
+ _caption = new YQWidgetCaption( this, toUTF8( label ) );
YUI_CHECK_NEW( _caption );
_caption->setAlignment( Qt::AlignRight );
@@ -60,85 +63,104 @@
QSlider::Horizontal, _hbox );
YUI_CHECK_NEW( _qt_slider );
- _qt_spinbox = new QSpinBox( minValue, maxValue,
+ _qt_spinBox = new QSpinBox( minValue, maxValue,
1, // step
_hbox );
- YUI_CHECK_NEW( _qt_spinbox );
+ YUI_CHECK_NEW( _qt_spinBox );
- _qt_spinbox->setValue( initialValue );
- _caption->setBuddy( _qt_spinbox );
+ _qt_spinBox->setValue( initialValue );
+ _caption->setBuddy( _qt_spinBox );
setValue( initialValue );
- connect( _qt_spinbox, SIGNAL( valueChanged(int) ),
+ connect( _qt_spinBox, SIGNAL( valueChanged(int) ),
_qt_slider, SLOT ( setValue (int) ) );
connect( _qt_slider, SIGNAL( valueChanged(int) ),
- _qt_spinbox, SLOT ( setValue (int) ) );
+ _qt_spinBox, SLOT ( setValue (int) ) );
- connect( _qt_spinbox, SIGNAL( valueChanged(int) ),
- this, SLOT ( setValueSlot(int) ) );
+ connect( _qt_spinBox, SIGNAL( valueChanged(int) ),
+ this, SLOT ( valueChanged(int) ) );
}
-void YQSlider::setEnabled( bool enabled )
+YQSlider::~YQSlider()
{
- _caption->setEnabled ( enabled );
- _qt_slider->setEnabled ( enabled );
- _qt_spinbox->setEnabled( enabled );
- YWidget::setEnabled( enabled );
+ // NOP
}
-int YQSlider::preferredWidth()
+int
+YQSlider::value()
{
- int hintWidth = _caption->isShown() ? _caption->sizeHint().width() : 0;
-
- // Arbitrary value - there is no really good default
- return max( 200, hintWidth );
+ return _qt_spinBox->value();
}
-int YQSlider::preferredHeight()
+void
+YQSlider::setValueInternal( int newValue )
{
- return sizeHint().height();
+ YQSignalBlocker sigBlocker1( _qt_spinBox );
+ YQSignalBlocker sigBlocker2( _qt_slider );
+ _qt_slider->setValue ( newValue );
+ _qt_spinBox->setValue( newValue );
}
-void YQSlider::setSize( int newWidth, int newHeight )
+void
+YQSlider::valueChanged( int newValue )
{
- resize( newWidth, newHeight );
+ if ( notify() )
+ YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
}
-void YQSlider::setLabel( const YCPString & newLabel )
+void
+YQSlider::setEnabled( bool enabled )
{
- _caption->setText( newLabel->value() );
- YSlider::setLabel( newLabel );
+ _caption->setEnabled ( enabled );
+ _qt_slider->setEnabled ( enabled );
+ _qt_spinBox->setEnabled( enabled );
+ YWidget::setEnabled( enabled );
}
-void YQSlider::setValue( int newValue )
+int
+YQSlider::preferredWidth()
{
- YQSignalBlocker sigBlocker( _qt_slider );
+ int hintWidth = _caption->isShown() ? _caption->sizeHint().width() : 0;
- _qt_slider->setValue( newValue );
- YSlider::setValue( newValue );
+ // Arbitrary value - there is no really good default
+ return max( 200, hintWidth );
}
-void YQSlider::setValueSlot( int newValue )
+int
+YQSlider::preferredHeight()
{
- setValue( newValue );
+ return sizeHint().height();
+}
- if ( notify() )
- YQUI::ui()->sendEvent( new YWidgetEvent( this, YEvent::ValueChanged ) );
+
+void
+YQSlider::setSize( int newWidth, int newHeight )
+{
+ resize( newWidth, newHeight );
+}
+
+
+void
+YQSlider::setLabel( const string & newLabel )
+{
+ _caption->setText( newLabel );
+ YSlider::setLabel( newLabel );
}
-bool YQSlider::setKeyboardFocus()
+bool
+YQSlider::setKeyboardFocus()
{
- _qt_spinbox->setFocus();
+ _qt_spinBox->setFocus();
return true;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQSlider.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQSlider.h?rev=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQSlider.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQSlider.h Wed Nov 7 18:22:07 2007
@@ -20,19 +20,14 @@
#ifndef YQSlider_h
#define YQSlider_h
-#include
-#include
-#include
-#include
#include
-#include
-
#include "YSlider.h"
-class QString;
class YQWidgetCaption;
class QSlider;
+class QSpinBox;
+class QHBox;
class YQSlider : public QVBox, public YSlider
{
@@ -43,12 +38,44 @@
/**
* Constructor.
**/
- YQSlider( QWidget * parent,
- const YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue );
+ YQSlider( YWidget * parent,
+ const string & label,
+ int minValue,
+ int maxValue,
+ int initialValue );
+
+ /**
+ * Destructor.
+ **/
+ virtual ~YQSlider();
+
+ /**
+ * Get the current value (the number entered by the user or set from the
+ * outside) of this slider.
+ *
+ * Implemented from YSlider / YIntField.
+ **/
+ virtual int value();
+
+protected:
+
+ /**
+ * Set the current value (the number entered by the user or set from the
+ * outside) of this slider. 'val' is guaranteed to be between minValue
+ * and maxValue; no further checks are required.
+ *
+ * Implemented from YSlider/ YIntField.
+ **/
+ virtual void setValueInternal( int val );
+
+public:
+
+ /**
+ * Set the label (the caption above the input field).
+ *
+ * Reimplemented from YSlider / YIntField.
+ **/
+ virtual void setLabel( const string & label );
/**
* Set enabled/disabled state.
@@ -79,26 +106,18 @@
virtual void setSize( int newWidth, int newHeight );
/**
- * Change the Slider label.
- * Calls YSlider::setLabel at the end.
- * Inherited from YSlider.
- **/
- void setLabel( const YCPString & label );
-
- /**
* Accept the keyboard focus.
**/
virtual bool setKeyboardFocus();
+
+public slots:
/**
- * Change the value.
- * Calls YSlider::setProgress at the end.
- * Inherited from YSlider.
+ * Slot for "value changed". This will send a ValueChanged event if
+ * 'notify' is set.
**/
- void setValue( int newValue );
+ void valueChanged( int newValue );
-
-public slots:
/**
* Slot for setting the value.
* This is needed separately from setValue() to avoid infinite loops via
@@ -111,7 +130,7 @@
YQWidgetCaption * _caption;
QSlider * _qt_slider;
- QSpinBox * _qt_spinbox;
+ QSpinBox * _qt_spinBox;
QHBox * _hbox;
};
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=41865&r1=41864&r2=41865&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Wed Nov 7 18:22:07 2007
@@ -22,16 +22,11 @@
#include "YQUI.h"
#include "YQBarGraph.h"
-#include "YQDateField.h"
#include "YQDialog.h"
#include "YQDownloadProgress.h"
#include "YQDumbTab.h"
-#include "YQIntField.h"
-#include "YQMultiProgressMeter.h"
#include "YQPackageSelectorPlugin.h"
#include "YQPartitionSplitter.h"
-#include "YQSlider.h"
-#include "YQTimeField.h"
@@ -54,7 +49,7 @@
-//========= Optional widgets ========================================================
+//========= Optional widgets ==================================================
bool YQUI::hasBarGraph()
@@ -99,28 +94,6 @@
}
-bool YQUI::hasSlider()
-{
- return true;
-}
-
-
-YWidget * YQUI::createSlider( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label,
- int minValue,
- int maxValue,
- int initialValue )
-{
- return new YQSlider( (QWidget *) ( parent->widgetRep() ),
- opt,
- label,
- minValue,
- maxValue,
- initialValue );
-}
-
-
bool YQUI::hasPartitionSplitter()
{
return true;
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org