Author: sh-sh-sh
Date: Fri Jun 1 17:16:50 2007
New Revision: 38253
URL: http://svn.opensuse.org/viewcvs/yast?rev=38253&view=rev
Log:
- Ported TextEntry
- Minor fixes for RadioButton
Modified:
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/YQTextEntry.cc
branches/tmp/sh/mod-ui/qt/src/YQTextEntry.h
branches/tmp/sh/mod-ui/qt/src/YQUI.h
branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc
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=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQRadioButton.cc Fri Jun 1 17:16:50 2007
@@ -41,7 +41,7 @@
YQRadioButton::YQRadioButton( QWidget * parent,
const YWidgetOpt & opt,
YRadioButtonGroup * rbg,
- const YCPString & label,
+ const std::string & label,
bool checked )
: QGroupBox( parent )
, YRadioButton( opt, label )
@@ -51,7 +51,7 @@
QBoxLayout * layout = new QBoxLayout( this, QBoxLayout::LeftToRight );
- _qt_radiobutton = new QRadioButton( fromUTF8( label->value() ), this );
+ _qt_radiobutton = new QRadioButton( fromUTF8( label ), this );
layout->addSpacing( SPACING );
layout->addWidget( _qt_radiobutton );
layout->addSpacing( SPACING );
@@ -97,9 +97,9 @@
}
-void YQRadioButton::setLabel( const YCPString & label )
+void YQRadioButton::setLabel( const std::string & label )
{
- _qt_radiobutton->setText( fromUTF8(label->value() ) );
+ _qt_radiobutton->setText( fromUTF8( label ) );
YRadioButton::setLabel( label );
}
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=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQRadioButton.h Fri Jun 1 17:16:50 2007
@@ -22,7 +22,6 @@
#define YQRadioButton_h
#include
-#include
#include "YRadioButton.h"
@@ -40,10 +39,26 @@
YQRadioButton( QWidget * parent,
const YWidgetOpt & opt,
YRadioButtonGroup * rbg,
- const YCPString & label,
+ const std::string & label,
bool checked );
/**
+ * Returns the "checked" state of the RadioButton.
+ */
+ bool value();
+
+ /**
+ * Sets the "checked" state of the RadioButton.
+ */
+ void setValue( bool checked );
+
+ /**
+ * Changes the label of the text entry.
+ */
+ void setLabel( const std::string & label );
+
+
+ /**
* Inherited from YWidget: Sets the enabled state of the
* widget. All new widgets are enabled per definition. Only
* enabled widgets can take user input.
@@ -63,31 +78,16 @@
void setSize( long newWidth, long newHeight );
/**
- * Sets the "checked" state of the RadioButton.
- */
- void setValue( bool checked );
-
- /**
- * Returns the "checked" state of the RadioButton.
- */
- bool value();
-
- /**
- * Changes the label of the text entry.
- */
- void setLabel( const YCPString & label );
-
- /**
* Accept the keyboard focus.
*/
virtual bool setKeyboardFocus();
/**
- * Returns the actual qt button. Used by
- * @ref YQButtonGroup
+ * Returns the actual qt button. Used by YQButtonGroup.
*/
QRadioButton * getQtButton();
+
protected slots:
/**
* Triggered when the RadioButton is toggled.
Modified: branches/tmp/sh/mod-ui/qt/src/YQTextEntry.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTextEntry.cc?rev=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTextEntry.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTextEntry.cc Fri Jun 1 17:16:50 2007
@@ -12,8 +12,7 @@
File: YQTextEntry.cc
- Author: Mathias Kettner
- Maintainer: Stefan Hundhammer
+ Author: Stefan Hundhammer
textdomain "packages-qt"
@@ -22,9 +21,9 @@
#include
#include
-#include
-#include
-#include
+#include // CapsLock detection
+#include // CapsLock detection
+#include // CapsLock detection
#define y2log_component "qt-ui"
#include
@@ -40,10 +39,10 @@
YQTextEntry::YQTextEntry( QWidget * parent,
const YWidgetOpt & opt,
- const YCPString & label,
- const YCPString & text )
+ const std::string & label,
+ bool passwordMode )
: QVBox( parent )
- , YTextEntry( opt, label )
+ , YTextEntry( opt, label, passwordMode )
, _validator(0)
, _displayingCapsLockWarning( false )
{
@@ -52,16 +51,15 @@
setSpacing( YQWidgetSpacing );
setMargin( YQWidgetMargin );
- _qt_label = new QLabel( fromUTF8( label->value() ), this );
+ _qt_label = new QLabel( fromUTF8( label ), this );
_qt_label->setTextFormat( QLabel::PlainText );
_qt_label->setFont( YQUI::ui()->currentFont() );
- if ( label->value() == "" )
+ if ( label.empty() )
_qt_label->hide();
_qt_lineEdit = new YQRawLineEdit( this );
_qt_lineEdit->setFont( YQUI::ui()->currentFont() );
- _qt_lineEdit->setText( fromUTF8(text->value() ) );
_qt_label->setBuddy( _qt_lineEdit );
@@ -70,7 +68,7 @@
connect( _qt_lineEdit, SIGNAL( textChanged( const QString & ) ),
this, SLOT ( changed ( const QString & ) ) );
- if ( opt.passwordMode.value() )
+ if ( passwordMode )
{
_qt_lineEdit->setEchoMode( QLineEdit::Password );
@@ -83,6 +81,30 @@
}
+std::string YQTextEntry::value()
+{
+ return toUTF8( _qt_lineEdit->text() );
+}
+
+
+void YQTextEntry::setValue( const std::string & newText )
+{
+ QString text = fromUTF8( newText );
+
+ if ( isValidText( text ) )
+ {
+ _qt_lineEdit->blockSignals( true );
+ _qt_lineEdit->setText( text );
+ _qt_lineEdit->blockSignals( false );
+ }
+ else
+ {
+ y2error( "%s \"%s\": Rejecting invalid value \"%s\"",
+ widgetClass(), debugLabel().c_str(), newText.c_str() );
+ }
+}
+
+
void YQTextEntry::setEnabling( bool enabled )
{
_qt_lineEdit->setEnabled( enabled );
@@ -113,33 +135,10 @@
resize( newWidth, newHeight );
}
-void YQTextEntry::setText( const YCPString & ytext )
-{
- QString text = fromUTF8( ytext->value() );
-
- if ( isValidText( text ) )
- {
- _qt_lineEdit->blockSignals( true );
- _qt_lineEdit->setText( text );
- _qt_lineEdit->blockSignals( false );
- }
- else
- {
- y2error( "%s \"%s\": Rejecting invalid value \"%s\"",
- widgetClass(), debugLabel().c_str(), ytext->value().c_str() );
- }
-}
-
-
-YCPString YQTextEntry::getText()
-{
- return YCPString( toUTF8(_qt_lineEdit->text() ) );
-}
-
-void YQTextEntry::setLabel( const YCPString & label )
+void YQTextEntry::setLabel( const std::string & label )
{
- _qt_label->setText( fromUTF8(label->value() ) );
+ _qt_label->setText( fromUTF8(label ) );
YTextEntry::setLabel( label );
}
@@ -156,15 +155,15 @@
}
-void YQTextEntry::setValidChars( const YCPString & newValidChars )
+void YQTextEntry::setValidChars( const std::string & newValidChars )
{
if ( _validator )
{
- _validator->setValidChars( fromUTF8( newValidChars->value() ) );
+ _validator->setValidChars( fromUTF8( newValidChars ) );
}
else
{
- _validator = new QY2CharValidator( fromUTF8( newValidChars->value() ), this );
+ _validator = new QY2CharValidator( fromUTF8( newValidChars ), this );
_qt_lineEdit->setValidator( _validator );
// No need to delete the validator in the destructor - Qt will take
@@ -176,16 +175,17 @@
y2error( "Old value \"%s\" of %s \"%s\" invalid according to ValidChars \"%s\" - deleting",
(const char *) _qt_lineEdit->text(),
widgetClass(), debugLabel().c_str(),
- newValidChars->value().c_str() );
+ newValidChars.c_str() );
_qt_lineEdit->setText( "" );
}
YTextEntry::setValidChars( newValidChars );
}
-void YQTextEntry::setInputMaxLength( const YCPInteger & numberOfChars)
+void YQTextEntry::setInputMaxLength( int len )
{
- _qt_lineEdit->setMaxLength(numberOfChars->asInteger()->value());
+ _qt_lineEdit->setMaxLength( len );
+ YTextEntry::setInputMaxLength( len );
}
bool YQTextEntry::setKeyboardFocus()
@@ -238,7 +238,7 @@
if ( _qt_lineEdit->echoMode() == QLineEdit::Normal )
return;
- _qt_label->setText( fromUTF8( getLabel()->value() ) );
+ _qt_label->setText( fromUTF8( label() ) );
_qt_label->setFont( YQUI::ui()->currentFont() );
_displayingCapsLockWarning = false;
}
Modified: branches/tmp/sh/mod-ui/qt/src/YQTextEntry.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/sh/mod-ui/qt/src/YQTextEntry.h?rev=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQTextEntry.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQTextEntry.h Fri Jun 1 17:16:50 2007
@@ -12,8 +12,7 @@
File: YQTextEntry.h
- Author: Mathias Kettner
- Maintainer: Stefan Hundhammer
+ Author: Stefan Hundhammer
/-*/
@@ -43,70 +42,80 @@
public:
/**
* Constructor.
- */
+ **/
YQTextEntry( QWidget * parent,
const YWidgetOpt & opt,
- const YCPString & label,
- const YCPString & text );
+ const std::string & label,
+ bool passwordMode = false );
/**
- * Inherited from YWidget: Sets the enabled state of the
- * widget. All new widgets are enabled per definition. Only
- * enabled widgets can take user input.
- */
- void setEnabling( bool enabled );
+ * Get the current value (the text entered by the user or set from the
+ * outside) of this input field.
+ *
+ * Reimplemented from YTextEntry.
+ **/
+ virtual std::string value();
/**
- * Minimum size the widget should have to make it look and feel
- * nice.
- * @dim Dimension, either YD_HORIZ or YD_VERT
+ * Set the current value (the text entered by the user or set from the
+ * outside) of this input field.
+ *
+ * Reimplemented from YTextEntry.
*/
- long nicesize( YUIDimension dim );
+ virtual void setValue( const std::string & text );
/**
- * Sets the new size of the widget.
- */
- void setSize( long newWidth, long newHeight );
+ * Set the label (the caption above the input field).
+ *
+ * Reimplemented from YTextEntry.
+ **/
+ void setLabel( const std::string & label );
/**
- * Set the text in the entry to a new value
- */
- void setText( const YCPString & text );
+ * Set the valid input characters. No input validation is performed (i.e.,
+ * the user can enter anything) if this is empty.
+ *
+ * Reimplemented from YTextEntry.
+ **/
+ void setValidChars( const std::string & validChars );
/**
- * Gets the text currently entered in the text entry
+ * Specify the amount of characters which can be inserted.
+ *
+ * Reimplemented from @ref YTextEntry.
*/
- YCPString getText();
+ void setInputMaxLength( int numberOfChars );
/**
- * Changes the label of the text entry.
- */
- void setLabel( const YCPString & label );
+ * Returns 'true' if a given text is valid according to ValidChars.
+ **/
+ bool isValidText( const QString & text ) const;
/**
- * Change the valid input characters.
+ * Set enabled/disabled status.
*
- * Reimplemented from @ref YTextEntry.
- */
- void setValidChars( const YCPString & validChars );
+ * Reimplemented from YWidget.
+ **/
+ void setEnabling( bool enabled );
/**
- * Specify the amount of characters which can be inserted.
- *
- * Reimplemented from @ref YTextEntry.
- */
- void setInputMaxLength( const YCPInteger & numberOfChars );
+ * Minimum size the widget should have to make it look and feel
+ * nice.
+ * dim Dimension, either YD_HORIZ or YD_VERT
+ * Reimplemented from YWidget.
+ **/
+ long nicesize( YUIDimension dim );
+
+ /**
+ * Sets the new size of the widget.
+ **/
+ void setSize( long newWidth, long newHeight );
/**
* Accept the keyboard focus.
*/
virtual bool setKeyboardFocus();
- /**
- * Returns 'true' if a given text is valid according to ValidChars.
- **/
- bool isValidText( const QString & text ) const;
-
protected slots:
/**
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=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI.h (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI.h Fri Jun 1 17:16:50 2007
@@ -438,13 +438,13 @@
YWidget * createPackageSelector ( YWidget * parent, YWidgetOpt & opt, const YCPString & floppyDevice );
YWidget * createPushButton ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
YWidget * createMenuButton ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
- YWidget * createRadioButton ( YWidget * parent, YWidgetOpt & opt, YRadioButtonGroup * rbg, const YCPString & label, bool checked);
+ YWidget * createRadioButton ( YWidget * parent, YWidgetOpt & opt, YRadioButtonGroup * rbg, const std::string & label, bool checked);
YWidget * createRichText ( YWidget * parent, YWidgetOpt & opt, const YCPString & text);
YWidget * createSelectionBox ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
YWidget * createMultiSelectionBox ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
YWidget * createSpacing ( YWidget * parent, YWidgetOpt & opt, float size, bool horizontal, bool vertical);
YWidget * createTable ( YWidget * parent, YWidgetOpt & opt, vector<string> header);
- YWidget * createTextEntry ( YWidget * parent, YWidgetOpt & opt, const YCPString & label, const YCPString & text);
+ YWidget * createTextEntry ( YWidget * parent, YWidgetOpt & opt, const std::string & label, bool passwordMode );
YWidget * createTree ( YWidget * parent, YWidgetOpt & opt, const YCPString & label);
YWidget * createPkgSpecial ( YWidget * parent, YWidgetOpt & opt, const YCPString & subwidget );
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=38253&r1=38252&r2=38253&view=diff
==============================================================================
--- branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc (original)
+++ branches/tmp/sh/mod-ui/qt/src/YQUI_widgets.cc Fri Jun 1 17:16:50 2007
@@ -250,7 +250,7 @@
YWidget * YQUI::createRadioButton ( YWidget * parent,
YWidgetOpt & opt,
YRadioButtonGroup * rbg,
- const YCPString & label,
+ const std::string & label,
bool checked)
{
return new YQRadioButton( (QWidget *) ( parent->widgetRep() ), opt, rbg, label, checked);
@@ -263,11 +263,11 @@
}
YWidget * YQUI::createTextEntry ( YWidget * parent,
- YWidgetOpt & opt,
- const YCPString & label,
- const YCPString & text )
+ YWidgetOpt & opt,
+ const std::string & label,
+ bool passwordMode )
{
- return new YQTextEntry( (QWidget *) ( parent->widgetRep() ), opt, label, text);
+ return new YQTextEntry( (QWidget *) ( parent->widgetRep() ), opt, label, passwordMode );
}
YWidget * YQUI::createMultiLineEdit ( YWidget * parent,
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org