*/
QString QDS_CheckBox::getString() const
{
- return checkBox() && checkBox()->isChecked() ? "1" : "0";
+ QString val;
+ if ( checkBox() && checkBox()->state() != QButton::NoChange )
+ val = checkBox()->isChecked() ? "1" : "0";
+ return val;
}
/*!
*/
void QDS_CheckBox::setString( const QString& txt )
{
- bool isOk;
- int val = (int)txt.toDouble( &isOk );
- if ( checkBox() )
+ if ( !checkBox() )
+ return;
+
+ if ( txt.isEmpty() )
+ {
+ checkBox()->setTristate();
+ checkBox()->setNoChange();
+ }
+ else
+ {
+ bool isOk;
+ int val = (int)txt.toDouble( &isOk );
checkBox()->setChecked( isOk && val != 0 );
+ }
}
/*!
QCheckBox* cb = new QCheckBox( parent );
connect( cb, SIGNAL( stateChanged( int ) ), SLOT( onParamChanged() ) );
connect( cb, SIGNAL( toggled( bool ) ), SIGNAL( toggled( bool ) ) );
+ connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged( int ) ) );
return cb;
}
emit paramChanged();
}
+void QDS_CheckBox::onStateChanged( int state )
+{
+ if ( state != QButton::NoChange && checkBox() )
+ checkBox()->setTristate( false );
+}
+
void QDS_CheckBox::setChecked( const bool theState )
{
if ( checkBox() )
return sdStr;
}
+QVariant QDS_Datum::value() const
+{
+ QVariant val;
+ if ( !isEmpty() )
+ val = stringValue();
+ return val;
+}
+
QString QDS_Datum::stringValue() const
{
initDatum();
}
}
+void QDS_Datum::setValue( const QVariant& val )
+{
+ if ( val.isValid() && val.canCast( QVariant::String ) )
+ setStringValue( val.toString() );
+ else
+ clear();
+}
+
void QDS_Datum::setStringValue( const QString& txt )
{
initDatum();
#include <qobject.h>
#include <qstring.h>
+#include <qvariant.h>
#include <qguardedptr.h>
#include <DDS_DicItem.h>
QString minimumValue() const;
QString maximumValue() const;
+ virtual QVariant value() const;
+
virtual QString stringValue() const;
virtual double doubleValue() const;
virtual int integerValue() const;
virtual void reset();
virtual void clear();
+ virtual void setValue( const QVariant& );
+
virtual void setStringValue( const QString& );
virtual void setDoubleValue( const double );
virtual void setIntegerValue( const int );