return aRes;
}
+/*!
+ Returns 'true' if specified data exist.
+*/
+Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const
+{
+ return ( myData & flag ) == flag;
+}
+
/*!
Parse record in XML file and retrieve information relevant for this data dic item
*/
else if ( aType.IsEqual( "Integer" ) )
aEnumType = Integer;
+ if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MINV" ) ).isNull() )
+ myData |= MinValue;
aMinV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MINV" ) );
aMinV.RemoveAll( ' ' );
if ( aMinV.IsRealValue() )
aRealMinV = aMinV.RealValue();
+ if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MAXV" ) ).isNull() )
+ myData |= MaxValue;
aMaxV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MAXV" ) );
aMaxV.RemoveAll( ' ' );
if ( aMaxV.IsRealValue() )
aRealMaxV = aMaxV.RealValue();
aDefV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) );
+ if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_DEFV" ) ).isNull() )
+ myData |= DefaultValue;
+
aDefV.RemoveAll( ' ' );
if ( aDefV.IsRealValue() )
aRealDefV = aDefV.RealValue();
{
public:
enum Type { String, Float, Integer, List, Unknown };
+ enum Data { MinValue = 0x01, MaxValue = 0x02, DefaultValue = 0x04 };
// This struct is intended for map of Format, Units, Precision and Scale
struct UnitData
Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const;
// convert value to and from default SI units according to current units
+ Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const;
+
private:
DDS_DicItem( const DDS_DicItem& );
// Copy constructor
Standard_Real myDefValue;
TCollection_ExtendedString myDefString;
+ Standard_Integer myData;
+
// valueList
TCollection_ExtendedString myListName;
{
QHBoxLayout* base = new QHBoxLayout( this );
base->setAutoAdd( true );
+ setFocusPolicy( StrongFocus );
}
QDS_Datum::Wrapper::~Wrapper()
if ( myWid->parent() != this )
myWid->reparent( this, QPoint( 0, 0 ) );
+ setTabOrder( this, myWid );
setFocusProxy( myWid );
myWid->updateGeometry();
*/
}
+QDS_Datum::operator QWidget*() const
+{
+ return widget( Control );
+}
+
QString QDS_Datum::id() const
{
initDatum();
initDatum();
QString min;
- if ( !myDicItem.IsNull() )
- min = format( format(), type(), myDicItem->GetMinValue() );
+ if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MinValue ) )
+ min = format( format(), type(), myDicItem->GetMinValue() );
return min;
}
initDatum();
QString max;
- if ( !myDicItem.IsNull() )
+ if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MaxValue ) )
max = format( format(), type(), myDicItem->GetMaxValue() );
return max;
}
if ( type() == DDS_DicItem::String && isDoubleFormat( format() ) )
return true;
+ QString req;
+ if ( !dicItem().IsNull() )
+ req = toQString( dicItem()->GetRequired() );
+
bool aState = true;
QString aStr = getString();
+
if ( aStr.isEmpty() )
- aState = false;
+ aState = !( req == QString( "yes" ) || req == QString( "true" ) || req.toInt() );
else
aState = validate( aStr );
info = QString( "<p><nobr>%1</nobr></p>" ).arg( msg );
QMessageBox::critical( controlWidget() ? controlWidget()->topLevelWidget() : 0,
- tr( "DATA_ERR_TITLE" ), info, tr( "BUT_OK" ) );
+ tr( "DATA_ERR_TITLE" ), info, tr( "OK" ) );
if ( controlWidget() )
controlWidget()->setFocus();
}
virtual bool eventFilter( QObject*, QEvent* );
+ operator QWidget*() const;
+
signals:
void paramChanged();
void paramChanged( QString& );
#include "QDS_SpinBox.h"
-#include <qspinbox.h>
+#include <QtxIntSpinBox.h>
+
#include <qvalidator.h>
/*!
QString QDS_SpinBox::getString() const
{
QString res;
- QSpinBox* aSpinBox = spinBox();
- if ( aSpinBox )
+ QtxIntSpinBox* aSpinBox = spinBox();
+ if ( aSpinBox && !aSpinBox->isCleared() )
{
res = aSpinBox->text();
if ( !aSpinBox->suffix().isEmpty() )
*/
void QDS_SpinBox::setString( const QString& txt )
{
- if ( spinBox() )
+ if ( !spinBox() )
+ return;
+
+ spinBox()->setCleared( txt.isEmpty() );
+ if ( !txt.isEmpty() )
spinBox()->setValue( txt.toInt() );
}
/*!
Returns pointer to QSpinBox widget.
*/
-QSpinBox* QDS_SpinBox::spinBox() const
+QtxIntSpinBox* QDS_SpinBox::spinBox() const
{
- return ::qt_cast<QSpinBox*>( controlWidget() );
+ return ::qt_cast<QtxIntSpinBox*>( controlWidget() );
}
/*!
*/
QWidget* QDS_SpinBox::createControl( QWidget* parent )
{
- QSpinBox* aSpinBox = new QSpinBox( parent );
+ QtxIntSpinBox* aSpinBox = new QtxIntSpinBox( parent );
aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( aSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged( int ) ) );
return aSpinBox;
#include "QDS_Datum.h"
-class QSpinBox;
+class QtxIntSpinBox;
class QDS_EXPORT QDS_SpinBox : public QDS_Datum
{
void onValueChanged( int );
protected:
- QSpinBox* spinBox() const;
+ QtxIntSpinBox* spinBox() const;
virtual QWidget* createControl( QWidget* );
{
QString res;
QtxDblSpinBox* sb = spinBox();
- if ( sb )
+ if ( sb && !sb->isCleared() )
{
bool hasFocus = sb->hasFocus();
if ( hasFocus )
*/
void QDS_SpinBoxDbl::setString( const QString& txt )
{
- if ( spinBox() )
+ if ( !spinBox() )
+ return;
+
+ spinBox()->setCleared( txt.isEmpty() );
+ if ( !txt.isEmpty() )
spinBox()->setValue( txt.toDouble() );
}
/*!
- Returns pointer to XMLGUI_SpinBoxDbl widget.
+ Returns pointer to QtxDblSpinBox widget.
*/
QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const
{
sb->setPrecision( aPreci );
sb->setLineStep( .1 );
- sb->setMinValue( minValue().toDouble() );
- sb->setMaxValue( maxValue().toDouble() );
+ sb->setMinValue( minValue().isEmpty() ? -DBL_MAX : minValue().toDouble() );
+ sb->setMaxValue( maxValue().isEmpty() ? DBL_MAX : maxValue().toDouble() );
}